diff options
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; } |