Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/renderer/webgl/shaders/TilemapGPULayer-frag.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ module.exports = [
'{',
' vec2 layerTexCoord = outTexCoord;',
' Tile tile = getLayerData(layerTexCoord);',
' if (tile.empty)',
' {',
' discard;',
' }',
' Samples samples = getFinalSamples(tile, layerTexCoord);',
' vec4 fragColor = samples.color;',
' #pragma phaserTemplate(declareSamples)',
Expand Down
9 changes: 9 additions & 0 deletions src/renderer/webgl/shaders/src/TilemapGPULayer.frag
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,15 @@ void main ()
vec2 layerTexCoord = outTexCoord;
Tile tile = getLayerData(layerTexCoord);

// Empty cells must not draw anything. Without this, empty tiles sample the
// tileset at (0, 0) - the top-left texel of tile 0 - which is opaque for
// most tilesets, painting tile 0 over everything drawn beneath the layer
// (and causing stacked GPU layers to hide one another).
if (tile.empty)
{
discard;
}

Samples samples = getFinalSamples(tile, layerTexCoord);

vec4 fragColor = samples.color;
Expand Down