From f7714b14db356250b74851f76119ce1b9cb1e1e2 Mon Sep 17 00:00:00 2001 From: Timothy van der Valk Date: Tue, 6 Jan 2026 21:01:53 +0100 Subject: [PATCH] Loading images with noise distortion. --- .editorconfig | 4 ++ .gitattributes | 2 + .gitignore | 3 + README.md | 3 + content/imagine.gdshader | 22 ++++++ content/imagine.gdshader.uid | 1 + content/mat_imagine.tres | 27 +++++++ icon.svg | 1 + icon.svg.import | 43 +++++++++++ project.godot | 28 ++++++++ run/main.gd | 19 +++++ run/main.gd.uid | 1 + run/main.tscn | 136 +++++++++++++++++++++++++++++++++++ 13 files changed, 290 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 README.md create mode 100644 content/imagine.gdshader create mode 100644 content/imagine.gdshader.uid create mode 100644 content/mat_imagine.tres create mode 100644 icon.svg create mode 100644 icon.svg.import create mode 100644 project.godot create mode 100644 run/main.gd create mode 100644 run/main.gd.uid create mode 100644 run/main.tscn 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/README.md b/README.md new file mode 100644 index 0000000..014fd82 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Imagine Composer + +A tool for creating dreamy imaginations from artwork, for use in the blind exploration game Blind Nature. diff --git a/content/imagine.gdshader b/content/imagine.gdshader new file mode 100644 index 0000000..d545d08 --- /dev/null +++ b/content/imagine.gdshader @@ -0,0 +1,22 @@ +shader_type canvas_item; + +uniform sampler2D ripples: repeat_enable; +uniform float warp; +uniform float time_scale = 0.1f; + +vec3 hmap_normal(sampler2D hmap, vec2 uv) { + float eps = 0.01f; + float z = texture(hmap, uv).z; + return normalize(vec3( + (texture(hmap, uv + vec2(eps, 0)).z - z) / eps, + (texture(hmap, uv + vec2(0, eps)).z - z) / eps, + -1 + )); +} + +void fragment() { + //vec3 normal = texture(ripples, UV + vec2(TIME * time_scale, 0)).xyz; + vec3 normal = hmap_normal(ripples, UV + vec2(TIME * time_scale, 0)); + vec4 col = texture(TEXTURE, UV + normal.xy * warp).rgba; + COLOR.rgb = col.rgb; +} diff --git a/content/imagine.gdshader.uid b/content/imagine.gdshader.uid new file mode 100644 index 0000000..f236041 --- /dev/null +++ b/content/imagine.gdshader.uid @@ -0,0 +1 @@ +uid://cutdjeuxu188p diff --git a/content/mat_imagine.tres b/content/mat_imagine.tres new file mode 100644 index 0000000..b496e0e --- /dev/null +++ b/content/mat_imagine.tres @@ -0,0 +1,27 @@ +[gd_resource type="ShaderMaterial" load_steps=4 format=3 uid="uid://wr6g6bhw2fyj"] + +[ext_resource type="Shader" uid="uid://cutdjeuxu188p" path="res://content/imagine.gdshader" id="1_74fhu"] + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_74fhu"] +noise_type = 0 +frequency = 0.0018 +cellular_distance_function = 1 +domain_warp_type = 2 +domain_warp_amplitude = 3.36 +domain_warp_fractal_type = 2 + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_74fhu"] +width = 1280 +height = 720 +noise = SubResource("FastNoiseLite_74fhu") +seamless = true +invert = true +in_3d_space = true +normalize = false +bump_strength = 32.0 + +[resource] +shader = ExtResource("1_74fhu") +shader_parameter/ripples = SubResource("NoiseTexture2D_74fhu") +shader_parameter/warp = 0.005 +shader_parameter/time_scale = 0.035 diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..c6bbb7d --- /dev/null +++ b/icon.svg @@ -0,0 +1 @@ + diff --git a/icon.svg.import b/icon.svg.import new file mode 100644 index 0000000..e697048 --- /dev/null +++ b/icon.svg.import @@ -0,0 +1,43 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dldw5nkqr0djl" +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/uastc_level=0 +compress/rdo_quality_loss=0.0 +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/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +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/project.godot b/project.godot new file mode 100644 index 0000000..b9a6701 --- /dev/null +++ b/project.godot @@ -0,0 +1,28 @@ +; 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="Imagine Composer" +run/main_scene="uid://b8c8qe2xi5m24" +config/features=PackedStringArray("4.5", "GL Compatibility") +config/icon="res://icon.svg" + +[display] + +window/size/viewport_width=1280 +window/size/viewport_height=720 +window/stretch/mode="canvas_items" +window/stretch/aspect="expand" + +[rendering] + +renderer/rendering_method="gl_compatibility" +renderer/rendering_method.mobile="gl_compatibility" diff --git a/run/main.gd b/run/main.gd new file mode 100644 index 0000000..4e63973 --- /dev/null +++ b/run/main.gd @@ -0,0 +1,19 @@ +extends Control + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + %LoadImageButton.pressed.connect(show_image_load_dialog) + %LoadImageDialog.file_selected.connect(load_image) + +func show_image_load_dialog(): + %LoadImageDialog.visible = true + +func load_image(path: String) -> bool: + var image = Image.load_from_file(path) + if image == null: + return false + + var tex = ImageTexture.create_from_image(image) + %PreviewImage.texture = tex + %LoadImageButton.text = path.get_file() + return true diff --git a/run/main.gd.uid b/run/main.gd.uid new file mode 100644 index 0000000..31f6935 --- /dev/null +++ b/run/main.gd.uid @@ -0,0 +1 @@ +uid://g3xgdtvbtg2f diff --git a/run/main.tscn b/run/main.tscn new file mode 100644 index 0000000..2a1c8a1 --- /dev/null +++ b/run/main.tscn @@ -0,0 +1,136 @@ +[gd_scene load_steps=5 format=3 uid="uid://b8c8qe2xi5m24"] + +[ext_resource type="Texture2D" uid="uid://dldw5nkqr0djl" path="res://icon.svg" id="1_4u770"] +[ext_resource type="Script" uid="uid://g3xgdtvbtg2f" path="res://run/main.gd" id="1_t8dga"] +[ext_resource type="Material" uid="uid://wr6g6bhw2fyj" path="res://content/mat_imagine.tres" id="2_vt7r5"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_t8dga"] +bg_color = Color(0.1003897, 0.10924364, 0.113670714, 1) + +[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 +script = ExtResource("1_t8dga") + +[node name="ColorRect" type="ColorRect" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +color = Color(0, 0, 0, 1) + +[node name="LoadImageDialog" type="FileDialog" parent="."] +unique_name_in_owner = true +oversampling_override = 1.0 +title = "Open a File" +dialog_hide_on_ok = true +file_mode = 0 +access = 2 +filters = PackedStringArray("*.png") +use_native_dialog = true +hidden_files_toggle_enabled = false +file_filter_toggle_enabled = false +file_sort_options_enabled = false +folder_creation_enabled = false +favorites_enabled = false + +[node name="MainSplit" type="HBoxContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="PreviewSide" type="MarginContainer" parent="MainSplit"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_stretch_ratio = 3.0 +theme_override_constants/margin_left = 8 +theme_override_constants/margin_top = 8 +theme_override_constants/margin_right = 8 +theme_override_constants/margin_bottom = 8 + +[node name="PreviewWindow" type="AspectRatioContainer" parent="MainSplit/PreviewSide"] +layout_mode = 2 +ratio = 1.7778 + +[node name="Panel" type="Panel" parent="MainSplit/PreviewSide/PreviewWindow"] +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_t8dga") + +[node name="PreviewImage" type="TextureRect" parent="MainSplit/PreviewSide/PreviewWindow/Panel"] +unique_name_in_owner = true +material = ExtResource("2_vt7r5") +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("1_4u770") +expand_mode = 1 +stretch_mode = 5 + +[node name="ControlSide" type="PanelContainer" parent="MainSplit"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="MarginContainer" type="MarginContainer" parent="MainSplit/ControlSide"] +layout_mode = 2 +theme_override_constants/margin_left = 4 +theme_override_constants/margin_top = 4 +theme_override_constants/margin_right = 4 +theme_override_constants/margin_bottom = 4 + +[node name="VBoxContainer" type="VBoxContainer" parent="MainSplit/ControlSide/MarginContainer"] +layout_mode = 2 + +[node name="TitleLabel" type="Label" parent="MainSplit/ControlSide/MarginContainer/VBoxContainer"] +custom_minimum_size = Vector2(0, 50) +layout_mode = 2 +text = "Imagine Composer" +horizontal_alignment = 1 + +[node name="FileContainer" type="FoldableContainer" parent="MainSplit/ControlSide/MarginContainer/VBoxContainer"] +layout_mode = 2 +title = "File" + +[node name="VBoxContainer" type="VBoxContainer" parent="MainSplit/ControlSide/MarginContainer/VBoxContainer/FileContainer"] +layout_mode = 2 + +[node name="LoadImageButton" type="Button" parent="MainSplit/ControlSide/MarginContainer/VBoxContainer/FileContainer/VBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 +text = "Load Image" + +[node name="LoadFXButton" type="Button" parent="MainSplit/ControlSide/MarginContainer/VBoxContainer/FileContainer/VBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 3 +text = "Load FX" + +[node name="HBoxContainer" type="HBoxContainer" parent="MainSplit/ControlSide/MarginContainer/VBoxContainer/FileContainer/VBoxContainer"] +layout_mode = 2 + +[node name="SaveFXButton" type="Button" parent="MainSplit/ControlSide/MarginContainer/VBoxContainer/FileContainer/VBoxContainer/HBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 3 +text = "Save FX" + +[node name="SaveFXAsButton" type="Button" parent="MainSplit/ControlSide/MarginContainer/VBoxContainer/FileContainer/VBoxContainer/HBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 3 +text = "Save FX As" + +[node name="FX Container" type="FoldableContainer" parent="MainSplit/ControlSide/MarginContainer/VBoxContainer"] +layout_mode = 2 +title = "Effects"