Shader customization

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

VariablesDescription
----------------------------------------------------------------------------
__MESH_VERT_BEGIN__Insert code at begin of vertex shader.
__MESH_VERT_END__Insert code at end of vertex shader
__MESH_VERT_OUT_POSITION__Replace vertex output position
__MESH_VERT_OUT_FRAG_POS__Replace vertex output world position
__MESH_VERT_OUT_FRAG_UV__Replace vertex output uv
__MESH_VERT_OUT_FRAG_COLOR__Replace vertex output color
__MESH_VERT_OUT_FRAG_NORMAL__Replace vertex output normal
__MESH_VERT_OUT_FRAG_TANGENT__Replace vertex output tangent
__MESH_VERT_OUT_FRAG_BINORMAL__Replace vertex output binormal
__MESH_VERT_OUT_FRAG_SHADOW_POS__Replace vertex output shadow map position
----------------------------------------------------------------------------
__MESH_FRAG_BEGIN__Insert code at begin of fragment shader
__MESH_FRAG_END__Insert code at end of fragment shader
__MESH_FRAG_PRE_TEXTURE__Insert code before custom texture access
__MESH_FRAG_POST_TEXTURE__Insert code after custom texture access
__MESH_FRAG_OUT_BASE__Replace fragment output color (color buf)
__MESH_FRAG_OUT_NORMAL__Replace fragment output normal (normal buf)
__MESH_FRAG_OUT_ID__Replace fragment output id (id buf)

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

VariablesScopeTypeDescriptionBEGINEND
----------------------------------------------------------------------------------------------------------
positionVarvec3Vertex position
texUVVarvec2Vertex uv
colorVarvec3Vertex color
normalVarvec3Vertex normal
tangentVarvec3Vertex tangent
binormalVarvec3Vertex binormal
posFromLightVarvec4Vertex position from light source shadow-map
outputVarVertexOutputThe vertex shader output
----------------------------------------------------------------------------------------------------------
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

VariablesScopeTypeDescriptionBEGINEND
---------------------------------------------------------------------------------------------------------------------
fragPosVarvec3Pixel world position
fragUVVarvec2Texture uv
fragColorVarvec3color
fragNormalVarvec3normal
fragTangentVarvec3tangent
fragBinormalVarvec3binormal
fragShadowPosVarvec3shadow direction
normalUVVarvec3normal uv
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
outputVarFragOutputThe fragment shader output
---------------------------------------------------------------------------------------------------------------------
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