Files
oak-editor/app/shaders/noise.frag
T
itsmattkcandThomas Wilshaw a4056d8454 Upgrade to OpenGL ES 3.2 (#1879)
* upgrade to opengl 3.2

* cornerpin: no need for hack

* renderer: Update OCIO shader language to ES 3.0

Co-authored-by: Thomas Wilshaw <thomaswilshaw@gmail.com>
2022-03-20 11:17:18 -07:00

39 lines
1.2 KiB
GLSL

uniform float time_in;
uniform float strength_in;
uniform bool color_in;
//uniform bool blend;
in vec2 ove_texcoord;
out vec4 frag_color;
float PHI = 1.61803398874989484820459 * 00000.1; // Golden Ratio
float PI = 3.14159265358979323846264 * 00000.1; // PI
float SQ2 = 1.41421356237309504880169 * 10000.0; // Square Root of Two
bool isNan( float val )
{
return ( val < 0.0 || 0.0 < val || val == 0.0 ) ? false : true;
// important: some nVidias failed to cope with version below.
// Probably wrong optimization.
/*return ( val <= 0.0 || 0.0 <= val ) ? false : true;*/
// Taken from: https://stackoverflow.com/questions/11810158/how-to-deal-with-nan-or-inf-in-opengl-es-2-0-shaders
}
float gold_noise(vec2 coordinate, float seed){
float value = fract(tan(distance(coordinate*(seed+PHI), vec2(PHI, PI)))*SQ2)*(strength_in*0.01);
return isNan(value) ? 0.0 : value;
}
void main(void) {
vec3 noise;
if (color_in) {
noise = vec3(gold_noise(ove_texcoord, time_in + 42069.0), gold_noise(ove_texcoord, time_in + 69220.0), gold_noise(ove_texcoord, time_in + 1337.0));
} else {
noise = vec3(gold_noise(ove_texcoord, time_in + 69420.0));
}
frag_color = vec4(noise, 1.0);
}