-
Notifications
You must be signed in to change notification settings - Fork 0
ChickenShaders
Luminous Chickens is a collection of 3D lighting shaders. It contains the three basic light types - point, directional, and spot lights. It also provides distance fog effects.
Up to 16 lights may be defined. Additional lights have no impact on performance; enabling two lights will have the same performance impact as enabling all sixteen. (Spot lights are marginally slower than point lights, which are marginally slower than directional lights - marginally.)
Lighting may be calculated in either the vertex shader (Gouraud shading - shd_cluck_vertex
) or the fragment shader (Phong shading - shd_cluck_fragment
). Normally one would calculate lighting in the vertex shader to achieve a faceted, flat-shaded (per-vertex) look, and the fragment shader to achieve a smoothly shaded (per-fragment) look. I will never understand people who try to do smooth shading using the vertex shader.
The lighting shaders are written in GLSL ES, and therefore may be used on any target platform GameMaker supports.
The vertex format is a standard 36-byte vertex:
- a 3D position (
vec3
) - a normal (
vec3
) - a texture coordinate (
vec2
) - a color (
vec4
derived from a 32-bit integer)
Most peoples' 3D vertex buffers in GameMaker will use a vertex format like this (the order in which the attributes are defined is not terribly important); if yours does not, you will need to edit the shader to compensate.
This is not something you ordinarily need to do, although you can if you want to. On weaker target platforms such as mobile phones, you may wish to reduce the number of lights used, in which case you will need to edit the MAX_LIGHTS
definition at the top of each shader file, as well as the CLUCK_MAX_LIGHTS
GML macro in cluck_init
.