1
1
/*
2
- * Copyright (c) 2009-2021 jMonkeyEngine
2
+ * Copyright (c) 2009-2024 jMonkeyEngine
3
3
* All rights reserved.
4
4
*
5
5
* Redistribution and use in source and binary forms, with or without
40
40
import java .io .IOException ;
41
41
42
42
/**
43
- *
44
43
* This Filter does basically the same as a DirectionalLightShadowRenderer
45
44
* except it renders the post shadow pass as a fullscreen quad pass instead of a
46
45
* geometry pass. It's mostly faster than PssmShadowRenderer as long as you have
47
46
* more than about ten shadow receiving objects. The expense is the drawback
48
47
* 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.
52
49
*
53
- * API is basically the same as the PssmShadowRenderer;
50
+ * API is basically the same as the PssmShadowRenderer.
54
51
*
55
52
* @author Rémy Bouquet aka Nehon
56
53
*/
57
54
public class DirectionalLightShadowFilter extends AbstractShadowFilter <DirectionalLightShadowRenderer > {
58
55
59
56
/**
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)
64
60
*/
65
61
public DirectionalLightShadowFilter () {
66
62
super ();
67
63
}
68
64
69
65
/**
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.
79
73
*/
80
74
public DirectionalLightShadowFilter (AssetManager assetManager , int shadowMapSize , int nbSplits ) {
81
75
super (assetManager , shadowMapSize , new DirectionalLightShadowRenderer (assetManager , shadowMapSize , nbSplits ));
82
76
}
83
77
84
78
/**
85
- * return the light used to cast shadows
79
+ * Returns the light used to cast shadows.
86
80
*
87
81
* @return the DirectionalLight
88
82
*/
@@ -91,7 +85,7 @@ public DirectionalLight getLight() {
91
85
}
92
86
93
87
/**
94
- * Sets the light to use to cast shadows
88
+ * Sets the light to use to cast shadows.
95
89
*
96
90
* @param light a DirectionalLight
97
91
*/
@@ -100,7 +94,7 @@ public void setLight(DirectionalLight light) {
100
94
}
101
95
102
96
/**
103
- * returns the lambda parameter
97
+ * Returns the lambda parameter.
104
98
*
105
99
* @see #setLambda(float lambda)
106
100
* @return lambda
@@ -110,24 +104,25 @@ public float getLambda() {
110
104
}
111
105
112
106
/**
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>
121
115
* The default value is 0.65 (the theoretical optimum).
122
116
*
123
- * @param lambda the lambda value.
117
+ * @param lambda the lambda value
124
118
*/
125
119
public void setLambda (float lambda ) {
126
120
shadowRenderer .setLambda (lambda );
127
121
}
128
122
129
123
/**
130
- * returns true if stabilization is enabled
124
+ * Returns true if stabilization is enabled.
125
+ *
131
126
* @return true if stabilization is enabled
132
127
*/
133
128
public boolean isEnabledStabilization () {
@@ -150,7 +145,6 @@ public void write(JmeExporter ex) throws IOException {
150
145
super .write (ex );
151
146
OutputCapsule oc = ex .getCapsule (this );
152
147
oc .write (shadowRenderer , "shadowRenderer" , null );
153
-
154
148
}
155
149
156
150
@ Override
@@ -159,4 +153,5 @@ public void read(JmeImporter im) throws IOException {
159
153
InputCapsule ic = im .getCapsule (this );
160
154
shadowRenderer = (DirectionalLightShadowRenderer ) ic .readSavable ("shadowRenderer" , null );
161
155
}
156
+
162
157
}
0 commit comments