vec3 modulus error
Posted: Fri Oct 30, 2015 9:11 am
Hello!
I tried converting this shader I found to love2d, but I can't get it right.
This statement is the one in error:
Unable to find compatible overloaded function "mod(float)". I get the error because mod is supposed to get 2 values, 2 floats, but it gets one. And I don't know how the dude that made this wants it to be.
Shader:
Link to reddit forum that made this originally:
https://m.reddit.com/r/opengl/comments/ ... ain_noise/
I tried converting this shader I found to love2d, but I can't get it right.
This statement is the one in error:
Code: Select all
vec3 grain = vec3(((mod(mod(int(x), 13) + 1)* (mod(int(x), 123) + 1), 0.01) - 0.005) * noiseStrength); // 0.01 and - 0.005
Shader:
Code: Select all
//layout(location = 0) out vec3 out_color;
//uniform sampler2D colorMap; // This is the original image without noise
uniform float time; // Time since the start of the frame
const float noiseStrength = 30.0; // The strength of the noise effect -- default 30.0
vec4 effect(vec4 col, Image texture, vec2 texturePos, vec2 screenPos)
{
vec3 color = texture2D(texture, texturePos).xyz;
float x = (texturePos.x + 4) * (texturePos.y + 4) * (time * 10);
int a = 13;
int b = 123;
vec3 grain = vec3(((mod(mod(int(x), 13) + 1)* (mod(int(x), 123) + 1), 0.01) - 0.005) * noiseStrength); // 0.01 and - 0.005
// This one is optional, it makes a small "tear" every now and then
//if(mod(time, 100) > 98 && mod(texcoord.y, 10) > 7) grain = vec3(-3.0, -3.0, -3.0);
//vec3 grain = vec3(0,0,0);
color += grain;
vec4 finalColor = vec4(color, 1.0);
return finalColor;
}
https://m.reddit.com/r/opengl/comments/ ... ain_noise/