From 71b3cd829f80de4c2cd3972d8bfd5ee470a5d180 Mon Sep 17 00:00:00 2001 From: Gone2Daly <71726742+Gone2Daly@users.noreply.github.com> Date: Sat, 22 Jul 2023 21:05:42 +0200 Subject: init_test --- .../tools/brush/shaders/flatten.gdshader | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 game/addons/zylann.hterrain/tools/brush/shaders/flatten.gdshader (limited to 'game/addons/zylann.hterrain/tools/brush/shaders/flatten.gdshader') diff --git a/game/addons/zylann.hterrain/tools/brush/shaders/flatten.gdshader b/game/addons/zylann.hterrain/tools/brush/shaders/flatten.gdshader new file mode 100644 index 0000000..c51f03a --- /dev/null +++ b/game/addons/zylann.hterrain/tools/brush/shaders/flatten.gdshader @@ -0,0 +1,22 @@ +shader_type canvas_item; +render_mode blend_disabled; + +#include "res://addons/zylann.hterrain/shaders/include/heightmap.gdshaderinc" + +uniform sampler2D u_src_texture; +uniform vec4 u_src_rect; +uniform float u_opacity = 1.0; +uniform float u_flatten_value; + +vec2 get_src_uv(vec2 screen_uv) { + vec2 uv = u_src_rect.xy + screen_uv * u_src_rect.zw; + return uv; +} + +void fragment() { + float brush_value = u_opacity * texture(TEXTURE, UV).r; + + float src_h = sample_heightmap(u_src_texture, get_src_uv(SCREEN_UV)); + float h = mix(src_h, u_flatten_value, brush_value); + COLOR = encode_height_to_viewport(h); +} -- cgit v1.2.3-56-ga3b1