Skip to content

Commit

Permalink
update: terrain dirt
Browse files Browse the repository at this point in the history
  • Loading branch information
gtibo committed Feb 9, 2023
1 parent f18f85c commit 6ac1f00
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 25 deletions.
18 changes: 13 additions & 5 deletions Environment/Terrain/terrain_shader.gdshader
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,22 @@ void fragment(){
float wall_edge = object_normal.y * wall_edge_offset;
float wall_mask = motif_mask(wall_edge, wall_motif);

float path_edge = triplanar_texture(grass_patch_pattern_sampler, triplanar_power_normal, triplanar_pos * 0.05).x;
float path_mask = motif_mask(smoothstep(0.5, 0.6, path_edge), grass_roughnes);
float path_edge = COLOR.x;
float path_mask = motif_mask(path_edge + 0.5, grass_roughnes * 2.0);

vec3 ground_albedo = mix(grass_albedo * vec3(0.85), grass_albedo * vec3(0.5), path_mask);
float grass_mix_noise_edge = triplanar_texture(grass_patch_pattern_sampler, triplanar_power_normal, triplanar_pos * 0.05).x;
float grass_mix_mask = motif_mask(smoothstep(0.5, 0.6, grass_mix_noise_edge), grass_roughnes);

vec3 grass_mixed_albedo =
mix(grass_albedo * vec3(0.85),
grass_albedo * vec3(0.5),
grass_mix_mask);

vec3 ground_albedo = mix(grass_mixed_albedo, dirt_albedo, path_mask);
float ground_roughness = mix(grass_roughnes, dirt_roughnes, path_mask);
vec3 ground_normal = mix(grass_normal, dirt_normal, path_mask);

ALBEDO = mix(cliff_albedo, ground_albedo, wall_mask);
ROUGHNESS = mix(cliff_roughness, grass_roughnes, wall_mask);
NORMAL_MAP = mix(cliff_normal, grass_normal, wall_mask);
ROUGHNESS = mix(cliff_roughness, ground_roughness, wall_mask);
NORMAL_MAP = mix(cliff_normal, ground_normal, wall_mask);
}
53 changes: 38 additions & 15 deletions Environment/environment.tscn

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions Environment/grass_scatter.gd
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ func _ready():

for i in range(mdt.get_face_count()):
var normal = mdt.get_face_normal(i)
if normal.dot(Vector3.UP) > 0.99:
triangles.append(i)
if normal.dot(Vector3.UP) < 0.99: continue

var v1 = mdt.get_vertex_color(mdt.get_face_vertex(i, 0))
var v2 = mdt.get_vertex_color(mdt.get_face_vertex(i, 1))
var v3 = mdt.get_vertex_color(mdt.get_face_vertex(i, 2))
var redness = (v1.r + v2.r + v3.r) / 3.0
if redness > 0.25: continue
triangles.append(i)

var triangle_count = triangles.size()

Expand Down
Binary file modified Environment/terrain.glb
Binary file not shown.
4 changes: 2 additions & 2 deletions Player/model/materials/face_mat.tres
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[gd_resource type="ShaderMaterial" load_steps=3 format=3 uid="uid://bbishx00t2kip"]

[ext_resource type="Shader" path="res://shared/shaders/face_mat.gdshader" id="1_js7p0"]
[ext_resource type="Texture2D" uid="uid://dbag7f8i27ub1" path="res://Player/model/faces/open.png" id="2_vumes"]
[ext_resource type="Texture2D" uid="uid://ci7cn145ld3l5" path="res://Player/model/faces/closed.png" id="2_gtaw8"]

[resource]
render_priority = 0
Expand All @@ -12,4 +12,4 @@ shader_parameter/screen_red_offset = Vector2(0, 0)
shader_parameter/screen_green_offset = Vector2(0, 0)
shader_parameter/screen_blue_offset = Vector2(0, 0)
shader_parameter/pixel_size = 44.0
shader_parameter/face_texture = ExtResource("2_vumes")
shader_parameter/face_texture = ExtResource("2_gtaw8")
2 changes: 1 addition & 1 deletion Player/model/materials/heart_core_mat.tres
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
albedo_color = Color(0, 0, 0, 1)
emission_enabled = true
emission = Color(0, 1, 0.392157, 1)
emission_energy_multiplier = 2.46309
emission_energy_multiplier = 1.76197

0 comments on commit 6ac1f00

Please sign in to comment.