PDA

View Full Version : DOT3 diffuse map integration



Purvis
02-06-2006, 07:07 AM
Hi,

Disregarding what <Smiley> says, I'll post this here as noone in the beginners forum replied. :(

I would really appreciate some help and advise from the experts.

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, halos, fx. etc..Is this the better way? Wouldn't it be too slow with so many passes? 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 english. ;)

CrazyButcher
02-06-2006, 09:11 AM
first: vertexprograms do output fogcoord, just make sure you do it. "ABS result.fogcoord.x, vertex.z;"

if you have just 2 textures, this is is gonna be pretty hard. note that actually you should pass tangent not as color but as texcoord and use a normalize cubemap, else you will get issues if your light source gets close to a low-tesselated surface.

also keep in mind that multiple lights only make sense with distance falloff, else it will look pretty weird if all lights fully affect a surface.

what I do on low-end hardware is just using a single perpixel light (sun) and do the fx lights like explosions and other short term stuff still pervertex... that way even with hardware with just 2 texunits you can do a single lightpass for all lights...

with ati_combine3 or nv_combine4 you can mix in the lightcolor as GL_CONSTANT source, though you will have to specify it manually...

here is what I do in the lightpass:
tex0: dot3 normalmap with cubemap(tangent light vector)
tex1: modulate prev with constant(light color) and add primarycolor (contains ambient term and pervertex light accumulations of the other lights)

the pass is set to modulate, and I fog both material and light pass, (light pass with white fog, material pass with proper fogcolor)

Purvis
02-06-2006, 01:14 PM
Thanks so much CrazyButcher. I have fog working ok now. I always thought GL_FOG was a sub-state of GL_LIGHTING.




here is what I do in the lightpass:
tex0: dot3 normalmap with cubemap(tangent light vector)
tex1: modulate prev with constant(light color) and add primarycolor (contains ambient term and pervertex light accumulations of the other lights)

I'm not sure I get it. You differentiate material passes from light passes. Can you develop further? What is done on each pass? Are you always doing two passes? (one for plain colors [materials] and the other for lighting, modulating the previous one?). How do you load both the normal map and the cube map into tex0? For your blending of tex1 are you talking about ati_combine3 and/or nv_combine4? Are you computing per-vertex light contribution of the other lights manually?

Here are my tex envs:



the pass is set to modulate, and I fog both material and light pass, (light pass with white fog, material pass with proper fogcolor)
Now I'm completely lost here... why two fog passes? fog colors get blended separately?

dorbie
02-06-2006, 04:47 PM
Please do not crosspost. Your other thread has been closed (1 comment).

Purvis
02-06-2006, 07:46 PM
Thanks Dorbie for your reply and sorry for crossposting.

I guess with only two texture units I'm completelly cooked.

I'm coming to the conclusion that for my engine I'll do a plain rendering (no bump finally) for OpenGL < 1.5 hw and a full blown version with fragment shaders for newer cards as I have on my desktop PC and forget about all the extension chaos that occured on the middle.