Results 1 to 6 of 6

Thread: Simple Multitexturing Question

  1. #1
    Senior Member Regular Contributor
    Join Date
    Nov 2003
    Location
    Michigan, USA
    Posts
    184

    Simple Multitexturing Question

    Okay, I store 2 textures, 512*512 containing pixel values ranging from -1.0 to 1.0. I am using GL_ADD.
    The results are not as expected. Multitexturing code is fine.

    I was under the impression that the pixel values were not capped to [0,1] until they were interpolated.

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Feb 2004
    Location
    Long Island, New York
    Posts
    569

    Re: Simple Multitexturing Question

    Could you be a little more specific?

    for example: how are they not as expected?

  3. #3
    Senior Member Regular Contributor
    Join Date
    Nov 2003
    Location
    Michigan, USA
    Posts
    184

    Re: Simple Multitexturing Question

    Okay,
    I am rendering the representation of two cosine functions, in each texture. Simplest version, 2nd tecture contains Cos + phase angle => Pi.
    Basically generating strips of black and white with transitions. If I combine(add these two textures), I do not get all black. As I should.

    Now I know the values get clamped to 0,1, which means this might not work, but I assume values were clamped after texture operations, so my textures could contain negative values, and adding them would produce the right result.

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

    Re: Simple Multitexturing Question

    Colors values are indeed clamped to [0,1] when stored to textures.
    ex, typical RGBA texture : each component is an unsigned byte going through 0 to 255, for intensities in the |0.0, 1.0] range.

    The common trick is shifting values from [-1,1] to [0,1] before creating texture.
    Then to add 2 textures :
    res = tex1 /2 + tex2 /2
    and res will be in the [0,1] range, for your case always 0.5, as expected.

    EDIT : with textures in floating point, you are only clamped to classic fp representations. If your card is listed here it support the GL_ATI_texture_float extension .

  5. #5
    Senior Member Regular Contributor
    Join Date
    Nov 2003
    Location
    Michigan, USA
    Posts
    184

    Re: Simple Multitexturing Question

    But, I used GL_ADD_SIGNED_EXT(spelling), and shifted by bias

    (X1+1.0)/2.0
    (X2+1.0)/2.0

    If I assigned, simple example, cos(t) for x1, and cos(t+Pi) to x2, do the above, combine using add signed, it will not work. In fact, the math does not work, unless the negative values are retained. I need to work with wave interference and construction.

    Thanks for the help.

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

    Re: Simple Multitexturing Question

    Math should work, providing you shift/scale properly (but I am not very good with multitexturing) :

    done on CPU :
    original range [-1,1]-> scaled/shifted to texture allowed range [O,1]-> scaled to avoid sum overflow [0,0.5] ->
    done on GPU :
    sum 2 tex [0,1] ->
    done on CPU : read result and scale back to [-1,1]

Similar Threads

  1. Another question on multitexturing.
    By darkrappey in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 04-18-2007, 05:14 PM
  2. ARB multitexturing question
    By dorinm in forum OpenGL: Basic Coding
    Replies: 10
    Last Post: 09-18-2003, 01:03 PM
  3. Multitexturing Question...
    By zix99 in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 07-27-2003, 02:30 AM
  4. Multitexturing question
    By flupke in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 07-14-2003, 12:46 PM
  5. Multitexturing Question
    By MrShoe in forum OpenGL: Basic Coding
    Replies: 21
    Last Post: 03-09-2002, 05:28 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