Archived

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

What, exactly, is a vertex shader?

This topic is 5747 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

I''ve looked everywhere, and I''m either missing the obvious, or I just can''t find any info. Can someone clue me in? -Normie the Infinitely Clueless

Share this post


Link to post
Share on other sites
A very quick reply (sorry, short on time...)

Check out the ripple sample in the SDK. The vertices in that sample are set to a flat plane. The ripple effect is being done by a shader that applies a sine wave to the vertices based on their distances from the center of the plane (I think it''s the center...)

A vertex shader manipulates vertices within the hardware. There are many many uses for this.

Share this post


Link to post
Share on other sites
No a vertex shader is an algorithm to procees 3D vertices into 2D screen space. You could use it for tweening ( I do)as well as a billion other things)

Example:

You want to have a simple water effect where the position of the x part of the vertex is multiplied by the sine of the y part. To do this without a vertex shader you would have to process each vertex with this sin function, copy that into another Vertex Buffer, Output that vertex buffer. Using a vertex shader you simply tell D3D to use your transormation code instead of passing an FVF to the SetVertexShader. A small piece of Vertex shader assembly processes that algorithm (which is HW accelerated on Geforce3+ and Radeon, or 3DNow/SSE/SSE2 on the processor here no HW Acceleration).

If you seach the net there are tone of cool demos and articles on them. It makes programming D3D 8 really cool as you can create your own effects so easily.

PS Vertex Shaders are called (more sensibly in my opinion) Vertex Programs.

WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!

Share this post


Link to post
Share on other sites
So, a vertex shader doesn''tchange vertex locations then. They basicaly just screw with the normals then... Kinda correct? So it acts kinda like a procedural bump map? Am I even in the right ballpark here? Thanks.

Landseknecht

Share this post


Link to post
Share on other sites
A vertex shader replaces the normal T&L route. Basically when you call DrawPrimitive, for every vertex your VS code is called.

This code may change the vert positions, the colours, apply lighting, apply bump effect, make every thing green, etc, etc.



Share this post


Link to post
Share on other sites
No, incorrect. You can change the position (or in fact: any vertex attribute) in the shader. You cannot create new vertices or delete them using a vertex shader.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
It sounds like a vertex shader is a vertex modifier, and has little to do with shading.

Share this post


Link to post
Share on other sites
It''s more like a Vertex PROCESSOR. You give it 3D coords and output to a 2D screen. Create whatever effects you like along the way.....

Neil

WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!

Share this post


Link to post
Share on other sites
Oooooooo, cool.... looks like I got something new to study (though I''m still mostly a beginner at D3D...am I biting off more than I can chew here?)

-Normie the Eternal Newbie

Share this post


Link to post
Share on other sites
There is a chapter devoted to vertex/pixel shaders in "special effects game programming with directx" by Mason McCuskey in case you need to learn more about it.

-Allen P

Share this post


Link to post
Share on other sites
Check out the thread

http://www.gamedev.net/community/forums/topic.asp?topic_id=86194

To check out my vertex tweening VS. Any questions my e-mail is in my profile.....

Neil

WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!

Share this post


Link to post
Share on other sites