Can somebody explain me what are shaders?
Shaders
Started by rogerdv, Aug 22 2003 05:39 PM
7 replies to this topic
#2
Posted 22 August 2003 - 06:20 PM
I'll try it:
In DirectX there are two sorts of Shaders: Vertex and Pixel Shaders. Vertex Shaders can influence everything which is connected with a single vertex, (vertex position, color, texture coordinates, etc.) Pixel Shaders can change the texel-color.
For instance you can use Vertex Shaders to calculate the LxN Vector for each vertex (lighting calculation) and with a Pixel Shader you can modulate the base texture with a bump-map.
Hope this is correct.
In DirectX there are two sorts of Shaders: Vertex and Pixel Shaders. Vertex Shaders can influence everything which is connected with a single vertex, (vertex position, color, texture coordinates, etc.) Pixel Shaders can change the texel-color.
For instance you can use Vertex Shaders to calculate the LxN Vector for each vertex (lighting calculation) and with a Pixel Shader you can modulate the base texture with a bump-map.
Hope this is correct.
#3
Posted 24 August 2003 - 11:21 AM
sounds correct.
when ever you send some vertex with glVertex(), or glDrawElements, or what ever, the vertex gets transformed, lighting with glLight get calculated, texcoords get set/generated (envmap,projected textures, etc..), etc. this part can get replaced by an own coded shader, wich takes care of the transformation, lighting, texcoord generating how ever YOU want.
then, the final generated vertices get send to the rastericer, wich then generates fragments (not exactly the same as pixels in multisampling..). those fragments have the interpolated texcoords, and colors, and that. they then get textured, and for example with multitexturing you do some math on how to combine that, etc. then, it gets drawn onto the screen (if it fits z-test, stencil-test, alpha-test, etc..). this part can get replaced by a pixelshader to make it configurable as you want, again.
in opengl terms they are called vertex and fragmentprograms for now. vertex and fragmentshaders in gl2.
think of it as like this:
and
about that..
when ever you send some vertex with glVertex(), or glDrawElements, or what ever, the vertex gets transformed, lighting with glLight get calculated, texcoords get set/generated (envmap,projected textures, etc..), etc. this part can get replaced by an own coded shader, wich takes care of the transformation, lighting, texcoord generating how ever YOU want.
then, the final generated vertices get send to the rastericer, wich then generates fragments (not exactly the same as pixels in multisampling..). those fragments have the interpolated texcoords, and colors, and that. they then get textured, and for example with multitexturing you do some math on how to combine that, etc. then, it gets drawn onto the screen (if it fits z-test, stencil-test, alpha-test, etc..). this part can get replaced by a pixelshader to make it configurable as you want, again.
in opengl terms they are called vertex and fragmentprograms for now. vertex and fragmentshaders in gl2.
think of it as like this:
glVertex(x,y,z) {
currentvertex.pos = (x,y,z);
finalvertex = vertexshader(¤tvertex);
rastericer.push_back(finalvertex);
}
and
//rastericer:
foreach(pixel p in triangle) {
finalp = pixelshader(p);
if(!ztest(finalp)) continue;
if(!stenciltest(finalp)) continue;
if(!alphatest(finalp)) continue;
if(blending) { screen[p.pos] = blend(screen[p.pos],finalp); }
else { screen[p.pos] = finalp; }
}
about that..
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....
#4
Posted 24 August 2003 - 05:19 PM
Aren't shaders just simple programs that take input (either the vertex or pixel data: colour of pixel, or colour, position, texture co-ord etc of the vertex). Then they perform calculations you program, then output and this is passed onto the rest of the pipeline?
baldurk
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.
#5
Posted 24 August 2003 - 05:28 PM
a shader is just a buzzword. and yes, they replace parts of the pipeline. i explained wich part got done by a vertexshader and wich part gets done by a pixelshader.
i don't call them programs, i call them functions. why? because they replace the fixed function :D (and they really ARE just functions. they get called per vertex/pixel with some input and return an output..)
i don't call them programs, i call them functions. why? because they replace the fixed function :D (and they really ARE just functions. they get called per vertex/pixel with some input and return an output..)
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....
#6
Posted 24 August 2003 - 06:55 PM
didn't MS coin the word 'shader'. It's probably just because shader sounds more impressive than program :).
If you replace one part of the pipeline, can you leave others? or do you have to replace all of T&L etc just to add a lighting effect.
If you replace one part of the pipeline, can you leave others? or do you have to replace all of T&L etc just to add a lighting effect.
baldurk
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.
#7
Posted 24 August 2003 - 07:31 PM
I read the other day about the argument ARB members had when they wanted to name the OpenGL "vertex shader" extension. Eventually they called it: "vertex program" since a shader implies fragment level processing.
#8
Posted 25 August 2003 - 12:22 PM
vertex and pixelshaders are individual thinks. most the time, to get a good effect, you need both at the same time, but technically, you can life with one or the other, it just depends.
vertexshaders manipulate the vertices of your object, one at a time.
pixelshaders manipulate the pixels of currently rendering triangle, one at a time.
its really not difficult to grasp.
its one of the reasons why i think everyone should at least one time in his life have coded a softwarerastericer. then he knows that all, how simple it is, how useful it is, how primitive it is.
vertexshaders manipulate the vertices of your object, one at a time.
pixelshaders manipulate the pixels of currently rendering triangle, one at a time.
its really not difficult to grasp.
its one of the reasons why i think everyone should at least one time in his life have coded a softwarerastericer. then he knows that all, how simple it is, how useful it is, how primitive it is.
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












