Sign in to follow this  
danromeo

Pix/HLSL wierdness

Recommended Posts

danromeo    238
Hey. I have a couple of related situations here that just don't make any sense to me. Seems like one of those deals where I'm simply missing a crucial piece of information. 1. Why doesn't a simple equation in HLSL like the following seem to work when debugging a pixel in Pix? uniform const float3 EyePosition; VertexShaderOutput VertexShaderFunction(float4 inPos : POSITION) { float3 pos = EyePosition; OR float3 pos; pos[0] = EyePosition[0]; pos[1] = EyePosition[1]; pos[2] = EyePosition[2]; } The Pix debugger seems to always return pos(0,0,0); 2. I'm experimenting with creating a LookAt view matrix in the same HLSL function (don't ask, long story, yes, I'm generating a view matrix per pixel). I'm using the identical source code from MS C# GraphicsDevice.CreateLookAt(yada yada yada...), tranlsated to HLSL. I'm reasonably certain that my code is correct, but the results are completely screwed up, ie, GraphicsDevice.CreateLookAt and HLSL CreateLookAt are returning completely different results. I suspect that this has much to do with the above situation (the lookat matrix is being generated using the results of pos=EyePosition). I don't really expect anybody to get any useful info out of the above code but I'm hopeful that this will ring a bell for somebody....any input would be useful. Thanks!

Share this post


Link to post
Share on other sites
MJP    19788
If you're using XNA, I definitely recommend having a read through the tutorial.

As for what I was talking about here...when you declare a shader constant in HLSL, it will get mapped to an assembly constant register (they're named c# where # is a number). If you flip over to the assembly view in the PIX debugger, it'll show you which registers your variables are mapped to. Then you can look in the registers tab to see the value of that register, to make sure it's what you expect it to be.

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