Updated raylib generic uber shader and custom shaders (markdown)

master
Ray 5 年之前
父節點
當前提交
579f356a16
共有 1 個文件被更改,包括 14 次插入1 次删除
  1. +14
    -1
      raylib-generic-uber-shader-and-custom-shaders.md

+ 14
- 1
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

Loading…
取消
儲存