Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit 23dd10b

Browse files
authored
Add files via upload
1 parent 20e94f3 commit 23dd10b

File tree

13 files changed

+281
-38
lines changed

13 files changed

+281
-38
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hey, you may notice that when exploring the /shaders/ directory there are some unused shaders, that means that they either are worked on or werent properly removed!
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[gd_scene load_steps=3 format=3 uid="uid://q8472v8awese"]
2+
3+
[ext_resource type="Shader" path="res://addons/post_processing/shaders/color_correction.gdshader" id="1_cf4sj"]
4+
5+
[sub_resource type="ShaderMaterial" id="ShaderMaterial_nmxm8"]
6+
shader = ExtResource("1_cf4sj")
7+
shader_parameter/tint = Color(1, 1, 1, 1)
8+
shader_parameter/brightness = 0.0
9+
shader_parameter/saturation = 0.0
10+
11+
[node name="ColorCorrection" type="CanvasLayer"]
12+
visible = false
13+
14+
[node name="data" type="ColorRect" parent="."]
15+
material = SubResource("ShaderMaterial_nmxm8")
16+
anchors_preset = 15
17+
anchor_right = 1.0
18+
anchor_bottom = 1.0
19+
grow_horizontal = 2
20+
grow_vertical = 2
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[gd_scene load_steps=3 format=3 uid="uid://bs1yan5h4eao8"]
2+
3+
[ext_resource type="Shader" path="res://addons/post_processing/shaders/pixelate.gdshader" id="1_yebq2"]
4+
5+
[sub_resource type="ShaderMaterial" id="ShaderMaterial_gfycf"]
6+
shader = ExtResource("1_yebq2")
7+
shader_parameter/pixelSize = 7
8+
9+
[node name="Pixelate" type="CanvasLayer"]
10+
visible = false
11+
12+
[node name="data" type="ColorRect" parent="."]
13+
material = SubResource("ShaderMaterial_gfycf")
14+
anchors_preset = 15
15+
anchor_right = 1.0
16+
anchor_bottom = 1.0
17+
grow_horizontal = 2
18+
grow_vertical = 2

addons/post_processing/node/post_process.gd

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ func update_shaders() -> void:
1717

1818
func _update_shader_parameters( _name : String, _material : Material) -> void:
1919
match _name:
20+
"Pixelate":
21+
_material.set_shader_parameter("pixelSize", configuration.PixelatePixelSize)
22+
"ColorCorrection":
23+
_material.set_shader_parameter("tint", configuration.ColorCorrectionTint)
24+
_material.set_shader_parameter("brightness", configuration.ColorCorrectionBrightness)
25+
_material.set_shader_parameter("saturation", configuration.ColorCorrectionSaturation)
2026
"ChromaticAberration":
2127
_material.set_shader_parameter("offset", configuration.StrenghtCA)
2228
"Blur":
@@ -81,7 +87,10 @@ func _update_shader_parameters( _name : String, _material : Material) -> void:
8187

8288

8389
func _check_shader_visibility(_name: String) -> bool:
84-
90+
if _name.begins_with("Pixelate"):
91+
return true if configuration.Pixelate else false
92+
if _name.begins_with("ColorCorrection"):
93+
return true if configuration.ColorCorrection else false
8594
if _name.begins_with("ChromaticAberration"):
8695
return true if configuration.ChromaticAberration else false
8796

@@ -139,6 +148,8 @@ func _enter_tree():
139148
_add_canvas_layer_children("res://addons/post_processing/node/children/speed_lines.tscn", "SDP_LIN")
140149
_add_canvas_layer_children("res://addons/post_processing/node/children/ascii.tscn", "ASCII")
141150
_add_canvas_layer_children("res://addons/post_processing/node/children/CRT.tscn", "CRT")
151+
_add_canvas_layer_children("res://addons/post_processing/node/children/color_correction.tscn", "CC")
152+
_add_canvas_layer_children("res://addons/post_processing/node/children/pixelate.tscn", "PXL")
142153

143154
update_shaders()
144155

@@ -153,11 +164,14 @@ func _process(delta):
153164
if not configuration:
154165
return
155166
if Engine.is_editor_hint():
156-
return
157-
if not dynamically_update:
158-
return
167+
if dynamically_update:
168+
update_shaders()
169+
else:
170+
if configuration.reload:
171+
configuration.reload = false
172+
update_shaders()
159173
else:
160174
update_shaders()
161175
if configuration.reload:
162-
update_shaders()
163176
configuration.reload = false
177+
update_shaders()

addons/post_processing/node/post_process.svg.import

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ type="CompressedTexture2D"
55
uid="uid://c76ob2amhl0ln"
66
path="res://.godot/imported/post_process.svg-a28c497815b0e679908309d25a9b379d.ctex"
77
metadata={
8+
"has_editor_variant": true,
89
"vram_texture": false
910
}
1011

@@ -34,4 +35,4 @@ process/size_limit=0
3435
detect_3d/compress_to=1
3536
svg/scale=1.0
3637
editor/scale_with_editor_scale=false
37-
editor/convert_colors_with_editor_theme=false
38+
editor/convert_colors_with_editor_theme=true

addons/post_processing/plugin.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
name="PostProcessing"
44
description="Simple Post Processing Plugin"
55
author="Korin"
6-
version=""
6+
version="0.0.9"
77
script="plugin.gd"

addons/post_processing/resource/post_processing_configuration.gd

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
class_name PostProcessingConfiguration extends Resource
22

33
# post-processing-config based system by loufe
4-
@export_group("Post Processing")
4+
@export_group("Settings")
55
@export var reload: bool
6-
@export_group("ASCII (No Color)")
6+
@export_group("Visual Effects")
7+
@export_subgroup("ASCII (No Color)")
78
@export var ASCII: bool
89
@export var ASCIISize: Vector2 = Vector2(4,9):
910
set(value):
1011
ASCIISize = value
1112
reload = true
12-
@export_group("Chromatic Aberration")
13+
@export_subgroup("Chromatic Aberration")
1314
@export var ChromaticAberration: bool
1415
@export var StrenghtCA: float = 1:
1516
set(value):
1617
StrenghtCA = value
1718
reload = true
18-
@export_group("Blur")
19+
@export_subgroup("Blur")
1920
@export var Blur: bool
2021
@export_range(0.0, 5) var L_O_D = 1.0:
2122
set(value):
2223
L_O_D = value
2324
reload = true
24-
@export_group("Fish Eye")
25+
@export_subgroup("Fish Eye")
2526
@export var FishEye: bool
2627
@export var FishEyeAspect = 1.0:
2728
set(value):
@@ -47,7 +48,7 @@ class_name PostProcessingConfiguration extends Resource
4748
set(value):
4849
FishEyeCropColor = value
4950
reload = true
50-
@export_group("Vignette")
51+
@export_subgroup("Vignette")
5152
@export var Vignette: bool
5253
@export var VignetteIntensity = 0.4:
5354
set(value):
@@ -61,7 +62,7 @@ class_name PostProcessingConfiguration extends Resource
6162
set(value):
6263
VignetteR_G_B = value
6364
reload = true
64-
@export_group("Glitch")
65+
@export_subgroup("Glitch")
6566
@export var Glitch: bool
6667
@export_range(0.0, 0.1, 0.005) var GlitchRange = 0.05:
6768
set(value):
@@ -83,7 +84,7 @@ class_name PostProcessingConfiguration extends Resource
8384
set(value):
8485
GlitchColorOffset = value
8586
reload = true
86-
@export_group("Outline")
87+
@export_subgroup("Outline")
8788
@export var Outline: bool
8889
@export var OutlineColor: Color = Color(0.0, 0.0, 0.0, 1.0):
8990
set(value):
@@ -97,25 +98,13 @@ class_name PostProcessingConfiguration extends Resource
9798
set(value):
9899
OutlineBlend = value
99100
reload = true
100-
@export_group("Screen Shake")
101-
@export var ScreenShake: bool
102-
@export var ScreenShakePower = 0.1:
103-
set(value):
104-
ScreenShakePower = value
105-
reload = true
106-
@export_group("Analog Monitor")
107-
@export var AnalogMonitor: bool
108-
@export var AnalogMonitorResolution = Vector2(256, 256):
109-
set(value):
110-
AnalogMonitorResolution = value
111-
reload = true
112-
@export_group("Grain")
101+
@export_subgroup("Grain")
113102
@export var Grain: bool
114103
@export_range(0, 150, 0.1) var GrainPower = 75:
115104
set(value):
116105
GrainPower = value
117106
reload = true
118-
@export_group("Circular Waves")
107+
@export_subgroup("Circular Waves")
119108
@export var CircularWaves: bool
120109
@export_range(0,2, 0.01) var CircularWavesAmplitude = 2.0:
121110
set(value):
@@ -129,7 +118,7 @@ class_name PostProcessingConfiguration extends Resource
129118
set(value):
130119
CircularWavesRippleRate = value
131120
reload = true
132-
@export_group("Speed Lines")
121+
@export_subgroup("Speed Lines")
133122
@export var SpeedLines: bool
134123
@export var SpeedLinesColor: Color = Color.WHITE:
135124
set(value):
@@ -147,7 +136,17 @@ class_name PostProcessingConfiguration extends Resource
147136
set(value):
148137
SpeedLineSpeed = value
149138
reload = true
150-
@export_group("CRT")
139+
140+
@export_group("Display")
141+
@export_subgroup("Color Correction")
142+
@export var ColorCorrection: bool
143+
@export var ColorCorrectionTint : Color
144+
@export_range(-1.0, 1.0) var ColorCorrectionBrightness : float = 0
145+
@export_range(-1.0, 1.0) var ColorCorrectionSaturation : float = 0
146+
@export_subgroup("Pixelate")
147+
@export var Pixelate : bool
148+
@export_range(0, 64) var PixelatePixelSize = 8
149+
@export_subgroup("CRT")
151150
@export var CRT: bool
152151
@export var overlay : bool = false:
153152
set(value):
@@ -225,10 +224,16 @@ class_name PostProcessingConfiguration extends Resource
225224
set(value):
226225
vignette_opacity = value
227226
reload = true
228-
229-
230-
#@export_category("Bloom")
231-
var Bloom: bool = false
232-
var BloomDirection = Vector2(0,0)
233-
var BloomRadius = 0.0
234-
var BloomIntensity = 0.0
227+
@export_subgroup("Analog Monitor")
228+
@export var AnalogMonitor: bool
229+
@export var AnalogMonitorResolution = Vector2(256, 256):
230+
set(value):
231+
AnalogMonitorResolution = value
232+
reload = true
233+
@export_group("Other")
234+
@export_subgroup("Screen Shake")
235+
@export var ScreenShake: bool
236+
@export var ScreenShakePower = 0.1:
237+
set(value):
238+
ScreenShakePower = value
239+
reload = true
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
shader_type canvas_item;
2+
3+
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear;
4+
uniform vec4 tint : source_color = vec4(1, 1, 1, 1);
5+
uniform float brightness : hint_range(-1.0, 1.0) = 0;
6+
uniform float saturation : hint_range(-1.0, 1.0) = 0;
7+
8+
void fragment(){
9+
vec4 color = texture(SCREEN_TEXTURE, SCREEN_UV);
10+
vec4 final_col = color * tint;
11+
final_col.rgb = final_col.rgb + brightness;
12+
13+
float avg_col = (final_col.r + final_col.g + final_col.b) / 3.0;
14+
vec3 sat_color = mix(vec3(avg_col), final_col.rgb, 1.0 + saturation);
15+
16+
final_col.rgb = clamp(sat_color, 0.0, 1.0);
17+
18+
COLOR = final_col;
19+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
This shader is under MIT license. Feel free to use, improve and
3+
change this shader according to your needs and consider sharing
4+
the modified result to godotshaders.com.
5+
*/
6+
7+
shader_type canvas_item;
8+
9+
uniform sampler2D u_dither_tex;
10+
uniform sampler2D u_color_tex;
11+
12+
uniform int u_bit_depth;
13+
uniform float u_contrast;
14+
uniform float u_offset;
15+
uniform int u_dither_size;
16+
17+
void fragment()
18+
{
19+
// sample the screen texture at the desired output resolution (according to u_dither_size)
20+
// this will effectively pixelate the resulting output
21+
vec2 screen_size = vec2(textureSize(TEXTURE, 0)) / float(u_dither_size);
22+
vec2 screen_sample_uv = floor(UV * screen_size) / screen_size;
23+
vec3 screen_col = texture(TEXTURE, screen_sample_uv).rgb;
24+
25+
// calculate pixel luminosity (https://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color)
26+
float lum = (screen_col.r * 0.299) + (screen_col.g * 0.587) + (screen_col.b * 0.114);
27+
28+
// adjust with contrast and offset parameters
29+
float contrast = u_contrast;
30+
lum = (lum - 0.5 + u_offset) * contrast + 0.5;
31+
lum = clamp(lum, 0.0, 1.0);
32+
33+
// reduce luminosity bit depth to give a more banded visual if desired
34+
float bits = float(u_bit_depth);
35+
lum = floor(lum * bits) / bits;
36+
37+
// to support multicolour palettes, we want to dither between the two colours on the palette
38+
// which are adjacent to the current pixel luminosity.
39+
// to do this, we need to determine which 'band' lum falls into, calculate the upper and lower
40+
// bound of that band, then later we will use the dither texture to pick either the upper or
41+
// lower colour.
42+
43+
// get the palette texture size mapped so it is 1px high (so the x value however many colour bands there are)
44+
ivec2 col_size = textureSize(u_color_tex, 0);
45+
col_size /= col_size.y;
46+
47+
float col_x = float(col_size.x) - 1.0; // colour boundaries is 1 less than the number of colour bands
48+
float col_texel_size = 1.0 / col_x; // the size of one colour boundary
49+
50+
lum = max(lum - 0.00001, 0.0); // makes sure our floor calculation below behaves when lum == 1.0
51+
float lum_lower = floor(lum * col_x) * col_texel_size;
52+
float lum_upper = (floor(lum * col_x) + 1.0) * col_texel_size;
53+
float lum_scaled = lum * col_x - floor(lum * col_x); // calculates where lum lies between the upper and lower bound
54+
55+
// map the dither texture onto the screen. there are better ways of doing this that makes the dither pattern 'stick'
56+
// with objects in the 3D world, instead of being mapped onto the screen. see lucas pope's details posts on how he
57+
// achieved this in Obra Dinn: https://forums.tigsource.com/index.php?topic=40832.msg1363742#msg1363742
58+
ivec2 noise_size = textureSize(u_dither_tex, 0);
59+
vec2 inv_noise_size = vec2(1.0 / float(noise_size.x), 1.0 / float(noise_size.y));
60+
vec2 noise_uv = UV * inv_noise_size * vec2(float(screen_size.x), float(screen_size.y));
61+
float threshold = texture(u_dither_tex, noise_uv).r;
62+
63+
// adjust the dither slightly so min and max aren't quite at 0.0 and 1.0
64+
// otherwise we wouldn't get fullly dark and fully light dither patterns at lum 0.0 and 1.0
65+
threshold = threshold * 0.99 + 0.005;
66+
67+
// the lower lum_scaled is, the fewer pixels will be below the dither threshold, and thus will use the lower bound colour,
68+
// and vice-versa
69+
float ramp_val = lum_scaled < threshold ? 0.0f : 1.0f;
70+
// sample at the lower bound colour if ramp_val is 0.0, upper bound colour if 1.0
71+
float col_sample = mix(lum_lower, lum_upper, ramp_val);
72+
vec3 final_col = texture(u_color_tex, vec2(col_sample, 0.5)).rgb;
73+
74+
// return the final colour!
75+
COLOR.rgb = final_col;
76+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
shader_type canvas_item;
2+
3+
uniform sampler2D flowMap; //Displacement map
4+
uniform float strength; //Force of the effect
5+
uniform float speed; //Speed of the effect
6+
uniform int frames : hint_range(1, 10); //Frames of the effect
7+
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear;
8+
9+
//Returns a value between 0 and 1 depending of the frames -> exemple: frames = 4, frame 1 = 0.25
10+
float clock(float time){
11+
float fframes = float(frames);
12+
return floor(mod(time * speed, fframes)) / fframes;
13+
}
14+
15+
void fragment(){
16+
float c = clock(TIME); //Get clock frame
17+
vec4 offset = texture(flowMap, vec2(SCREEN_UV.x + c, SCREEN_UV.y + c)) * strength; //Get offset
18+
//COLOR = texture(TEXTURE, vec2(UV.x,UV.y) + normal.xy); //Apply offset
19+
COLOR = texture(SCREEN_TEXTURE, vec2(SCREEN_UV.x,SCREEN_UV.y) + offset.xy - vec2(0.5,0.5)*strength); //We need to remove the displacement
20+
}

0 commit comments

Comments
 (0)