variables
Documentation from code comments
wrapper for material color properties and other settings
customUniforms: adds some uniforms to the shader so they can be accessed from the postFragment function
postFragment: Adds a function to the material shader that will get executed after all lighting and material calculations
The source passed has to include a function with the signature:
vec4 postFragment(vec4 localColor){ return localColor; }
which will receive the final color after calculating all the lights and material and can modify it and return a new color
The function has access to the following variables:
vec2 v_texcoord; // texture coordinate
vec3 v_normal; // normal at this fragment
vec3 v_transformedNormal; // normal multiplied by the normal matrix
vec3 v_eyePosition; // position of this fragment in eye coordinates
vec3 v_worldPosition; // position of this fragment in world coordinates
vec4 v_color; // color interpolated from the vertex colors
SAMPLER tex0; // the bound texture if there's any
vec4 mat_ambient; // material ambient color
vec4 mat_diffuse; // material diffuse color
vec4 mat_specular; // material specular
vec4 mat_emissive; // material emissive
float mat_shininess; // material shininess
vec4 global_ambient; // global ambient light
mat4 modelViewMatrix; // model view matrix
mat4 projectionMatrix; // projection matrix
mat4 textureMatrix; // texture matrix
mat4 modelViewProjectionMatrix; // model view projection matrix
MAX_LIGHTS // the total number of lights in the scen
And an array of lights each light has the following properties:
float lights[i].enabled;
vec4 lights[i].ambient;
float lights[i].type; // 0 = pointlight
// 1 = directionlight
// 2 = spotlight
// 3 = area
vec4 lights[i].position; // where are we
vec4 lights[i].diffuse; // how diffuse
vec4 lights[i].specular; // what kinda specular stuff we got going on?
// attenuation, how the light attenuates with the distance
float lights[i].constantAttenuation;
float lights[i].linearAttenuation;
float lights[i].quadraticAttenuation;
// only for spot
float lights[i].spotCutoff;
float lights[i].spotCosCutoff;
float lights[i].spotExponent;
// spot and area
vec3 lights[i].spotDirection;
// only for directional
vec3 lights[i].halfVector;
// only for area
float lights[i].width;
float lights[i].height;
vec3 lights[i].right;
vec3 lights[i].up;
Last updated 星期六, 17 八月 2024 20:47:26 UTC - 99bfb4fd7929e233b87b05758efc36f91505592e
If you have any doubt about the usage of this module you can ask in the forum.
If you want to contribute better documentation or start documenting this section you can do so here
If you find anything wrong with this docs you can report any error by opening an issue