The mesh shader is customizable with four global variables (window object).
Variables | Description |
---------------- | ----------------------------------------- |
MESH_VERT_BEFORE | Insert code before vertex computation |
MESH_FRAG_BEFORE | Insert code before fragment computation |
MESH_VERT_AFTER | Insert code after vertex computation |
MESH_FRAG_AFTER | Insert code after fragment computation |
Create a shader.ts file at the same level of your main.ts.
Set variables of your choices and import the script in index.html on top of main.ts.
By this way all these variables are set before the engine start and by extension before the shader program compilation start.
A set of built-in uniforms are reserved for customization.
For now there is 16 floats available in Gfx3Material params.
Variables | Scope | Type | Description | In before | In after |
------------- | ------- | -------------- | --------------------------------------------- | ------------- | -------------- |
position | Var | vec3 | Vertex position | ||
texUV | Var | vec2 | Vertex uv | ||
color | Var | vec3 | Vertex color | ||
normal | Var | vec3 | Vertex normal | ||
tangent | Var | vec3 | Vertex tangent | ||
binormal | Var | vec3 | Vertex binormal | ||
posFromLight | Var | vec4 | Vertex position from light source shadow-map | ||
------------- | ------- | -------------- | --------------------------------------------- | ------------- | -------------- |
LVP_MATRIX | Uniform | mat4x4 | Light view projection (shadow-map) | ||
MESH_INFOS | Uniform | MeshInfos | Contains matrices and mesh identifier | ||
MAT_PARAMS | Uniform | MaterialParams | List of float material parameters |
Variables | Scope | Type | Description | From before | From after |
------------------------ | ------- | -------------- | --------------------------------------------- | ------------- | -------------- |
fragPos | Var | vec3 | Vertex world position | ||
fragUV | Var | vec2 | Vertex uv | ||
fragColor | Var | vec3 | Vertex color | ||
fragNormal | Var | vec3 | Vertex normal | ||
fragTangent | Var | vec3 | Vertex tangent | ||
fragBinormal | Var | vec3 | Vertex binormal | ||
fragShadowPos | Var | vec3 | Vertex shadow direction | ||
outputColor | Var | vec4 | Output color (default: 0, 0, 0, 1) | ||
texel | Var | vec4 | Texel color (default: 1, 1, 1, 1) | ||
textureUV | Var | vec2 | Texture uv after scrolling | ||
shadow | Var | float | Shadow-map factor | ||
------------------------ | ------- | -------------- | --------------------------------------------- | ------------- | -------------- |
MESH_INFOS | Uniform | MeshInfos | Contains matrices and mesh identifier | ||
SCENE_INFOS | Uniform | SceneInfos | Contains matrices and mesh identifier | ||
DIR_LIGHT | Uniform | DirLight | Directionnal light informations | ||
POINT_LIGHTS | Uniform | PointLight[] | Point light list | ||
SPOT_LIGHTS | Uniform | SpotLight[] | Spot light list | ||
DECALS | Uniform | Decal[] | Decal list | ||
FOG | Uniform | Fog | Fog informations | ||
MAT_COLORS | Uniform | MaterialColors | Material colors (ambiant, diffuse, etc...) | ||
MAT_PARAMS | Uniform | MaterialParams | Material parameters for some settings | ||
MAT_UVS | Uniform | MaterialUvs | Material uv scrolling | ||
MAT_TOON_LIGHT_DIR | Uniform | vec3 | Material toon light direction | ||
MAT_TEXTURE | Uniform | Texture | Color texture | ||
MAT_DISPLACEMENT_TEXTURE | Uniform | Texture | Displace the color texture | ||
MAT_DIFFUSE_TEXTURE | Uniform | Texture | Diffuse color texture | ||
MAT_SPECULAR_TEXTURE | Uniform | Texture | Specular texture (color and specularity) | ||
MAT_EMISSIVE_TEXTURE | Uniform | Texture | Emissive color texture | ||
MAT_NORM_TEXTURE | Uniform | Texture | Normal map texture | ||
MAT_ENV_MAP_TEXTURE | Uniform | Texture | Env map texture | ||
MAT_TOON_TEXTURE | Uniform | Texture | Toon details texture | ||
DECAL_ATLAS_TEXTURE | Uniform | Texture | Decals texture | ||
DECAL_ATLAS_TEXTURE | Uniform | Texture | Decals texture | ||
SHADOW_MAP_TEXTURE | Uniform | Texture | Shadow map texture |