Main repository of MikuMikuStudio
リビジョン | 6df71aae069fc6075e8eb78f97f7309f0de711a0 (tree) |
---|---|
日時 | 2013-06-13 04:11:21 |
作者 | remy.bouquet@gmail.com <remy.bouquet@gmai...> |
コミッター | remy.bouquet@gmail.com |
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: http://jmonkeyengine.googlecode.com/svn/trunk@10648 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
@@ -71,7 +71,13 @@ public class SpotLight extends Light implements Savable { | ||
71 | 71 | float innerCos=FastMath.cos(spotInnerAngle); |
72 | 72 | float outerCos=FastMath.cos(spotOuterAngle); |
73 | 73 | packedAngleCos=(int)(innerCos*1000); |
74 | + //due to approximations, very close angles can give the same cos | |
75 | + //here we make sure outer cos is bellow inner cos. | |
76 | + if(((int)packedAngleCos)== ((int)(outerCos*1000)) ){ | |
77 | + outerCos -= 0.001f; | |
78 | + } | |
74 | 79 | packedAngleCos+=outerCos; |
80 | + System.out.println("anfle"+ packedAngleCos); | |
75 | 81 | } |
76 | 82 | |
77 | 83 | @Override |