MCPcopy Create free account
hub / github.com/Rust-GPU/rust-gpu / fs

Function fs

examples/shaders/sky-shader/src/lib.rs:138–159  ·  view source on GitHub ↗
(
    constants: &ShaderConstants,
    frag_coord: Vec2,
    sun_intensity_extra_spec_const_factor: u32,
)

Source from the content-addressed store, hash-verified

136}
137
138pub fn fs(
139 constants: &ShaderConstants,
140 frag_coord: Vec2,
141 sun_intensity_extra_spec_const_factor: u32,
142) -> Vec4 {
143 let mut uv = (frag_coord - 0.5 * vec2(constants.width as f32, constants.height as f32))
144 / constants.height as f32;
145 uv.y = -uv.y;
146
147 // hard-code information because we can't bind buffers at the moment
148 let eye_pos = vec3(0.0, 0.0997, 0.2);
149 let sun_pos = vec3(0.0, 75.0, -1000.0);
150 let dir = get_ray_dir(uv, eye_pos, sun_pos);
151
152 // evaluate Preetham sky model
153 let color = sky(dir, sun_pos, sun_intensity_extra_spec_const_factor);
154
155 // Tonemapping
156 let color = color.max(Vec3::splat(0.0)).min(Vec3::splat(1024.0));
157
158 tonemap(color).extend(1.0)
159}
160
161#[spirv(fragment)]
162pub fn main_fs(

Callers 2

mainFunction · 0.85
main_fsFunction · 0.85

Calls 3

get_ray_dirFunction · 0.85
skyFunction · 0.85
tonemapFunction · 0.85

Tested by

no test coverage detected