From b57a26a7112d19fdee27c99028092463e550119c Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Sun, 27 Jan 2019 18:57:47 +0500 Subject: More advanced textures animation support --- cwd/assets/altcraft/shaders/vert/face.vs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'cwd/assets/altcraft/shaders/vert') 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; } -- cgit v1.2.3