From 1496de8262b104ad7dd52b9f6e936fcd6ed1d384 Mon Sep 17 00:00:00 2001 From: hop311 Date: Mon, 8 Jul 2024 22:34:57 +0100 Subject: Scrolling model materials (tank tracks and smoke) --- game/src/Game/Model/scrolling.gdshader | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 game/src/Game/Model/scrolling.gdshader (limited to 'game/src/Game/Model/scrolling.gdshader') 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; +} -- cgit v1.2.3-56-ga3b1