Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Multi texturing question.

Hybrid View

  1. #1
    Intern Newbie
    Join Date
    Aug 2013
    Posts
    32

    Multi texturing question.

    I'm not sure exactly what would be the best or at least a good way to do multi texturing just yet so I figured I'd ask some advice.

    It seems like the most obvious choice would be glActiveTexture and all that goes with it but is this really good for texturing entire terrains with many different textures. Some textures would be blended, others wouldn't or would require a different kind of blending(like stone path to grass would be goofy to blend together). It seems that it's also limited in the amount of textures I'd be able to load into the terrain aswell which would be kinda sad because I would want the option to easily add more textures later.

    Another option could be to use large textures that cover the terrain but it seems like this would require a huge amount of memory.

    Any advice on this subject would be much appreciated.

  2. #2
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    474
    Quote Originally Posted by Exempt View Post
    It seems like the most obvious choice would be glActiveTexture and all that goes with it but is this really good for texturing entire terrains with many different textures. Some textures would be blended, others wouldn't or would require a different kind of blending(like stone path to grass would be goofy to blend together). It seems that it's also limited in the amount of textures I'd be able to load into the terrain aswell which would be kinda sad because I would want the option to easily add more textures later.
    The number of textures isn't really an issue if you use GL_TEXTURE_2D_ARRAY. This allows you to store multiple textures as layers of a single texture unit, with the layer selected by the third texture coordinate. Array textures are similar to 3D textures except that interpolation and mipmapping are only performed within layers, not between them.

    The main limitation of array textures versus multiple texture units is that all layers of an array texture have the same dimensions, and the filter and wrap modes apply to the entire array. The dimensions are less of an issue for textures which don't need to wrap, as you can just pack multiple images into each texture layer (but be careful about bleed-over with the lower mipmap levels).

    Quote Originally Posted by Exempt View Post
    Another option could be to use large textures that cover the terrain but it seems like this would require a huge amount of memory.
    A single texture isn't practical for large areas. You need to research the various ways of combining multiple textures together, e.g. splat mapping, overlaid texture patches, etc.

    The main thing is that you need to understand shader programming. Don't waste your time with the fixed-function multi-texturing capability (glTexEnv(target, GL_TEXTURE_MODE, GL_COMBINE)); it's too limited for anything beyond the simplest cases. Using shaders allows you to combine textures in any way that you can think of. That flexibility is necessary if you want to render large amounts of terrain with reasonable detail, without obvious repetition, and within your memory budget.

  3. #3
    Intern Newbie
    Join Date
    Aug 2013
    Posts
    32
    Ugh, shaders... I was hoping to avoid them for a while but I guess I'll have to try and break into them. If I move onto shader programming do you think it'd be worth while to just switch to opengl 3.3, it seems to be supported pretty well but I know I could use 2.1 and shaders but 3.3 isn't depreciated at all from what I've read.

    Edit: Just to make sure I understand this correctly. Lets say I had some textures I wanted blended and others I didn't want to blend I could just do this...

    TEXTURE0 grass, dirt, sand, water, rock - would have blending
    TEXTURE1 stone path, cobble stone path, wooden plank path - would have no blending

    Edit2: After some reading and study about shaders I think I have an idea how to go about this but I'm not 100% sure (It's hard to find a lot of info on this subject).

    Let say I have a Map Editor program will just load a big flat map, I can make hills and add trees and whatnot where I need them. Then for texture I would just define an area I want the texture to be then set a flag inside the data array (what the map editor will export) like GL_TEXTURE0+1, GL_TEXTURE0+2..

    something like this

    Code :
    struct vertexData
    {
        float x, y, z;
        float normalx, normaly, normal;
        float u, v;
        unsigned int currentTexture;
        BaseObjectClass object = NULL; //This would just store things like trees, fences, houses... w/e.    
    };

    I should be able to pass the currentTexture variable to the shader to change the texture.
    Last edited by Exempt; 08-24-2013 at 01:53 PM.

Posting Permissions

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