Jump to content
  • Advertisement
Sign in to follow this  

Looks like NORMAL semantic causes an exception in Visual Studio

This topic is 2967 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello guys, I must have some sort of magnet for this kind of error. I have the following code in my effect:

uniform float4x4 w;
uniform float4x4 wv;
uniform float4x4 wvp;
uniform float4x4 wvpToTex;
uniform float4 lightPositionsW[4];
uniform float4 lightColors[4];
uniform float4 lightDirsW[4];
uniform int nLights;

void VSLighting(
float4 iPosition : POSITION,
float3 iNormal : NORMAL,
float4 iColor : COLOR0,

out float4 oPositionWVP : POSITION,
out float4 oPositionWVP_TC : TEXCOORD3,
out float4 oPositionW : TEXCOORD1,
out float3 oNormalWV : TEXCOORD0,
out float3 oNormalW : TEXCOORD2,
out float4 oColor : COLOR0)
oPositionWVP = mul(iPosition, wvp);
oPositionWVP_TC = mul(iPosition, wvp);
oPositionW = mul(iPosition, w);
oNormalWV = mul(iNormal, wv);
oNormalW = mul(iNormal, w);
oColor = iColor;

void PSLighting(
float4 iPositionWVP : POSITION,
float4 iPositionWVP_TC : TEXCOORD3,
float4 iPositionW : TEXCOORD1,
float3 iNormalWV : TEXCOORD0,
float3 iNormalW : TEXCOORD2,
float4 iColor : COLOR0,

out float4 oColorValid : COLOR0,
out float4 oPositionW : COLOR1,
out float4 oNormalWDist : COLOR2)
oColorValid.rgb = iColor.rgb;
oColorValid.a = 1.0f;

oPositionW = iPositionW / iPositionW.w;

oNormalWDist.xyz = normalize(iNormalW);
oNormalWDist.w = iPositionWVP_TC.w;

The problem is in the following line in function VSLighting()

oNormalW = mul(iNormal, w);

Despite w being the identity matrix in my case, when I call DrawIndexedPrimitive() i get the following exceptions:

First-chance exception at 0x003b00af in RSGI.exe: 0xC0000005: Access violation reading location 0x00244014.
Unhandled exception at 0x003b00af in RSGI.exe: 0xC0000005: Access violation reading location 0x00244014.

while, if i change that line in

oNormalW = iNormal;

everything seems to work fine. Even more weird than this, if I don't use TEXCOORD2 int the pixel shader, everything works fine no matter what the vertex shader looks like; that is, if I change line

oNormalWDist.xyz = normalize(iNormalW);

in the pixel shader to

oNormalWDist.xyz = 123;

everything works fine. If I run the program outside Visual Studio, aparently everything works fine no matter what the VS and PS look like.

Now I am in a seaside resort, in a few days I'll go back home and I will have a real computer and a real Internet connection, and obviously I will update DXSDK and maybe drivers and everything, but it would be cool if you can think to some explanation.

Thank you very much have a great day.


I'm working on an Acer Aspire One with Intel GMA 945, DirectX SDK March 2009. All of this is happening with the REF device.

Could it be that I'm exceding the maximum number of instructions allowed for profile 3.0? If yes, why I'm not getting any warning or error, not even if I try to compile with FXC? And why outside of Visual Studio it works (aparently) without raising any exception?

[Edited by - damix911 on September 2, 2010 10:38:44 AM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!