Lynix

NZSL 1.1 example

Oct 2nd, 2025
476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.66 KB | Source Code | 0 0
  1. [nzsl_version("1.1")]
  2. module;
  3.  
  4. import VertOut, VertexShader from Engine.FullscreenVertex;
  5.  
  6. option HasTexture: bool; //< a compilation constant set by the application
  7.  
  8. [layout(std140)]
  9. struct Parameters
  10. {
  11.     colorMultiplier: vec4[f32]
  12. }
  13.  
  14. external
  15. {
  16.     [binding(0)] params: uniform[Parameters],
  17.     [cond(HasTexture), binding(1)] texture: sampler2D[f32]
  18. }
  19.  
  20. struct FragOut
  21. {
  22.     [location(0)] color: vec4[f32]
  23. }
  24.  
  25. [entry(frag)]
  26. fn main(input: VertOut) -> FragOut
  27. {
  28.     let output: FragOut;
  29.     output.color = params.colorMultiplier;
  30.     const if (HasTexture)
  31.         output.color.rgb *= texture.Sample(input.uv).rgb;
  32.  
  33.     return output;
  34. }
  35.  
Tags: Shader nzsl
Advertisement
Add Comment
Please, Sign In to add comment