Skip to main content
GameDev.net gamedev.net
🔒 Locked

Pixel Shader Interpolation...

Started by devronious Jan 27, 2007 at 11:04 AM 7 replies 5.8k views
Original Post
devronious
devronious
In ps2.0: if I have passed in to a vertex shader the vertex locations (ie: 0,0 and 100,100) as a Texture coordinate TEXCOORD1. Then pass it straight thru to the pixel shader will the pixel shader interpolate between the two vertex locations per pixel? I would like to know the exact vertex coordinate per pixel. Thanks, Devin
Demus79
Demus79

Well, I don't see any reason for you not to test this simple by feeding the data to the shader and see the results.

According to the DX SDK, a texture coordinate register in PS2.0 contains high precision, high dunamic range data value with precision of a float. So you should get the position data quite well to the shader.

All the texture coordinates are interpolated correctly.

Cheers!
S1CA
S1CA
If I understand what you're asking correctly, then: yes.


For a primitive such as a triangle:

     t1    //\\   //  \\    //    \\ //  P   \\ t3-------t2


(Please ignore the double lines, the forum software seems to want to swallow backslashes in code and source tags...)

If texture coordinates t1, t2, t3 contain the vertex positions, the texture coordinate read in the pixel shader for pixel P will indeed be the vertex position of P.

Things to bear in mind:

1) the interpolation is perspective correct (which is usually what you want).

2) the position of P will be in the same space/coordinate system as t1,t2,t3. So if the values you store for t1,t2,t3 are in object space, the interpolated position P will be in object space too. If you want the position in some other space (like screen space), remember to transform the texture coordinates first (usually in the vertex shader).
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site
devronious
devronious
Demus79,

"Well, I don't see any reason for you not to test this simple by feeding the data to the shader and see the results. "

I'm not sure how to look at a pixel shader register in debug mode. Is there a way to break the pixel operation and look at the registers?

Thanks for the assurance. I'm having trouble getting my deal to work.

-Devin

S1CA
S1CA
Quote:
Original post by devronious
I'm not sure how to look at a pixel shader register in debug mode. Is there a way to break the pixel operation and look at the registers?


PIX
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site
Demus79
Demus79

As said, you can use tools like PIX, but I was referring that you can use also the "I feel it's right" - method or "looks correct on screen" - method. It's kind of visual debugging.

So, pass the (world/object/view space) position to the pixel shader through the texture coordinate and make the pixel shader to output the (absolute value of the)position as a color (XYZ -> RGB).

You'll need to add some scale so that you can present a bigger range of space than 0 to 1. If you use the view space you'll need to do some divisions with the w component.

Naturally this should output black near the origo of the space and brighter colors at the distance.

Good luck !
devronious
devronious
I'm trying to debug my project using shader debugging. But I can't seem to find the shader debug portion of the debug menu in vs2005. Is this not operable in vs2005?
Demus79
Demus79

You should have under the debug menu Direct3D -> Start With Direct3D Debugging.

If you don't have it, then you should go to the SDK installer and install the missing parts. If I remember correctly, it isn't installed by default.

Cheers !

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.