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. 12
      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(){
#if !defined( RENDER_SHADOWS )
gl_FragColor = texture2D(m_Texture,texCoord);
return;
#endif
float depth = texture2D(m_DepthTexture,texCoord).r;
vec4 color = texture2D(m_Texture,texCoord);

@ -56,6 +56,9 @@ MaterialDef Post Shadow {
FADE : FadeInfo
PSSM : Splits
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(){
#if !defined( RENDER_SHADOWS )
outFragColor = fetchTextureSample(m_Texture,texCoord,0);
return;
#endif
#ifdef RESOLVE_MS
vec4 color = vec4(0.0);
for (int i = 0; i < m_NumSamples; i++){

@ -71,7 +71,7 @@ public abstract class AbstractShadowFilter<T extends AbstractShadowRenderer> ext
@SuppressWarnings("all")
protected AbstractShadowFilter(AssetManager manager, int shadowMapSize, T shadowRenderer) {
super("Post Shadow");
material = new Material(manager, "Common/MatDefs/Shadow/PostShadowFilter.j3md");
material = new Material(manager, "Common/MatDefs/Shadow/PostShadowFilter.j3md");
this.shadowRenderer = shadowRenderer;
this.shadowRenderer.setPostShadowMaterial(material);
}
@ -86,7 +86,7 @@ public abstract class AbstractShadowFilter<T extends AbstractShadowRenderer> ext
return true;
}
public Material getShadowMaterial() {
public Material getShadowMaterial() {
return material;
}
Vector4f tmpv = new Vector4f();
@ -103,11 +103,17 @@ public abstract class AbstractShadowFilter<T extends AbstractShadowRenderer> ext
@Override
protected void postQueue(RenderQueue queue) {
shadowRenderer.postQueue(queue);
if(shadowRenderer.skipPostPass){
//removing the shadow map so that the post pass is skipped
material.setTexture("ShadowMap0", null);
}
}
@Override
protected void postFrame(RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer) {
shadowRenderer.setPostShadowParams();
if(!shadowRenderer.skipPostPass){
shadowRenderer.setPostShadowParams();
}
}
@Override

@ -104,6 +104,8 @@ public abstract class AbstractShadowRenderer implements SceneProcessor, Savable
protected GeometryList shadowMapOccluders = new GeometryList(new OpaqueComparator());
private String[] shadowMapStringCache;
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) {
GeometryList occluders = rq.getShadowQueueContent(ShadowMode.Cast);
sceneReceivers = rq.getShadowQueueContent(ShadowMode.Receive);
skipPostPass = false;
if (sceneReceivers.size() == 0 || occluders.size() == 0) {
skipPostPass = true;
return;
}
@ -427,7 +431,9 @@ public abstract class AbstractShadowRenderer implements SceneProcessor, Savable
abstract GeometryList getReceivers(GeometryList sceneReceivers, GeometryList lightReceivers);
public void postFrame(FrameBuffer out) {
if (skipPostPass) {
return;
}
if (debug) {
displayShadowMap(renderManager.getRenderer());
}

Loading…
Cancel
Save