Structure of an R3D Surface Shader
masterR3D surface shaders follow a specific structure using GLSL. They support optional vertex and fragment stages, and use specific keywords for communication between stages and built-in outputs.
Key Components:
#pragma usage <hints>: (Optional) Specifies pre-compiled variants.#define R3D_NO_AUTO_FETCH: (Optional) Disables automatic material sampling.uniform <type> <name>: Uniform variables.varying <type> <name>: Varying variables used to pass data from the vertex stage to the fragment stage.void vertex(): (Optional) The vertex stage. Used to modify built-ins likePOSITIONorNORMAL.void fragment(): (Optional) The fragment stage. Used to modify built-ins likeALBEDO,ROUGHNESS, orALPHA.
#pragma usage <hints> // Optional: opaque, transparent, shadow, etc.
#define R3D_NO_AUTO_FETCH // Optional: disable automatic material sampling
uniform <type> <name>; // Uniforms
varying <type> <name>; // Varyings (communication between stages)
void vertex() { // Optional: vertex stage
// Modify POSITION, NORMAL, etc.
}
void fragment() { // Optional: fragment stage
// Modify ALBEDO, ROUGHNESS, etc.
}