Jump to content
  • Advertisement

Joe Malik

Member
  • Content Count

    2
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Joe Malik

  • Rank
    Newbie

Personal Information

  • Role
    Programmer
  • Interests
    Programming
  1. Joe Malik

    GLSL texture sampler precision

    Hi Irusan, thanks a lot for your reply. I agree, using alpha for this would be the obvious approach at hand for things like this. I tried it and it seems to suffer from the same issue in my use case. It seems that I have to be aware of the fact that the pixel data is stored as RGBA32 and not as floats. So if I darken a color value of e.g 16 by 2% to 15.68 it will remain a 16 when stored again as a byte. At least I got it working when I defined a minimum delta according to this consideration: #version 420 core in vec2 uv; out vec4 out_Color; uniform float Tail; // interval [0,1] uniform highp sampler2D texture; void main() { highp vec3 col = texture2D(texture, uv).rgb; highp vec3 darken = col * Tail; darken.r = max(darken.r, 1.0 / 256.0); darken.g = max(darken.g, 1.0 / 256.0); darken.b = max(darken.b, 1.0 / 256.0); col -= darken; out_Color = vec4(col, 1.0); }
  2. Hi folks, I'm currently working on a sample/learning project where I have some colourful dots moving around. And I'm trying to achieve that these dots are leaving trails that fade out after some time. For this purpose I render my frames to two textures (alternating each frame) and draw the last frame as background of the next frame. The sahder for this looks like this: #version 420 core in vec2 uv; out vec4 out_Color; uniform highp sampler2D texture; void main() { highp vec3 col = texture2D(texture, uv).rgb * 0.97; out_Color = vec4(col, 1.0); } This approach seems to be basically working but with the flaw that the color never converges to black but stops fading out at some reasonably dark color. It seems hard to believe to me that the precision of this calculation should be that low that it calculates x * 0.97 = x where x is nothing near to epsilon but let's say 0.05. But this would be a good explanation for the behaviou I observe. Or am I missing something else here? It would be really great to get some advice on this or any hints how I could fix this issue.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!