Jump to content
  • Advertisement

Archived

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

duck17

dx8 render pipeline question....

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, im in the process of learning how vertex shaders in dx8. does the shader execute before or after the world, camera, and view transforms; *or do i need to manually include world, camera, view transforms into my vertex shader code? if there are any other details i should be aware of please let me know. Thanks, -Duck17

Share this post


Link to post
Share on other sites
Advertisement
I cannot offer you exact details at this instant. But I can tell you that in order for your vertex shaders to function properly you must provide the contatonation of the world, view, and projection matrices as a series of four constant variables of four components each. It is important that you realize that in general, a vertex program assumes that the matrix you have provided is in row-major order. This is because in order to transform your points you will be using a series of 4 dot products to attain the homogenus coordinates of your vertices:

eg.
# where oPos is the output vertex, vPos is the input vertex
# and c[0] - c[3] constitute your projection/view/world matrix.
#
dp4 oPos.x, c[0], vPos
dp4 oPos.y, c[1], vPos
dp4 oPos.z, c[2], vPos
dp4 oPos.w, c[3], vPos

As a simple example try using the four dot product method on a plain translation matrix:

row-major
| 1 0 0 x |
| 0 1 0 y |
| 0 0 1 z |
| 0 0 0 1 |

vs

column-major
| 1 0 0 0 |
| 0 1 0 0 |
| 0 0 1 0 |
| x y z 1 |

Which of these two will yield a correct result? And Just imagine throwing rotation into the mix.

Now, the folly here is that DirectX and OpenGL both natively fancy column-major ordering thus requiring you to, at one point, transpose your matrix before it is passed to your vertex shader. If you are not familiar with such matrix operations, please take a look at the description of matrices at Math World:
http://mathworld.wolfram.com/Matrix.html

More specifically:
http://mathworld.wolfram.com/Transpose.html

I personally store my matrices in row-major order since it is consistent with the proper mathmatical representation of matrices. Also, since I am turning so heavily towards vertex shaders, I see no need to have my matrices column-major. Do as you will, and good luck playing with vertex shaders. They are a hell of a lot of fun. You can come up with some very interseting effects.

Danny

Share this post


Link to post
Share on other sites
quote:
Original post by duck17
hi, im in the process of learning how vertex shaders in dx8.

does the shader execute before or after the world, camera, and view transforms; *or do i need to manually include world, camera, view transforms into my vertex shader code?

if there are any other details i should be aware of please let me know.

Thanks,
-Duck17



Vertex shaders replace EVERYTHING before clipping.

So you need to handle transformation from object->world space, world->view space, view->clip space yourself.

The only requirement with a vertex shader is that you ouput vertices in homogeneous clip space, what happens before that is entirely your decision.

So the matrices used by the fixed function pipeline, which are set with SetTransform() calls have *no effect* when using shaders.

One small subtlety is certain types of clipping will require a valid fixed function projection matrix to be set even when using shaders.

It''d probably be a good idea to check out:

1) the pipeline diagram in the SDK documentation
2) the simpler vertex shader samples in the SDK
3) the vertex shader samples available on the nVidia/ATI websites
4) the articles by Wolfgang Engel which I think are linked off the GameDev.net title page

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!