From a91b6999ec74a380263dfb2a8b2aa27866f52f31 Mon Sep 17 00:00:00 2001 From: mehbark Date: Mon, 5 May 2025 23:02:44 -0400 Subject: [PATCH] improved ground grid shader --- ground.gdshader | 13 +++++++++---- main.gd | 5 ++++- main.tscn | 10 +++++++++- piece.gd | 2 +- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/ground.gdshader b/ground.gdshader index ae527a1..04e738a 100644 --- a/ground.gdshader +++ b/ground.gdshader @@ -3,12 +3,17 @@ shader_type spatial; uniform vec2 dims; uniform vec3 light_color : source_color; uniform vec3 dark_color : source_color; +// uniform float line_width : hint_range(0.0, 0.1, 0.001); +uniform sampler2D NOISE_PATTERN; void fragment() { - vec2 p = UV*dims/2.0; - if (round(mod(p.x,1)) == round(mod(p.y,1))) { - ALBEDO = light_color; - } else { + vec2 p = UV*dims; + float noise = (texture(NOISE_PATTERN, p).x-0.5)/10.0; + ivec2 pos = ivec2(int(p.x), int(p.y)); + vec2 sub = mod(p, 1.0); + if (pos.x % 2 == pos.y % 2) { ALBEDO = dark_color; + } else { + ALBEDO = light_color; } } \ No newline at end of file diff --git a/main.gd b/main.gd index e410cf1..ac72608 100644 --- a/main.gd +++ b/main.gd @@ -7,6 +7,9 @@ extends Node3D @onready var camera: Camera3D = $Camera +# TODO: wall that player cannot go through but balls can +# (important) + var hist := UndoRedo.new() var board: Board var player: Piece @@ -23,7 +26,7 @@ var levels: Array[PackedScene] = [ var time := 0: set(new_time): var tween := get_tree().create_tween() - var anim_time = 1 if slowmo() else 0.1 + var anim_time = 1.0 if slowmo() else 0.1 tween.tween_property($Sun, "rotation_degrees:y", -20*new_time, anim_time) time = new_time var advancing := false diff --git a/main.tscn b/main.tscn index 9f9a03f..85b308c 100644 --- a/main.tscn +++ b/main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=11 format=3 uid="uid://lrk2whqxl0w0"] +[gd_scene load_steps=13 format=3 uid="uid://lrk2whqxl0w0"] [ext_resource type="Script" uid="uid://c707s0tgd88pg" path="res://main.gd" id="1_ig7tw"] [ext_resource type="Texture2D" uid="uid://crahyipmcudoy" path="res://ui/undo.png" id="3_lquwl"] @@ -20,12 +20,20 @@ background_mode = 2 sky = SubResource("Sky_lquwl") tonemap_mode = 2 +[sub_resource type="FastNoiseLite" id="FastNoiseLite_lquwl"] +noise_type = 0 +frequency = 0.0102 + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_7mycd"] +noise = SubResource("FastNoiseLite_lquwl") + [sub_resource type="ShaderMaterial" id="ShaderMaterial_lquwl"] render_priority = 0 shader = ExtResource("5_lquwl") shader_parameter/dims = Vector2(64, 64) shader_parameter/light_color = Color(0.321254, 0.470959, 0.199863, 1) shader_parameter/dark_color = Color(0.308333, 0.451677, 0.191453, 1) +shader_parameter/NOISE_PATTERN = SubResource("NoiseTexture2D_7mycd") [sub_resource type="PlaneMesh" id="PlaneMesh_1bvp3"] material = SubResource("ShaderMaterial_lquwl") diff --git a/piece.gd b/piece.gd index d79d5d4..e2b5a4b 100644 --- a/piece.gd +++ b/piece.gd @@ -151,5 +151,5 @@ func format_vel(vel: Vector2) -> String: else: return "%d,%d" % [vel.x,vel.y] -func _process(delta: float) -> void: +func _process(_delta: float) -> void: speedometer.text = format_vel(lvel)