Guest User

Nora shader examples

a guest
Jan 26th, 2025
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // default.glsl
  2. #type source
  3.  
  4. #use <nora3D.glsl>
  5. #uniforms
  6.     vec2 u_Offset : fast_read;
  7.     vec4 u_Tint : fast_write;
  8.     sampler2D u_AlbedoTex : frag_access;
  9. #end
  10.  
  11. #vert
  12.     layout(location = 0) out vec3 v_Normal;
  13.     layout(location = 1) out vec2 v_UV0;
  14.     layout(location = 2) out vec3 v_Tangent;
  15.     layout(location = 3) out vec4 v_Color;
  16.  
  17.     void main() {
  18.         gl_Position = APPLY_TF(a_Pos);
  19.        
  20.         v_Normal = a_Normal;
  21.         v_UV0 = a_UV0;
  22.         v_Tangent = a_Tangent;
  23.         v_Color = a_Color;
  24.     }
  25. #end
  26.  
  27. #frag
  28.     layout(location = 0) in vec3 v_Normal;
  29.     layout(location = 1) in vec2 v_UV0;
  30.     layout(location = 2) in vec3 v_Tangent;
  31.     layout(location = 3) in vec4 v_Color;
  32.  
  33.     void main() {
  34.         o_Col = texture(u_AlbedoTex, v_UV0 + u_Offset) * u_Tint;
  35.     }
  36. #end
  37.  
  38.  
  39. // nora3D.glsl
  40. #type include
  41. #unique NORA3D
  42.  
  43. #use <nora.glsl>
  44. #body
  45.     #ifdef VERT
  46.         #define APPLY_TF(pos) (u_ProjMat * u_ViewMat * u_ModelMat * vec4(pos, 1.0))
  47.  
  48.         layout(location = 0) in vec3 a_Pos;
  49.         layout(location = 1) in vec3 a_Normal;
  50.         layout(location = 2) in vec2 a_UV0;
  51.         layout(location = 3) in vec2 a_UV1;
  52.         layout(location = 4) in vec3 a_Tangent;
  53.         layout(location = 5) in vec4 a_Color;
  54.  
  55.         layout(std140, binding = 0) uniform SlowMatrices {
  56.             mat4 u_ProjMat; // This one goes here because it changes relatively sparely
  57.         };
  58.  
  59.         layout(std140, push_constant) uniform FastMatrices {
  60.             mat4 u_ModelMat;
  61.             mat4 u_ViewMat;
  62.         };
  63.     #endif
  64. #end
  65.  
  66.  
  67. // nora.glsl
  68. #type include
  69. #unique NORA
  70.  
  71. #body
  72.     #ifdef FRAG
  73.         layout(location = 0) out vec4 o_Col;
  74.     #endif
  75. #end
Advertisement
Add Comment
Please, Sign In to add comment