I created a simple pointlight shader in HLSL, and it works great if I choose ps_4_0 or ps_5_0. But I want my game to support directX 9 so I want to use ps_4_0_level_9_1. However when I choose this I get this error:
Shader model ps_4_0_level_9_1 doesn’t allow reading from position semantics.
my shader:
#define MAX_LIGHTS 8
sampler TextureSampler : register(s0);
Texture2D input_texture;
float2 light_pos[MAX_LIGHTS];
float light_intensity[MAX_LIGHTS];
float4 light_color[MAX_LIGHTS];
int light_count;
float4 PixelShaderFunction(float4 pos : SV_POSITION, float4 color1 : COLOR0, float2 texCoord : TEXCOORD0) : SV_TARGET
{
float4 tex;
tex = input_texture.Sample(TextureSampler, texCoord.xy);
float intensity = 0.0f;
float4 lightColor = float4(0, 0, 0, 0);
for (int i = 0; i < light_count; i++)
{
intensity += (1.0 / length(pos.xy - light_pos[i])) * light_intensity[i];
lightColor += (light_color[i] * (1.0 / length(pos.xy - light_pos[i])) * light_intensity[i]);
}
return (tex * lightColor * saturate(intensity));
}
technique Technique1
{
pass Pass1
{
PixelShader = compile ps_4_0_level_9_1 PixelShaderFunction();
}
}
Can anyone point me in the right direction here?
Thanks!