# Pixel Shader Interpolation...

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

## Recommended Posts

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

##### Share on other sites

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!

##### Share on other sites
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).

##### Share on other sites
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

##### Share on other sites
Quote:
 Original post by devroniousI'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

##### Share on other sites

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 !

##### Share on other sites
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?

##### Share on other sites

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 !

##### Share on other sites
I don't know, but it might have been removed from VS2005 to encourage use of PIX.

1. 1
2. 2
Rutin
25
3. 3
4. 4
5. 5

• 10
• 13
• 19
• 14
• 9
• ### Forum Statistics

• Total Topics
632942
• Total Posts
3009342
• ### Who's Online (See full list)

There are no registered users currently online

×