yossi
08-27-2005, 11:28 PM
Hello all,
I am trying to find a way to do a sum of textures (each texture allocated to a texture unit) such as:
Cout = W1*CT1 + W2*CT2 + W3*CT3
Where w1 + w2 + w3 = 1.0 (Wi for texture unit i)
And CTi is the RGB texel value for texture unit i.
I do not want to use shaders.
I also don't want to change the alpha for each texel in the texture itself (it is a constant 1).
I guess there is probably a way to do it by using GL_tex_env_combine, but I am so confused by the amount of the new tokens in the spec. :confused:
I will be glad if someone has an idea or give me a link to source code showing how to use this extension.
Many thanks,
Yossi
CrazyButcher
08-28-2005, 12:28 AM
http://www.ati.com/developer/sdk/rage128sdk/Multex/OGLMultex.html
this should help, you would use the constants for your weighting
yossi
08-28-2005, 02:34 AM
Thanks a lot 'CrazyButcher',
The utility shows visually the pileline in the GL_tex_env_combine extension.
Still, I don't see a simple way (if any) to scale the texture RGB and to add it to the previous texture unit RGB.
To do scaling I must use GL_MODULATE and to do the addition I must use GL_ADD, but I can't do both.
Did i miss something?
Thanks again,
Yossi
Korval
08-28-2005, 09:20 AM
Still, I don't see a simple way (if any) to scale the texture RGB and to add it to the previous texture unit RGB.There may be some TEV extensions that let you do what you're doing, but I don't recall any. The standard multitexture pipeline typically isn't good enough to do many interesting things. So yes, you're probably going to need shaders.
V-man
08-28-2005, 10:51 AM
With standard TexEnv and
ATI_texture_env_combine3
float myWeight1[4], myWeight2[4], myWeight3[4];
glActiveTexture(GL_TEXTURE0);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_CONSTANT);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, myWeight1);
glActiveTexture(GL_TEXTURE1);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE_ADD_ATI);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_CONSTANT);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_COLOR);
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, myWeight2);
glActiveTexture(GL_TEXTURE2);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE_ADD_ATI);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_CONSTANT);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_COLOR);
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, myWeight3);It should be possible to use crossbar for this.
yossi
08-28-2005, 07:39 PM
Thanks folks for your help,
I think I found a way to do what I want.
With some simple math you can find weights that when using the combiner in GL_INTERPOLATE_EXT mode, are equivalent to the sum of the textures multiplied by the original weights.
I will post it soon.
Thanks,
Yossi
Ido Ilan
08-31-2005, 09:19 PM
Hi Yossi,
Just check http://www.delphi3d.net/articles/viewarticle.php?article=terraintex.htm
It explain this in details and also have source coude (in delphi - but OpenGL commands are the same :) )
Ido
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.