diff --git a/godot/.mono/metadata/ide_messaging_meta.txt b/godot/.mono/metadata/ide_messaging_meta.txt deleted file mode 100644 index ac5abdb..0000000 --- a/godot/.mono/metadata/ide_messaging_meta.txt +++ /dev/null @@ -1,2 +0,0 @@ -36673 -/home/squirrel/.local/bin/godot_mono diff --git a/godot/assets/effects/dithering/CanvasLayer.tscn b/godot/assets/effects/dithering/CanvasLayer.tscn index 652f678..79a862b 100644 --- a/godot/assets/effects/dithering/CanvasLayer.tscn +++ b/godot/assets/effects/dithering/CanvasLayer.tscn @@ -4,7 +4,9 @@ [sub_resource type="ShaderMaterial" id=1] shader = ExtResource( 1 ) -shader_param/param = 15.0 +shader_param/param = 13.0 +shader_param/scale = 2.0 +shader_param/grid = 4 shader_param/anim_period = 1.65 [node name="CanvasLayer" type="CanvasLayer"] diff --git a/godot/assets/effects/dithering/screen_space_shader.tres b/godot/assets/effects/dithering/screen_space_shader.tres index 1d6690e..ffbaf24 100644 --- a/godot/assets/effects/dithering/screen_space_shader.tres +++ b/godot/assets/effects/dithering/screen_space_shader.tres @@ -110,18 +110,57 @@ vec3 band_colors_preserve_hue_lum(vec3 rgb) return hsv2rgb(hsv); } +uniform float scale = 2.0; +uniform int grid = 5; + +vec3 band_dither(vec3 rgb, vec2 uv) +{ + + uv *= (1.0 / scale); + int x = int(mod(uv.x, float(grid))) + 1; + int y = int(mod(uv.y, float(grid))) + 1; + + vec3 hsv = rgb2hsv(rgb); + + int g = int(round(mix(float(grid), float(2), fract(hsv.r * param)))); + + + if (x % g == 0 && y % g == 0) { + hsv.r = ceil(hsv.r * param) / param; + } else { + hsv.r = floor(hsv.r * param) / param; + } + vec3 lab = xyz2lab(rgb2xyz(rgb)); + if (x % g == 0 && y % g == 0) { + lab.r = ceil(lab.r * (param / 100.0)) / (param / 100.0); + } else { + lab.r = floor(lab.r * (param / 100.0)) / (param / 100.0); + } + + // Into HSV + vec2 sv = rgb2hsv(xyz2rgb(lab2xyz(lab))).gb; + hsv.gb = sv; + + + return hsv2rgb(hsv); + +} + uniform float anim_period : hint_range(0.1, 5, 0.01); void fragment() { vec3 rgb = textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0).rgb; - vec3 banded_preserved = band_colors_preserve_hue_lum(rgb); - vec3 banded_nostalgia = band_colors(rgb); - float weight = mod(TIME, anim_period) / anim_period; - float double_weight = mod(TIME, anim_period*2.0) / (anim_period*2.0); - weight = double_weight > 0.5 ? (1.-weight) : weight; - vec3 mixed = mix(banded_nostalgia, banded_preserved, weight); - COLOR.rgb = mixed; + vec3 banded_preserved = band_dither(rgb, FRAGCOORD.xy); + //vec3 banded_nostalgia = band_colors(rgb); + //float weight = mod(TIME, anim_period) / anim_period; + //float double_weight = mod(TIME, anim_period*2.0) / (anim_period*2.0); + //weight = double_weight > 0.5 ? (1.-weight) : weight; + //vec3 mixed = mix(banded_nostalgia, banded_preserved, weight); + //COLOR.rgb = mixed; + + + COLOR.rgb = banded_preserved; } " diff --git a/godot/tests/dither.tscn b/godot/tests/dither.tscn index 473a1bb..11ff59c 100644 --- a/godot/tests/dither.tscn +++ b/godot/tests/dither.tscn @@ -25,3 +25,11 @@ light_energy = 16.0 light_indirect_energy = 1.306 omni_range = 8.917 omni_attenuation = 2.73208 + +[node name="SpotLight" type="SpotLight" parent="."] +transform = Transform( -0.999987, 5.82069e-11, 0.00514878, 0.00507827, 0.164927, 0.986293, -0.000849173, 0.986306, -0.164925, 0, 4.25661, -0.823411 ) +light_color = Color( 0.623529, 0.247059, 0.756863, 1 ) +light_energy = 30.0 +light_specular = 0.594 +spot_range = 13.9301 +spot_angle = 57.9366