The mesh shader is customizable with four global variables (window object).
Variables | Description |
--------------------------------- | ------------------------------------------- |
__MESH_VERT_BEFORE__ | Insert code before vertex computation |
__MESH_VERT_AFTER__ | Insert code after vertex computation |
__MESH_VERT_OUT_POSITION__ | Replace vertex out position |
__MESH_VERT_OUT_FRAG_POS__ | Replace vertex out world position |
__MESH_VERT_OUT_FRAG_UV__ | Replace vertex out uv |
__MESH_VERT_OUT_FRAG_COLOR__ | Replace vertex out color |
__MESH_VERT_OUT_FRAG_NORMAL__ | Replace vertex out normal |
__MESH_VERT_OUT_FRAG_TANGENT__ | Replace vertex out tangent |
__MESH_VERT_OUT_FRAG_BINORMAL__ | Replace vertex out binormal |
__MESH_VERT_OUT_FRAG_SHADOW_POS__ | Replace vertex out shadow map position |
--------------------------------- | ------------------------------------------- |
__MESH_FRAG_BEFORE__ | Insert code before fragment computation |
__MESH_FRAG_AFTER__ | Insert code after fragment computation |
__MESH_FRAG_OUT_BASE__ | Replace fragment out color (color buffer) |
__MESH_FRAG_OUT_NORMAL__ | Replace fragment out normal (normal buffer) |
__MESH_FRAG_OUT_ID__ | Replace fragment out id (id buffer) |
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.
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) | ||
SCENE_INFOS | Uniform | SceneInfos | Various scene informations | ||
MESH_INFOS | Uniform | MeshInfos | Contains matrices and mesh identifier | ||
MAT_PARAMS | Uniform | MaterialParams | List of float material parameters |
Variables | Scope | Type | Description | In before | In 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 | ||
matS0 | Var | vec4 | Texel from free material texture 0 | ||
matS1 | Var | vec4 | Texel from free material texutre 1 | ||
s0 | Var | vec4 | Texel from free texture 0 | ||
s1 | Var | vec4 | Texel from free texture 1 | ||
------------------------ | ------- | -------------- | --------------------------------------------- | ------------- | -------------- |
MESH_INFOS | Uniform | MeshInfos | Contains matrices and mesh identifier | ||
SCENE_INFOS | Uniform | SceneInfos | Various scene informations | ||
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 | ||
MAT_S0_TEXTURE | Uniform | Texture | Free material texture 0 | ||
MAT_S1_TEXTURE | Uniform | Texture | Free material texture 1 | ||
DECAL_ATLAS_TEXTURE | Uniform | Texture | Decals texture | ||
DECAL_ATLAS_TEXTURE | Uniform | Texture | Decals texture | ||
SHADOW_MAP_TEXTURE | Uniform | Texture | Shadow map texture | ||
S0_TEXTURE | Uniform | Texture | Free texture 0 | ||
S1_TEXTURE | Uniform | Texture | Free texture 1 |
For numeric there is:
About texture there is: