aboutsummaryrefslogtreecommitdiff
path: root/game/addons/zylann.hterrain/tools/minimap/minimap_normal.gdshader
diff options
context:
space:
mode:
author Gone2Daly <71726742+Gone2Daly@users.noreply.github.com>2023-07-22 21:05:42 +0200
committer Gone2Daly <71726742+Gone2Daly@users.noreply.github.com>2023-07-22 21:05:42 +0200
commit71b3cd829f80de4c2cd3972d8bfd5ee470a5d180 (patch)
treeb4280fde6eef2ae6987648bc7bf8e00e9011bb7f /game/addons/zylann.hterrain/tools/minimap/minimap_normal.gdshader
parentce9022d0df74d6c33db3686622be2050d873ab0b (diff)
init_testtest3d
Diffstat (limited to 'game/addons/zylann.hterrain/tools/minimap/minimap_normal.gdshader')
-rw-r--r--game/addons/zylann.hterrain/tools/minimap/minimap_normal.gdshader24
1 files changed, 24 insertions, 0 deletions
diff --git a/game/addons/zylann.hterrain/tools/minimap/minimap_normal.gdshader b/game/addons/zylann.hterrain/tools/minimap/minimap_normal.gdshader
new file mode 100644
index 0000000..0ea3120
--- /dev/null
+++ b/game/addons/zylann.hterrain/tools/minimap/minimap_normal.gdshader
@@ -0,0 +1,24 @@
+shader_type canvas_item;
+
+uniform sampler2D u_normalmap;
+uniform sampler2D u_globalmap;
+uniform vec3 u_light_direction = vec3(0.5, -0.7, 0.2);
+
+vec3 unpack_normal(vec4 rgba) {
+ return rgba.xzy * 2.0 - vec3(1.0);
+}
+
+void fragment() {
+ vec3 albedo = texture(u_globalmap, UV).rgb;
+ // Undo sRGB
+ // TODO I don't know what is correct tbh, this didn't work well
+ //albedo *= pow(albedo, vec3(0.4545));
+ //albedo *= pow(albedo, vec3(1.0 / 0.4545));
+ albedo = sqrt(albedo);
+
+ vec3 normal = unpack_normal(texture(u_normalmap, UV));
+ float g = max(-dot(u_light_direction, normal), 0.0);
+
+ COLOR = vec4(albedo * g, 1.0);
+}
+