Sign in to follow this  
nts

GL_ARB_texture_env_combine question...

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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_texture
combine = replace

unit1
source0 = previous
operand0 = src_color
source1 = detail_texture
operand1 = src_alpha (maybe...)
combine = modulate

unit2
source1 = previous
operand1= src_color
source2 = low_freq_texture
operand2= src_color
combine = modulate
scale = 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

Share this post


Link to post
Share on other sites
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."

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this