Per-pixel attenuated diffuse bump
Hi forum!
I''ve been thinking about the lighting equation trying to implement it only with 4 TMU''s. And that''s what I''ve thought:
When you are doing per-pixel lighting, You are (basically) resolving for diffuse light:
(N dot L) · Att · Decal · Color
You Normalize L with a Normalization CubeMap, N is in a 2D Texture, Decal another 2D Texture, Color is a constant and Att is at least a 3D texture, or a 2D + 1D one, or a pass-through, so it eats al least 1 TMU.
But lets think mathematically:
(N dot L) · Att = (Nx·Lx+Ny·Ly+Nz·Lz) · Att
So you can do:
(N dot (L·Att)) = (Nx·Lx·Att+Ny·Ly·Att+Nz·Lz·Att) = (Nx·Lx+Ny·Ly+Nz·Lz) · Att
Ok. Att is function of distance, so Att = Att(d)
and usually Att(d)=1-d^2, being d=sqrt(x^2+y^2+z^2)
so, if we use a 3DTexture instead of a Normalization CubeMap to perform light normalization, we could include attenuation on this stage. You should compute de reverse distance vector from the center of the cube which is the 3d texture to each pixel of the 3d texture, being (1,1,1) on the center and (0,0,0) outside a sphere of radius 1 inside de cube, so when you normalize your light vector, the 3Dtexture will return you L·Att. It''s like non-attenuated per-pixel lighting, but you will have to transform (r,s,t) coordinates dividing by light''s radius in the vertex program!
Am I right? Or I have a big mess in my head? I''m thinking about specular too, but I haven''t found a way to do it in my spare TMU (the forth). Maybe storing specular attenuation into alpha component of 3d texture?
What do you think about that??
---------------------------------------
"It''s only a bit, it can''t hurt you..."
--------------------------------------- "It's only a bit, it can't hurt you..."
Nice idea. But I think you'll run into some precision problems (on cards without FP textures). If you try it please upload some pictures. I have no idea about specular. I don't think alpha chanel will work for this.
You should never let your fears become the boundaries of your dreams.
[edited by - _DarkWIng_ on July 19, 2003 3:44:03 AM]
You should never let your fears become the boundaries of your dreams.
[edited by - _DarkWIng_ on July 19, 2003 3:44:03 AM]
You should never let your fears become the boundaries of your dreams.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement