Advertisement

detail texture blend-out

Started by May 14, 2002 11:13 AM
29 comments, last by _DarkWIng_ 22 years, 9 months ago
I''m not even sure a GF4 can do it in multipass
Anyway, you might be able to use register combiners on GF2+


Bump-mapping and detail-texturing are very similar.
The only difference is that bump-mapping is more complicated since it is dependant on the light source''s position (and on the viewpoint position for specular bump-mapping).


BTW, I''ve thought of another technique which may work on your TNT2 using both texture_env_combine and texture_env_combine4 extensions :

In first pass :
combine with INTERPOLATE : Arg0 * (Arg2) + Arg1 * (1-Arg2)
Arg0 = "detail" texture
Arg1 = texture environment color (ie GL_CONSTANT)
Arg2 = color->alpha

using the Texture Environment Color to (0.5, 0.5, 0.5, 0.5).
for Arg1 you may either use GL_SRC_COLOR or GL_SRC_ALPHA as OPERAND since both give a RGB value of (0.5, 0.5, 0.5)

In second pass :
combine4 with ADD_SIGNED : Arg0 * Arg1 + Arg2 * Arg3 - 0.5
Arg0 = color->rgb
Arg1 = "decal" texture
Arg2 = Previous texture
Arg3 = texture environment color

using Texture Environment Color to white.
or as Arg3 you can use GL_ZERO as SOURCE and GL_ONE_MINUS_SRC_COLOR/ALPHA as OPERAND. This way you don''t need to call glTexEnvf to set the texture environment color to white.

Hope that does the trick !

Explanations :

The first pass computes the bright/dark to apply, using detail texture modulated by color->alpha. The result of the first pass is between 0 and 1 :
* 0 means ''darken''
* 0,5 means ''no effect''
* 1 means ''brighten''
If color->alpha is 1, the detail texture rules the bright/dark.
If color->alpha is 0, the bright/dark rule is 0.5 (because of texture environment color) which means ''no bright no dark''

The second pass applies the recently computed bright/dark element (in range [0,1]) to the "decal" texture.
The decal texture is multiplied by the primary color in order to modulate the texture with current color of the polygon (especially due to lighting).
The bright/dark element is multiplied by 1 because we don''t need to change it.
And after the addition, we subtract 0.5 so that :
* when the bright/dark element is 0, that subtracts 0.5 to the color, (darken)
* when the bright/dark element is 0.5, that adds 0 to the color,
* when the bright/dark element is 1, that adds 0.5 to the color (brighten).

USEFUL :
If your primary color is white (eg there''s no lighting and you called glColor3f(1,1,1)) then you can replace the second pass by a simple ADD_SIGNED (without combine4, so the equation is Arg0 + Arg1 - 0.5) :
Arg0 = "decal" texture
Arg1 = previous texture
hmm... seeing no reply, I''m assuming this doesn''t work..
Too bad, I would have bet it might have helped.
Advertisement
because I use .dds textures (mipmaps in the texture) I did this by fading the mipmaps to white. Very easy, very fast, and looks good. For your situation, have you considered just using fogging? set fog to white (or grey for signed), and the distance you want, and bang, done. But it'd have to be it's own seperate pass (I think).
something to consider.

[edited by - RipTorn on May 20, 2002 9:24:25 PM]
Sorry for no reply. I''ve actualy tried it. But resulats are not so good. The bigest problem is speed(it works way to slow). I''ll just wait until I can use register combiners and try then.
Thanks

RipTorn: What do you mean by using fog? Right now I''m using OpenGL''s fog(well, NV_RADIAL thingy)

You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
Too slow ? I'm sorry I guess I was not explicit enough. I meant it was possible to do it in one pass only.
By 'first pass' I meant 'first texture unit' and by 'second pass' I meant 'second texture unit'. I have to be careful about technical terms. Sorry.
Because your TNT2 supports HW multitexturing, it should not be that slow (unless you use linear-mipmap-linear for both decal and detail textures).
Anyway, apart from the fact that it's slow, does that work ?

RipTorn : That's a good idea, but it may not be possible to blend with 'signed' colors, and it assumes that detailed parts of the objects do not intersect the fog volume if there is one.

[edited by - vincoof on May 21, 2002 6:11:53 AM]
use the fog to fade the texture out for you. ie, if your using signed additive, make the fog grey, or if it''s lightmap style scaling, white. that should, in theory, do the trick. Ie, in the distance, where complete foggin effects the texture, the blending operation will have no effect, as it will either signed add grey, or multiply by white.
This is what you want, isn''t it?
Advertisement
RipTorn : Now I get it. Interesting idea. I''ll try it.

vincoof : with slow I think like not much faster than using 2 passes or detail texture (add and then subtract)

You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
There exist a blending fuction GL_SIGNED ?
I didn''t know...
As slow as in two passes ? Well, it shouldn''t but since it''s a complex function, the drivers may have to simulate it by two passes.
Anyway, theorically it can be done in one pass. In practice, I need a TNT2 to test it, but I''m not gonna buy a TNT2 now that I''ve got a GeForce3
Multitexturing on TNT is sloooooowwwww! I get almost the same speed using 1 multitexture pass or 2 single texture passes. The ony reason I use it becoue it works much faster on GF+.

about that fog idea.. before I try to code it.. Isn't fog added to color after blending?

You should never let your fears become the boundaries of your dreams.

[edited by - _DarkWIng_ on May 21, 2002 2:52:41 PM]
You should never let your fears become the boundaries of your dreams.

This topic is closed to new replies.

Advertisement