Tryinng to implement some shaders to do basic stuff and I'm having trouble passing values to the shader I've set up. The shader works and I can edit the texture coordinates using hard coded numbers/variables using the shader, but nothing happens when I pass a value from my program to the shader and then update it inside the program.
I'm calling the following code every time I render said object
[source="cpp"]
pd3dDevice->SetVertexShader(vertexShader);
pd3dDevice->SetPixelShader(pixelShader);
constantTable->SetInt(pd3dDevice, "MyTestInt", testInt);
testInt++;
pd3dDevice->SetStreamSource(0, waterPlaneBuffer, 0, sizeof(CUSTOMVERTEX));
pd3dDevice->SetTexture(0, waterTexture);
pd3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
//Disable Shaders
pd3dDevice->SetVertexShader(NULL);
pd3dDevice->SetPixelShader(NULL);
My pixel shader
[source="hlsl"]
// Pixel shader input structure
struct PS_INPUT
{
float4 Position : POSITION;
float2 Texture : TEXCOORD0;
};
// Pixel shader output structure
struct PS_OUTPUT
{
float4 Color : COLOR0;
};
// Global variables
sampler2D Tex0;
float time;
int MyTestInt : MYTESTINT;
// Name: Simple Pixel Shader
// Type: Pixel shader
// Desc: Fetch texture and blend with constant color
//
PS_OUTPUT ps_main( in PS_INPUT In )
{
PS_OUTPUT Out; //create an output pixel
In.Texture.y = In.Texture.y + (sin(In.Texture.x*MyTestInt)*0.01);
Out.Color = tex2D(Tex0, In.Texture); //do a texture lookup
//Out.Color *= float4(0.9f, 0.8f, 0.4, 1); //do a simple effect
return Out; //return output pixel
}
I tried declaring it as
int MyTestInt : MYTESTINT;
int MyTestInt;
Even tried pd3dDevice->SetPixelShaderConstantI(num, testInt, 1) and referring to c<num> in the shader. Not sure how to do this at all.
[Edited by - RaptorJesus on March 30, 2010 4:32:20 PM]