Archived

This topic is now archived and is closed to further replies.

weasalmongler

NVIDIA Register Combiners Extension Information

Recommended Posts

Hello all, I have been fiddling about with NVIDIA Register combiners and learning about them, and I have managed to use them for Per Pixel Lighting, the thing that I''m not sure about is using Multiple combiners. I know that I can use 1 combiner (GL_COMBINER0_NV) to do nearly all the stuff I want but it may take multiple passes, passing the results from the previous pass into the next one, but If I use more than 1 then does it work with less passes. Basically, the way I see it is if I use GL_COMBINER0_NV and GL_COMBINER1_NV, each doing a different operation and storing the result, and then them both passing their results to the final combiner stage, does it effectively cut out 1 pass because they are processing in parallel? - Weasalmongler

Share this post


Link to post
Share on other sites
quote:

Basically, the way I see it is if I use GL_COMBINER0_NV and GL_COMBINER1_NV, each doing a different operation and storing the result, and then them both passing their results to the final combiner stage, does it effectively cut out 1 pass because they are processing in parallel?


Basically, yes. There will be a (very small) performance hit, if you activate a second combiner stage, but it''s far less than the performance hit you get with multiple passes. Although not all effects that can be done in two rendering passes can also be done on two combiners and a single pass. But most work very well that way.

Also note, that you don''t necessarily need to use the final combiner to unify the results of the two general combiners. You can also pass the result from combiner 0 to combiner 1 and continue processing it there.

/ Yann

Share this post


Link to post
Share on other sites
Thanks Yann U helped a lot yesterday too, now I have another question.

I am using them for bump mapping, and I want to sample a pixel from the colour on the gourad shaded polygon whose colour component will be my light direction converted to texture space, so that I can dot product it with my Normal Map. However, I am not sure which source I should use to get it from, I am guessing that it is the GL_PRIMARY_COLOUR_NV source, but I am not sure. Also, dya know how I can convert my light direction to Texture Space? Thanks lots, U are an excellent programmer.

- Weasalmongler

Share this post


Link to post
Share on other sites
Hi, you pass that transformed(to textre space) light vector to glColor3f() per-vertex so it can be interpolated across the surface and you can access it in the register combiners using GL_PRIMARY_COLOR_NV, so...passing that light vector(R = X, G = Y, B = Z) to glColor3f is just to be able to get it in the register combiners. Hope you get it. I''m not very good with my english.

Transforming a vector into texture space you need to use derivatives and i''m not good at math so i''ll stay quiet
All i cant tell you is that you need to use derivatives, check the nVidia papers to get more information on it.

Hope this help you.

Bye

Share this post


Link to post
Share on other sites
Thanks _Rambo_. I knew about the R=X, G=Y, B=Z but the GL_PRIMARY_COLOR_NV was just what I was looking for. I''ll go and look at NVIDIA''s site but I would really appriciate anyone who could explain how to do it here Thanks again everyone for your time

- Weasalmongler

Share this post


Link to post
Share on other sites
OK, I worked out that to get a light vector into texture space you have got to build a 3x3 matrix and multiply the light by it.

This is build like this:

N = normal, B = Binormal, T = tangent
(all of the vertex currently being processed)

|T.x B.x N.x|
|T.y B.y N.y|
|T.z B.z N.z|

Now, I am not sure how to calculate the binormal and tangent. The normal is simple enough, I have that, and I know I can calculate the Binormal as a cross product of the Normal and the Tangent, but How do I get the tangent?

This is the final piece to my Bump Mapping puzzle (I think) so would anybody be able to help me out with this last bit?

- Weasalmongler

Share this post


Link to post
Share on other sites
tangent is ''texture space''
heaps of info at the nvidia site (umungst others)

http://uk.geocities.com/sloppyturds/gotterdammerung.html

Share this post


Link to post
Share on other sites
quote:

Now, I am not sure how to calculate the binormal and tangent. The normal is simple enough, I have that, and I know I can calculate the Binormal as a cross product of the Normal and the Tangent, but How do I get the tangent?



Ok. Imagine your normal sticking out of a triangle. This triangle also defines a plane (and the triangle's normal is also the normal of that plane). The tangent is a vector along this plane, and the binormal the crossproduct between the normal and tangent. The binormal also runs along the triangle plane, it's perpendicular to the tangent.

Now, the tangent defines texture space. To get it's exact direction along the plane, it must follow the mapping coordinates of the normal map. The analogy is simple: the tangent T corresponds to the direction of the texture coordinate s, and the binormal B to the texture coordinate t.

Try to imagine how your normalmap is applied to the triangle in 3 dimensions. Try to picture the direction of the s,t axes on the 3D triangle. Now, the tangent is simply a vector that follows the direction of s and the binormal follows t. Both stay on the plane of the triangle.

That's per triangle. To get them per-vertex, just weight them as you would do with per-vertex normals.

It's not that easy to explain this without pictures. Have a look this paper from nVidia. It explains how to create the texture space coordinate frames (the normal, tangent and binormal), incl. nice little images.

/ Yann

[edited by - Yann L on August 31, 2002 1:32:06 AM]

Share this post


Link to post
Share on other sites