Hi
is it possible to use some string variable for a vertex shader? I d like to be able to input arbitrary functions for the newPos
float Scale = 1;
float Offset = 0;
float3 Mesh(float2 uv)
{
uv *= Scale;
uv += Offset;
float u = uv.x;
float v = uv.y;
float3 newPos;
// replace here the math function for a string variable
newPos.x = cos(v)+u*cos(v/2)*cos(v);
newPos.y = u*sin(v/2);
newPos.z = sin(v)+u*cos(v/2)*sin(v);
return newPos;
}
vs2ps VS(
float4 PosO : POSITION,
float4 TexCd : TEXCOORD0)
{
//declare output struct
vs2ps Out;
//set new position
PosO.xyz = Mesh(PosO.xy);
//transform position
Out.Pos = mul(PosO, tWVP);
//transform texturecoordinates
Out.TexCd = mul(TexCd, tTex);
return Out;
}