Skip to content
Merged
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
38 changes: 24 additions & 14 deletions src/main/java/rs117/hd/renderer/zone/ZoneRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -978,20 +978,30 @@ public void drawZoneAlpha(Projection entityProjection, Scene scene, int level, i
}

if (!sceneManager.isRoot(ctx) || z.inSceneFrustum) {
// Write color without depth writes
sceneCmd.DepthMask(false);
sceneCmd.ColorMask(true, true, true, true);

z.renderAlpha(sceneCmd, zx - offset, zz - offset, level, ctx, false, false);

// Write depth without color
sceneCmd.DepthMask(true);
sceneCmd.ColorMask(false, false, false, false);

z.renderAlpha(sceneCmd, zx - offset, zz - offset, level, ctx, true, false);

// Restore color writes
sceneCmd.ColorMask(true, true, true, true);
if (renderWater) {
// Water is currently drawn with depth writes & depth testing enabled, and as such, alpha models and the water plane
// can Z-fight depending on draw order. To avoid alpha models above water causing the water surface to fail its
// depth test, we disable depth writes for alpha models and rely on correct back to front ordering of the zones
sceneCmd.DepthMask(false);
z.renderAlpha(sceneCmd, zx - offset, zz - offset, level, ctx, false, false);
sceneCmd.DepthMask(true);
} else {
// Draw alpha models in two passes, first blending colors correctly, then writing depth for subsequent opaque models
// to test against. This is necessary because opaque models on higher planes can be drawn later

// Write color without depth writes
sceneCmd.DepthMask(false);
sceneCmd.ColorMask(true, true, true, true);
z.renderAlpha(sceneCmd, zx - offset, zz - offset, level, ctx, false, false);

// Write depth without color
sceneCmd.DepthMask(true);
sceneCmd.ColorMask(false, false, false, false);
z.renderAlpha(sceneCmd, zx - offset, zz - offset, level, ctx, true, false);

// Restore color writes
sceneCmd.ColorMask(true, true, true, true);
}
}
}
frameTimer.end(Timer.DRAW_ZONE_ALPHA);
Expand Down