From 7eebf4e2d727de64ce4d6948e80992d05627dce6 Mon Sep 17 00:00:00 2001 From: Daniel Snider Date: Fri, 18 Apr 2025 01:41:24 -0700 Subject: [PATCH] first commit --- .gitattributes | 2 ++ .gitignore | 2 ++ icon.svg | 1 + icon.svg.import | 37 ++++++++++++++++++++++++++++++ main.tscn | 36 +++++++++++++++++++++++++++++ project.godot | 15 ++++++++++++ stairs.gdshader | 56 +++++++++++++++++++++++++++++++++++++++++++++ stairs.gdshader.uid | 1 + 8 files changed, 150 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 icon.svg create mode 100644 icon.svg.import create mode 100644 main.tscn create mode 100644 project.godot create mode 100644 stairs.gdshader create mode 100644 stairs.gdshader.uid 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..4709183 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Godot 4+ specific ignores +.godot/ diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..1a10d58 --- /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..757d257 --- /dev/null +++ b/icon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://csyjb53nj0273" +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.tscn b/main.tscn new file mode 100644 index 0000000..35ed3c3 --- /dev/null +++ b/main.tscn @@ -0,0 +1,36 @@ +[gd_scene load_steps=3 format=3 uid="uid://bmh3d4xt71wx5"] + +[ext_resource type="Shader" uid="uid://brqn8rgcnleng" path="res://stairs.gdshader" id="1_ig7tw"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_ig7tw"] +shader = ExtResource("1_ig7tw") +shader_parameter/step_count = 168 +shader_parameter/inner = 101 +shader_parameter/pixel_size = 121 +shader_parameter/highlight = 0 +shader_parameter/grid_thickness = 0.125 +shader_parameter/offset = 0.0 + +[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="ColorRect" type="ColorRect" parent="."] +material = SubResource("ShaderMaterial_ig7tw") +custom_minimum_size = Vector2(128, 128) +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -324.0 +offset_top = -324.0 +offset_right = 324.0 +offset_bottom = 324.0 +grow_horizontal = 2 +grow_vertical = 2 diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..b75fb3e --- /dev/null +++ b/project.godot @@ -0,0 +1,15 @@ +; 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="stairs" +config/features=PackedStringArray("4.4") +config/icon="res://icon.svg" diff --git a/stairs.gdshader b/stairs.gdshader new file mode 100644 index 0000000..5ffea92 --- /dev/null +++ b/stairs.gdshader @@ -0,0 +1,56 @@ +shader_type canvas_item; +uniform int step_count = 168; +uniform int inner = 101; +uniform int pixel_size = 121; +uniform int highlight = 0; +uniform float grid_thickness = 0.125; +uniform float offset = 0.0; + +float mask(float inner_radius, float outer_radius, vec2 p) { + if (inner_radius < length(p) && length(p) < outer_radius) { + return 1.0; + } else { + return 0.0; + } +} + +float f(vec2 uv, vec2 p) { + + float angle = atan(p.y, p.x) / PI / 2.0 + 0.5 + offset/float(step_count); + float color = round(angle * float(step_count)) / float(step_count); + + + return color; +} + +float grid_mask(vec2 uv) { + float x = mod(uv.x*float(pixel_size), 1.0); + float y = mod(uv.y*float(pixel_size), 1.0); + return step(grid_thickness, x)* step(grid_thickness, y); +} + +void fragment() { + vec2 p = UV - vec2(0.5, 0.5); + p = round(p * float(pixel_size)) / float(pixel_size); + + float color = f(UV, p); + //color *= edge_mask(UV, vec2(0.002, 0.002)); + vec3 chroma = vec3(color, color, color); + int i = int(color * float(step_count)); + if (i == highlight) { + chroma = vec3(0.0, 1.0, 0.0); + } else if (i % 2 == 0) { + chroma = vec3(0.3, 0.3, 0.3); + } else if (i % 2 == 1) { + chroma = vec3(0.6, 0.6, 0.6); + } + chroma *= grid_mask(UV); + chroma *= mask(float(inner) / float(pixel_size * 2), 0.5, p); + COLOR = vec4(chroma, 1.0); + +} + +//void light() { +// // Called for every pixel for every light affecting the CanvasItem. +// // Uncomment to replace the default light processing function with this one. +//} diff --git a/stairs.gdshader.uid b/stairs.gdshader.uid new file mode 100644 index 0000000..d11b66d --- /dev/null +++ b/stairs.gdshader.uid @@ -0,0 +1 @@ +uid://brqn8rgcnleng