Shadows : post pass is no longer rendered when there is no geometry that cast shadows, avoiding rendering what ever there is in the graphic memory in that particular case.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10832 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
experimental
rem..om 11 years ago
parent 6f6b123936
commit ade8d30d8c
  1. 4
      engine/src/core-data/Common/MatDefs/Shadow/PostShadowFilter.frag
  2. 3
      engine/src/core-data/Common/MatDefs/Shadow/PostShadowFilter.j3md
  3. 5
      engine/src/core-data/Common/MatDefs/Shadow/PostShadowFilter15.frag
  4. 8
      engine/src/core/com/jme3/shadow/AbstractShadowFilter.java
  5. 8
      engine/src/core/com/jme3/shadow/AbstractShadowRenderer.java

@ -35,6 +35,10 @@ vec3 getPosition(in float depth, in vec2 uv){
} }
void main(){ void main(){
#if !defined( RENDER_SHADOWS )
gl_FragColor = texture2D(m_Texture,texCoord);
return;
#endif
float depth = texture2D(m_DepthTexture,texCoord).r; float depth = texture2D(m_DepthTexture,texCoord).r;
vec4 color = texture2D(m_Texture,texCoord); vec4 color = texture2D(m_Texture,texCoord);

@ -56,6 +56,9 @@ MaterialDef Post Shadow {
FADE : FadeInfo FADE : FadeInfo
PSSM : Splits PSSM : Splits
POINTLIGHT : LightViewProjectionMatrix5 POINTLIGHT : LightViewProjectionMatrix5
//if no shadow map don't render shadows
RENDER_SHADOWS : ShadowMap0
} }
} }

@ -87,6 +87,11 @@ vec4 main_multiSample(in int numSample){
void main(){ void main(){
#if !defined( RENDER_SHADOWS )
outFragColor = fetchTextureSample(m_Texture,texCoord,0);
return;
#endif
#ifdef RESOLVE_MS #ifdef RESOLVE_MS
vec4 color = vec4(0.0); vec4 color = vec4(0.0);
for (int i = 0; i < m_NumSamples; i++){ for (int i = 0; i < m_NumSamples; i++){

@ -103,11 +103,17 @@ public abstract class AbstractShadowFilter<T extends AbstractShadowRenderer> ext
@Override @Override
protected void postQueue(RenderQueue queue) { protected void postQueue(RenderQueue queue) {
shadowRenderer.postQueue(queue); shadowRenderer.postQueue(queue);
if(shadowRenderer.skipPostPass){
//removing the shadow map so that the post pass is skipped
material.setTexture("ShadowMap0", null);
}
} }
@Override @Override
protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) { protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {
shadowRenderer.setPostShadowParams(); if(!shadowRenderer.skipPostPass){
shadowRenderer.setPostShadowParams();
}
} }
@Override @Override

@ -104,6 +104,8 @@ public abstract class AbstractShadowRenderer implements SceneProcessor, Savable
protected GeometryList shadowMapOccluders = new GeometryList(new OpaqueComparator()); protected GeometryList shadowMapOccluders = new GeometryList(new OpaqueComparator());
private String[] shadowMapStringCache; private String[] shadowMapStringCache;
private String[] lightViewStringCache; private String[] lightViewStringCache;
//used to skip the post pass when there are no shadow casters.
protected boolean skipPostPass;
/** /**
@ -350,7 +352,9 @@ public abstract class AbstractShadowRenderer implements SceneProcessor, Savable
public void postQueue(RenderQueue rq) { public void postQueue(RenderQueue rq) {
GeometryList occluders = rq.getShadowQueueContent(ShadowMode.Cast); GeometryList occluders = rq.getShadowQueueContent(ShadowMode.Cast);
sceneReceivers = rq.getShadowQueueContent(ShadowMode.Receive); sceneReceivers = rq.getShadowQueueContent(ShadowMode.Receive);
skipPostPass = false;
if (sceneReceivers.size() == 0 || occluders.size() == 0) { if (sceneReceivers.size() == 0 || occluders.size() == 0) {
skipPostPass = true;
return; return;
} }
@ -427,7 +431,9 @@ public abstract class AbstractShadowRenderer implements SceneProcessor, Savable
abstract GeometryList getReceivers(GeometryList sceneReceivers, GeometryList lightReceivers); abstract GeometryList getReceivers(GeometryList sceneReceivers, GeometryList lightReceivers);
public void postFrame(FrameBuffer out) { public void postFrame(FrameBuffer out) {
if (skipPostPass) {
return;
}
if (debug) { if (debug) {
displayShadowMap(renderManager.getRenderer()); displayShadowMap(renderManager.getRenderer());
} }

Loading…
Cancel
Save