Pixel Shader explanation

Stercus

Junior Member
Aug 24, 2002
14
0
0
I am looking for some explanation of the Pixel Shader. I would like to know what is does (not that it makes the image look cool) and what the difference is between the different versions.

So an article or something would help. I have been searching the last day on google and microsoft.com but only found something about the registers.
 

Stercus

Junior Member
Aug 24, 2002
14
0
0
Am I asking the wrong place? I am not used to this forum but it seemed to be here I should ask.
It does not have to be a 1273 pages long explanation, just so I get the most important.
 

ScrewFace

Banned
Sep 21, 2002
3,812
0
0
Pixel shaders are amazing. Each individual pixel can be a different color and shaded to make awesomelly real-looking games.
 

Stercus

Junior Member
Aug 24, 2002
14
0
0
Even though I am quite stupid I do know that.

And it does not tell what the difference is between the different versions.
 
Jun 18, 2000
11,197
769
126
The goal of the raster (render) process is to assign a color value to every pixel on your screen.

Multitexture:
Imagine a 256x256 texture map being layed overtop a 256x256 square of pixels. In the multitexture process, the pixels get assigned a numeric color value directly from the texture applied to it. Pixel(x,y) will get assigned a RGB (red/green/blue) value based on the texel that overlays the pixel's coordinates.

fetch color from texture -> assign to pixel

Pixel Shader:
Now imagine the same 256x256 square of pixels. Instead of fetching a RGB value from the texture and directly assigning it to the pixel, we are going to fetch the RGB value and execute a shader that will calculate a NEW color value. This new color value then gets assigned to the pixel.

fetch color from texture -> execute pixel shader -> assign results of shader to pixel

Rmember, everything in nature can be expressed with mathemetics. With the proper mathematical formula/shader, you can reproduce complicated shadows, reflections, refractions, etc, etc.

Its a tad more complicated than that, but you get the idea. As a side note, OpenGL calls them fragment shaders - they are the same thing.
 

Stercus

Junior Member
Aug 24, 2002
14
0
0
Thanks that sure was a good explanation of what Pixel Shading is.

My foremost concern (which I presume I haven't made clear) is what the difference is between the different version of Pixel Shader. What are the requirements for version 1.0, 1.1, 1.2, 1.3, 1.4 and 2.0.

Hope you can help me with this also. Google hasn't given me what I was looking for.
 
Jun 18, 2000
11,197
769
126
Regarding the different shader versions:
The different versions denote the functionality exposed to the developer. The added functionality varies from more temp registers to more instructions.

You have 2 color values, X and Y, and you need to find the product. In this example, you would multiply the 2 color values using the MUL instruction, and then store the resulting color value into a temp register for later processing (if you need it). There is a limit to the number of math instructions you can string together to make a shader. This limit is a major difference between the various pixel shader versions. The other differences, like data-dependent branching, dynamic branching, conditional assignments, etc, I won't get into.

A sequence in shader assembly would look like the following:

sub TMP, X, Y;
ble X, 0, SETY;
mov X, Y;
j DONE;
SETY:
mov Y, X;
DONE:

(the assembly is ripped from Beyond3D.com)