diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2019-01-27 14:57:47 +0100 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2019-01-27 15:06:37 +0100 |
commit | b57a26a7112d19fdee27c99028092463e550119c (patch) | |
tree | 132863eab01c9f22727bc9057da4d1bf3eb4015d /cwd | |
parent | Basic animated textures support (diff) | |
download | AltCraft-b57a26a7112d19fdee27c99028092463e550119c.tar AltCraft-b57a26a7112d19fdee27c99028092463e550119c.tar.gz AltCraft-b57a26a7112d19fdee27c99028092463e550119c.tar.bz2 AltCraft-b57a26a7112d19fdee27c99028092463e550119c.tar.lz AltCraft-b57a26a7112d19fdee27c99028092463e550119c.tar.xz AltCraft-b57a26a7112d19fdee27c99028092463e550119c.tar.zst AltCraft-b57a26a7112d19fdee27c99028092463e550119c.zip |
Diffstat (limited to 'cwd')
-rw-r--r-- | cwd/assets/altcraft/shaders/face.json | 3 | ||||
-rw-r--r-- | cwd/assets/altcraft/shaders/vert/face.vs | 14 |
2 files changed, 13 insertions, 4 deletions
diff --git a/cwd/assets/altcraft/shaders/face.json b/cwd/assets/altcraft/shaders/face.json index 1454dcf..840e670 100644 --- a/cwd/assets/altcraft/shaders/face.json +++ b/cwd/assets/altcraft/shaders/face.json @@ -5,6 +5,7 @@ "projView", "textureAtlas", "DayTime", - "MinLightLevel" + "MinLightLevel", + "GlobalTime" ] }
\ No newline at end of file diff --git a/cwd/assets/altcraft/shaders/vert/face.vs b/cwd/assets/altcraft/shaders/vert/face.vs index 9c40846..044c012 100644 --- a/cwd/assets/altcraft/shaders/vert/face.vs +++ b/cwd/assets/altcraft/shaders/vert/face.vs @@ -1,4 +1,5 @@ #version 330 core + layout (location = 0) in vec3 position; layout (location = 2) in vec2 UvCoordinates; layout (location = 7) in vec4 Texture; @@ -6,6 +7,7 @@ layout (location = 8) in mat4 model; layout (location = 12) in vec3 color; layout (location = 13) in vec2 light; layout (location = 14) in float TextureLayer; +layout (location = 15) in float TextureFrames; out VS_OUT { vec2 UvPosition; @@ -14,8 +16,7 @@ out VS_OUT { vec2 Light; } vs_out; -//uniform mat4 view; -//uniform mat4 projection; +uniform float GlobalTime; uniform mat4 projView; vec3 TransformTextureCoord(vec4 TextureAtlasCoords, vec2 UvCoords, float Layer) { @@ -34,8 +35,15 @@ void main() vec4 sourcePosition = vec4(position,1.0f); gl_Position = projView * model * sourcePosition; + vec4 texturePos = Texture; + float frameHeight = texturePos.w / TextureFrames; + float currentFrame = mod(GlobalTime * 4.0f, TextureFrames); + currentFrame = trunc(currentFrame); + texturePos.w = frameHeight; + texturePos.y = texturePos.y + currentFrame * frameHeight; + vs_out.UvPosition = vec2(UvCoordinates.x,UvCoordinates.y); - vs_out.Texture = TransformTextureCoord(Texture,UvCoordinates,TextureLayer); + vs_out.Texture = TransformTextureCoord(texturePos,UvCoordinates,TextureLayer); vs_out.Color = color; vs_out.Light = light; } |