Skip to content

Commit 2aaff95

Browse files
committed
revert formatting and docs
1 parent 0932cb9 commit 2aaff95

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

jme3-core/src/main/java/com/jme3/shadow/SpotLightShadowRenderer.java

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -52,51 +52,47 @@
5252
import java.io.IOException;
5353

5454
/**
55-
* Implements a shadow renderer specifically for {@link SpotLight SpotLights}
56-
* using the **Parallel Split Shadow Mapping (PSSM)** technique.
57-
*
58-
* <p>PSSM divides the camera's view frustum into multiple sections,
59-
* generating a separate shadow map for each. These splits are
60-
* intelligently distributed, with smaller, higher-resolution maps for areas
61-
* closer to the camera and larger, lower-resolution maps for distant areas.
62-
* This approach optimizes shadow map usage, leading to superior shadow quality
63-
* compared to standard shadow mapping techniques.
64-
*
65-
* <p>For a detailed explanation of PSSM, refer to:
66-
* <a href="https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch10.html">GPU Gems 3, Chapter 10: Parallel-Split Shadow Maps on Programmable GPUs</a>
55+
* SpotLightShadowRenderer renderer use Parallel Split Shadow Mapping technique
56+
* (pssm)<br> It splits the view frustum in several parts and compute a shadow
57+
* map for each one.<br> splits are distributed so that the closer they are from
58+
* the camera, the smaller they are to maximize the resolution used of the
59+
* shadow map.<br> This results in a better quality shadow than standard shadow
60+
* mapping.<br> for more information on this read <a
61+
* href="http://http.developer.nvidia.com/GPUGems3/gpugems3_ch10.html">http://http.developer.nvidia.com/GPUGems3/gpugems3_ch10.html</a><br>
6762
*
6863
* @author Rémy Bouquet aka Nehon
6964
*/
7065
public class SpotLightShadowRenderer extends AbstractShadowRenderer {
7166

72-
protected Camera shadowCam;
67+
protected Camera shadowCam;
7368
protected SpotLight light;
74-
protected final Camera[] cameras = new Camera[1];
69+
protected final Camera[] tempCams = new Camera[1];
7570
protected final Vector3f[] points = new Vector3f[8];
7671
protected final Vector3f tempVec = new Vector3f();
7772

7873
/**
79-
* For serialization only. Do not use.
74+
* Used for serialization use SpotLightShadowRenderer#SpotLightShadowRenderer(AssetManager assetManager, int shadowMapSize)
8075
*/
8176
protected SpotLightShadowRenderer() {
8277
super();
8378
}
8479

8580
/**
86-
* Creates a new {@code SpotLightShadowRenderer} instance.
81+
* Create a SpotLightShadowRenderer This use standard shadow mapping
8782
*
88-
* @param assetManager The application's asset manager.
89-
* @param shadowMapSize The size of the rendered shadow maps (e.g., 512, 1024, 2048).
90-
* Higher values produce better quality shadows but may impact performance.
83+
* @param assetManager the application asset manager
84+
* @param shadowMapSize the size of the rendered shadowmaps (512,1024,2048,
85+
* etc...) The more quality, the fewer fps.
9186
*/
9287
public SpotLightShadowRenderer(AssetManager assetManager, int shadowMapSize) {
9388
super(assetManager, shadowMapSize, 1);
9489
init(shadowMapSize);
9590
}
9691

92+
9793
private void init(int shadowMapSize) {
9894
shadowCam = new Camera(shadowMapSize, shadowMapSize);
99-
cameras[0] = shadowCam;
95+
tempCams[0] = shadowCam;
10096
for (int i = 0; i < points.length; i++) {
10197
points[i] = new Vector3f();
10298
}
@@ -144,9 +140,10 @@ protected void updateShadowCams(Camera viewCam) {
144140
//We prevent computing the frustum points and splits with zeroed or negative near clip value
145141
float frustumNear = Math.max(viewCam.getFrustumNear(), 0.001f);
146142
ShadowUtil.updateFrustumPoints(viewCam, frustumNear, zFar, 1.0f, points);
143+
//shadowCam.setDirection(direction);
147144

148145
shadowCam.setFrustumPerspective(light.getSpotOuterAngle() * FastMath.RAD_TO_DEG * 2.0f, 1, 1f, light.getSpotRange());
149-
shadowCam.getRotation().lookAt(light.getDirection(), shadowCam.getUp(tempVec));
146+
shadowCam.getRotation().lookAt(light.getDirection(), shadowCam.getUp());
150147
shadowCam.setLocation(light.getPosition());
151148

152149
shadowCam.update();
@@ -165,7 +162,7 @@ protected GeometryList getOccludersToRender(int shadowMapIndex, GeometryList sha
165162
protected void getReceivers(GeometryList lightReceivers) {
166163
lightReceivers.clear();
167164
for (Spatial scene : viewPort.getScenes()) {
168-
ShadowUtil.getLitGeometriesInViewPort(scene, viewPort.getCamera(), cameras, RenderQueue.ShadowMode.Receive, lightReceivers);
165+
ShadowUtil.getLitGeometriesInViewPort(scene, viewPort.getCamera(), tempCams, RenderQueue.ShadowMode.Receive, lightReceivers);
169166
}
170167
}
171168

@@ -211,6 +208,7 @@ public void read(JmeImporter im) throws IOException {
211208
fadeInfo = (Vector2f) ic.readSavable("fadeInfo", null);
212209
fadeLength = ic.readFloat("fadeLength", 0f);
213210
init((int) shadowMapSize);
211+
214212
}
215213

216214
@Override
@@ -229,17 +227,18 @@ public void write(JmeExporter ex) throws IOException {
229227
* @return true if intersects, otherwise false
230228
*/
231229
@Override
232-
protected boolean checkCulling(Camera viewCam) {
230+
protected boolean checkCulling(Camera viewCam) {
233231
Camera cam = viewCam;
234-
if (frustumCam != null) {
235-
cam = frustumCam;
232+
if(frustumCam != null){
233+
cam = frustumCam;
236234
cam.setLocation(viewCam.getLocation());
237235
cam.setRotation(viewCam.getRotation());
238236
}
239237
TempVars vars = TempVars.get();
240-
boolean intersects = light.intersectsFrustum(cam, vars);
238+
boolean intersects = light.intersectsFrustum(cam,vars);
241239
vars.release();
242240
return intersects;
241+
243242
}
244243

245244
}

0 commit comments

Comments
 (0)