raylib default shader - raysan5/raylib GitHub Wiki
The default shaders included in raylib defines the following default input and output parameters if no custom shader is provided by user.
For custom shaders usage check raylib custom shader page.
The default shader source is embedded as a string in function rlLoadShaderDefault
, which is implemented in the rlgl.h module. Note that there are multiple GLSL shader versions for the multiple OpenGL versions supported.
default vertex shader input/output parameters
OPENGL_ES2 or OPENGL_21
attribute vec3 vertexPosition; // Vertex input attribute: position
attribute vec2 vertexTexCoord; // Vertex input attribute: texture coordinate
attribute vec4 vertexColor; // Vertex input attribute: color
varying vec2 fragTexCoord; // To-fragment attribute: texture coordinate
varying vec4 fragColor; // To-fragment attribute: color
OPENGL_33
in vec3 vertexPosition; // Vertex input attribute: position
in vec2 vertexTexCoord; // Vertex input attribute: texture coordinate
in vec4 vertexColor; // Vertex input attribute: color
out vec2 fragTexCoord; // To-fragment attribute: texture coordinate
out vec4 fragColor; // To-fragment attribute: color
All
uniform mat4 mvp; // Model-View-Projection matrix
default fragment shader input/output parameters
OPENGL_ES2 or OPENGL_21
varying vec2 fragTexCoord; // Fragment input attribute: texture coordinate
varying vec4 fragColor; // Fragment input attribute: color
OPENGL_ES2 also defines:
precision mediump float; // OpenGL ES 2.0 optimization, using 16bit floats
OPENGL_33
in vec2 fragTexCoord; // Fragment input attribute: texture coordinate
in vec4 fragColor; // Fragment input attribute: color
out vec4 finalColor; // Fragment output: color
All
uniform sampler2D texture0; // Fragment input texture (always required, could be a white pixel)
uniform vec4 colDiffuse; // Fragment input color diffuse (multiplied by texture color)
NOTE: On OPENGL_ES2 and OPENGL_21 we use the default built-in fragment output gl_FragColor
(same as the explicitly defined finalColor
).