From 130ddbdfd2e873fe3fa43cbdc24cbc4542f886f8 Mon Sep 17 00:00:00 2001 From: "rem..om" Date: Wed, 12 Jun 2013 19:11:21 +0000 Subject: [PATCH] SpotLigth: the cosine of the inner and outer angle of a spotlight are packed in the same float to send it to the shader (to save some varryings). This imples that their precision is no more than 0.001. This was producing wrong lighting for very close angles because the cosine were equals. There is now a check that ensure that the outer cos is lower than the inner cos. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10648 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- engine/src/core/com/jme3/light/SpotLight.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/engine/src/core/com/jme3/light/SpotLight.java b/engine/src/core/com/jme3/light/SpotLight.java index d1dbf8a8e..04e6ca7d4 100644 --- a/engine/src/core/com/jme3/light/SpotLight.java +++ b/engine/src/core/com/jme3/light/SpotLight.java @@ -71,7 +71,13 @@ public class SpotLight extends Light implements Savable { float innerCos=FastMath.cos(spotInnerAngle); float outerCos=FastMath.cos(spotOuterAngle); packedAngleCos=(int)(innerCos*1000); + //due to approximations, very close angles can give the same cos + //here we make sure outer cos is bellow inner cos. + if(((int)packedAngleCos)== ((int)(outerCos*1000)) ){ + outerCos -= 0.001f; + } packedAngleCos+=outerCos; + System.out.println("anfle"+ packedAngleCos); } @Override