diff --git a/raylib-generic-uber-shader-and-custom-shaders.md b/raylib-generic-uber-shader-and-custom-shaders.md index 058cf22..d02554f 100644 --- a/raylib-generic-uber-shader-and-custom-shaders.md +++ b/raylib-generic-uber-shader-and-custom-shaders.md @@ -45,22 +45,33 @@ typedef enum { #define SHADER_LOC_MAP_SPECULAR SHADER_LOC_MAP_METALNESS ``` -When loading a shader, raylib tries to bind by default the following **vertex shader** attributes: +When loading a shader, raylib tries to find some default attributes and uniforms locations: ```c -// Default shader vertex attribute names to set location points -#define DEFAULT_SHADER_ATTRIB_NAME_POSITION "vertexPosition" // Bound by default to shader location: 0 -#define DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD "vertexTexCoord" // Bound by default to shader location: 1 -#define DEFAULT_SHADER_ATTRIB_NAME_NORMAL "vertexNormal" // Bound by default to shader location: 2 -#define DEFAULT_SHADER_ATTRIB_NAME_COLOR "vertexColor" // Bound by default to shader location: 3 -#define DEFAULT_SHADER_ATTRIB_NAME_TANGENT "vertexTangent" // Bound by default to shader location: 4 -#define DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2 "vertexTexCoord2" // Bound by default to shader location: 5 +#define RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION "vertexPosition" // Binded by default to shader location: 0 +#define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD "vertexTexCoord" // Binded by default to shader location: 1 +#define RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL "vertexNormal" // Binded by default to shader location: 2 +#define RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR "vertexColor" // Binded by default to shader location: 3 +#define RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT "vertexTangent" // Binded by default to shader location: 4 +#define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2 "vertexTexCoord2" // Binded by default to shader location: 5 + +#define RL_DEFAULT_SHADER_UNIFORM_NAME_MVP "mvp" // model-view-projection matrix +#define RL_DEFAULT_SHADER_UNIFORM_NAME_VIEW "matView" // view matrix +#define RL_DEFAULT_SHADER_UNIFORM_NAME_PROJECTION "matProjection" // projection matrix +#define RL_DEFAULT_SHADER_UNIFORM_NAME_MODEL "matModel" // model matrix +#define RL_DEFAULT_SHADER_UNIFORM_NAME_NORMAL "matNormal" // normal matrix (transpose(inverse(matModelView)) +#define RL_DEFAULT_SHADER_UNIFORM_NAME_COLOR "colDiffuse" // color diffuse (base tint color, multiplied by texture color) +#define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE0 "texture0" // texture0 (texture slot active 0) +#define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE1 "texture1" // texture1 (texture slot active 1) +#define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE2 "texture2" // texture2 (texture slot active 2) ``` -And also the following uniform location names are checked: +The uniform locations belong to VertesShader or FragmentShader: ```glsl uniform mat4 mvp; // VS: ModelViewProjection matrix -uniform mat4 projection; // VS: Projection matrix -uniform mat4 view; // VS: View matrix +uniform mat4 matView; // VS: View matrix +uniform mat4 matProjection; // VS: Projection matrix +uniform mat4 matModel; // VS: Model matrix +uniform mat4 matNormal; // VS: Normal matrix uniform vec4 colDiffuse; // FS: Diffuse color uniform sampler2D texture0; // FS: GL_TEXTURE0