improved sand pit material

This commit is contained in:
Haze Weathers 2025-02-23 04:22:15 -05:00
parent 4a7cc4c401
commit c7d401a752
2 changed files with 24 additions and 10 deletions

View file

@ -0,0 +1,16 @@
shader_type spatial;
uniform sampler2D albedo_texture : repeat_enable, filter_nearest, source_color;
uniform vec2 horizontal_uv_offset = vec2(0.0);
void vertex() {
vec3 world_position = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xyz;
vec3 world_normal = (MODEL_NORMAL_MATRIX * NORMAL).xyz;
vec2 uv_y = world_position.xz + horizontal_uv_offset;
//vec3 normal_weights = world_normal / (world_normal.x + world_normal.y + world_normal.z);
UV = mix(UV, uv_y, abs(world_normal.y));
}
void fragment() {
ALBEDO = texture(albedo_texture, UV).rgb;
}

View file

@ -1,22 +1,20 @@
[gd_scene load_steps=4 format=3 uid="uid://bfic5n608nc5j"]
[gd_scene load_steps=5 format=3 uid="uid://bfic5n608nc5j"]
[ext_resource type="Shader" path="res://assets/shaders/horizontal_world_uv.gdshader" id="1_2mr0t"]
[ext_resource type="Texture2D" uid="uid://djx2x3jjn01w2" path="res://assets/textures/world/sand.png" id="1_yg8om"]
[ext_resource type="Script" path="res://objects/sand_pit.gd" id="2_vtyum"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_r0cip"]
shading_mode = 2
specular_mode = 2
albedo_texture = ExtResource("1_yg8om")
metallic_specular = 0.0
uv1_triplanar = true
uv1_world_triplanar = true
texture_filter = 0
[sub_resource type="ShaderMaterial" id="ShaderMaterial_7s0pr"]
render_priority = 0
shader = ExtResource("1_2mr0t")
shader_parameter/horizontal_uv_offset = Vector2(0, 0)
shader_parameter/albedo_texture = ExtResource("1_yg8om")
[node name="SandPit" type="CSGPolygon3D" node_paths=PackedStringArray("collision_polygon")]
process_physics_priority = 100
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0)
depth = 0.03
material = SubResource("StandardMaterial3D_r0cip")
material = SubResource("ShaderMaterial_7s0pr")
script = ExtResource("2_vtyum")
friction = 9.0
collision_polygon = NodePath("Area3D/CollisionPolygon3D")