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.

What about uniforms ?

A set of built-in uniforms are reserved for customization.
For now there is 16 floats available in Gfx3Material params.

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)
MESH_INFOSUniformMeshInfosContains matrices and mesh identifier
MAT_PARAMSUniformMaterialParamsList of float material parameters

Table fragment vars

VariablesScopeTypeDescriptionFrom beforeFrom 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
---------------------------------------------------------------------------------------------------------------------
MESH_INFOSUniformMeshInfosContains matrices and mesh identifier
SCENE_INFOSUniformSceneInfosContains matrices and mesh identifier
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
DECAL_ATLAS_TEXTUREUniformTextureDecals texture
DECAL_ATLAS_TEXTUREUniformTextureDecals texture
SHADOW_MAP_TEXTUREUniformTextureShadow map texture

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