Results 1 to 6 of 6

Thread: Detail Mapping

  1. #1
    Member Contributor
    Join Date
    Jun 2002
    Posts
    50

    Detail Mapping

    How to do it??

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Detail Mapping

    GL_ADD_SIGNED, instead of GL_REPLACE or GL_MODULATE, and the detail map should go through an emboss filter in some paint program before you use it.

  3. #3
    Member Contributor
    Join Date
    Jun 2002
    Posts
    50

    Re: Detail Mapping

    What???

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Detail Mapping

    What part did you not understand?

  5. #5
    Member Contributor
    Join Date
    Jun 2002
    Posts
    50

    Re: Detail Mapping

    I didn't understand anything

  6. #6
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Detail Mapping

    Uhm, think I was typing a little bit faster than I could think. Setting up the states to use GL_ADD_SIGNED is a little bit more work than just replacing GL_REPLACE/GL_MODULATE, which I first thought.

    I don't know how much you know about texturing, but to deal with detail mapping, you have to know how multitexturing and texture combine functions works. This is a base requirement, and if you don't know about it, you should wait with detail mapping until you know it.

    Anyways, the basic idea is like this. The first base texture is applied as usual, using the first texture unit. The detail map is then added ontop of the base texture, using the second texture unit. Detail mapping usually uses the extension ARB_texture_env_combine and the GL_ADD_SIGNED combine function. Have a look in the specification for the ARB_texture_env_combine extension for more information. A typical detail function setup may look something likt this, and it's also the way I do it, more or less
    Code :
    // First texture unit, modulate base texture with primary color
    glActiveTextureARB(GL_TEXTURE0_ARB);
    glBindTexture(GL_TEXTURE_2D, base_texture);
    glEnable(GL_TEXTURE_2D);
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
    glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
    glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PRiMARY);
    glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
    glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
    glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
    // Second texture unit, add detail map ontop of base texture
    glActiveTextureARB(GL_TEXTURE1_ARB);
    glBindTexture(GL_TEXTURE_2D, detail_texture);
    glEnable(GL_TEXTURE_2D);
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
    glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_SIGNED_ADD);
    glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS);
    glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
    glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
    glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);

Similar Threads

  1. More Tesselation Detail
    By D3v01d in forum OpenGL: GLSL
    Replies: 2
    Last Post: 05-11-2014, 06:31 AM
  2. Detail tex + ??? = Detail bumpmap
    By Freelancer in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 10-27-2004, 03:52 AM
  3. Better way to do detail mapping than this?
    By TheGecko in forum OpenGL: Advanced Coding
    Replies: 7
    Last Post: 03-27-2002, 02:02 PM
  4. detail textures
    By zen in forum OpenGL: Advanced Coding
    Replies: 12
    Last Post: 03-21-2002, 01:32 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
  •  
Proudly hosted by Digital Ocean