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
6 changes: 6 additions & 0 deletions LuaRules/Gadgets/Shaders/gfx_overdrive_cables.frag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ uniform float losViewEnabled; // 1.0 = LOS overlay is on (GetMapDrawMode=="los")

// Same SSBO as the GS — per-edge coverage bitmask, gates per-segment
// ghost rendering for enemy fragments.
#if !defined(SHADOW_PASS) && !defined(DEFERRED_PASS)
layout (std430, binding = 6) coherent buffer cableCoverageBuffer {
uvec4 cableCoverage[];
};
#endif

in DataGS {
vec3 worldPos;
Expand Down Expand Up @@ -350,6 +352,7 @@ void main() {
vec2 losUV0 = clamp(worldPos.xz, vec2(0.0), mapSize.xy) / mapSize.zw;
float los0 = texture(infoTex, losUV0).r;
if (los0 >= ENEMY_LOS_CUT) discard;
#if !defined(SHADOW_PASS) && !defined(DEFERRED_PASS)
uint cov0 = (gsSlot >= 0) ? cableCoverage[gsSlot].x : 0u;
// Per-segment ghost gating, mirroring the calc done lower in the FS
// for live fragments. spawnAlongMain carries lenPerSeg for main
Expand All @@ -363,6 +366,7 @@ void main() {
segBit0 = 0xFFFFFFu;
}
if ((cov0 & segBit0) == 0u) discard;
#endif

// Flat ghost shade: light gray, slight capacity-driven brightening,
// branches a touch dimmer. Alpha-blend over terrain (depth-write off
Expand Down Expand Up @@ -523,8 +527,10 @@ void main() {
if (enemyOutOfLOS) {
// Ghosts disabled: no SSBO read, no branch evaluation; just discard.
if (ghostsEnabled < 0.5) discard;
#if !defined(SHADOW_PASS) && !defined(DEFERRED_PASS)
uint cov = (gsSlot >= 0) ? cableCoverage[gsSlot].x : 0u;
if ((cov & segBit) == 0u) discard;
#endif
// Same flat translucent shading as the ghost-VBO fast path so
// live-out-of-LOS and orphaned ghosts read identically.
float capT2 = clamp(capacity / 100.0, 0.0, 1.0);
Expand Down
2 changes: 2 additions & 0 deletions LuaRules/Gadgets/Shaders/gfx_overdrive_cables.geom.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ uniform float ghostsEnabled; // 1.0 = run coverage SSBO updates, 0.0 = by
//
// Slots are declared as uvec4 because Spring's VBO API requires vec4-aligned
// attributes; we only use `.x` and ignore `.yzw`.
#if !defined(SHADOW_PASS) && !defined(DEFERRED_PASS)
layout (std430, binding = 6) coherent buffer cableCoverageBuffer {
uvec4 cableCoverage[];
};
#endif

in DataVS {
vec2 vsWorldXZ;
Expand Down