pixel/vertex shader?

Discussion about everything. New games, 3d math, development tips...
Post Reply
Phunk
Posts: 78
Joined: Sun Dec 14, 2003 8:18 pm
Location: The Netherlands

pixel/vertex shader?

Post by Phunk »

I'm kinda new to 3d programming, an i've read about pixel and(I think) vertex shading, but its all abracadabra to me, can somebody please explain what they are, do, and what is so great about them? It also seems to me that it is very dificult to program(involves algebra?) is this true, or is it just something that you need to get the hang off?
Greets, Robin
Luke923
Posts: 59
Joined: Wed Nov 05, 2003 5:26 am

Post by Luke923 »

For all intents and purposes, vertex/pixel shaders are nothing more than "programs" (for lack of a better term) that run on the graphics processor instead of the CPU. The main advantages are that:

1. They free the CPU up for running other types of code (AI,sound, physics, etc.).
2. They tend to run faster than the "software" counterparts since all the shader has to do is load once into video memory and run on the GPU, thus reducing traffic on the AGP/PCI bus since the GPU and the CPU will have to communicate less than attempting the same the same "program" in software.

As far as difficulty, it definitely doesn't hurt to know Linear Algebra, since the majority of the "program" involves multiplying matrices - just as anything involving 3d programming would require. On the other hand, if you aren't planning on creating your own shaders (i.e. taking someone else's shader code and putting it into your own app/game), you can probably get by without knowing higher math.

Hope that helps
"Object-oriented programming is an exceptionally bad idea which could only have originated in California."
- E.W. Dijkstra
Gorgon Zola
Posts: 118
Joined: Thu Sep 18, 2003 10:05 pm
Location: switzerland

Post by Gorgon Zola »

http://www.cgshaders.org --> tutorials
http://www.cgshaders.org/shaders/ --> shader examples

just to get a idea what shaders are :wink:

cheers
tom
Tels
Posts: 65
Joined: Fri Feb 27, 2004 7:56 pm
Location: Antarctica
Contact:

Post by Tels »

Some more notes:

A vertex shader is a (very small, limited) program that is run for each vertex (polygon/triangle edge). For instance, instead of deforming/animating a model, you send over a static version to the grafic card, and let it deform it for each frame.

Not only can the GPU (very probably) deform the vertices much faster than your CPU, the deformed vertices don't need to be sent over the bus (PCI, now AGP) to the grafic card, which means it is much faster.

Deforming here means position, and also light value plus texture coordinates.

A pixel shader is a (similiar, usually even smaller) program thatis run for _each_ pixel that is drawn. It can "deform" the texture coordinates, therefor drawing a different pixel than you normally would see. The same goes for lighting, color etc. This is usually used for effects like water waves, bumb mapping etc, which are all just "illusions". E.g. there are no real waves on the face of the object, but the texture is distorted and warped so that you think there are waves.

Best wishes,

Tels
Perl + Irrlicht + Audiere = Game: http://bloodgate.com/perl/game
Phunk
Posts: 78
Joined: Sun Dec 14, 2003 8:18 pm
Location: The Netherlands

Post by Phunk »

thank you all!!!!, I know enough now,

Greets.
(PS: And all you posters in the forum, Great work! I think this is one of the most friendly, tollerant, helpfull forums I've found)
Post Reply