I'm trying to implement DoomIII graphics (well, at least per pixel lighting and stencil shadows) on GF2 class hardware, and I found this idea by pcchen in an old DoomIII thread:
I'm just wondering, how the h*ll would you do it (D3D)? As I see it i'd have to, for each light:
pass 1: Do a dotproduct3, put in destination alpha
pass 2: Modulate material color texture by some attenuation factor (maybe another texture) and blend it in additively, but multiplying by destination alpha
But you can't put the result of a dotprod in the alpha channel! D3D docs about dotprod3:
So, I'm stumped. Any ideas?
If it is not possible to compute diffuse in one pass, it will be much more complicated. A method is to use the destination alpha as a temporary storage for intensity of the light, and later modulate it with the color of the light into the color buffer (use "dest_color + dest_alpha X light_color"). This will be required if you want to implement an accurate per-pixel lighting with per-pixel attenuation on a GeForce 1/2 class hardware.
I'm just wondering, how the h*ll would you do it (D3D)? As I see it i'd have to, for each light:
pass 1: Do a dotproduct3, put in destination alpha
pass 2: Modulate material color texture by some attenuation factor (maybe another texture) and blend it in additively, but multiplying by destination alpha
But you can't put the result of a dotprod in the alpha channel! D3D docs about dotprod3:
Also, note that as a color operation this does not updated the alpha it just updates the rgb components.
However, in DirectX 8.1 shaders you can specify that the output be routed to the .rgb or the .a components or both (the default). You can also specify a separate scalar operation on the alpha channel.
So, I'm stumped. Any ideas?