It seems like the grain is applying to the entire screen at once, rather than a per-pixel basis like it should. I believe I've nailed down the below as the cause
Code:
vec3 col = texture2D(bgl_RenderedTexture, texCoord).rgb;
I'm assuming that this takes the RGB value of a specific pixel that is at texCoord of the passed in image bgl_RenderedTexture.
Here's all of the relevant code as is if anyone wants to take a look.
Code:
uniform sampler2D bgl_RenderedTexture; //rendered scene sampler
float2 tcor : TEXCOORD0;
.
. //bunch of code
.
float4 GrainPass( float4 colorInput, float2 tex )
{
float2 texCoord = tcor;
.
.
.
float3 col = tex2D(bgl_RenderedTexture, texCoord).rgb;
//noisiness response curve based on scene luminance
float3 lumcoeff = float3(0.299,0.587,0.114);
float luminance = lerp(0.0,dot(col, lumcoeff),lumamount);
float lum = smoothstep(0.2,0.0,luminance);
lum += luminance;
noise = lerp(noise,0.0,pow(lum,4.0));
col = col+noise*grainamount;
return float4(col,1.0);
}
I was originally using colorInput.rgb for the value of col, but that changes the color of the whole image. Does colorinput have coordinate values as well or something maybe? I don't know!
In the current implementation, it is simply a blinking image, with none of the original image showing through. I believe that means I need to incorporate the "colorInput" somewhere, but I'm not certain where just yet. It looks like color input comes from
Code:
float4 c0 = tex2D(s0, tex);
I've tried replacing the tex2D from above with this
Code:
float3 col = tex2D(s0, tex).rgb;
but I get the original issue of it seeming to apply one noise pixel to the entire screen.