GL_ARB_texture_env_combine question...

Started by
4 comments, last by JD 19 years, 7 months ago
Using this extension is it possible to modulate 2 textures and output the second texture based on the alpha of the vertex. What I have is terrain with a base texture and then i can have detail textures on top of that, where (and how much) each detail texture should be applied on the terrain is held in the color stream (GL_COLOR_ARRAY) of the patch. So is it possible to do it this way or would i need to store a mask/alpha texture and use that as a lookup. Thanks in advance
Advertisement
I think you can load detail texture into source1 and vertex clr+alpha into texture unit1 then modulate them and output the results into second unit where a low freq. texture is used as source2 and previous result as source1. Then the two are modulated to output to color buffer. Possibly scaled by 2 or 4 in the process. You can also input a constant color+alpha to the texture units. You can also blend the output from last texture unit with the color buffer. Lastly, you can multipass if running out of texture units. Don't forget crossbar to cut down on passes.
Quote:Original post by JD
I think you can load detail texture into source1 and vertex clr+alpha into texture unit1 then modulate them and output the results into second unit where a low freq. texture is used as source2 and previous result as source1. Then the two are modulated to output to color buffer. Possibly scaled by 2 or 4 in the process. You can also input a constant color+alpha to the texture units. You can also blend the output from last texture unit with the color buffer. Lastly, you can multipass if running out of texture units. Don't forget crossbar to cut down on passes.



Hmm, I'm a bit confused about how to do this.

So are you saying to load unit0 with the base map and unit1 would hold the detail texture (in source1) and the vertex alpha (how would i load this in, besides binding the color array).

Could you clarify what you mean by a low frequency texture in unit2.

so a setup like this
unit0    = base_texturecombine  = replaceunit1source0  = previousoperand0 = src_colorsource1  = detail_textureoperand1 = src_alpha (maybe...)combine  = modulateunit2source1 = previousoperand1= src_colorsource2 = low_freq_textureoperand2= src_colorcombine = modulatescale   = 2



This would take 3 units to do the whole thing, any possibility to use 2 as I'm gonna be doing up to 4 detail textures per patch.

btw what do you mean by the crossbar?


thanks for the reply, but since i dont have much experience with the combiner hope you can clarify a few things :D

Try this,

unit1:
source1 = detail texture
source2 = vertex color (alpha replicated into rgb channels with src_alpha flag)
modulate source1 & source2
output goes into next unit as source1

unit2:
source1 = previous
source2 = base texture
modulate(or whatever) source1 & source2

This will modulate detail texture color by vertex's alpha value and the result of this is then modulated with base texture. I think this is what you want? With two texture unit hw you can only bind max of two textures, one to each unit. When you specify color/alpha source for second unit for example, you don't have to get it from the second unit bound texture. You can get the color/alpha from the first unit's bound texture. Otherwise you would have to bound two of the same textures to both units. The operation would propagate into the next unit without crossbar thus burning one extra unit. There are some situations where crossbar comes handy and I use it for doom3 like renderer.

Here's what the gl specs say about crossbar:

"Texture crossbar extends the texture combine environment mode COMBINE by allowing
use of the texture color from different texture units as sources to the texture
combine function."
thanks a lot, that seems to have done it (rate++) :D
Thanks :)

This topic is closed to new replies.

Advertisement