Hi all! I want my game to look “dusty” with grain footage. I know it’s possible to add a video in BGE, but is it possible to change the blend mode of the texture? Just as in any video editing software you have “Add”, “Multiply”, “Difference”, etc. I’m looking specifically for the “Overlay” blending mode. I’ll attach some pictures just in case!
How my game actually looks:
The grain footage I have:
The final look I want to achieve (if you look close, the grain footage is “overlaying” the game footage):
I’m working in BGE 2.79b, I don’t know if this might complicate things. Thanks a lot for your time!
it would be easier to use a noise texture sampler in a glsl 2d filter shader. it should be pretty simple, change the seed or coords to add randomness.
That sounds really good! Could you explain me the process? I just started messing with GLSL 2D Filters not long ago, and I don’t know exactly how to create this animated noise texture. Thanks for your reply!
MattFrnndz
(Matías Fernández)
April 21, 2022, 2:41pm
4
As Daedalus suggested, a 2D Filter would be a better option. Here’s my take:
// Noise overlay by MattFrnndz
// requires a timer game property called 'time'
const float noiseContrast = 0.2;
uniform float time;
uniform sampler2D bgl_RenderedTexture;
vec2 texCoord = gl_TexCoord[0].st;
float rand(vec2 co)
{
return fract(sin(dot(co.xy,vec2(12.9898,78.233)*3.0)) * 43758.5453);
}
vec4 mix_overlay(float fac, vec4 col1, vec4 col2)
{
fac = clamp(fac, 0.0, 1.0);
float facm = 1.0 - fac;
vec4 outcol = col1;
if (outcol.r < 0.5)
outcol.r *= facm + 2.0 * fac * col2.r;
else
outcol.r = 1.0 - (facm + 2.0 * fac * (1.0 - col2.r)) * (1.0 - outcol.r);
if (outcol.g < 0.5)
outcol.g *= facm + 2.0 * fac * col2.g;
else
outcol.g = 1.0 - (facm + 2.0 * fac * (1.0 - col2.g)) * (1.0 - outcol.g);
if (outcol.b < 0.5)
outcol.b *= facm + 2.0 * fac * col2.b;
else
outcol.b = 1.0 - (facm + 2.0 * fac * (1.0 - col2.b)) * (1.0 - outcol.b);
return outcol;
}
void main(void)
{
vec4 texcolor = texture2D(bgl_RenderedTexture, texCoord, 2.0);
float noise = rand(texCoord.xy + mod(time, 1.5)) * noiseContrast + (0.5 - noiseContrast / 2.0);
gl_FragColor = mix_overlay(1.0, texcolor, vec4(noise));
}
It looks better when animated.
Noise overlay.blend (346.1 KB)
1 Like
This is awesome!! Thank you SO much for this!!!