Hi All,
I've written a few shaders, no problems. However, I just tried to write a really simple program just to test a shader and it won't work. I've even tried using the most simple shader I can think of, still no dice. I don't think it is the shader code, but I can't see any problem with the way I've called it from DBPro. I've spent several hours staring at it now, changing variables etc, and it is driving me a little bit crazy. The object the shader is applied to disappears.
The DBPro code is real simple:
make object cube 1, 1.0
position object 1, 0, 0, 0
position camera 10, 10, 10
point camera 0, 0, 0
convert object fvf 1, 530 ` XYZ+NORMAL+TEX2
load effect "shaders\ambient.fx", 1, 0
set object effect 1, 1
do
sync
LOOP
end
The shader just applies an ambient light and is real simple. See below:
float4x4 World;
float4x4 View;
float4x4 Projection;
float4 AmbientColor = float4(1, 1, 1, 1);
float AmbientIntensity = 0.1;
struct VertexShaderInput
{
float4 Position : POSITION0;
};
struct VertexShaderOutput
{
float4 Position : POSITION0;
};
VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
VertexShaderOutput output;
float4 worldPosition = mul(input.Position, World);
float4 viewPosition = mul(worldPosition, View);
output.Position = mul(viewPosition, Projection);
return output;
}
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
return AmbientColor * AmbientIntensity;
}
technique Ambient
{
pass Pass1
{
VertexShader = compile vs_1_1 VertexShaderFunction();
PixelShader = compile ps_1_1 PixelShaderFunction();
}
}
Is there something really simple I am missing?
Thanks,
Mr Grumpy
GrumpyOne - the natural state of the programmer