View Full Version : Question on shaders.
sancheuz
07-Sep-2002, 18:46
Let me ask you geniouses a couple of questions. I am a rookie 17 years of age, i know alot about computer hardware, ect, but not programming. I've been hearing alot about shaders. What are shaders? Also, can you guys tell me how the 3d design and animation business is going. Is it a good career for me to go into?
Runitai
10-Sep-2002, 03:53
I usually have a difficult time explaining shaders, but I'll try:
A shader is basically an assembly program for your GPU. The assembly instructions that make up shaders are referred to as "shader language." While a GPU must implement all standard instructions in order to claim "shader language" compatibility, most GPU's contain some extra instructions to show off features specific to that particular card, such as displacement maps.
Now, the two main shaders used today are pixel shaders and vertex shaders. Things like cube environment maps for reflections fall into the pixel shader category. 3D ripples across a water surface could be done using a vertex shader.
If you want to see shaders in action, run around in quake3 and look at any shiny surfaces or animated textures (like the sky), or browse around nvidia's demo archives.
Shaders let you do some really cool things you wouldn't be able to do otherwise, either because the card doesn't have direct hardware support for it, or because it would take too long to do in software and copy to the card every frame. DOOM 3 draws shadows using a pixel shader. Actually calculating all these shadows in software and then rendering them using API calls would take way too long, and no card/API has hardware shadow support (although things like the stencil buffer make it seem like they do, sometimes, but that's another thread).
Right now, shaders are the equivalent of assembly programs before there was C. Not terribly many people know how to write them, and the resulting code isn't very easy to read. High level shading languages like Cg are the equivalent of C for shader languages. They let you write shaders using a set of human readable commands, and they make it so you don't have to worry about which GPU you're writing your shader for. You just write your code and let the compiler worry about turning it into instructions the GPU can deal with. You never have to program the hardware, so to speak.
I'm sure I screwed up a few things in there, but that's pretty much the way I think of shaders. Granted, I don't know as much about them as I'd like, so don't take my word for it, go read some white papers.
Shader Hacker
26-Dec-2002, 04:32
I disagree on the previous posters definition on shaders. Shaders didn't originate with 3d hardware.
Shaders are, simply put - what gives a 3d mesh its surface color and texture coupled with how light reacts with this surface material.
-M
I disagree on the previous posters definition on shaders. Shaders didn't originate with 3d hardware.
Shaders are, simply put - what gives a 3d mesh its surface color and texture coupled with how light reacts with this surface material.
-M
I agree... it might be true that they haven't been called "shaders" al the time. for example, even legendary Povray has been able to do some fancy tricks using per pixel calculations as well as normal/vertex modifiers since version 2 (heck, I ran it on my 486sx and though it was slow as a snail on highway, it still was my first touch on 3D.)
(I am still waiting when someone writes a program that takes POV files as HLSL/VRML sourcecode and compiles it for hardware previewing / rendering. ;) )
Runitai
12-Feb-2003, 14:47
My apologies.
I've actually gotten into this argument with graphic artists types a few times, where I'll be saying things like Lingo can't do shading, when what I mean is Lingo can't use OpenGL or Direct3D style shaders. I substitute the word "shader" for "shader program" constantly, but I feel my definition answers the original question in the context in which it was asked.
well, i'm a CS student, and in one of our courses we do some 6809 coding :) it's quite interesting.. there's really been a huge progress since when those were the state of the art :)
Luke Philpot
23-Feb-2003, 08:43
There are three main types of "Shader Programs" ;), texture, vertex and pixel.
You can see texture shaders all over Quake 3. The .shader files are the texture shaders, and although they are getting a bit old, they still look quite good, and they are quite fast. Animated textures, environment mapping, etc. are all texture shaders in Quake 3.
Vertex shaders are programs written in an assembly like language that "talk" directly to the GPU itself. These define the position and colour of each individual vertex. They are extremely fast on cards that have hardware vertex shader support, and the software implementations are also quite fast. They are easy to implement (in OpenGL at least, I haven't really done much DirectX coding).
Pixel shaders are also programs written in an language similar to vertex program assembly. However these deal on a per-pixel level, and are generally being used for advanced lighting models (such as phong) which are generally slow on GeForce 2 and lower cards. They are also used in Doom 3 for environment mapping and shadows, and are starting to become more commonplace.
The ARB_fragment_program extension for OpenGL pixel (fragment) shaders are currently only supported by R300 class cards, however the GeForce FX supports this extension. I'm almost certain you can emulate this if you are running Detonator 40's, grab NVEmulate.exe from NVIDIA's developer relations site, or from "Lukey's Dump" - http://www.nightfallinteractive.com/luke
If you need more information just ask, however since I only have a GeForce 2 I can't garruntee that all this post is 100% correct :)
Luke Philpot
23-Feb-2003, 08:47
Ooops, I forgot something.
You are now no longer limited to programming your shader programs in assembly. With the release of Cg, (C for Graphics) and DirectX 9 with its HLSL (high level shader language), you can code in a more C-like language. This makes for less headaches :D and faster development time.
That is all :D
vBulletin® v3.8.6, Copyright ©2000-2013, Jelsoft Enterprises Ltd.