|
|
@ -34,8 +34,10 @@ package com.jme3.shadow.next; |
|
|
|
import com.jme3.shadow.next.pssm.DirectionalShadowParameters; |
|
|
|
import com.jme3.shadow.next.pssm.DirectionalShadowParameters; |
|
|
|
import com.jme3.light.DirectionalLight; |
|
|
|
import com.jme3.light.DirectionalLight; |
|
|
|
import com.jme3.light.Light; |
|
|
|
import com.jme3.light.Light; |
|
|
|
|
|
|
|
import com.jme3.light.Light.Type; |
|
|
|
import com.jme3.light.PointLight; |
|
|
|
import com.jme3.light.PointLight; |
|
|
|
import com.jme3.light.SpotLight; |
|
|
|
import com.jme3.light.SpotLight; |
|
|
|
|
|
|
|
import com.jme3.material.MatParamOverride; |
|
|
|
import com.jme3.material.RenderState; |
|
|
|
import com.jme3.material.RenderState; |
|
|
|
import com.jme3.math.Vector3f; |
|
|
|
import com.jme3.math.Vector3f; |
|
|
|
import com.jme3.post.SceneProcessor; |
|
|
|
import com.jme3.post.SceneProcessor; |
|
|
@ -46,6 +48,7 @@ import com.jme3.renderer.ViewPort; |
|
|
|
import com.jme3.renderer.queue.GeometryList; |
|
|
|
import com.jme3.renderer.queue.GeometryList; |
|
|
|
import com.jme3.renderer.queue.OpaqueComparator; |
|
|
|
import com.jme3.renderer.queue.OpaqueComparator; |
|
|
|
import com.jme3.renderer.queue.RenderQueue; |
|
|
|
import com.jme3.renderer.queue.RenderQueue; |
|
|
|
|
|
|
|
import com.jme3.shader.VarType; |
|
|
|
import com.jme3.shadow.next.array.DirectionalArrayShadowMap; |
|
|
|
import com.jme3.shadow.next.array.DirectionalArrayShadowMap; |
|
|
|
import com.jme3.shadow.next.array.PointArrayShadowMap; |
|
|
|
import com.jme3.shadow.next.array.PointArrayShadowMap; |
|
|
|
import com.jme3.shadow.next.array.SpotArrayShadowMap; |
|
|
|
import com.jme3.shadow.next.array.SpotArrayShadowMap; |
|
|
@ -80,6 +83,7 @@ public class PreShadowArrayRenderer implements SceneProcessor { |
|
|
|
private final GeometryList shadowCasters = new GeometryList(new OpaqueComparator()); |
|
|
|
private final GeometryList shadowCasters = new GeometryList(new OpaqueComparator()); |
|
|
|
private final ListMap<Light, ShadowMap> shadowedLights = new ListMap<>(); |
|
|
|
private final ListMap<Light, ShadowMap> shadowedLights = new ListMap<>(); |
|
|
|
private final RenderState prePassRenderState = RenderState.ADDITIONAL.clone(); |
|
|
|
private final RenderState prePassRenderState = RenderState.ADDITIONAL.clone(); |
|
|
|
|
|
|
|
private final MatParamOverride pointLightOverride = new MatParamOverride(VarType.Boolean, "IsPointLight", true); |
|
|
|
private final TextureArray array = new TextureArray(); |
|
|
|
private final TextureArray array = new TextureArray(); |
|
|
|
|
|
|
|
|
|
|
|
private int textureSize = 1024; |
|
|
|
private int textureSize = 1024; |
|
|
@ -190,6 +194,7 @@ public class PreShadowArrayRenderer implements SceneProcessor { |
|
|
|
private void renderShadowMaps(ViewPort viewPort) { |
|
|
|
private void renderShadowMaps(ViewPort viewPort) { |
|
|
|
renderManager.setForcedRenderState(prePassRenderState); |
|
|
|
renderManager.setForcedRenderState(prePassRenderState); |
|
|
|
renderManager.setForcedTechnique(PRE_SHADOW_TECHNIQUE_NAME); |
|
|
|
renderManager.setForcedTechnique(PRE_SHADOW_TECHNIQUE_NAME); |
|
|
|
|
|
|
|
renderManager.addForcedMatParam(pointLightOverride); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < shadowedLights.size(); i++) { |
|
|
|
for (int i = 0; i < shadowedLights.size(); i++) { |
|
|
|
Light light = shadowedLights.getKey(i); |
|
|
|
Light light = shadowedLights.getKey(i); |
|
|
@ -206,6 +211,8 @@ public class PreShadowArrayRenderer implements SceneProcessor { |
|
|
|
vars.release(); |
|
|
|
vars.release(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pointLightOverride.setEnabled(shadowMap.getLightType() == Type.Point); |
|
|
|
|
|
|
|
|
|
|
|
switch (shadowMap.getLightType()) { |
|
|
|
switch (shadowMap.getLightType()) { |
|
|
|
case Directional: |
|
|
|
case Directional: |
|
|
|
DirectionalArrayShadowMap directionalShadow = (DirectionalArrayShadowMap) shadowMap; |
|
|
|
DirectionalArrayShadowMap directionalShadow = (DirectionalArrayShadowMap) shadowMap; |
|
|
@ -228,6 +235,7 @@ public class PreShadowArrayRenderer implements SceneProcessor { |
|
|
|
|
|
|
|
|
|
|
|
Renderer renderer = renderManager.getRenderer(); |
|
|
|
Renderer renderer = renderManager.getRenderer(); |
|
|
|
renderer.setFrameBuffer(viewPort.getOutputFrameBuffer()); |
|
|
|
renderer.setFrameBuffer(viewPort.getOutputFrameBuffer()); |
|
|
|
|
|
|
|
renderManager.removeForcedMatParam(pointLightOverride); |
|
|
|
renderManager.setForcedRenderState(null); |
|
|
|
renderManager.setForcedRenderState(null); |
|
|
|
renderManager.setForcedTechnique(null); |
|
|
|
renderManager.setForcedTechnique(null); |
|
|
|
renderManager.setCamera(viewPort.getCamera(), false); |
|
|
|
renderManager.setCamera(viewPort.getCamera(), false); |
|
|
|