Results 1 to 6 of 6

Thread: OpenGL Texture masking problem

  1. #1

    OpenGL Texture masking problem

    Hello,

    im trying mask textrures but it blend colors, how fix it or exist other way ?



    Code:
       glEnable(GL_BLEND); // Enable Blending
    
       Images['ground_dirt'].draw(5,5,0); // dirt texture
    
       glBlendFunc(GL_DST_COLOR,GL_ZERO);
       Images['transition01'].draw(5,5,0); // mask texture
    
       glBlendFunc(GL_ONE, GL_ONE);
       Images['ground_grass'].draw(5,5,0); // grass texture
    
       glDisable(GL_BLEND);

  2. #2

    Re: OpenGL Texture masking problem

    Have you tried inverting the "transition" image (black becomes white, white becomes black)?

    Also, how does it look when you do this?

    Code:
       glEnable(GL_BLEND); // Enable Blending
    
       Images['ground_dirt'].draw(5,5,0); // dirt texture
    
       glBlendFunc(GL_DST_COLOR,GL_ZERO);
       Images['transition01'].draw(5,5,0); // mask texture
    
       //Leave grass texture out!
    
       glDisable(GL_BLEND);
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  3. #3

    Re: OpenGL Texture masking problem

    inverted colors:


    no grass texture made this:

  4. #4
    well.. blend func is not good way and i cant find tutorial for texture splatting (like this Direct3d - http://www.gamedev.net/reference/art...rticle2238.asp), can anyone help ?

  5. #5
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25
    Don't know if this helps, but if you had a mask that was alpha blended, that might work. Trick is you need a graphics program that will generate the proper alpha blending where you need it. Not all of them are the most intuitive when it comes to drawing in alpha.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  6. #6
    You can do it in two different ways:

    Single-pass: I'd recommend you to start using shaders. You can combine 4 textures in your shader, of say dirt, grass, snow, rock in your terrain and use one RGBA texture where each channel represents one texture. This works pretty fast on today's hardware.
    You could probably do something similar in OpenGL by setting the right states, but I'm not sure how (I know it's possible in D3D, like the article shows).

    Multi-pass: You can render the terrain multiple times using alpha-blending. This is not the most efficient way and therefore not my favorite. But it might be good if you don't want go down the shader path.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •