Skip to content

Commit 7d5a0d7

Browse files
authored
DirectionalLightShadowRenderer: fix javadoc
1 parent cfc2c96 commit 7d5a0d7

1 file changed

Lines changed: 22 additions & 13 deletions

File tree

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

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import com.jme3.export.JmeImporter;
3838
import com.jme3.export.OutputCapsule;
3939
import com.jme3.light.DirectionalLight;
40+
import com.jme3.light.SpotLight;
4041
import com.jme3.material.Material;
4142
import com.jme3.math.ColorRGBA;
4243
import com.jme3.math.Vector2f;
@@ -51,14 +52,19 @@
5152
import java.io.IOException;
5253

5354
/**
54-
* DirectionalLightShadowRenderer renderer use Parallel Split Shadow Mapping
55-
* technique (pssm)<br> It splits the view frustum in several parts and compute
56-
* a shadow map for each one.<br> splits are distributed so that the closer they
57-
* are from the camera, the smaller they are to maximize the resolution used of
58-
* the shadow map.<br> This results in a better quality shadow than standard
59-
* shadow mapping.<br> for more information on this read <a
60-
* href="https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch10.html">https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch10.html</a><br>
55+
* Implements a shadow renderer specifically for {@link DirectionalLight DirectionalLight}
56+
* using the **Parallel Split Shadow Mapping (PSSM)** technique.
6157
*
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>
67+
*
6268
* @author Nehon
6369
*/
6470
public class DirectionalLightShadowRenderer extends AbstractShadowRenderer {
@@ -89,21 +95,24 @@ protected DirectionalLightShadowRenderer() {
8995
* Creates a DirectionalLight shadow renderer. This renderer implements the
9096
* Parallel Split Shadow Mapping (PSSM) technique.
9197
*
92-
* @param assetManager The application's asset manager.
98+
* @param assetManager The application's asset manager.
9399
* @param shadowMapSize The size of the rendered shadow maps (e.g., 512, 1024, 2048).
94-
* @param nbSplits The number of shadow maps to render (1 to 4). More maps
95-
* improve quality but can reduce performance.
100+
* Higher values produce better quality shadows but may impact performance.
101+
* @param nbSplits The number of shadow maps to render (1 to 4). More maps
102+
* improve quality but can reduce performance.
96103
*/
97104
public DirectionalLightShadowRenderer(AssetManager assetManager, int shadowMapSize, int nbSplits) {
98105
super(assetManager, shadowMapSize, nbSplits);
99106
init(nbSplits, shadowMapSize);
100107
}
101108

102109
private void init(int nbSplits, int shadowMapSize) {
103-
nbShadowMaps = Math.max(Math.min(nbSplits, 4), 1);
104-
if (nbShadowMaps != nbSplits) {
105-
throw new IllegalArgumentException("Number of splits must be between 1 and 4. Given value : " + nbSplits);
110+
// Ensure the number of shadow maps is within the valid range [1, 4]
111+
if (nbSplits < 1 || nbSplits > 4) {
112+
throw new IllegalArgumentException("Number of splits must be between 1 and 4. Given value: " + nbSplits);
106113
}
114+
115+
nbShadowMaps = nbSplits;
107116
splits = new ColorRGBA();
108117
splitsArray = new float[nbSplits + 1];
109118
shadowCam = new Camera(shadowMapSize, shadowMapSize);

0 commit comments

Comments
 (0)