Hi,
First thanks for everyones help in the past, but i am once again stuck...I have searched for this but cannot find an answer. Basically, i have my terrain drawn and want to use a vertex shader to change its color. But, i cannot get the vertex shader to output anything but grey, no matter what i try.
My terrain is the standard vertex/index buffer with no materials, textures vertex colors etc. I am using a FVF for this example of the following format
Vertex::FVF = D3DFVF_XYZ|D3DFVF_NORMAL;
struct Vertex
{
Vertex(){};
Vertex(float x, float y, float z,float nx, float ny, float nz);
float mx;
float my;
float mz;
float mnx;
float mny;
float mnz;;
static const DWORD FVF;
};
My shader is as follows (i have used a number of different values for color (including the "blue" vector defined, but no luck). I am definately using the shader!
//terrain shader
//only maps to clip space for now
//matrix to hold the required transform
matrix ViewProjMatrix;
matrix ViewMatrix;
//some vectors to hold our values
vector blue = {0.0f,0.0f,1.0f,1.0f};
//input and output structures
struct VS_INPUT
{
vector position : POSITION;
vector normal : NORMAL;
};
struct VS_OUTPUT
{
vector position : POSITION;
vector diffuse : COLOR;
};
//Main
VS_OUTPUT Main(VS_INPUT input)
{
//zero output
VS_OUTPUT output = (VS_OUTPUT) 0;
//transform position to clipspace
//input.position.y =0;
output.position = mul(input.position, ViewProjMatrix);
output.diffuse = 0xffff00;
return output;
}
I have not set any settings using the SetRenderState method as i don't beleive these apply when using vertex shaders (if i'm wrong please say!)
Any help would be greatly appreciated!
Thanks,
Matt
[Edited by - mattm on March 3, 2005 5:14:07 PM]