I've recently made the switch to Visual 2015 and the .fx files have been depreciated. My project contained .fx files for the shaders so I've been switching over.

Only during the switch have I changed to using deferred rendering for lighting.

The only shader I've made so far is the Pixel Shader that is used on the 2nd Pass, the shader that does the Per Pixel x Per Light calculations, sums them, and outputs final color.

However, whenever I compile (I'm not actually using the shader in runtime, I'm just getting it all setup, the window is still just cleared to a color every frame, no actual rendering) I get a failure that says....

error X4502: Shader model ps_4_0_level_9_3 doesn't allow reading from position semantics.

Here is the only shader I have in the project that is causing this error.

I omitted the getGBufferAttributes and calculateLighting methods because I know they are not the issue.

Texture2D NormalTexture                 : register(t0);
Texture2D DiffuseAlbedoTexture          : register(t1);
Texture2D SpecularAlbedoTexture         : register(t2);
Texture2D PositionTexture               : register(t3);

cbuffer LightParams
    float3 LightPos;
    float3 LightColor;
    float3 LightDirection;
    float2 SpotlightAngles;
    float4 LightRange;

cbuffer CameraParams
    float3 CameraPos;

float4 main(in float4 screenPos : SV_Position) : SV_Target0
    float3 normal;
    float3 position;
    float3 diffuseAlbedo;
    float3 specularAlbedo;
    float specularPower;

    getGBufferAttributes(screenPos.xy, normal, position, diffuseAlbedo, specularAlbedo, specularPower);

    float3 lighting = calculateLighting(normal, position, diffuseAlbedo, specularAlbedo, specularPower);

    return float4(lighting, 1.0f);

The code used for this shader is highly based off the code used as the deferred rendering example in the book, Practical Rendering with Direct3D 11 by Jason Zink, Matt Pettineo, and Jack Hoxley.

I don't understand why they would give source code that doesn't work. Does it have something to do with the new compiler in Visual 2015 and the Runtime?

Also, since I'm going from only using effects before to now raw HLSL shaders, is there anything I should be aware of that might trip somebody like me up?


1 Answer 1


A very novice mistake, I was compiling with the old HLSL compiler. But why would that be the default? Very strange.

For anybody wondering, just right click the HLSL file in the solution explorer and go to properties -> HLSL Compiler -> General, and switch Shader Model to the one you want which was newest one for me (5.0)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.