Remove scale from updateFrustumPoints since its always 1.0

in-pass-shadows
Kirill Vainer 8 years ago
parent f5ad0274b3
commit 55e9fd067a
  1. 1
      jme3-core/src/main/java/com/jme3/shadow/BasicShadowRenderer.java
  2. 4
      jme3-core/src/main/java/com/jme3/shadow/DirectionalLightShadowRenderer.java
  3. 4
      jme3-core/src/main/java/com/jme3/shadow/PssmShadowRenderer.java
  4. 17
      jme3-core/src/main/java/com/jme3/shadow/ShadowUtil.java
  5. 2
      jme3-core/src/main/java/com/jme3/shadow/SpotLightShadowRenderer.java

@ -158,7 +158,6 @@ public class BasicShadowRenderer implements SceneProcessor {
ShadowUtil.updateFrustumPoints(viewCam,
viewCam.getFrustumNear(),
viewCam.getFrustumFar(),
1.0f,
points);
Vector3f frustaCenter = new Vector3f();

@ -148,7 +148,7 @@ public class DirectionalLightShadowRenderer extends AbstractShadowRenderer {
//We prevent computing the frustum points and splits with zeroed or negative near clip value
float frustumNear = Math.max(viewCam.getFrustumNear(), 0.001f);
ShadowUtil.updateFrustumPoints(viewCam, frustumNear, zFar, 1.0f, points);
ShadowUtil.updateFrustumPoints(viewCam, frustumNear, zFar, points);
shadowCam.setFrustumFar(zFar);
shadowCam.getRotation().lookAt(light.getDirection(), shadowCam.getUp());
@ -183,7 +183,7 @@ public class DirectionalLightShadowRenderer extends AbstractShadowRenderer {
protected GeometryList getOccludersToRender(int shadowMapIndex, GeometryList shadowMapOccluders) {
// update frustum points based on current camera and split
ShadowUtil.updateFrustumPoints(viewPort.getCamera(), splitsArray[shadowMapIndex], splitsArray[shadowMapIndex + 1], 1.0f, points);
ShadowUtil.updateFrustumPoints(viewPort.getCamera(), splitsArray[shadowMapIndex], splitsArray[shadowMapIndex + 1], points);
//Updating shadow cam with curent split frustra
if (lightReceivers.size()==0) {

@ -398,7 +398,7 @@ public class PssmShadowRenderer implements SceneProcessor {
//We prevent computing the frustum points and splits with zeroed or negative near clip value
float frustumNear = Math.max(viewCam.getFrustumNear(), 0.001f);
ShadowUtil.updateFrustumPoints(viewCam, frustumNear, zFar, 1.0f, points);
ShadowUtil.updateFrustumPoints(viewCam, frustumNear, zFar, points);
//shadowCam.setDirection(direction);
shadowCam.getRotation().lookAt(direction, shadowCam.getUp());
@ -428,7 +428,7 @@ public class PssmShadowRenderer implements SceneProcessor {
for (int i = 0; i < nbSplits; i++) {
// update frustum points based on current camera and split
ShadowUtil.updateFrustumPoints(viewCam, splitsArray[i], splitsArray[i + 1], 1.0f, points);
ShadowUtil.updateFrustumPoints(viewCam, splitsArray[i], splitsArray[i + 1], points);
//Updating shadow cam with curent split frustra
ShadowUtil.updateShadowCamera(viewPort, lightReceivers, shadowCam, points, splitOccluders, shadowMapSize);

@ -96,7 +96,6 @@ public class ShadowUtil {
public static void updateFrustumPoints(Camera viewCam,
float nearOverride,
float farOverride,
float scale,
Vector3f[] points) {
Vector3f pos = viewCam.getLocation();
@ -149,22 +148,6 @@ public class ShadowUtil {
points[5].set(farCenter).addLocal(farUp).subtractLocal(farRight);
points[6].set(farCenter).addLocal(farUp).addLocal(farRight);
points[7].set(farCenter).subtractLocal(farUp).addLocal(farRight);
if (scale != 1.0f) {
// find center of frustum
Vector3f center = new Vector3f();
for (int i = 0; i < 8; i++) {
center.addLocal(points[i]);
}
center.divideLocal(8f);
Vector3f cDir = new Vector3f();
for (int i = 0; i < 8; i++) {
cDir.set(points[i]).subtractLocal(center);
cDir.multLocal(scale - 1.0f);
points[i].addLocal(cDir);
}
}
}
/**

@ -137,7 +137,7 @@ public class SpotLightShadowRenderer extends AbstractShadowRenderer {
//We prevent computing the frustum points and splits with zeroed or negative near clip value
float frustumNear = Math.max(viewCam.getFrustumNear(), 0.001f);
ShadowUtil.updateFrustumPoints(viewCam, frustumNear, zFar, 1.0f, points);
ShadowUtil.updateFrustumPoints(viewCam, frustumNear, zFar, points);
//shadowCam.setDirection(direction);
shadowCam.setFrustumPerspective(light.getSpotOuterAngle() * FastMath.RAD_TO_DEG * 2.0f, 1, 1f, light.getSpotRange());

Loading…
Cancel
Save