diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index 5ae11047..0a3917d1 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -1964,6 +1964,7 @@ Performance improvements - Block entities are back to using same mesh for all blocks, will eventually just have closest ones ONLY on client use multi-mesh - Accumulator draw calls do not use bones - LOD skipping in realm simulation + - Shadow map pipeline only considers entities that are nearby diff --git a/src/main/java/electrosphere/renderer/pipelines/ShadowMapPipeline.java b/src/main/java/electrosphere/renderer/pipelines/ShadowMapPipeline.java index 0cd59c95..a475b796 100644 --- a/src/main/java/electrosphere/renderer/pipelines/ShadowMapPipeline.java +++ b/src/main/java/electrosphere/renderer/pipelines/ShadowMapPipeline.java @@ -31,6 +31,11 @@ public class ShadowMapPipeline implements RenderPipeline { */ public static final int SHADOW_MAP_RESOLUTION = 4096; + /** + * Cutoff for adding to shadow map pipeline draw accumulator + */ + public static final double DRAW_CUTOFF_DIST = 30f; + /** * The eye of the camera that is used to render the shadow map */ diff --git a/src/main/java/electrosphere/renderer/target/DrawTargetEvaluator.java b/src/main/java/electrosphere/renderer/target/DrawTargetEvaluator.java index 4926d3ca..56453f35 100644 --- a/src/main/java/electrosphere/renderer/target/DrawTargetEvaluator.java +++ b/src/main/java/electrosphere/renderer/target/DrawTargetEvaluator.java @@ -14,6 +14,7 @@ import electrosphere.entity.EntityTags; import electrosphere.entity.EntityUtils; import electrosphere.renderer.actor.Actor; import electrosphere.renderer.pipelines.MainContentPipeline; +import electrosphere.renderer.pipelines.ShadowMapPipeline; /** * Evaluates the draw targets @@ -61,10 +62,12 @@ public class DrawTargetEvaluator { //fetch actor Actor currentActor = EntityUtils.getActor(currentEntity); + //get distance from camera + posVec.set(position); + double dist = posVec.distance(cameraCenter); + //evaluate LOD level if(currentActor.getLowResPath() != null){ - posVec.set(position); - double dist = posVec.distance(cameraCenter); if(dist < LOD_CUTOFF){ currentActor.setLodLevel(Actor.LOD_LEVEL_FULL); } else { @@ -88,7 +91,7 @@ public class DrawTargetEvaluator { if(MainContentPipeline.shouldDrawSolidPass(currentEntity)){ mainAccumulator.addCall(currentActor.getModelPath(), position, modelTransformMatrix); } - if(shadowList.contains(currentEntity)){ + if(dist < ShadowMapPipeline.DRAW_CUTOFF_DIST && shadowList.contains(currentEntity)){ shadowAccumulator.addCall(currentActor.getModelPath(), position, modelTransformMatrix); } } @@ -96,7 +99,7 @@ public class DrawTargetEvaluator { if(MainContentPipeline.shouldDrawSolidPass(currentEntity)){ mainQueue.add(currentEntity); } - if(shadowList.contains(currentEntity)){ + if(dist < ShadowMapPipeline.DRAW_CUTOFF_DIST && shadowList.contains(currentEntity)){ shadowQueue.add(currentEntity); } }