Skip to content

Commit

Permalink
Use AutoInvertColors shader for the cursor tool icons
Browse files Browse the repository at this point in the history
  • Loading branch information
OverloadedOrama committed Jun 4, 2021
1 parent a67855a commit a4c9e0e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
19 changes: 12 additions & 7 deletions src/Main.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=17 format=2]
[gd_scene load_steps=20 format=2]

[ext_resource path="res://assets/themes/dark/theme.tres" type="Theme" id=1]
[ext_resource path="res://src/Main.gd" type="Script" id=2]
Expand All @@ -9,6 +9,7 @@
[ext_resource path="res://src/UI/Dialogs/ImageEffects/ImageEffects.tscn" type="PackedScene" id=7]
[ext_resource path="res://src/UI/Dialogs/SaveSpriteHTML5.tscn" type="PackedScene" id=8]
[ext_resource path="res://src/UI/Timeline/FrameProperties.tscn" type="PackedScene" id=9]
[ext_resource path="res://src/Shaders/AutoInvertColors.shader" type="Shader" id=10]
[ext_resource path="res://src/UI/Dialogs/SaveSprite.tscn" type="PackedScene" id=11]
[ext_resource path="res://src/UI/Dialogs/OpenSprite.tscn" type="PackedScene" id=12]
[ext_resource path="res://src/UI/Dialogs/SplashDialog.tscn" type="PackedScene" id=27]
Expand All @@ -17,6 +18,12 @@
[ext_resource path="res://src/UI/Dialogs/AboutDialog.tscn" type="PackedScene" id=34]
[ext_resource path="res://src/UI/Dialogs/ExportDialog.tscn" type="PackedScene" id=39]

[sub_resource type="ShaderMaterial" id=1]
shader = ExtResource( 10 )

[sub_resource type="ShaderMaterial" id=2]
shader = ExtResource( 10 )

[node name="Control" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
Expand Down Expand Up @@ -111,15 +118,13 @@ Do you want to reload it?"

[node name="FrameProperties" parent="Dialogs" instance=ExtResource( 9 )]

[node name="LeftCursor" type="Sprite" parent="." groups=[
"UIButtons",
]]
[node name="LeftCursor" type="Sprite" parent="."]
visible = false
material = SubResource( 1 )

[node name="RightCursor" type="Sprite" parent="." groups=[
"UIButtons",
]]
[node name="RightCursor" type="Sprite" parent="."]
visible = false
material = SubResource( 2 )

[node name="ModulateTween" type="Tween" parent="."]

Expand Down
2 changes: 1 addition & 1 deletion src/Preferences/RestoreDefaultButton.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[ext_resource path="res://assets/graphics/misc/icon_reload.png" type="Texture" id=1]
[ext_resource path="res://src/Preferences/RestoreDefaultButton.gd" type="Script" id=2]


[sub_resource type="ImageTexture" id=1]

[node name="RestoreDefaultButton" type="TextureButton" groups=[
Expand All @@ -19,4 +18,5 @@ script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}

[connection signal="pressed" from="." to="." method="_on_RestoreDefaultButton_pressed"]
9 changes: 6 additions & 3 deletions src/Shaders/AutoInvertColors.shader
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ shader_type canvas_item;


void fragment() {
vec3 inverted = vec3(1.0) - COLOR.rgb;
vec4 color = texture(TEXTURE, UV);
COLOR = color;
vec3 inverted = vec3(1.0) - color.rgb;
vec3 screen_color = textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0).rgb;
float avg = (screen_color.r + screen_color.g + screen_color.b) / 3.0;
COLOR.rgb = inverted * step(avg, 0.5);
float screen_avg = (screen_color.r + screen_color.g + screen_color.b) / 3.0;

COLOR.rgb = inverted * step(0.5, screen_avg) + color.rgb * step(screen_avg, 0.5);
}

0 comments on commit a4c9e0e

Please sign in to comment.