Compare commits

..

2 Commits

Author SHA1 Message Date
b960fb689a AO hinzugefügt 2026-07-21 13:51:46 +02:00
b38937cdea Bug Fixes 2026-07-21 12:39:31 +02:00
5 changed files with 63 additions and 9 deletions

View File

@@ -23,6 +23,7 @@ import org.lwjgl.glfw.GLFW;
import org.lwjgl.glfw.GLFWVidMode; import org.lwjgl.glfw.GLFWVidMode;
import org.lwjgl.system.MemoryStack; import org.lwjgl.system.MemoryStack;
import com.jme3.system.lwjgl.LwjglWindow; import com.jme3.system.lwjgl.LwjglWindow;
import de.blight.game.state.DrownState;
import de.blight.game.state.HotbarState; import de.blight.game.state.HotbarState;
import de.blight.game.state.HudState; import de.blight.game.state.HudState;
import de.blight.game.state.LoadingScreenState; import de.blight.game.state.LoadingScreenState;
@@ -63,6 +64,7 @@ public class BlightGame extends SimpleApplication {
private long pendingFullscreenFixAt = Long.MAX_VALUE; private long pendingFullscreenFixAt = Long.MAX_VALUE;
private boolean firstLaunch = true; // false nach dem ersten simpleInitApp() private boolean firstLaunch = true; // false nach dem ersten simpleInitApp()
private boolean initialFixDone = false; // Initial-Fix bei 0.5s bereits gelaufen private boolean initialFixDone = false; // Initial-Fix bei 0.5s bereits gelaufen
private boolean pendingMenuRebuild = false; // nur true nach explizitem app.restart()
private JWindow splashWindow; private JWindow splashWindow;
@@ -427,6 +429,12 @@ public class BlightGame extends SimpleApplication {
pendingFullscreenFixAt = System.currentTimeMillis() + 1000; pendingFullscreenFixAt = System.currentTimeMillis() + 1000;
} }
/** Wird von GraphicsScreen vor app.restart() aufgerufen erlaubt beim nächsten
* reshape() die Menü-States neu aufzubauen. Darf NICHT beim Startup-Fix feuern. */
public void scheduleMenuRebuild() {
pendingMenuRebuild = true;
}
// ── Render-Loop ────────────────────────────────────────────────────────── // ── Render-Loop ──────────────────────────────────────────────────────────
@Override @Override
@@ -479,6 +487,16 @@ public class BlightGame extends SimpleApplication {
rebuildState(HudState.class); rebuildState(HudState.class);
rebuildState(HotbarState.class); rebuildState(HotbarState.class);
rebuildState(LoadingScreenState.class); rebuildState(LoadingScreenState.class);
if (pendingMenuRebuild) {
pendingMenuRebuild = false;
rebuildEnabled(mainMenuState);
rebuildEnabled(pauseMenu);
rebuildEnabled(configScreen);
rebuildEnabled(audioScreen);
rebuildEnabled(graphicsScreen);
}
DrownState drown = stateManager.getState(DrownState.class);
if (drown != null) drown.rebuild();
JmeConsole console = stateManager.getState(JmeConsole.class); JmeConsole console = stateManager.getState(JmeConsole.class);
if (console != null) console.rebuild(); if (console != null) console.rebuild();
} }
@@ -491,6 +509,13 @@ public class BlightGame extends SimpleApplication {
} }
} }
private void rebuildEnabled(com.jme3.app.state.BaseAppState state) {
if (state != null && state.isEnabled()) {
state.setEnabled(false);
state.setEnabled(true);
}
}
// ── Konsolen-Befehle ───────────────────────────────────────────────────── // ── Konsolen-Befehle ─────────────────────────────────────────────────────
private void registerGameCommands(JmeConsole console) { private void registerGameCommands(JmeConsole console) {

View File

@@ -219,6 +219,7 @@ public class GraphicsScreen extends MenuScreen {
s.setVSync(live.vsync); s.setVSync(live.vsync);
s.setSamples(live.samples); s.setSamples(live.samples);
app.setSettings(s); app.setSettings(s);
((BlightGame) getApplication()).scheduleMenuRebuild();
if (live.fullscreen) { if (live.fullscreen) {
((BlightGame) getApplication()).scheduleFullscreenFix(); ((BlightGame) getApplication()).scheduleFullscreenFix();
} }

View File

@@ -17,10 +17,10 @@ public class GraphicsSettings {
* lambda/zExtend/zFade/backface können zur Laufzeit angepasst werden. * lambda/zExtend/zFade/backface können zur Laufzeit angepasst werden.
*/ */
public enum ShadowQuality { public enum ShadowQuality {
// mapSize splits lambda zExtend zFade backface // mapSize splits lambda zExtend zFade backface ssaoR ssaoI
LOW ( 1024, 2, 0.70f, 40f, 5f, false), LOW ( 1024, 2, 0.70f, 40f, 5f, false, 0f, 0f ),
MEDIUM ( 2048, 3, 0.75f, 60f, 8f, true ), MEDIUM ( 2048, 3, 0.75f, 60f, 8f, true, 1.0f, 1.5f),
HIGH ( 4096, 4, 0.80f, 80f, 10f, true ); HIGH ( 4096, 4, 0.80f, 80f, 10f, true, 1.5f, 2.5f);
public final int shadowMapSize; public final int shadowMapSize;
public final int splits; public final int splits;
@@ -28,15 +28,20 @@ public class GraphicsSettings {
public final float zExtend; public final float zExtend;
public final float zFade; public final float zFade;
public final boolean backface; public final boolean backface;
public final float ssaoRadius;
public final float ssaoIntensity;
ShadowQuality(int shadowMapSize, int splits, float lambda, ShadowQuality(int shadowMapSize, int splits, float lambda,
float zExtend, float zFade, boolean backface) { float zExtend, float zFade, boolean backface,
float ssaoRadius, float ssaoIntensity) {
this.shadowMapSize = shadowMapSize; this.shadowMapSize = shadowMapSize;
this.splits = splits; this.splits = splits;
this.lambda = lambda; this.lambda = lambda;
this.zExtend = zExtend; this.zExtend = zExtend;
this.zFade = zFade; this.zFade = zFade;
this.backface = backface; this.backface = backface;
this.ssaoRadius = ssaoRadius;
this.ssaoIntensity = ssaoIntensity;
} }
} }

View File

@@ -736,6 +736,16 @@ public class WorldScene extends BaseAppState {
// Schatten als Filter vermeidet das Setzen von ShadowMap-Texturen in Scene-Materialien // Schatten als Filter vermeidet das Setzen von ShadowMap-Texturen in Scene-Materialien
fpp.addFilter(shadowFilter); fpp.addFilter(shadowFilter);
// SSAO Stärke und Radius abhängig von Schattenqualität (LOW = kein SSAO)
if (graphicsSettings.shadowQuality.ssaoRadius > 0f) {
com.jme3.post.ssao.SSAOFilter ssao = new com.jme3.post.ssao.SSAOFilter(
graphicsSettings.shadowQuality.ssaoRadius,
graphicsSettings.shadowQuality.ssaoIntensity,
0.2f, 0.05f);
ssao.setApproximateNormals(true);
fpp.addFilter(ssao);
}
// Globales Wasser bei Y=0 (bedeckt die gesamte Karte unterhalb der Wasserlinie) // Globales Wasser bei Y=0 (bedeckt die gesamte Karte unterhalb der Wasserlinie)
try { try {
DynamicWaterFilter waterFilter = new DynamicWaterFilter(rootNode, sunDir); DynamicWaterFilter waterFilter = new DynamicWaterFilter(rootNode, sunDir);

View File

@@ -79,13 +79,26 @@ public class DrownState extends BaseAppState {
@Override @Override
protected void initialize(Application application) { protected void initialize(Application application) {
app = (SimpleApplication) application; app = (SimpleApplication) application;
float w = app.getCamera().getWidth();
float h = app.getCamera().getHeight();
overlay = new Geometry("drown_overlay", new Quad(w, h));
overlayMat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); overlayMat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
overlayMat.setColor("Color", new ColorRGBA(0f, 0f, 0f, 0f)); overlayMat.setColor("Color", new ColorRGBA(0f, 0f, 0f, 0f));
overlayMat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha); overlayMat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
buildOverlay();
}
/** Neu aufrufen wenn sich die Auflösung ändert. */
public void rebuild() {
if (app == null) return;
boolean wasAttached = overlay != null && overlay.getParent() != null;
detachOverlay();
buildOverlay();
if (wasAttached) attachOverlay();
}
private void buildOverlay() {
float w = app.getCamera().getWidth();
float h = app.getCamera().getHeight();
overlay = new Geometry("drown_overlay", new Quad(w, h));
overlay.setMaterial(overlayMat); overlay.setMaterial(overlayMat);
overlay.setQueueBucket(RenderQueue.Bucket.Gui); overlay.setQueueBucket(RenderQueue.Bucket.Gui);
overlay.setLocalTranslation(0f, 0f, 50f); overlay.setLocalTranslation(0f, 0f, 50f);