Conversation
Nehon
left a comment
There was a problem hiding this comment.
Several remarks:
1- Don't you have a Test class to see the usage and well... test it.
2- It's seems that inpass shadows use a different technique and techniqueDefLogic so how could I combine them with the PBR shader?
3- It seems there is 1 shadow renderer by light type is that correct?
4- Could be nice that you explain the whole principle in a short summary.
|
| private void updateRenderState(RenderManager renderManager, Renderer renderer, TechniqueDef techniqueDef) { | ||
| if (renderManager.getForcedRenderState() != null) { | ||
| renderer.applyRenderState(renderManager.getForcedRenderState()); | ||
| if (techniqueDef.getForcedRenderState() != null) { |
There was a problem hiding this comment.
This could break compatibility... I think it fixes a bug, or changes behavior
|
|
||
| protected float encodeLightType(Light light) { | ||
| switch (light.getType()) { | ||
| case Directional: |
There was a problem hiding this comment.
FYI, this breaks any custom lighting shaders
| import com.jme3.texture.TextureArray; | ||
| import java.util.EnumSet; | ||
|
|
||
| public class ShadowStaticPassLightingLogic extends StaticPassLightingLogic { |
There was a problem hiding this comment.
Static pass should probably be removed. It doesn't add any value now
| return super.makeCurrent(assetManager, renderManager, rendererCaps, lights, defines); | ||
| ambientLightColor.a = 1.0f; | ||
|
|
||
| filteredLightList.sort(new Comparator<Light>() { |
There was a problem hiding this comment.
Should refactor this comparator to avoid allocation
| * @author Kirill Vainer | ||
| */ | ||
| public final class StaticPassLightingLogic extends DefaultTechniqueDefLogic { | ||
| public class StaticPassLightingLogic extends DefaultTechniqueDefLogic { |
| * | ||
| * @author Kirill Vainer | ||
| */ | ||
| public class PreShadowRenderer implements SceneProcessor { |
There was a problem hiding this comment.
This needs a test... TestInPassShadows uses the regular PreShadowArrayRenderer
| * | ||
| * @author Kirill Vainer | ||
| */ | ||
| final class ShadowDebugControl extends AbstractControl { |
There was a problem hiding this comment.
This needs to be used by the test
| /** | ||
| * @author Kirill Vainer | ||
| */ | ||
| public interface ShadowParameters { |
There was a problem hiding this comment.
What's the point of this?
There was a problem hiding this comment.
DirectionalShadowParameters implement it... not sure why it's needed though.
There is no other type of Shadow parameter and directional parameters are used with the type DirectionalShadowParameters So this interface is IMO useless. I'll remove it if you agree.
| super(array, layer, textureSize, true); | ||
| } | ||
|
|
||
| private static boolean isParallelToYUp(Vector3f direction) { |
There was a problem hiding this comment.
Should this be used for directional lights too?
| @Override | ||
| public Matrix4f getBiasedViewProjectionMatrix() { | ||
| // return shadowCamera.getViewProjectionMatrix(); | ||
| throw new UnsupportedOperationException(); |
| } | ||
|
|
||
| public void setNumSplits(int numSplits) { | ||
| // TODO: ensure it is 1 to 4 |
| lightDir.w = clamp(lightDir.w, 1.0 - posLight, 1.0); | ||
| #else | ||
| lightDir.w = clamp(1.0 - position.w * dist * posLight, 0.0, 1.0); | ||
| lightDir.w = 1.0; // clamp(1.0 - position.w * dist * posLight, 0.0, 1.0); |
…. Also addressed some comments on the PR
|
What is the state of this one btw? is this still alive? |
|
@empirephoenix |
This is the PR implementing in-pass shadows as shown in the April 2016 screenshot thread:
https://hub.jmonkeyengine.org/t/april-2016-monthly-wip-screenshot-thread/35512/128
How it works:
PreShadowArrayRendereris responsible for generating a texture array containing shadow maps for every light that should be shadowed. Directional lights use PSSM with 1-4 slices, spot lights use 1 slice, and point lights will use 6 slices (not implemented yet). The information of which texture array to use and the slices is represented in theShadowMapinterface. This is then associated with the light so that later it can be retrieved.When the scene is rendered,
ShadowStaticPassLightingLogicis theTechniqueDefLogicimplementation that is capable of rendering in-pass shadows. The light types are statically known which allows the shader to avoid control flow. It works similarly toSinglePass, except that the lights are first sorted by type and then their counts are known statically, so instead of this loop:It becomes
This then allows using different logic depending on the light type. The way shadow maps are fetched varies depending on the type of light, which is why this is required.
Theoretically, if we have control flow in the shader then we don't need to know the light type in advance and we can calculate the slice to fetch per each light. This is probably how in-pass shadows will be integrated with the rest of the lighting shaders.
TODO:
ShadowUtilOptional: