Hi,
i've just started toying around with HLSL/shaders in SlimDX/Direct3D9, so please forgive me if i missed something totaly obvious. But i can't seem to even get the most basic shaders running. Thats how i try to create the effect:
fx = Effect.FromFile( GraphicsDevice, "Content\\Effects\\Test.fx", ShaderFlags.None );
this line always throws a Direct3D9Exception "E_FAIL: An undetermined error occurred (-2147467259)".
GraphicsDevice is a valid Direct3D9.Device (i use it just above that line to create a VertexBuffer without any trouble), the file is there (opening and dumping to console works like expected) and the shader seems to be ok (compiles and runs in fx composer) and i tried different types/combinations of shader flags (i.e. ShaderFlag.Debug | ShaderFlags.PartialPrecision like in the water sample that comes with SlimDX).
I'm using the November 2008 distribution of SlimDX, the samples work, even those that use effects like the water sample. I also tried the debug runtimes + unmanaged code debugging but that only gives the usual infos when the device is created. No extra details or actually nothing at all about that error.
What am i missing here? Thanks.
Edit: if that helps, here's the shader:
float4x4 ProjectionMatrix : PROJECTION;
float4x4 ViewMatrix : VIEW;
float4x4 WorldMatrix : WORLD;
float4 LightDirection;
float4 LightAmbient;
float4 LightColor;
struct VertexIn {
float3 Position : POSITION;
float3 Normal : NORMAL;
};
struct VertexOut {
float4 Position : POSITION0;
float3 Normal : TEXCOORD0;
float3 LightDir : TEXCOORD1;
};
void VS_Main( VertexIn input, out VertexOut output ) {
float4x4 WorldViewProjectionMatrix = mul( WorldMatrix, mul( ViewMatrix, ProjectionMatrix ) );
float3 LightDir = normalize( LightDirection );
output.Position = mul( float4( input.Position, 1 ), WorldViewProjectionMatrix );
output.Normal = normalize( mul( input.Normal, WorldMatrix ) );
output.LightDir = LightDir;
}
float4 PS_Main( float3 Normal : TEXCOORD0, float3 LightDir : TEXCOORD1 ) : COLOR0 {
return LightAmbient + LightColor * saturate( dot( LightDir, Normal ) );
}
technique Test {
pass P0 {
VertexShader = compile vs_2_0 VS_Main();
PixelShader = compile ps_2_0 PS_Main();
}
}
but as i said: it compiles, runs and works in fx composer so shouldn't be the problem.