#### Archived

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

# What, exactly, is a vertex shader?

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

## 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 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 on other sites
So, a vertex shader actually has nothing to do with shading? It just tweens the vertices in place?

Makes sense, but why is it called a shader then?

Also not sure,
Landsknecht

##### Share on other sites
if you''re familiar with Raytracer software, just think of Vertex shader as procedural displacement maps.

##### 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 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 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 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 on other sites
Yes, as I said, the vert positions, the colours, apply lighting, apply bump effect, make every thing green, etc, etc.

##### Share on other sites
It sounds like a vertex shader is a vertex modifier, and has little to do with shading.

1. 1
2. 2
3. 3
Rutin
18
4. 4
5. 5
JoeJ
13

• 14
• 10
• 25
• 9
• 57
• ### Forum Statistics

• Total Topics
632640
• Total Posts
3007618
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!