What exactly are shaders?

Started by
10 comments, last by Qatal 19 years, 1 month ago
What do they do that you can't do with a normal graphics API such as DirectX or OpenGL?
______________________________________________________________________________________With the flesh of a cow.
Advertisement
Lots and lots.

(For more specific answers, please give more specific questions.)

Per pixel lighting, for example, is not easily done without pixel shaders. Per vertex computations are done far more efficiently on the GPU.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
I really have no idea what they are. A link to an article would be really helpful.
______________________________________________________________________________________With the flesh of a cow.
Shader basics lecture given in #graphicsdev earlier today.

Shaders allow you to compute quantities on a per vertex or per pixel basis efficiently on the GPU. Vertex shaders can be done (more slowly) on the CPU; pixel shaders can't be done without a software renderer (not counting hardware support, obviously).

Basically, this ability gives you a lot of power and flexibility in terms of what you do. Compare Doom 3 to Quake 3. That's the difference shaders make.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
The 'old' Fixed Function Pipeline is very limited. It can handle T&L Vertex calculations and some more functions, but not the fancy stuff for example Cartoon Shading. With Shaders, you actually replace the Fixed Function Pipeline with your own calculations.

In case you don't know what I'm talking about: see Pipeline as the thing that all your data goes through to end up correctly on the screen. E.g. 3D Vertex ->Pipeline-> 2D Pixel.
So with shaders you can do anything with the Pipeline.
Before shaders, graphics hardware processed data in One Way. You could customize things a little bit by turning states on and off, controlling the way different aspects of that One Way behaved, but at the end of the day the One Way was all there was. You couldn't add new bits to it, create entirely new states to change the One Way in some particular manner, and so on. That One Way is better known as the 'Fixed Function Pipeline.'

Shaders simply allow you to replace that One Way with your Own Way. Want to do fog which changes colour with height? The fixed function pipeline had no provision for doing that, but you could write a shader to do it. Want to do dot3 lighting but subtract the redness of the result from the green and blue? Fixed function can't do it. Shaders can.

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

no shaders to shaders is like calculators to computers.
There is article serie called Vertex Shader Fundamentals in GameDev.Net.

I'm reading it currently, and it has helped me to understand things more in-depth than just reading DirectX SDK's documentation.

Hope that helps
A shader is a program that is on the graphics card.

Because it is on the graphics card and modifies resources on the graphics card it is much faster than computing values on the main cpu and sending to the graphics card. Technically you can do everything on the cpu that you can do with shaders, only much much slower.

Shaders are compiled to a low level assembly-like language and sent to the gpu at runtime.
Thanks. I get the idea now.


BTW:I'm Ainokea, I'm at a school computer so I can't log in.

This topic is closed to new replies.

Advertisement