Simple Grain

  • Posts: 160
2 years 3 months ago - 2 years 3 months ago #1 by Fu-Bama
I recently made simple film grain filter as the default one dropped for me like 10FPS in every game.
Minor thing; this one affects black areas. I think it's more realistic that way.
Also, it has limiter for noise seed value, to assure the ting won't Go Skrrrraaa after longer period of playing. ;P



Shader Code:
Warning: Spoiler! [ Click to expand ]
The following user(s) said Thank You: Wicked Sick

Please Log in or Create an account to join the conversation.

  • Posts: 530
2 years 3 months ago - 2 years 3 months ago #2 by lowenz
Black Areas? Do you mean in a letterboxed frame?

Please Log in or Create an account to join the conversation.

  • Posts: 160
2 years 3 months ago - 2 years 3 months ago #3 by Fu-Bama

lowenz wrote: Black Areas? Do you mean in a letterboxed frame?

:lol: No, black areas like shadows, black pixels. The default one applies noise 0-black, 1-gray, 0-white pixels.
This one has 1.62 gamma curve, so it's like 1-black, 0.33≈gray, 0-white.

On the picture right side you have white lamp, some medium cans and shadow in the background under the ladder, also there is pure black letterbox with noise applied.

Please Log in or Create an account to join the conversation.

  • Posts: 15
2 years 3 months ago #4 by UTwelve
I like this ! :woohoo:
Can be calculated according to the average brightness of the screen? Like a real camera AUTO ISO


example
Light: iso200
dark: iso6400
(Not rigorous)
——Google Translate :silly:

Please Log in or Create an account to join the conversation.

  • Posts: 160
2 years 3 months ago #5 by Fu-Bama

UTwelve wrote: Can be calculated according to the average brightness of the screen?

Very nice chart.
Yes it could, but digital camera ISO is not noise-value, but signal amplify amount.
Signal is amplified with higher ISO, but as things go, background noise is amplified too.

Please Log in or Create an account to join the conversation.

  • Posts: 15
2 years 3 months ago - 2 years 3 months ago #6 by UTwelve
During the day(or average brightness),Because ‘auto iso’ ,iso about 100-200iso。
black pixels should be no grain。just black

Please Log in or Create an account to join the conversation.

  • Posts: 280
2 years 3 months ago #7 by brussell
Try to add this code for grain depending on average screen luminance.
texture2D texLuminance { Width = 256; Height = 256; Format = R8; MipLevels = 7; };
sampler SamplerLuminance { Texture = texLuminance; };

float PS_Luminance(float4 pos : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
{
   return dot(tex2D(ReShade::BackBuffer, texcoord.xy).xyz, 0.333);
}

void SimpleGrainPS(float4 vois : SV_Position, float2 TexCoord : TEXCOORD, out float3 Image : SV_Target)
{
...
float avglum = tex2Dlod(SamplerLuminance, float4(0.5.xx, 0, 7)).x;
Noise *= (1-avglum);
...
}

technique SimpleGrain {
    pass
    {
        VertexShader = PostProcessVS;
        PixelShader = PS_Luminance;
        RenderTarget = texLuminance;
    }
    pass
    {
	VertexShader = PostProcessVS;
	PixelShader = SimpleGrainPS;
    }
}

Please Log in or Create an account to join the conversation.

  • Posts: 15
2 years 3 months ago #8 by UTwelve
Good use

Please Log in or Create an account to join the conversation.

  • Posts: 6
2 years 2 months ago #9 by BONKERS
Really liked using this shader. Here are a few phone wallpapers I made from screenshots of RE7 using this.
abload.de/img/re7b2pwu4l.jpg
abload.de/img/re7b4ogum1.jpg
abload.de/img/re7b5npusb.jpg

Please Log in or Create an account to join the conversation.

  • Posts: 504
2 years 1 month ago #10 by Wicked Sick
I really liked this shader. I hope to see it in the repository too.

Please Log in or Create an account to join the conversation.

  • Posts: 6
2 years 1 month ago #11 by BONKERS
One thing I really don't like about this shader though, in order to get a really decently noticeable effect running at same framerate as the game. You have to turn it up a bit. But then it really becomes noticeable that the grain shader affects the luminosity on the lower end of the image and causes it to lose a little bit of contrast and appear just slightly washed out.
Easily visible when turning it off A/B.

Please Log in or Create an account to join the conversation.