Vertex Shader - Geometry vertex manipulation problem
by Matt Huston · in Torque 3D Professional · 03/26/2011 (6:22 pm) · 1 replies
I am trying to create a vertex shader that manipulates a mesh that I have. As a stripped down test, I found some code from codesampler that does geometry manipulation, in their case it makes a flag wave. In my case, it should flatten the geometry onto the y-plane. However the results are a little odd. I get two meshes, the vertex shader (white) and the original (orange)
img64.imageshack.us/i/testpfg.jpg/
Here is the code:
HLSL
customMaterial.cs
img64.imageshack.us/i/testpfg.jpg/
Here is the code:
HLSL
#define IN_HLSL
#include "../shdrConsts.h"
#include "../hlslStructs.h"
struct outData
{
float4 hpos : POSITION;
};
outData main( VertexIn_PC In, uniform float4x4 modelView : register(VC_WORLD_PROJ))
{
outData Out;
float4 v = float4( In.pos.x, In.pos.y, In.pos.z, 1.0f );
v.y = sin( In.pos.x + 180.0f );
v.y += sin( In.pos.z + 180.0f );
v.y *= In.pos.x * 0.08f;
Out.hpos = mul( modelView, v );
return Out;
}customMaterial.cs
singleton ShaderData(TestShaderData)
{
DXVertexShaderFile = "shaders/common/testShader.hlsl";
};
singleton CustomMaterial(TestMat)
{
mapTo = "testmodel_tex";
shader = TestShaderData;
version = 2.0;
};About the author
www.atomicbanzai.com
Torque 3D Owner Matt Huston
Atomic Banzai Games