Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new way for hash generation #180

Merged
merged 2 commits into from
Jan 7, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions filters/zoom-blur/src/zoom-blur.frag
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ uniform float uRadius;

const float MAX_KERNEL_SIZE = 32.0;

float random(vec3 scale, float seed) {
// use the fragment position for a different seed per-pixel
return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);
// author: http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/
highp float rand(vec2 co, float seed) {
const highp float a = 12.9898, b = 78.233, c = 43758.5453;
highp float dt = dot(co + seed, vec2(a, b)), sn = mod(dt, 3.14159);
return fract(sin(sn) * c + seed);
}

void main() {
Expand Down Expand Up @@ -52,7 +54,7 @@ void main() {
}

// randomize the lookup values to hide the fixed number of samples
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
float offset = rand(vTextureCoord, 0.0);

float total = 0.0;
vec4 color = vec4(0.0);
Expand All @@ -78,7 +80,7 @@ void main() {

color /= total;
// switch back from pre-multiplied alpha
color.rgb /= color.a + 0.00001;
// color.rgb /= color.a + 0.00001;

gl_FragColor = color;
}