From 7314c5f61319017f960e6de819fbfdce46c6bdf9 Mon Sep 17 00:00:00 2001 From: "sha..rd" Date: Fri, 1 Jul 2011 17:01:00 +0000 Subject: [PATCH] * Fix lighting "early cull" issue for terrain lighting shader as well git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7794 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- engine/src/core-data/Common/MatDefs/Light/Lighting.vert | 3 +++ .../src/lwjgl-ogl/com/jme3/system/lwjgl/LwjglDisplay.java | 6 ++++++ .../src/terrain/Common/MatDefs/Terrain/TerrainLighting.frag | 3 +++ 3 files changed, 12 insertions(+) diff --git a/engine/src/core-data/Common/MatDefs/Light/Lighting.vert b/engine/src/core-data/Common/MatDefs/Light/Lighting.vert index a74fe9438..03996c022 100644 --- a/engine/src/core-data/Common/MatDefs/Light/Lighting.vert +++ b/engine/src/core-data/Common/MatDefs/Light/Lighting.vert @@ -99,6 +99,9 @@ void lightComputeDir(in vec3 worldPos, in vec4 color, in vec4 position, out vec4 } float lightComputeSpecular(in vec3 norm, in vec3 viewdir, in vec3 lightdir, in float shiny){ + if (shiny <= 1.0){ + return 0.0; + } #ifndef LOW_QUALITY vec3 H = (viewdir + lightdir) * vec3(0.5); return pow(max(dot(H, norm), 0.0), shiny); diff --git a/engine/src/lwjgl-ogl/com/jme3/system/lwjgl/LwjglDisplay.java b/engine/src/lwjgl-ogl/com/jme3/system/lwjgl/LwjglDisplay.java index bd38bd2e1..31bd7b39b 100644 --- a/engine/src/lwjgl-ogl/com/jme3/system/lwjgl/LwjglDisplay.java +++ b/engine/src/lwjgl-ogl/com/jme3/system/lwjgl/LwjglDisplay.java @@ -125,6 +125,12 @@ public class LwjglDisplay extends LwjglAbstractDisplay { } Display.setVSyncEnabled(settings.isVSync()); + + if (created.get()){ + Display.releaseContext(); + Display.makeCurrent(); + Display.update(); + } if (!created.get() || pixelFormatChanged){ ContextAttribs attr = createContextAttribs(); diff --git a/engine/src/terrain/Common/MatDefs/Terrain/TerrainLighting.frag b/engine/src/terrain/Common/MatDefs/Terrain/TerrainLighting.frag index 3233c3158..c06cca739 100644 --- a/engine/src/terrain/Common/MatDefs/Terrain/TerrainLighting.frag +++ b/engine/src/terrain/Common/MatDefs/Terrain/TerrainLighting.frag @@ -161,6 +161,9 @@ float lightComputeDiffuse(in vec3 norm, in vec3 lightdir, in vec3 viewdir){ } float lightComputeSpecular(in vec3 norm, in vec3 viewdir, in vec3 lightdir, in float shiny){ + if (shiny <= 1.0){ + return 0.0; + } #ifdef WARDISO // Isotropic Ward vec3 halfVec = normalize(viewdir + lightdir);