Author Topic: Seascape corruptions.  (Read 570 times)

0 Members and 1 Guest are viewing this topic.

Dorian

  • Newbie
  • *
  • Posts: 6
    • View Profile
Seascape corruptions.
« on: February 14, 2019, 10:29:45 AM »
Hi,

There is a issue on recent Intel graphics (SKL+) on seascape demo.
Screenshot (occurs after couple of seconds): https://imgur.com/a/TiTj1dz

The reason is a float overflow if order of operations is changed by shader compiler.
There is a simple workaround for this by changing one dot operation to use precise float.

Instead of using:
Code: [Select]
float hash(vec2 p)
{
    float h = dot(p, vec2(127.09999847412109375, 311.70001220703125));
    return fract(sin(h) * 43758.546875);
}
This can be used
Code: [Select]
float dot_precise(vec2 a, vec2 b)
{
    precise float result = 0;
    result += a.x * b.x;
    result += a.y * b.y;
    return result;
}

float hash(vec2 p)
{
    float h = dot_precise(p, vec2(127.09999847412109375, 311.70001220703125));
    return fract(sin(h) * 43758.546875);
}

in s01-ps.frag.

« Last Edit: February 14, 2019, 10:43:14 AM by Dorian »


JeGX

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1867
    • View Profile
    • Geeks3D.com
Re: Seascape corruptions.
« Reply #1 on: February 18, 2019, 01:24:50 PM »
Thanks!
I will update the shader in GPU Caps Viewer (and in the Shadertoy demopack)