Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: Rainbow color band and color palettes in OpenGL?

  1. #11
    Member Regular Contributor
    Join Date
    Aug 2008
    Posts
    455
    You should be providing coordinates between 0.0 and 1.0. How you map the values you have (-500 to 3346) to this range is up to you.
    If you want to map your range in an increasing linear fashion (lowest value = 0.0, highest value = 1.0, linear mapping between), you could use:

    Code :
    //TexCoord = (Value -(-500))/(3346-(-500));
    TexCoord = (Value + 500)/(500+3346)
    You could either do this before you pass values into the shaders, or within the shader.

  2. #12
    Intern Contributor
    Join Date
    Jun 2009
    Posts
    91
    Quote Originally Posted by Dan Bartlett View Post
    You should be providing coordinates between 0.0 and 1.0. How you map the values you have (-500 to 3346) to this range is up to you.
    If you want to map your range in an increasing linear fashion (lowest value = 0.0, highest value = 1.0, linear mapping between), you could use:

    Code :
    //TexCoord = (Value -(-500))/(3346-(-500));
    TexCoord = (Value + 500)/(500+3346)
    You could either do this before you pass values into the shaders, or within the shader.
    Which one would be the good approach? Mapping values before they are passed into shaders? or within the shaders itself? I feel doing it within the shader is easy.

    Thanks

Posting Permissions

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