Translucent entities render in opaque pass instead of transparent pass #46
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Entities with translucent materials (refract, translucent props, etc.) render during the opaque pass (layer 0) instead of the transparent pass (layer 2). This means only the skybox is visible through them — opaque entities and BSP geometry behind them are not composited correctly.
Visible in
shader_test_01ground truth vs our render — the bottom two rows of cubes should show the caution tape and wall through them, but instead appear opaque or show only skybox.Root cause
The layer 2 assignment in
_loadMaterialTexture(loader.js) only applies to BSP world meshes. For entities,_applyEntityTransparency(scene.js) only checks entity color alpha — it doesn't account for materials that are inherently transparent (via$translucent,$alphatest, refract shader, etc.).When an entity's model has a transparent material but entity color alpha is 1.0, the mesh stays on layer 0 and renders during the opaque pass.
Fix
After entity materials are resolved (model loading + material overrides), check if any mesh material has
transparent = trueand assign those meshes to layer 2 regardless of entity color alpha. This needs to happen in:_replaceWithModel(scene.js) — when a model template replaces a placeholder_refreshMaterialOverrides(scene.js) — when materials are swapped at runtimeRelated