Help needed - Unexpected scary rendering issue
Posted: Mon Apr 25, 2022 10:56 am
Hi there, I am currently struggling with an issue that I fear will make my game unreleasable.
I am rendering a 2d grid-based world map with 3 different layers (each layer is a spritebatch). Sometimes when running the game 2 of the layers render in a very weird way: some of the tiles either flash (either to 0 opacity, or to white), or they seem to stretch from their actual tile coordinates to some (seemingly) random coordinates near the top of the grid, or both. Only some of the tiles do this, not the whole batch. I have encountered the issue multiple times, nothing I've changed has stopped it. What makes it more difficult and weird is that the issue only occurs occasionally, most times I run the game it all works as normal.
Relevant Details:
- There are 3 rendering layers rendered in this order: base map (grass etc), border lines, towns.
- The issue only ever affects layers 2 and 3 (border lines and towns).
- Each layer is contained within its own spritebatch (so as to store a large number of different tiles).
- The border line spritebatch has different colours applied to its various tiles, and also the blend mode is changed to 'add' when actually rendering the layer. The other two layers have no colours or blend modes applied to them.
- There are two texture atlases (1 for base map and the second for border lines and towns).
- The game uses the 'Push' library to double the resolution.
- The game uses a simple camera logic to translate the screen when holding mouse right.
- The issue only occurs sometimes, perhaps 1 in 10 or even 1 in 20 playthroughs.
- I am unable to decipher what the conditions that cause it are.
- The tiles that are affected by the issue vary and are not the same every time.
- When it occurs, most of the tiles remain perfectly normal - but a significant number have this behaviour which completely ruins the game.
Thoughts on issue:
- I have encountered the same issue before with using spritebatches (and I also did not discover the solution to it back then!)
- Could it be to do with the camera / or push?
- Or is there a known issue with spritebatch rendering in love 2d? I cannot seem to find anything on google.
- I believe that my limited knowledge on the underlying rendering processes is hindering me here...
Code extract to follow
Any help greatly appreciated.
Sisyphu2
I am rendering a 2d grid-based world map with 3 different layers (each layer is a spritebatch). Sometimes when running the game 2 of the layers render in a very weird way: some of the tiles either flash (either to 0 opacity, or to white), or they seem to stretch from their actual tile coordinates to some (seemingly) random coordinates near the top of the grid, or both. Only some of the tiles do this, not the whole batch. I have encountered the issue multiple times, nothing I've changed has stopped it. What makes it more difficult and weird is that the issue only occurs occasionally, most times I run the game it all works as normal.
Relevant Details:
- There are 3 rendering layers rendered in this order: base map (grass etc), border lines, towns.
- The issue only ever affects layers 2 and 3 (border lines and towns).
- Each layer is contained within its own spritebatch (so as to store a large number of different tiles).
- The border line spritebatch has different colours applied to its various tiles, and also the blend mode is changed to 'add' when actually rendering the layer. The other two layers have no colours or blend modes applied to them.
- There are two texture atlases (1 for base map and the second for border lines and towns).
- The game uses the 'Push' library to double the resolution.
- The game uses a simple camera logic to translate the screen when holding mouse right.
- The issue only occurs sometimes, perhaps 1 in 10 or even 1 in 20 playthroughs.
- I am unable to decipher what the conditions that cause it are.
- The tiles that are affected by the issue vary and are not the same every time.
- When it occurs, most of the tiles remain perfectly normal - but a significant number have this behaviour which completely ruins the game.
Thoughts on issue:
- I have encountered the same issue before with using spritebatches (and I also did not discover the solution to it back then!)
- Could it be to do with the camera / or push?
- Or is there a known issue with spritebatch rendering in love 2d? I cannot seem to find anything on google.
- I believe that my limited knowledge on the underlying rendering processes is hindering me here...
Code extract to follow
Any help greatly appreciated.
Sisyphu2