Sign in to follow this  
Dospro

Whats vertex Shader and stream?

Recommended Posts

Dospro    257
Hi. I was reading the Jim Adams' book nd when i got to the vertex stream and vertex shader section, i didnt understand a word. What are them? Con someone give me a better explanation about this?

Share this post


Link to post
Share on other sites
Supernat02    604
Don't try to over-think it (I am guilty of always doing that!). It's really just what it sounds like. The vertex stream is a stream of vertex data from memory to the processor (in some cases from video card memory to the Graphics processor(GPU), in some cases from system memory to the GPU, etc.). The Vertex Shader is the "entity" responsible for shading the vertices. Say you have a triangle with 3 points on the screen. You need to shade that triangle to see it, right? You can make it all white, all burgundy, shade from blue to green, or apply a texture to it for instance. That's what the shaders (vertex and pixel) are responsible for, and so much more these days. You can use the Fixed Function Pipeline (FFP) which uses a built-in hardware shader on the video card. You just supply a Flexible Vertex Format (FVF) to the pipeline and it will know what to expect in the vertices that you stream to it.

The FVF is really just a bit-packed DWORD that tells the video card what you're going to put in each vertex. A 3D Position, diffuse color, and texture coordinates for example. You would Bitwise OR the 3 D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1. Instead of calling SetVertexShader(FVF), you would call SetFVF(FVF) and call SetVertexShader(NULL); The reasoning behind this is that most people think of vertex shader as a piece of software that can be used in place of the fixed function pipeline. If you aren't using software, you set it to NULL. That brings up the next topic. A software Vertex Shader (or programmable vertex shader) is set using the SetVertexShader function. A vertex shader can do many things. For instance, it could move the triangle to a different part of the screen. It could move just one vertex of the triangle to a different location. On a frame by frame basis, you can use a vertex shader to move vertices each frame in real-time. You can't add or remove vertices from the pipeline however (although I'm sure in the future.....)

Chris

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this