How to modify texture coordinates in a ShaderFeature?
by 7nMs23fF · in Torque 3D Professional · 04/13/2011 (9:22 am) · 3 replies
I struggled to find documentation on this subject, but only found Pat Wilson's articles at gameclay.com. They were pretty straight-forward, but left me clueless as they only covered how to change the color of the material.
So my question is - how would I grab the texture coordinates, modify them, and feed them back to the shader? My goal is to scale the texture per axis.
Thanks in advance.
So my question is - how would I grab the texture coordinates, modify them, and feed them back to the shader? My goal is to scale the texture per axis.
Thanks in advance.
Torque Owner Ivan Mandzhukov
Liman3D
http://www.garagegames.com/community/resources/view/19161
Now,as I understand,you want to implement a scale on each axis.
Well, your processVert() should look like:
Var *inTex = getVertTexCoord( "texCoord" ); ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] ); Var *outTex = connectComp->getElement( RT_TEXCOORD ); outTex->setName( "texCoord" ); outTex->setStructName( "OUT" ); outTex->setType( "float2" ); outTex->mapsToSampler = true; Var *texScale= (Var *)( LangElement::find("texScale") ); if( !texScale) { texScale= new Var; texScale->setType( "float2" ); texScale->setName( "texScale" ); texScale->constSortPos = cspPotentialPrimitive; texScale->uniform = true; } meta->addStatement( new GenOp( "@ = @ * @;", outTex, inTex , texScale ) );Now your new multipliers are texScale.x and texScale.y