Closed eliaswolfy closed 1 month ago
I tried to implement a random hash that I saw on Shadertoy, but the result was not as expected.
#version 320 es #ifdef GL_FRAGMENT_PRECISION_HIGH precision highp float; #else precision mediump float; #endif out vec4 flagColor; uniform int frame; uniform vec3 resolution; // random uint rngState; uint PCGHash() { uint state = rngState; rngState = rngState * 747796405u + 2891336453u; uint word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u; return (word >> 22u) ^ word; } float random() { return float(PCGHash()) / 4294967296.; } void main() { float index = gl_FragCoord.y * resolution.x + gl_FragCoord.x; rngState = uint(index) + uint(frame) * 719393u; flagColor = vec4(vec3(random()), 1); }
the result:
I tried to implement a random hash that I saw on Shadertoy, but the result was not as expected.
the result: