im using an include file, its code is like this:

vec3 ApplyThreshold(vec3 CLR, float Threshold){
	return max(CLR - vec3(Threshold), vec3(0.0));

vec3 Saturation(vec3 InputCLR, float Saturation){
	return mix(vec3(dot(InputCLR.rgb, vec3(0.299, 0.587, 0.114))), InputCLR.rgb, Saturation);

also the code is based off of some article i found so idrk if its MIT but who really gives a shit, yk?

for all i care its free and open source code and you SHOULD use it in your project

Shader code
shader_type canvas_item;
render_mode blend_add;

#include "res://Assets/Materials/Shaders/Library/CLREDIT.gdshaderinc"

uniform lowp sampler2D Screen_Sample : hint_screen_texture, filter_linear_mipmap_anisotropic;
uniform lowp sampler2D FlareMult;
uniform lowp sampler2D FlareMult2;

uniform float Blur = 2.5;
uniform float FlareThreshold;
uniform int Flares;
uniform float FlareSpacing;

uniform float Intensity;
uniform float Saturation_;

void fragment(){
	vec2 FlippedUV = vec2(1.0) - SCREEN_UV;
	vec2 FlareVector = (vec2(0.5) - SCREEN_UV) * FlareSpacing;
	vec3 FinalFlare = vec3(0.0);
	for (int i = 0; i < Flares; ++i){
		vec2 SUV = fract(SCREEN_UV + FlareVector * vec2(float(i)));
		float Dist = distance(SUV, vec2(0.5));
		float Weight = 1.0 - smoothstep(0.0, 0.75, Dist);
		vec3 BlurredScreen = texture(Screen_Sample, SUV, Blur).rgb;
		BlurredScreen = ApplyThreshold(BlurredScreen, FlareThreshold);
		FinalFlare += BlurredScreen * Weight;
	FinalFlare *= texture(FlareMult, SCREEN_UV).rgb;
	FinalFlare *= texture(FlareMult2, SCREEN_UV).rgb;
	COLOR.rgb = FinalFlare * Intensity;
	COLOR.rgb = Saturation(COLOR.rgb, Saturation_);
camera, distortion, fast, flare, fx, lens, lensflare, screen-space
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

More from Unhinged Dev

Double Vision w/ chromatic aberration

Advanced 7 Texture Albedo Terrain Shader

Notify of

Newest Most Voted
Inline Feedbacks
View all comments
18 days ago

Hey! I’m trying to use this one but don’t really know where should i put it, i tried to apply this one into a SubViewportContainer but doesn’t really seem to work, any help would be appreciated, thanks in advance!