commit 0f05a2bdef641dbf8fd860988454d9110116ac8d Author: Vojtěch Struhár Date: Tue Jun 3 15:29:34 2025 +0200 Get shader to work diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f28239b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +root = true + +[*] +charset = utf-8 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8ad74f7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0af181c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# Godot 4+ specific ignores +.godot/ +/android/ diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..9d8b7fa --- /dev/null +++ b/icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/icon.svg.import b/icon.svg.import new file mode 100644 index 0000000..8257e25 --- /dev/null +++ b/icon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://e05aocekoxi5" +path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.svg" +dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/main.gdshader b/main.gdshader new file mode 100644 index 0000000..4ca1453 --- /dev/null +++ b/main.gdshader @@ -0,0 +1,53 @@ +shader_type canvas_item; + +#define SPIN_ROTATION -2.0 +#define SPIN_SPEED 7.0 +#define OFFSET vec2(0.0) +#define COLOUR_1 vec4(0.871, 0.267, 0.231, 1.0) +#define COLOUR_2 vec4(0.0, 0.42, 0.706, 1.0) +#define COLOUR_3 vec4(0.086, 0.137, 0.145, 1.0) +#define CONTRAST 3.5 +#define LIGTHING 0.4 +#define SPIN_AMOUNT 0.25 +#define PIXEL_FILTER 745.0 +#define SPIN_EASE 1.0 +#define PI 3.14159265359 +#define IS_ROTATE false + +vec4 effect(vec2 screenSize, vec2 screen_coords) { + float pixel_size = length(screenSize.xy) / PIXEL_FILTER; + vec2 uv = (floor(screen_coords.xy*(1./pixel_size))*pixel_size - 0.5*screenSize.xy)/length(screenSize.xy) - OFFSET; + float uv_len = length(uv); + + float speed = (SPIN_ROTATION*SPIN_EASE*0.2); + if(IS_ROTATE){ + speed = TIME * speed; + } + speed += 302.2; + float new_pixel_angle = atan(uv.y, uv.x) + speed - SPIN_EASE*20.*(1.*SPIN_AMOUNT*uv_len + (1. - 1.*SPIN_AMOUNT)); + vec2 mid = (screenSize.xy/length(screenSize.xy))/2.; + uv = (vec2((uv_len * cos(new_pixel_angle) + mid.x), (uv_len * sin(new_pixel_angle) + mid.y)) - mid); + + uv *= 30.; + speed = TIME*(SPIN_SPEED); + vec2 uv2 = vec2(uv.x+uv.y); + + for(int i=0; i < 5; i++) { + uv2 += sin(max(uv.x, uv.y)) + uv; + uv += 0.5*vec2(cos(5.1123314 + 0.353*uv2.y + speed*0.131121),sin(uv2.x - 0.113*speed)); + uv -= 1.0*cos(uv.x + uv.y) - 1.0*sin(uv.x*0.711 - uv.y); + } + + float contrast_mod = (0.25*CONTRAST + 0.5*SPIN_AMOUNT + 1.2); + float paint_res = min(2., max(0.,length(uv)*(0.035)*contrast_mod)); + float c1p = max(0.,1. - contrast_mod*abs(1.-paint_res)); + float c2p = max(0.,1. - contrast_mod*abs(paint_res)); + float c3p = 1. - min(1., c1p + c2p); + float light = (LIGTHING - 0.2)*max(c1p*5. - 4., 0.) + LIGTHING*max(c2p*5. - 4., 0.); + return (0.3/CONTRAST)*COLOUR_1 + (1. - 0.3/CONTRAST)*(COLOUR_1*c1p + COLOUR_2*c2p + vec4(c3p*COLOUR_3.rgb, c3p*COLOUR_1.a)) + light; +} + + +void fragment() { + COLOR = effect(vec2(1920, 1080), vec2(UV.x * 1920.0, UV.y * 1080.0)); +} diff --git a/main.gdshader.uid b/main.gdshader.uid new file mode 100644 index 0000000..ea5d403 --- /dev/null +++ b/main.gdshader.uid @@ -0,0 +1 @@ +uid://c2bxvd7878rqy diff --git a/main.tscn b/main.tscn new file mode 100644 index 0000000..25c2126 --- /dev/null +++ b/main.tscn @@ -0,0 +1,27 @@ +[gd_scene load_steps=4 format=3 uid="uid://vkokd44wy82r"] + +[ext_resource type="Shader" uid="uid://c2bxvd7878rqy" path="res://main.gdshader" id="1_ig7tw"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_7dm0k"] +shader = ExtResource("1_ig7tw") + +[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_ig7tw"] +size = Vector2(1920, 1080) + +[node name="Main" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="TextureRect" type="TextureRect" parent="."] +material = SubResource("ShaderMaterial_7dm0k") +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = SubResource("PlaceholderTexture2D_ig7tw") diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..6bd32bc --- /dev/null +++ b/project.godot @@ -0,0 +1,20 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +[application] + +config/name="balatro-shader" +config/features=PackedStringArray("4.4", "Forward Plus") +config/icon="res://icon.svg" + +[display] + +window/size/viewport_width=1920 +window/size/viewport_height=1080