Jump to content
  • Advertisement
Sign in to follow this  
soconne

4 detail textures, only 2 tex units

This topic is 4938 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've recently come across the following article http://www.cs.auckland.ac.nz/~jvan006/multitex/multitex.html It states that its possible to mix 4 detail textures and a colormap all with only 2 texture units using Dot3. I've attempted to do it but I've run into some problems. Here's how I do my setup. Texture0 = alpha map Texture1 = detail textures Texture2 = color map The alpha map is an RGB image, where R is the blending for the first detail texture and so forth. I have 3 detail textures mixed into the RGB channels of the detail texture itself, and then the color map is simply a regular texture. Here are the textures below color map detail map alpha map Here's how I setup the texture parameters
// setup multitexturing stuff
    glActiveTextureARB(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, alphaTex);
    glEnable(GL_TEXTURE_2D);
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
    
    glActiveTextureARB(GL_TEXTURE1);
    glBindTexture(GL_TEXTURE_2D, detailTex);
    glEnable(GL_TEXTURE_2D);
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DOT3_RGB);
    glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0);
    glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
    glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_TEXTURE1);
    glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);

    glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
    glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE0);
    glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
    glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_TEXTURE1);
    glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
    

    glActiveTextureARB(GL_TEXTURE2);
    glBindTexture(GL_TEXTURE_2D, textureTex);
    glEnable(GL_TEXTURE_2D);
    float mixcol[4] = {1.0, 1, 1, 1};
    glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, mixcol);
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
    glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE);
    glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS);
    glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR);
    glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_TEXTURE2);
    glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
    glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_CONSTANT);
    glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_COLOR);

    glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
    glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
    glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
    glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_CONSTANT);



And here is what I get as a result Also, here is what it looks like WITHOUT the final texture being blended. This is only the detail and alpha maps. As you can see the colors are NOT what they're suppose to be. The detail textures itself are being blended where they're suppose to be, its just not blending correctly with the final texture. How do I comebine the detail textures with the alpha map, then have a resulting "GRAY" detail texture to combine with the final color map texture? The author of the article seemed to have done it but I cannot figure it out.

Share this post


Link to post
Share on other sites
Advertisement
Well, your "alpha map" isnt alpha at all, thats just an rgb image, or maybe argb, but an alpha map would be just a.

hope that sets you in the right direction
-Dan

Share this post


Link to post
Share on other sites
Quote:
Original post by Ademan555
Well, your "alpha map" isnt alpha at all, thats just an rgb image, or maybe argb, but an alpha map would be just a.


It's not a normal alpha map, but a four dimensional alpha map, or 'mix map', packed into a normal RGBA texture. Think of it like four alpha maps in one.

oconnellseanm, you do realize you're using three texture units, not two? The article author encodes the mixmap into the vertices of his terrain, rather than having a texture for it. What he's calling a lightmap seems to be what you call the colormap, perhaps with premultiplied lighting baked in.

hope this helps you get back on track
-bodisiw

Share this post


Link to post
Share on other sites
Quote:
Original post by NoahAdler
Quote:
Original post by Ademan555
Well, your "alpha map" isnt alpha at all, thats just an rgb image, or maybe argb, but an alpha map would be just a.


It's not a normal alpha map, but a four dimensional alpha map, or 'mix map', packed into a normal RGBA texture. Think of it like four alpha maps in one.

oconnellseanm, you do realize you're using three texture units, not two? The article author encodes the mixmap into the vertices of his terrain, rather than having a texture for it. What he's calling a lightmap seems to be what you call the colormap, perhaps with premultiplied lighting baked in.

hope this helps you get back on track
-bodisiw


It should not matter if I'm using 3 texture units. It would basically work out to be the same thing as if I had encoded the colors in the vertices.

Share this post


Link to post
Share on other sites
NoahAdler is correct u cant access 3 textures at the same time with a card that only has 2 texture units eg gf2

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!