| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- // Sky Backdrop + 3D Debug Lines Shader (Tracers, Tactical Order Lines, F3 Acoustic Bounce Rays)
- @group(0) @binding(0) var<uniform> u: GlobalUniforms;
- struct SkyOut {
- @builtin(position) position: vec4<f32>,
- @location(0) uv: vec2<f32>,
- };
- @vertex
- fn vs_sky(@builtin(vertex_index) vid: u32) -> SkyOut {
- var out: SkyOut;
- let x = f32(i32(vid & 1u) * 4 - 1);
- let y = f32(i32(vid >> 1u) * 4 - 1);
- out.position = vec4<f32>(x, y, 0.99999, 1.0);
- out.uv = vec2<f32>(x * 0.5 + 0.5, -y * 0.5 + 0.5);
- return out;
- }
- @fragment
- fn fs_sky(in: SkyOut) -> @location(0) vec4<f32> {
- let ndc = vec2<f32>(in.uv.x * 2.0 - 1.0, -(in.uv.y * 2.0 - 1.0));
- let world_far = u.inv_view_proj * vec4<f32>(ndc, 1.0, 1.0);
- let dir = normalize(world_far.xyz / world_far.w - u.camera_pos.xyz);
- let col = eval_winter_sky(dir, normalize(u.sun_dir.xyz), u.sun_dir.w);
- return vec4<f32>(col, 1.0);
- }
- struct LineIn {
- @location(0) position: vec3<f32>,
- @location(1) color: vec4<f32>,
- };
- struct LineOut {
- @builtin(position) position: vec4<f32>,
- @location(0) color: vec4<f32>,
- };
- @vertex
- fn vs_line(v: LineIn) -> LineOut {
- var out: LineOut;
- out.position = u.view_proj * vec4<f32>(v.position, 1.0);
- out.color = v.color;
- return out;
- }
- @fragment
- fn fs_line(in: LineOut) -> @location(0) vec4<f32> {
- return in.color;
- }
|