aboutsummaryrefslogtreecommitdiff
path: root/game/src/Game/Model/scrolling.gdshader
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2024-07-11 20:33:49 +0200
committer GitHub <noreply@github.com>2024-07-11 20:33:49 +0200
commit114394f4d1bcf5249089b6e3632d259a195ec584 (patch)
tree8e82ee10733a1f41cbf44063cd12d9bdc9bc7f63 /game/src/Game/Model/scrolling.gdshader
parentd1ff26c46dbba3e373f5c71f7ed093b5cd9ca6a0 (diff)
parent1496de8262b104ad7dd52b9f6e936fcd6ed1d384 (diff)
Merge pull request #237 from OpenVicProject/scrolling-textures
Scrolling model materials (tank tracks and smoke)
Diffstat (limited to 'game/src/Game/Model/scrolling.gdshader')
-rw-r--r--game/src/Game/Model/scrolling.gdshader19
1 files changed, 19 insertions, 0 deletions
diff --git a/game/src/Game/Model/scrolling.gdshader b/game/src/Game/Model/scrolling.gdshader
new file mode 100644
index 0000000..c90ee19
--- /dev/null
+++ b/game/src/Game/Model/scrolling.gdshader
@@ -0,0 +1,19 @@
+shader_type spatial;
+
+// depth_prepass_alpha is to ensure opaque scrolling textures
+// (e.g. tank tracks) are rendered correctly
+render_mode cull_disabled, depth_prepass_alpha;
+
+uniform sampler2D scroll_texture_diffuse[32] : source_color, filter_linear_mipmap, repeat_enable;
+uniform float scroll_factor[32];
+
+instance uniform uint scroll_tex_index_diffuse;
+instance uniform float scroll_speed;
+
+void fragment() {
+ vec2 uv_scrolled = UV;
+ uv_scrolled.y += TIME * scroll_speed * scroll_factor[scroll_tex_index_diffuse];
+
+ ALBEDO = texture(scroll_texture_diffuse[scroll_tex_index_diffuse], uv_scrolled).rgb;
+ ALPHA = texture(scroll_texture_diffuse[scroll_tex_index_diffuse], UV).a;
+}