11/*
2- * Copyright (c) 2009-2021 jMonkeyEngine
2+ * Copyright (c) 2009-2024 jMonkeyEngine
33 * All rights reserved.
44 *
55 * Redistribution and use in source and binary forms, with or without
4040import java .io .IOException ;
4141
4242/**
43- *
4443 * This Filter does basically the same as a DirectionalLightShadowRenderer
4544 * except it renders the post shadow pass as a fullscreen quad pass instead of a
4645 * geometry pass. It's mostly faster than PssmShadowRenderer as long as you have
4746 * more than about ten shadow receiving objects. The expense is the drawback
4847 * that the shadow Receive mode set on spatial is ignored. So basically all and
49- * only objects that render depth in the scene receive shadows. See this post
50- * for more details
51- * http://jmonkeyengine.org/groups/general-2/forum/topic/silly-question-about-shadow-rendering/#post-191599
48+ * only objects that render depth in the scene receive shadows.
5249 *
53- * API is basically the same as the PssmShadowRenderer;
50+ * API is basically the same as the PssmShadowRenderer.
5451 *
5552 * @author Rémy Bouquet aka Nehon
5653 */
5754public class DirectionalLightShadowFilter extends AbstractShadowFilter <DirectionalLightShadowRenderer > {
5855
5956 /**
60- * Used for serialization.
61- * Use DirectionalLightShadowFilter#DirectionalLightShadowFilter
62- * (AssetManager assetManager, int shadowMapSize, int nbSplits)
63- * instead.
57+ * For serialization only. Do not use.
58+ *
59+ * @see #DirectionalLightShadowFilter(AssetManager assetManager, int shadowMapSize, int nbSplits)
6460 */
6561 public DirectionalLightShadowFilter () {
6662 super ();
6763 }
6864
6965 /**
70- * Creates a DirectionalLight shadow filter. More info on the
71- * technique at <a
72- * href="http://http.developer.nvidia.com/GPUGems3/gpugems3_ch10.html">http://http.developer.nvidia.com/GPUGems3/gpugems3_ch10.html</a>
73- *
74- * @param assetManager the application's asset manager
75- * @param shadowMapSize the size of the rendered shadowmaps (512, 1024, 2048,
76- * etcetera)
77- * @param nbSplits the number of shadow maps rendered (More shadow maps mean
78- * better quality, fewer frames per second.)
66+ * Creates a DirectionalLightShadowFilter.
67+ *
68+ * @param assetManager the application's asset manager
69+ * @param shadowMapSize the size of the rendered shadow maps (512, 1024, 2048, etc...)
70+ * @param nbSplits the number of shadow maps rendered (more shadow maps = better quality, but slower)
71+ *
72+ * @throws IllegalArgumentException if the provided 'nbSplits' is not within the valid range of 1 to 4.
7973 */
8074 public DirectionalLightShadowFilter (AssetManager assetManager , int shadowMapSize , int nbSplits ) {
8175 super (assetManager , shadowMapSize , new DirectionalLightShadowRenderer (assetManager , shadowMapSize , nbSplits ));
8276 }
8377
8478 /**
85- * return the light used to cast shadows
79+ * Returns the light used to cast shadows.
8680 *
8781 * @return the DirectionalLight
8882 */
@@ -91,7 +85,7 @@ public DirectionalLight getLight() {
9185 }
9286
9387 /**
94- * Sets the light to use to cast shadows
88+ * Sets the light to use to cast shadows.
9589 *
9690 * @param light a DirectionalLight
9791 */
@@ -100,7 +94,7 @@ public void setLight(DirectionalLight light) {
10094 }
10195
10296 /**
103- * returns the lambda parameter
97+ * Returns the lambda parameter.
10498 *
10599 * @see #setLambda(float lambda)
106100 * @return lambda
@@ -110,24 +104,25 @@ public float getLambda() {
110104 }
111105
112106 /**
113- * Adjusts the partition of the shadow extend into shadow maps.
114- * Lambda is usually between 0 and 1.
115- * A low value gives a more linear partition,
116- * resulting in consistent shadow quality over the extend,
117- * but near shadows could look very jagged.
118- * A high value gives a more logarithmic partition,
119- * resulting in high quality for near shadows,
120- * but quality decreases rapidly with distance.
107+ * Adjusts the partition of the shadow extend into shadow maps. Lambda is
108+ * usually between 0 and 1.
109+ * <p>
110+ * A low value gives a more linear partition, resulting in consistent shadow
111+ * quality over the extend, but near shadows could look very jagged. A high
112+ * value gives a more logarithmic partition, resulting in high quality for near
113+ * shadows, but quality decreases rapidly with distance.
114+ * <p>
121115 * The default value is 0.65 (the theoretical optimum).
122116 *
123- * @param lambda the lambda value.
117+ * @param lambda the lambda value
124118 */
125119 public void setLambda (float lambda ) {
126120 shadowRenderer .setLambda (lambda );
127121 }
128122
129123 /**
130- * returns true if stabilization is enabled
124+ * Returns true if stabilization is enabled.
125+ *
131126 * @return true if stabilization is enabled
132127 */
133128 public boolean isEnabledStabilization () {
@@ -150,7 +145,6 @@ public void write(JmeExporter ex) throws IOException {
150145 super .write (ex );
151146 OutputCapsule oc = ex .getCapsule (this );
152147 oc .write (shadowRenderer , "shadowRenderer" , null );
153-
154148 }
155149
156150 @ Override
@@ -159,4 +153,5 @@ public void read(JmeImporter im) throws IOException {
159153 InputCapsule ic = im .getCapsule (this );
160154 shadowRenderer = (DirectionalLightShadowRenderer ) ic .readSavable ("shadowRenderer" , null );
161155 }
156+
162157}
0 commit comments