Quote:

If you could tell me exactly how did YOU personaly learn this




What i did was to simply get some sample shaders and modify them a lot, first changing little things, like colors, or multipliers, then gradually learning the various optical and rendering theories behind them. Shaders are quite complex becasue they depend a wide variety of considerations.

You must learn the basic tools of shader development, like how to set up an HLSL shader body, declaration structs, etc. Learn about the fx format, the required inputs and outputs, render states, and masking or swizzling. "Swizzling" is a funny word for a very important concept, and is really quite simple. I will explain this later...

Remember that in a shader you are mostly dealing with 'vectors' which are really arrays of several floating point numbers. This vectors can contain colors, positions, angles, etc. A pixel shader ONLY deals with one pixel at a time, so(except for partial derivatives) you have no access to otehr pixels within a pixel sahder unless you multisample some textures. So just rememeber that you dealig with ojnly one final color and alpha value. This confused me for a long time.

For instance, a texture is normally a float4, meaning that its a vector composed of four floating point values: red,green.blue,alpha. Say I have a texture I define as "tex1". I can access any or all of the channels (or componenets of the vector) by using this method:

tex1.r = 1.0f (makes the red channel 100% red)
tex1.rgb = 1.0f (makes the color pure white)
tex.a=0.5f (makes the alpha channel 50%)
tex1.rgba = 1 (makes the color white and the alpha white or 100% opaque)

This is called "swizzling", masking, etc. Basically this is how you access the individual parsts of a vector, and is very useful. You should already be used to concpet if you use C-Script, like "my.x", "my.pan", etc.. as C-SCripts vars can also be vectors.


------------------------------------------------------------------------------

In short, shader programming takes quite a while to learn, especially if you not really familiar with rendering terms and techniques or the C language, which HLSL is based on.

Start small; i learn best by hacking other people's code. i think you will too.


Sphere Engine--the premier A6 graphics plugin.