I get this error when trying to build the following shader:
Lighting.fx(30,18-27): error X4502: invalid input semantic ‘POSITION’: Legal indices are in [1,15]
Lighting.fx(30,18-27): error X4502: invalid ps_3_0 input semantic ‘POSITION’
Lighting.fx(30,18-27): error X4502: invalid input semantic ‘POSITION’: Legal indices are in [1,15]
Lighting.fx(30,18-27): error X4502: invalid ps_3_0 input semantic ‘POSITION’
I am using dotnet core on MacOS High Sierra (Can provide more information if need). I tried experimenting with gradually removing and reintroducing my uniform variables, and as soon as I introduce light_diffuse, I start getting the errors. I was able to get the shader to build If I change the #define for SV_POSITION to POSITION1, but then I get a runtime exception about shader compilation, obviously that is causing it to generate bad GLSL. I have very little experience with HLSL, I am a little more comfortable in GLSL, I am at a loss for what is going on here.
#if OPENGL
#define SV_POSITION POSITION
#define VS_SHADERMODEL vs_3_0
#define PS_SHADERMODEL ps_3_0
#else
#define VS_SHADERMODEL vs_4_0_level_9_1
#define PS_SHADERMODEL ps_4_0_level_9_1
#endif
Texture2D SpriteTexture;
float4 light_pos;
float4 light_diffuse;
//float4 light_specular;
float light_constant;
float light_linear;
float light_quadratic;
float4 AmbientColor = float4(1, 1, 1, 1);
float AmbientIntensity = 0.1;
sampler2D SpriteTextureSampler = sampler_state
{
Texture = <SpriteTexture>;
};
struct VertexShaderOutput
{
float4 Position : SV_POSITION;
float4 Color : COLOR0;
float2 TextureCoordinates : TEXCOORD0;
};
float4 MainPS(VertexShaderOutput input) : COLOR
{
float distance = length(light_pos - input.Position);
float attenuation = 1.0 / (light_constant + light_linear * distance +
light_quadratic * (distance * distance));
float4 ambient = AmbientColor * AmbientIntensity;
float4 diffuse = light_diffuse * attenuation;
//float4 specular = light_specular * attenuation;
//float4 lightIntensity = ambient + diffuse + specular;
float lightIntensity = ambient + diffuse;
return tex2D(SpriteTextureSampler, input.TextureCoordinates) * lightIntensity;
}
technique SpriteDrawing
{
pass P0
{
PixelShader = compile PS_SHADERMODEL MainPS();
}
}