Results 1 to 6 of 6

Thread: Texture negative values

  1. #1
    Newbie Newbie
    Join Date
    Oct 2012
    Posts
    3

    Texture negative values

    Hello! I'm trying to implement fluid dynamics on GPU, and each step of the algorithm is implemented by pair of shaders. Unfortunately, I faced a problem, which I don't know how to deal with. When Fragment Shader 1 renders to texture, I get an image with different values, negative and positive. But when I try to pass this texture to the next shader as uniform sampler2D, all values in this texture become positive. For example, as output of Fragment Shader 1 I have an RGBA pixel (-1.0, 1.0, -1.0, 1.0), in sampler2D I have (1.0, 1.0, 1.0, 1.0). I really don't know how to solve this, and I would be grateful, if someone helped me.

  2. #2
    Member Newbie
    Join Date
    Jan 2014
    Posts
    40
    Normalize your output data to 0-1 range.

  3. #3
    Newbie Newbie
    Join Date
    Jan 2014
    Posts
    1
    Have you tried what nenad said?

    I am wondering about that myself, did not work here.

    Best Regads.

  4. #4
    Member Newbie
    Join Date
    Jan 2014
    Posts
    40
    You'd of course need to de-normalize it back to original range in the next shader, or even better keep all your calculations across the shaders in the normalized range.

  5. #5
    Senior Member Frequent Contributor arekkusu's Avatar
    Join Date
    Nov 2003
    Posts
    890
    Or use a texture format that can represent negative values. Like any _SNORM format, or any float format.

    Pick a texture format that matches the precision and range needs of your algorithm.

  6. #6
    Newbie Newbie
    Join Date
    Oct 2012
    Posts
    3
    Thank you very much for replies! As it turned out, it was not a problem with a texture, but with my algorithm, and somehow the problem disappeared, and now I'm trying to find out, why did it happen. I use GL_FLOAT format, and, of course, it must represent negative values.

Similar Threads

  1. how to scale am matrix non-uniformly/with negative values?
    By Vexator in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 07-25-2006, 02:29 AM
  2. negative Z values
    By Paulo Costa in forum OpenGL: General
    Replies: 1
    Last Post: 08-29-2004, 11:35 PM
  3. Negative values for materials and color...
    By Iceman in forum OpenGL: Advanced Coding
    Replies: 7
    Last Post: 08-13-2002, 06:32 PM
  4. Having some problem with negative scale values and normals
    By Super-K in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 02-09-2002, 02:05 PM
  5. negative znear or zfar values in glOrtho
    By in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 04-14-2001, 06:40 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