PDA

View Full Version : DOT3 diffse bump map questions



Purvis
02-05-2006, 01:36 PM
Hi,

I've implemented diffuse bump mapping using the DOT3 blend mode and is working fine. It does its job in a simple pass, and does not require a top-notch graphic card.

However, I have some questions that arise when 'I guess- when we pass from an eye-candy bump-map demo to a real implementation in a rendering engine.

The first one is related to the light color. I pass the light vector in tangent space in texcoord1, and then render in a single pass using multitexture, with diffuse texture loaded in tu0 and the normal map in tu1. Then the blend modes are set to perform a dot3 on tu1, but I don't know where to put the light color in the blending states, and worse, if its possible to accomodate for it somewhere, as to render in a single pass.

Any idea?

Another question is related to fog. I have my scene with fog and I have some materials with dot3 bump-map. However I lost the fog in those materials: Since I'm using a vertex program, fog calculation and contribution are bypassed. So, the question is... Is there a way to add the fog in computations *without* fragment shaders? Or there is no other way than rendering those triangles with all material properties set to 0,0,0,0 in a second, additive pass (Ambient light could be added here too).

Finally, how do we manage multiple light sources with bump-mapping? I guess only by multiple passes, one for each light. So the rendering algo would be:


* Render all materials that have no bump, with std shading, fog enabled
Then for each light
* Render materials with bump using vp, for light0
* Render materials with bump using vp, for light1
...
* Render materials with bump using vp, for lightn

* Render materials with bump as pure black, std lighting and fog enabled.
* Render transparencies.
etc..Is this the better way? Wouldn't it be too slow? Or would it be better to have a vp (vertex program) that computes the light vector in tangent space for several light sources and outputs these in various different txcoords. If that's the way, how can I use a texcoord (aka vertex attribute) as a blending operand?

Of course, all this should be possible with OpenGL 2.0. But can it be done with 1.3 or 1.4?
(No fragment shaders)

I really would like to have bump-map well integrated in my rendering engine, and running in GL < 1.5 hardware.

Thanks in advance and excuse my engligh. ;)

dorbie
02-06-2006, 05:31 PM
Well to do light color you need another parameter but it could be a constant.

You do DOT3 on TU1 that suggests TU0 is free, because you need to modulate diffuse afterwards, that's if you're using standard combiners, something like register combiners are more powerful still.

Anyhoo, I'd expect the DOT3 on TU0 with diffuse or light color modulation on TU1. Now it could be a texenv constant color that you use in a modulate but if you already have a modulation (say for that diffuse texture) then that implies using another texture environment combiner (depending on extension this may be a problem). So you could enable features like light colors depending on available texture units.

As for fog, make sure that you set the fog value if you have your own vertex program, the problem is probably that your vertex program doesn't pass for to the fixed function fragment pipeline if you're using vanilla combiners. As an aside some vendor specific extensions require you set up fog on a final combiner.

(thread closed due to crosspost)