Pixelated Film Grain Shader

Forum rules
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.

Got a cool project idea but nothing else? Put it in the project ideas thread instead!

Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.

Please read the full rules for more details.
User avatar
Nash
 
 
Posts: 17296
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Pixelated Film Grain Shader

Post by Nash »



This is a port of the film grain shader from https://www.shadertoy.com/view/Mdj3zd but combined with the concept of a pixelated screen shader from https://gamedev.stackexchange.com/quest ... ion-shader

What makes this shader different from your typical film grain shader? Have you noticed that with usual film grain shaders, the effect becomes harder to see as your video resolution goes up? That is because the effect is applied per-pixel, so at 640x480, for example, the effect is very clear, but at 4k resolution, you almost can't see the effect because the pixels are too tiny. Then you compensate for this by cranking the "amount", but then it starts to look bad because you are just making the viewport harder to see.

With this shader, the size of one "grain" stays constant no matter resolution you're using. You can use the options to adjust the pixel size - lower number produces larger, blockier grains.

This shader is best understood by just running it and playing with the options, while changing resolutions. The film grain effect and intensity will remain consistent regardless of whatever resolution you set.

Have fun!

EDIT: Updated on 02/28/2020 - better random noise generator (fixes weird bug where the grain starts having zig-zag patterns after extended lengths of time)
You do not have the required permissions to view the files attached to this post.
Last edited by Nash on Fri Feb 28, 2020 3:16 am, edited 1 time in total.
User avatar
Tormentor667
Posts: 13462
Joined: Wed Jul 16, 2003 3:52 am

Re: Pixelated Film Grain Shader

Post by Tormentor667 »

This is cool!
User avatar
Nash
 
 
Posts: 17296
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: Pixelated Film Grain Shader

Post by Nash »

Thanks. Feel free to use in BoA if you want - I know you love shaders. ;)
User avatar
Ozymandias81
Posts: 2052
Joined: Thu Jul 04, 2013 8:01 am
Graphics Processor: nVidia with Vulkan support
Location: Mount Olympus, Mars

Re: Pixelated Film Grain Shader

Post by Ozymandias81 »

Will check this and replace actual noise filter on BoA with this one :)
User avatar
Ozymandias81
Posts: 2052
Joined: Thu Jul 04, 2013 8:01 am
Graphics Processor: nVidia with Vulkan support
Location: Mount Olympus, Mars

Re: Pixelated Film Grain Shader

Post by Ozymandias81 »

Aaaand it has been added, wonder if there are some fallbacks or issues since I kept zscript version at 3.7.2 as present on BoA instead of 4.2.0 (which generated a little pack of deprecated warnings not belonging only to Film Grain anyway)
User avatar
Nash
 
 
Posts: 17296
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: Pixelated Film Grain Shader

Post by Nash »

ZScript version should be irrelevant, as far as I can tell, I didn't use any new ZScript-side features for this shader. :)
User avatar
Ozymandias81
Posts: 2052
Joined: Thu Jul 04, 2013 8:01 am
Graphics Processor: nVidia with Vulkan support
Location: Mount Olympus, Mars

Re: Pixelated Film Grain Shader

Post by Ozymandias81 »

Noticed it in the end... Thanks a lot for this shader!
XLightningStormL
Posts: 375
Joined: Mon May 09, 2016 1:38 am

Re: Pixelated Film Grain Shader

Post by XLightningStormL »

Now all we need is a VHS shader lol
User avatar
MFG38
Posts: 399
Joined: Sun Apr 14, 2019 8:26 am
Graphics Processor: nVidia (Modern GZDoom)
Location: Finland

Re: Pixelated Film Grain Shader

Post by MFG38 »

XLightningStormL wrote:Now all we need is a VHS shader lol
I do recall seeing one that at least comes close to that. "Old Video Shader" was its name, I believe.
User avatar
Nash
 
 
Posts: 17296
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: Pixelated Film Grain Shader

Post by Nash »

Updated on 02/28/2020 - better random noise generator (fixes weird bug where the grain starts having zig-zag patterns after extended lengths of time)
User avatar
Ozymandias81
Posts: 2052
Joined: Thu Jul 04, 2013 8:01 am
Graphics Processor: nVidia with Vulkan support
Location: Mount Olympus, Mars

Re: Pixelated Film Grain Shader

Post by Ozymandias81 »

Ah thanks for the update, need to fiddle it and export that on BoA later then
User avatar
Nash
 
 
Posts: 17296
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: Pixelated Film Grain Shader

Post by Nash »

You can just lift the updates from the shader (.fp) file - there are no changes to any of the other files. :)

Return to “Shaders”