Skip to content

Vertex Shader Input

Parameters

The input values for the Vertex Shader are all in the SurfacesStandardVertexIntermediate structure and are passed in as function parameters.

Vertex Shader Input ValuesTypeNeeded MacrosMeaning
positionvec4N/ALocal position
normalvec3N/ALocal normal
tangentvec4CC_SURFACES_USE_TANGENT_SPACELocal tangent and mirror normal flag
colorvec4CC_SURFACES_USE_VERTEX_COLORVertex color
texCoordvec2N/AUV0
texCoord1vec2CC_SURFACES_USE_SECOND_UVUV1
clipPosvec4N/AProjected coordinates
worldPosvec3N/AWorld position
worldNormalvec4N/AWorld normal and double-sided material flag
worldTangentvec3CC_SURFACES_USE_TANGENT_SPACEWorld tangent
worldBinormalvec3CC_SURFACES_USE_TANGENT_SPACEWorld binormal

Macro Switch

When you need to use input parameters with a macro switch, you need to enable the corresponding macro in the macro-remapping code segment. The example code is as follows.

glsl
CCProgram macro-remapping %{
    ...
    //Use the second set of UVs
    #define CC_SURFACES_USE_SECOND_UV 1
    //Use the world's binormal
    #define CC_SURFACES_USE_TANGENT_SPACE 1
    ...
}

Usage Example

In any function with SurfacesStandardVertexIntermediate parameters, you can directly access the relevant parameters, taking the SurfacesVertexModifyWorldPos function as an example.

glsl
#define CC_SURFACES_VERTEX_MODIFY_WORLD_POS
vec3 SurfacesVertexModifyWorldPos(in SurfacesStandardVertexIntermediate In)
{
    vec3 worldPos = In.worldPos;
    worldPos.x += sin(cc_time.x * worldPos.z);
    worldPos.y += cos(cc_time.x * worldPos.z);
    return worldPos;
}