improved ground grid shader

This commit is contained in:
mehbark 2025-05-05 23:02:44 -04:00
parent 99ee97c0c1
commit a91b6999ec
4 changed files with 23 additions and 7 deletions

View file

@ -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;
}
}

View file

@ -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

View file

@ -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")

View file

@ -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)