feat(foliage): add recovering grass trails and bush contact
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
// Per-world data texture, deliberately not a global shader parameter.
|
||||
uniform bool foliage_trails_enabled = false;
|
||||
uniform sampler2D foliage_trail_map : filter_linear, repeat_disable;
|
||||
uniform vec4 foliage_trail_rect = vec4(0.0, 0.0, 64.0, 64.0);
|
||||
|
||||
vec3 sample_foliage_trail(vec3 ground_position) {
|
||||
if (!foliage_trails_enabled) { return vec3(0.0); }
|
||||
vec2 uv = (ground_position.xz - foliage_trail_rect.xy) / foliage_trail_rect.zw;
|
||||
if (any(lessThan(uv, vec2(0.0))) || any(greaterThan(uv, vec2(1.0)))) { return vec3(0.0); }
|
||||
vec4 trail = textureLod(foliage_trail_map, uv, 0.0);
|
||||
float foot_height = trail.a / max(trail.b, 0.0001);
|
||||
// Walkers on a bridge or above a slope do not press plants underneath them.
|
||||
float same_level = 1.0 - smoothstep(0.55, 1.35, abs(ground_position.y - foot_height));
|
||||
float edge = smoothstep(0.0, 0.025, min(min(uv.x, uv.y), min(1.0 - uv.x, 1.0 - uv.y)));
|
||||
return trail.rgb * same_level * edge;
|
||||
}
|
||||
Reference in New Issue
Block a user