per pixel shaders..

Started by
1 comment, last by Fluid FX 20 years, 11 months ago
ok i have some questions which do not get clear... how do i know what commands i can "pair"? (mov .. + mul .. for example) and, isn't it impossible to do lightning or shadowing (maps) with pixel shader 1.3? cause the instruction count is so low that you can do max 2 lights (which would be four if enough could be paired)?? GreeTZ Sound Sphere [edited by - Fluid FX on May 28, 2003 4:16:05 PM]
Advertisement
you can''t really ''pair'' functions. I think you read it in the SDK. They just say that, that you should logically use the least possible intsructions.

so mad instead of mul and add and so on

mul r0, r1, r2
add r0, r0, r3
//should be
mad r0, r1, r2, r3

and:
mul r0, r1, r2
mov oT0, r0
//should be
mul oT0, r1, r2
1)
a. There are two pipelines in a pixel shader just as there are with the fixed function pixel processing: "colour" and "alpha" (or "vector" and "scalar").

b. Two instructions can be paired if they each use different pipelines. So if instruction #1 writes to .rgb and instruction #2 writes to .a, those two instructions can be paired (no guarantees that they will be - that''s up to the hardware/driver).

c. As mentioned in the docs :
DirectX Graphics ->
Reference ->
Pixel Shader Reference ->
Architecture ->
Instruction Pairing


2) The majority of your lighting and shadowing stuff should go in vertex shaders. The output of your vertex shader should be one of the values that''s interpolated across the polygon (color1, color2, texture coordinate).

Or do you mean that you can''t get enough dp3 instructions in a pixel shader to do: L.N, N.H, clamp and occlusion term for more than two lights? (i.e. number of lights * (L.N,N.H,clamp,occlude etc).

Unfortunately that''s just the limitation of current hardware!
AFAIK the vast majority of developers aren''t trying to use the extra power of shaders to reduce multiple per-pixel lighting into a single pass; that''s not even practical with per-vertex lighting without severely limiting the number of light sources.
Instead, people are continuing to do multiple passes (i.e. one pass per light), but making each pass much more rich (more sophisticated BRDFs etc).

A current hot topic which in a way DOES allow multiple per-pixel sources in a single pass (albeit usually far away) is the whole Spherical Harmonics thing and its image based lighting relatives.





--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

This topic is closed to new replies.

Advertisement