-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
raylib default shader
Marcelino Rodriguez Cancio edited this page Aug 14, 2023
·
3 revisions
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.
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
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
).
www.raylib.com | itch.io | GitHub | Discord | YouTube
- Architecture
- Syntax analysis
- Data structures
- Enumerated types
- External dependencies
- GLFW dependency
- libc dependency
- Platforms and graphics
- Input system
- Default shader
- Custom shaders
- Coding conventions
- Integration with other libs
- Working on Windows
- Working on macOS
- Working on GNU Linux
- Working on Chrome OS
- Working on FreeBSD
- Working on Raspberry Pi
- Working for Android
- Working for Web (HTML5)
- Working on exaequOS Web Computer
- Creating Discord Activities
- Working anywhere with CMake
- CMake Build Options
- raylib templates: Get started easily
- How To: Quick C/C++ Setup in Visual Studio 2022, GCC or MinGW
- How To: C# Visual Studio Setup
- How To: VSCode
- How To: Eclipse
- How To: Sublime Text
- How To: Code::Blocks