Sign in to follow this  
Chimaira

MDX hlsl-effect ranomly rendering wrong

Recommended Posts

I've made a game with mdx which is using a couple of hlsl-effects. One of these is a normalmap-effect that some times works fine but some times it looks realy strange, can't realy explain how it looks and it's hard to get a screenshot of it. Anyway, I've tried to render only the normalmap without any lightning or diffuse colors just like a simple texture and it works fine, if i transform the normalmap into tangent-space for the vertex, only the faces that faces up will get the correct(from the normalmap transformed into tangentspace) normals, all other faces will become totaly yellow, blue or green(normal from the vertex, not from the normalmap). The code for getting the normalmap looks like this:
Vertexshader
...
    output.tangentToWorld[0] = normalize(mul(input.tangent, World));
    output.tangentToWorld[1] = normalize(mul(input.binormal, World));
    output.tangentToWorld[2] = normalize(mul(input.normal, World));   
...
pixelshader
....
float4 normalFromMap = 2*tex2D(NormalMapSampler, scaledTexCoord)-1;
//return normalFromMap; works fine here, just like a normal texutre
normalFromMap.xyz = mul(normalFromMap.xyz, input.tangentToWorld);					
//return normalFromMap; here will return a correct normalmap for faces facing up, other faces will get their flat vertex-normal
normalFromMap.xyz = normalize(normalFromMap.xyz);
...
I know this probably isn't enough info for anyone to help, especialy since the code above sometimes works! I havn't got a slightest idea where else it can be wrong, everything else looks just like it should. I've tried my game on four computers and got the effect above to work on two of them. On the computers i got it to work on i sometimes also get the corrupted normalmap, but simply switching anistrotopic filtering on or off in catalyst control center makes the game run normaly, it doesn't matter if you switch AF on or off, as long as you switch it the game will work. (Don't ask me how i figured that out :S) I have to do this every time i restart the computer or return from hibernate/standby. On the third computer i get the same looks as on the two computers above when it doesn't work, only difference is that you can't fix it by switching anistrotopic filtering on or off. :( All computers above use radeon cards, I have tried with both catalyst 7.4 and 6.10 and it's the same problem with both versions.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this