Results 1 to 3 of 3

Thread: Colormap texture

  1. #1
    Member Contributor
    Join Date
    Nov 2010
    Posts
    52

    Colormap texture

    I'm trying to use a color lookup table in shaders to convert rgb grayscale gl_Color to rgb color gl_Color. I want to use something similar to this :
    http://blogs.mathworks.com/images/lo...apManip_14.png

    I would like to know how to code this. I just don't know how to create a texture and to write the good color values in that texture to have a color map. I didn't find any tutorial while looking on google, well at least searching for "creat lookup texture opengl" didn't give anything. Thanks for your help.

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: Colormap texture

    Well did you try with correct spelling for "create" ?
    Take any texture tutorial, but instead of loading image array from disk, create the array with the code and fill it with you values. A 1D texture will do.

  3. #3
    Member Contributor
    Join Date
    Nov 2010
    Posts
    52

    Re: Colormap texture

    Quote Originally Posted by ZbuffeR
    Well did you try with correct spelling for "create" ?
    Take any texture tutorial, but instead of loading image array from disk, create the array with the code and fill it with you values. A 1D texture will do.
    I thought i needed a 3D texture for each color since i have a red, green and blue value for each.
    Do you mean something like that?
    Code :
    color_triplet table[256] = {{0,0,0}}; /* Initialize to all black */
     
        i = 20; /* first 20 and last 20 are reserved */
        for (red = 0; red <= 255; red+= 51) {/* the six values of red */
            for (green = 0; green <= 255; green += 51) {
                for (blue = 0; blue <= 255; blue+= 51) {
                    table[i].r = red;
                    table[i].g = green;
                    table[i].b = blue;
                    ++i;
                }
            }
        }
    What should be the format of the array in order to load it as a uniform texture in glsl?

Similar Threads

  1. Apply my own colormap in the fragment shader
    By neon29 in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 02-23-2016, 04:15 PM
  2. glut colormap
    By Ben Chern in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 04-11-2008, 04:44 AM
  3. 3 detail maps and a colormap with only 2 tex units
    By soconne in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 06-11-2005, 11:55 PM
  4. Colormap per window?
    By in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 02-03-2004, 09:12 AM
  5. Q: Changing colormap of texture after creation
    By silverfox in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 07-30-2003, 12:34 AM

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