mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
Page:
raylib default shader
Pages
CMake Build Options
Community Resources
Compile for OSX
Create Visual Studio 2019 Project
Create Visual Studio Project
Creating Discord Activities with raylib
Frequently Asked Questions
Home
Install and configure Touchscreen Drivers (RPi)
Quick Setup for Windows with Visual Studio 2022, GCC, or MinGW
Redirect raylib output to Framebuffer 1
Screen Recording
Use multiple windows
Use raylib with Code Blocks
Use raylib with Eclipse
Use raylib with Sublime Text
Using BMFonts
Using SPI Displays with raylib
Using raylib in VSCode
Using raylib with Cpp
Visual Studio C# Setup
Working for Android (on Linux)
Working for Android (on macOS)
Working for Android
Working for Web (HTML5)
Working on Chrome OS
Working on FreeBSD
Working on GNU Linux
Working on Raspberry Pi
Working on Windows
Working on exaequOS
Working on macOS
Working with CMake
raylib GLFW dependency
raylib architecture
raylib coding conventions
raylib data structures
raylib default shader
raylib dependencies
raylib enumerated types
raylib generic uber shader and custom shaders
raylib input system
raylib integration with other libraries
raylib libc dependency
raylib platforms and graphics
raylib syntax analysis
raylib templates
Clone
3
raylib default shader
Marcelino Rodriguez Cancio edited this page 2023-08-14 15:58:32 -04:00
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).
Frequently Asked Questions
Library Design
- 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
Development Platforms
- 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
IDE Configurations
- 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
Misc Help
www.raylib.com | itch.io | GitHub | Discord | YouTube