Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualWaterlimon

Posted 27 January 2013 - 11:27 AM

1) You can update the texture itself. I believe minecraft did something like this. This has the possibly not wanted effect of animating all the tiles using that texture in the same way. And updating the texture isnt probably very cheap either.

2) In the shader add some offset to the texture if the tile is animated based on the amount of tile passed and amount of keyframes the tile animation has. So each vertex will have some isAnimated style property (0 to keyframecount) and when you render all the tiles you pass "Time" in. And then the shader adds to each texcoord something like floor(time%keyframecount) units. In the tile sheet you need to make animated tiles be next to each other in some specific direction (so its a line). For unanimated tiles just have isAnimated be 0 (isAnimated would be a per vertex vertex attribute)
You could also add another vertex attribute (or make isAnimated have 2 components) to set the animation speed of that specific tile

3)Update the texcoords using glBufferSubData each time you want the animation to change. I believe this is the most flexible, allowing each tile to animate in its own pace, but the cost might be higher than 2

edit:

#1Waterlimon

Posted 27 January 2013 - 11:23 AM

1) You can update the texture itself. I believe minecraft did something like this. This has the possibly not wanted effect of animating all the tiles using that texture in the same way. And updating the texture isnt probably very cheap either.

 

2) In the shader add some offset to the texture if the tile is animated. So each vertex will have some isAnimated style propertty (0 - keyframecount) and when you render all the tiles you pass "Time" in. And then the shader adds to each texcoord something like time%keyframecount units. In the tile sheet you need to make animated tiles be next to each other in some specific direction (so its a line)

 

3)Update the texcoords using glBufferSubData each time you want the animation to change. I believe this is the most flexible, allowing each tile to animate in its own pace, but the cost might be higher than 2


PARTNERS