Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2021 jMonkeyEngine
* Copyright (c) 2009-2025 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -66,9 +66,9 @@ public class SpotLightShadowRenderer extends AbstractShadowRenderer {

protected Camera shadowCam;
protected SpotLight light;
protected Vector3f[] points = new Vector3f[8];
//Holding the info for fading shadows in the far distance

protected final Camera[] tempCams = new Camera[1];
protected final Vector3f[] points = new Vector3f[8];
protected final Vector3f tempVec = new Vector3f();

/**
* Used for serialization use SpotLightShadowRenderer#SpotLightShadowRenderer(AssetManager assetManager, int shadowMapSize)
Expand Down Expand Up @@ -101,7 +101,8 @@ private void init(int shadowMapSize) {
protected void initFrustumCam() {
Camera viewCam = viewPort.getCamera();
frustumCam = viewCam.clone();
frustumCam.setFrustum(viewCam.getFrustumNear(), zFarOverride, viewCam.getFrustumLeft(), viewCam.getFrustumRight(), viewCam.getFrustumTop(), viewCam.getFrustumBottom());
frustumCam.setFrustum(viewCam.getFrustumNear(), zFarOverride, viewCam.getFrustumLeft(),
viewCam.getFrustumRight(), viewCam.getFrustumTop(), viewCam.getFrustumBottom());
}

/**
Expand Down Expand Up @@ -141,7 +142,7 @@ protected void updateShadowCams(Camera viewCam) {
//shadowCam.setDirection(direction);

shadowCam.setFrustumPerspective(light.getSpotOuterAngle() * FastMath.RAD_TO_DEG * 2.0f, 1, 1f, light.getSpotRange());
shadowCam.getRotation().lookAt(light.getDirection(), shadowCam.getUp());
shadowCam.getRotation().lookAt(light.getDirection(), shadowCam.getUp(tempVec));
shadowCam.setLocation(light.getPosition());

shadowCam.update();
Expand All @@ -159,10 +160,9 @@ protected GeometryList getOccludersToRender(int shadowMapIndex, GeometryList sha
@Override
protected void getReceivers(GeometryList lightReceivers) {
lightReceivers.clear();
Camera[] cameras = new Camera[1];
cameras[0] = shadowCam;
tempCams[0] = shadowCam;
for (Spatial scene : viewPort.getScenes()) {
ShadowUtil.getLitGeometriesInViewPort(scene, viewPort.getCamera(), cameras, RenderQueue.ShadowMode.Receive, lightReceivers);
ShadowUtil.getLitGeometriesInViewPort(scene, viewPort.getCamera(), tempCams, RenderQueue.ShadowMode.Receive, lightReceivers);
}
}

Expand Down