Misplaced Shadows

Hi, I’m starting with tutorials and trying some shadows I don’t know why the shadow appears misplaced.



Here are some caps:



PssmShadowRenderer





BasicShadowRenderer





Red arrow code

[java]Arrow arrow = new Arrow(new Vector3f(cylinder.getLocalTranslation().subtract(light.getPosition()).normalize()));[/java]



Thanks

Hi

I can’t see your images

try to upload them on imageshack

Fixed :slight_smile:

Do you set the light direction to the shadowRenderer?

search for setDirection

It’s a PointLight, it’s why I can get the position from the light.

[java]

PointLight light = new PointLight();

light.setPosition(new Vector3f(0,0,0));

light.setRadius(30);

light.setColor(ColorRGBA.White);[/java]



Edit: Ah, fuck the renderer, i will try it now



Edit2:



Here’s the PssmShadowRenderer:

[java]PssmShadowRenderer pssmRenderer = new PssmShadowRenderer(

assetManager,2048,8,PssmShadowRenderer.EDGE_FILTERING_PCF);

pssmRenderer.setDirection(new Vector3f(-1,-1, -1).normalizeLocal());

viewPort.addProcessor(pssmRenderer);[/java]



It’s like in the Shadow tests.

So the shadow comes by the direction of the renderer instead of the direction of the light? I don’t quite get it :confused:

So, Lighting only affect objects with Lighting Material and Shadow renderer affects objects with setShadow and has his own direction?



You can set DirectionalLight’s direction the same as the shadow render direction and it will be seen the right way.



Is it any way to cast shadows for PointLights?

khanser said:
You can set DirectionalLight's direction the same as the shadow render direction and it will be seen the right way.

Exactly

khanser said:
Is it any way to cast shadows for PointLights?

Actually you are close.
You need to compute the light direction,and that's exactly what you do on your Arrow initialization
nehon said:
You need to compute the light direction,and that's exactly what you do on your Arrow initialization


But then the renderer will only work for the desired object right? What if I have 5 objects around and beneath my PointLight? I would want the shadows to be casted right below and before each object.

JME3’s shadow Processors only work with directional lights.

If you really need omni directional shadowing, your options are :


Thanks a lot :slight_smile: