From 579f356a16aff13e74923d1e6205e3a7019d6259 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 27 Jul 2020 12:42:01 +0200 Subject: [PATCH] Updated raylib generic uber shader and custom shaders (markdown) --- raylib-generic-uber-shader-and-custom-shaders.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/raylib-generic-uber-shader-and-custom-shaders.md b/raylib-generic-uber-shader-and-custom-shaders.md index f17350f..e4fe68f 100644 --- a/raylib-generic-uber-shader-and-custom-shaders.md +++ b/raylib-generic-uber-shader-and-custom-shaders.md @@ -45,16 +45,29 @@ typedef enum { #define LOC_MAP_SPECULAR LOC_MAP_METALNESS ``` -On shader loading, the following GLSL location names are checked: +When loading a shader, raylib tries to bind by default the following **vertex shader** attributes: +```c +// Default shader vertex attribute names to set location points +#define DEFAULT_SHADER_ATTRIB_NAME_POSITION "vertexPosition" // Binded by default to shader location: 0 +#define DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD "vertexTexCoord" // Binded by default to shader location: 1 +#define DEFAULT_SHADER_ATTRIB_NAME_NORMAL "vertexNormal" // Binded by default to shader location: 2 +#define DEFAULT_SHADER_ATTRIB_NAME_COLOR "vertexColor" // Binded by default to shader location: 3 +#define DEFAULT_SHADER_ATTRIB_NAME_TANGENT "vertexTangent" // Binded by default to shader location: 4 +#define DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2 "vertexTexCoord2" // Binded by default to shader location: 5 +``` + +And also the following uniform location names are checked: ```glsl uniform mat4 mvp; // VS: ModelViewProjection matrix uniform mat4 projection; // VS: Projection matrix uniform mat4 view; // VS: View matrix + uniform vec4 colDiffuse; // FS: Diffuse color uniform sampler2D texture0; // FS: GL_TEXTURE0 uniform sampler2D texture1; // FS: GL_TEXTURE1 uniform sampler2D texture2; // FS: GL_TEXTURE2 ``` +Those are the attributes/uniform names used by the internal [default shader](https://github.com/raysan5/raylib/wiki/raylib-default-shader). It's recommended to use that naming convention also on custom shaders to make sure everything will be automatically setup on `LoadShader()` but some of the default attribute names could re-defined in [config.h](https://github.com/raysan5/raylib/blob/master/src/config.h) in case it was necessary. Shaders are also directly related to the Material struct: ```c