Shader customization

The mesh shader is customizable with four global variables (window object).

VariablesDescription
---------------------------------------------------------
MESH_VERT_BEFOREInsert code before vertex computation
MESH_FRAG_BEFOREInsert code before fragment computation
MESH_VERT_AFTERInsert code after vertex computation
MESH_FRAG_AFTERInsert 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.

Table vertex vars

VariablesScopeTypeDescriptionIn beforeIn after
----------------------------------------------------------------------------------------------------------
positionVarvec3Vertex position
texUVVarvec2Vertex uv
colorVarvec3Vertex color
normalVarvec3Vertex normal
tangentVarvec3Vertex tangent
binormalVarvec3Vertex binormal
posFromLightVarvec4Vertex position from light source shadow-map
----------------------------------------------------------------------------------------------------------
LVP_MATRIXUniformmat4x4Light view projection (shadow-map)
SCENE_INFOSUniformSceneInfosVarious scene informations
MESH_INFOSUniformMeshInfosContains matrices and mesh identifier
MAT_PARAMSUniformMaterialParamsList of float material parameters

Table fragment vars

VariablesScopeTypeDescriptionIn beforeIn after
---------------------------------------------------------------------------------------------------------------------
fragPosVarvec3Vertex world position
fragUVVarvec2Vertex uv
fragColorVarvec3Vertex color
fragNormalVarvec3Vertex normal
fragTangentVarvec3Vertex tangent
fragBinormalVarvec3Vertex binormal
fragShadowPosVarvec3Vertex shadow direction
outputColorVarvec4Output color (default: 0, 0, 0, 1)
texelVarvec4Texel color (default: 1, 1, 1, 1)
textureUVVarvec2Texture uv after scrolling
shadowVarfloatShadow-map factor
matS0Varvec4Texel from free material texture 0
matS1Varvec4Texel from free material texutre 1
s0Varvec4Texel from free texture 0
s1Varvec4Texel from free texture 1
---------------------------------------------------------------------------------------------------------------------
MESH_INFOSUniformMeshInfosContains matrices and mesh identifier
SCENE_INFOSUniformSceneInfosVarious scene informations
DIR_LIGHTUniformDirLightDirectionnal light informations
POINT_LIGHTSUniformPointLight[]Point light list
SPOT_LIGHTSUniformSpotLight[]Spot light list
DECALSUniformDecal[]Decal list
FOGUniformFogFog informations
MAT_COLORSUniformMaterialColorsMaterial colors (ambiant, diffuse, etc...)
MAT_PARAMSUniformMaterialParamsMaterial parameters for some settings
MAT_UVSUniformMaterialUvsMaterial uv scrolling
MAT_TOON_LIGHT_DIRUniformvec3Material toon light direction
MAT_TEXTUREUniformTextureColor texture
MAT_DISPLACEMENT_TEXTUREUniformTextureDisplace the color texture
MAT_DIFFUSE_TEXTUREUniformTextureDiffuse color texture
MAT_SPECULAR_TEXTUREUniformTextureSpecular texture (color and specularity)
MAT_EMISSIVE_TEXTUREUniformTextureEmissive color texture
MAT_NORM_TEXTUREUniformTextureNormal map texture
MAT_ENV_MAP_TEXTUREUniformTextureEnv map texture
MAT_TOON_TEXTUREUniformTextureToon details texture
MAT_S0_TEXTUREUniformTextureFree material texture 0
MAT_S1_TEXTUREUniformTextureFree material texture 1
DECAL_ATLAS_TEXTUREUniformTextureDecals texture
DECAL_ATLAS_TEXTUREUniformTextureDecals texture
SHADOW_MAP_TEXTUREUniformTextureShadow map texture
S0_TEXTUREUniformTextureFree texture 0
S1_TEXTUREUniformTextureFree texture 1

What about new uniforms ?

For numeric there is:

About texture there is:


Front page   New Page list Search Recent changes   Help   RSS of recent changes