diff options
author | Hop311 <Hop3114@gmail.com> | 2024-05-12 17:17:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-12 17:17:32 +0200 |
commit | bfccdb87d66304604ad018037db1581746646bfa (patch) | |
tree | ac4394e8ceaca22fa0deaeebd8cf5eafedecaa3e /game/src/Game/Model/flag.gdshader | |
parent | b0a533f945bbc6201fd7df4bc60746cb98efaba4 (diff) | |
parent | ac29e4040fc20c50c8f0eb64b1194f6398165eb0 (diff) |
Merge pull request #227 from OpenVicProject/models
Models
Diffstat (limited to 'game/src/Game/Model/flag.gdshader')
-rw-r--r-- | game/src/Game/Model/flag.gdshader | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/game/src/Game/Model/flag.gdshader b/game/src/Game/Model/flag.gdshader new file mode 100644 index 0000000..d338e36 --- /dev/null +++ b/game/src/Game/Model/flag.gdshader @@ -0,0 +1,26 @@ +shader_type spatial; + +render_mode cull_disabled; + +// Both vanilla flags use the same normal texture +uniform uvec2 flag_dims; +uniform sampler2D texture_flag_sheet_diffuse : source_color; +uniform sampler2D texture_normal : hint_normal; + +instance uniform uint flag_index; + +uniform vec2 scroll_speed = vec2(-0.25,0); + +// Scroll the Normal map, but leave the albedo alone +void fragment() { + uvec2 flag_sheet_dims = uvec2(textureSize(texture_flag_sheet_diffuse, 0)); + uint scaled_index = flag_index * flag_dims.x; + + uvec2 flag_pos = uvec2(scaled_index % flag_sheet_dims.x, scaled_index / flag_sheet_dims.x * flag_dims.y); + + vec2 flag_uv = (vec2(flag_pos) + UV * vec2(flag_dims)) / vec2(flag_sheet_dims); + + ALBEDO = texture(texture_flag_sheet_diffuse, flag_uv).rgb; + //ALBEDO = vec3(1, 0, 0); + NORMAL_MAP = texture(texture_normal, UV + TIME*scroll_speed).rgb; +} |