debug_lines.wgsl 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Sky Backdrop + 3D Debug Lines Shader (Tracers, Tactical Order Lines, F3 Acoustic Bounce Rays)
  2. @group(0) @binding(0) var<uniform> u: GlobalUniforms;
  3. struct SkyOut {
  4. @builtin(position) position: vec4<f32>,
  5. @location(0) uv: vec2<f32>,
  6. };
  7. @vertex
  8. fn vs_sky(@builtin(vertex_index) vid: u32) -> SkyOut {
  9. var out: SkyOut;
  10. let x = f32(i32(vid & 1u) * 4 - 1);
  11. let y = f32(i32(vid >> 1u) * 4 - 1);
  12. out.position = vec4<f32>(x, y, 0.99999, 1.0);
  13. out.uv = vec2<f32>(x * 0.5 + 0.5, -y * 0.5 + 0.5);
  14. return out;
  15. }
  16. @fragment
  17. fn fs_sky(in: SkyOut) -> @location(0) vec4<f32> {
  18. let ndc = vec2<f32>(in.uv.x * 2.0 - 1.0, -(in.uv.y * 2.0 - 1.0));
  19. let world_far = u.inv_view_proj * vec4<f32>(ndc, 1.0, 1.0);
  20. let dir = normalize(world_far.xyz / world_far.w - u.camera_pos.xyz);
  21. let col = eval_winter_sky(dir, normalize(u.sun_dir.xyz), u.sun_dir.w);
  22. return vec4<f32>(col, 1.0);
  23. }
  24. struct LineIn {
  25. @location(0) position: vec3<f32>,
  26. @location(1) color: vec4<f32>,
  27. };
  28. struct LineOut {
  29. @builtin(position) position: vec4<f32>,
  30. @location(0) color: vec4<f32>,
  31. };
  32. @vertex
  33. fn vs_line(v: LineIn) -> LineOut {
  34. var out: LineOut;
  35. out.position = u.view_proj * vec4<f32>(v.position, 1.0);
  36. out.color = v.color;
  37. return out;
  38. }
  39. @fragment
  40. fn fs_line(in: LineOut) -> @location(0) vec4<f32> {
  41. return in.color;
  42. }