Skip to content

Restore Lighting.j3md fog in SinglePass by fixing SPLighting varying linkage#2771

Merged
riccardobl merged 2 commits into
masterfrom
copilot/fix-fog-effect-in-alpha4
May 12, 2026
Merged

Restore Lighting.j3md fog in SinglePass by fixing SPLighting varying linkage#2771
riccardobl merged 2 commits into
masterfrom
copilot/fix-fog-effect-in-alpha4

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 12, 2026

Lighting.j3md fog parameters (UseFog, LinearFog/ExpFog/ExpSqFog) were no longer taking effect in 3.10.0-alpha4 on the SinglePass path. The fog distance computed in SPLighting.vert was not reaching MaterialFog.glsllib due to a varying name mismatch.

  • Root cause

    • SPLighting.vert exported fog distance as fog_distance, while fog consumers (MaterialFog.glsllib + fragment shaders) read fogDistance.
  • Change

    • Updated Common/MatDefs/Light/SPLighting.vert to use fogDistance consistently for declaration and assignment.
  • Impact

    • Reconnects vertex-to-fragment fog distance flow in SinglePass lighting, restoring effective fog blending for Lighting.j3md.
// SPLighting.vert
#ifdef USE_FOG
-varying float fog_distance;
+varying float fogDistance;
#endif

#ifdef USE_FOG
-    fog_distance = distance(g_CameraPosition, (TransformWorld(modelSpacePos)).xyz);
+    fogDistance = distance(g_CameraPosition, (TransformWorld(modelSpacePos)).xyz);
#endif

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED -XX:MaxMetaspaceSize=384m -XX:+HeapDumpOnOutOfMemoryError -Xms256m -Xmx512m -Dfile.encoding=UTF-8 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Fix fog effect not working in 3.10.0-alpha4 Restore Lighting.j3md fog in SinglePass by fixing SPLighting varying linkage May 12, 2026
Copilot AI requested a review from riccardobl May 12, 2026 11:43
@riccardobl riccardobl marked this pull request as ready for review May 12, 2026 11:45
@riccardobl riccardobl merged commit e77e5e5 into master May 12, 2026
14 checks passed
@stephengold stephengold deleted the copilot/fix-fog-effect-in-alpha4 branch May 12, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lighting.j3md fog not effective in 3.10.0-alpha4

2 participants