MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / processVert

Method processVert

Engine/source/forest/glsl/windDeformationGLSL.cpp:79–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79void WindDeformationGLSL::processVert( Vector<ShaderComponent*> &componentList,
80 const MaterialFeatureData &fd )
81{
82 MultiLine *meta = new MultiLine;
83 output = meta;
84
85 // We combined all the tree parameters into one float4 to
86 // save constant space and reduce the memory copied to the
87 // card.
88 //
89 // .x = bend scale
90 // .y = branch amplitude
91 // .z = detail amplitude
92 // .w = detail frequency
93 //
94 Var *windParams = new Var( "windParams", "vec4" );
95 windParams->uniform = true;
96 windParams->constSortPos = cspPotentialPrimitive;
97
98 // If we're instancing then we need to instance the wind direction
99 // and speed as its unique for each tree instance.
100 Var *windDirAndSpeed;
101 if ( fd.features[MFT_UseInstancing] )
102 {
103 ShaderConnector *vertStruct = dynamic_cast<ShaderConnector *>( componentList[C_VERT_STRUCT] );
104 windDirAndSpeed = vertStruct->getElement( RT_TEXCOORD );
105 windDirAndSpeed->setStructName( "IN" );
106 windDirAndSpeed->setName( "inst_windDirAndSpeed" );
107 windDirAndSpeed->setType( "vec3" );
108
109 mInstancingFormat->addElement( "windDirAndSpeed", GFXDeclType_Float3, windDirAndSpeed->constNum );
110 }
111 else
112 {
113 windDirAndSpeed = new Var( "windDirAndSpeed", "vec3" );
114 windDirAndSpeed->uniform = true;
115 windDirAndSpeed->constSortPos = cspPrimitive;
116 }
117
118 Var *accumTime = (Var*)LangElement::find( "accumTime" );
119 if ( !accumTime )
120 {
121 accumTime = new Var( "accumTime", "float" );
122 accumTime->uniform = true;
123 accumTime->constSortPos = cspPass;
124 }
125
126 // Get the transform to world space.
127 Var *objTrans = getObjTrans( componentList, fd.features[MFT_UseInstancing], meta );
128
129 // First check for an input position from a previous feature
130 // then look for the default vertex position.
131 Var *inPosition = (Var*)LangElement::find( "inPosition" );
132 if ( !inPosition )
133 inPosition = (Var*)LangElement::find( "position" );
134
135 // Copy the input position to the output first as
136 // the wind effects are conditional.

Callers

nothing calls this directly

Calls 8

setStructNameMethod · 0.80
addStatementMethod · 0.80
findFunction · 0.50
getElementMethod · 0.45
setNameMethod · 0.45
setTypeMethod · 0.45
addElementMethod · 0.45
getPixelShaderVersionMethod · 0.45

Tested by

no test coverage detected