Shaders
Shaders are small programs that run on the GPU to control how graphics are rendered. They allow full control over the appearance of 3D objects, from simple color modifications to complex lighting, post-processing, and procedural effects. Lemonate supports writing shaders in GLSL and applying them within the engine using Lua scripts.
Shader Types
Shaders typically come in two main types:
- Vertex shaders process each vertex of a 3D model. They control the position of vertices in 3D space and can modify attributes such as vertex color, normals, or texture coordinates before the rasterization stage. The rasterization process converts these transformed vertices into pixels (fragments) on the screen. Vertex shaders are useful for effects such as deforming objects, animating characters (skinning), or generating geometry procedurally.
- Fragment shaders (also called pixel shaders) compute the color and other attributes of each pixel on the screen. They run after vertex processing and rasterization, determining the final appearance of surfaces, including textures, lighting, and transparency.
In Lemonate, users can implement GLSL vertex and fragment shaders for materials or scene backgrounds to achieve custom visual effects.
Usage in Backgrounds and Materials
In Lemonate, shaders can be used to customize the scene background or applied to object Materials. Background shaders enable dynamic skies, procedural gradients, animated patterns, or any visual effects you can phantom. Object shaders allow you to create custom surface appearances or procedural textures.
Background can be controlled at runtime using the API by updating their uniforms by calling Renderer.setBackgroundShaderUniform.