Skip to content

Commit

Permalink
Fixing the animated wall shader on macs
Browse files Browse the repository at this point in the history
  • Loading branch information
Interrupt committed Nov 21, 2018
1 parent c97ab36 commit 0e3f8f0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Dungeoneer/assets/shaders/animate.vert
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void main() {
v_color = a_color + u_AmbientColor;

// Flip through the atlas on this row
v_texCoords.x += float(int(u_time * c_animateSpeed) % u_sprite_columns) * u_tex_width;
v_texCoords.x += mod(floor(u_time * c_animateSpeed), float(u_sprite_columns)) * u_tex_width;

if(u_UsedLights != 0) {
for(int i=0; i < {{MAX_DYNAMIC_LIGHTS}}; i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public void render() {
return;

ShaderInfo lastShader = null;
TextureAtlas lastAtlas = null;

for(int i = 0; i < tesselators.size; i++) {
// Bind the atlas for drawing
Expand All @@ -61,7 +62,7 @@ public void render() {
if(shader == null)
shader = defaultShader;

if(shader != lastShader) {
if(shader != lastShader || atlas != lastAtlas) {
// End the last shader before starting the new one
if(lastShader != null)
lastShader.end();
Expand All @@ -71,7 +72,7 @@ public void render() {
// Set some shader properties based on the atlas
Texture tex = atlas.texture;
if(tex != null) {
shader.setAttribute("u_tex_width", (1f / tex.getWidth()) * atlas.getTotalRegions());
shader.setAttribute("u_tex_width", (float)atlas.spriteSize / tex.getWidth());
shader.setAttribute("u_tex_height", 1f / tex.getHeight());
}

Expand All @@ -81,6 +82,7 @@ public void render() {

tesselators.getValueAt(i).renderMesh(shader);
lastShader = shader;
lastAtlas = atlas;
}

// Finish any shaders before continuing
Expand Down

0 comments on commit 0e3f8f0

Please sign in to comment.