StarArawn / bevy_tiled

A plugin for rendering tiled maps.
MIT License
155 stars 40 forks source link

Z Blending with other pipelines #7

Open wmiller848 opened 4 years ago

wmiller848 commented 4 years ago

I noticed an issue when adding a bevy sprite sheet. There is something odd occurring where the frame buffer is not blending the components of different passes.

In the screen shot you'll notice that the two layers in the tile map are blended correctly but the sprite is ignored.

I've tried changing bevy upstream to use depth_compare: CompareFunction::LessEqual but that didn't seem to have any effect. It looks like the frame buffer is being overridden on the tile map draw pass.

https://github.com/StarArawn/bevy_tiled/compare/master...wmiller848:sprite_blend_issue

depth_issue
wmiller848 commented 4 years ago

So this is an artifact of position.z = layer_id; in the shader. If you apply the z offset via a translation when building the chunk it fixes the issue.

StarArawn commented 4 years ago

Yeah that sounds like the correct approach to take. Ideally we should have a transform per layer. I think whenever I get around to it I can refactor the entities/components to look something like this: World Entity > Layer Entity > Chunk Entity. Chunk entities should have their own transform probably too.