does your GameStates update method include the call to update the shadows?
passManager.updatePasses(tpf)
does your GameStates update method include the call to update the shadows?
passManager.updatePasses(tpf)
yes
Are you inside a shadow volume? ZFail is not yet implemented. Also, have you tried additive vs. modulative?
Also, you may need to play a bit with the alpha state… See TestShadowPass for a way to pull up a simple editor dialog to tweak things and see if you can get it looking like you want. Also, you did not lock() the scene did you? That would lock the shadows as well. Finally, if your fish is a skinned mesh, it should flag itself as "dirty" when it updates. (See Skin.updateSkin()) If it's some other kind of animated object though, you may need to call setHasDirtyVertices(true) on the affected batches manually.
renanse said:
Are you inside a shadow volume? ZFail is not yet implemented.
Also, have you tried additive vs. modulative?
renanse said:
Also, you may need to play a bit with the alpha state... See TestShadowPass for a way to pull up a simple editor dialog to tweak things and see if you can get it looking like you want.
Also, you did not lock() the scene did you?
That would lock the shadows as well.
Finally, if your fish is a skinned mesh, it should flag itself as "dirty" when it updates. (See Skin.updateSkin()) If it's some other kind of animated object though, you may need to call setHasDirtyVertices(true) on the affected batches manually.
anlumo said:
Hm... where? That example isn't that large, and I can't find any editor in there. The only interaction I can see is the x-button to enable and disable the shadow volumes...
(I'm using jme 1.0)
if (debug) new ShadowTweaker(sPass).setVisible(true);
renanse said:
This little editor frame has sliders for the blend values and gives you the ability to switch back and forth between shadow techniques, etc.
Also, does the shadow test work for you?
On this same line, how do you set these values once you have picked them… I tried something like:
ShadowedRenderPass.blended.setDstFunction( AlphaState.SB_DST_COLOR );
True, haven't thought about that one yet.
The workaround I prefer is calling:
shadowPass.doRender( game.getDisplay().getRenderer() );
ShadowedRenderPass.blended.setDstFunction( AlphaState.SB_DST_COLOR );
...
Coming back to the topic, maybe I could enable rendering the bounding boxes somehow, to check if jme thinks that the objects are somewhere else than they really are?
Hi there,
for debugging I wanted to give you the hint to look at the bounding boxes and the shadow volume.
To see bounding Boxes simply use the DebugGameState. It lets you enable Stuff like BoundingBoxes, Light on/off, Texture on/off etc.
The only thing necessary for me was to remove the default Lights from the DebugGameState so I copied the Code to MyDebugState and changed it - not pretty but fits for debugging.
The second hint is to look at the shadow volumes. Simply remove the comment from the line you already have in your code - performance is horrible but again its just for debugging
shadowPass.setRenderVolume(true);
Thanks for the hints. The bounding boxes are good, the shadow volumes look just like you'd expect them when non-existing items cast shadows…
I created a new map in blender, and now the shadows work properly… maybe there was something wrong with my old model (the four walls shared a single mesh, maybe the stencil shadow algorithm doesn't like that).
Well shadows do not work properly when the camera is contained in one of the volumes… I heard this might be a feature to add to jME 2.0, perhaps?
It's because we use zpass only so far.
Hi!
I’m working with a BaseGame and I’m trying to see shadows in my game, but you can see in the image what I’ve achieved. I have written everything you have posted here, this are the extensions of my code:
Lights in initGame():
lightState = display.getRenderer().createLightState();
lightState.setEnabled(true);
lightState.setGlobalAmbient(new ColorRGBA(1, 1, 1, 1));
PointLight pl = new PointLight();
pl.setAmbient(new ColorRGBA(1f, 1f, 1f, 1.0f));
pl.setLocation(new Vector3f(0, 45, 0));
pl.setEnabled(true);
pl.setShadowCaster(true);
lightState.attach(pl);
rootNode.setRenderState(lightState);
PassManager in initGame:
passManager = new BasicPassManager();
ShadowedRenderPass sPass = new ShadowedRenderPass();
sPass.add(rootNode);
sPass.setRenderShadows(true);
sPass.setRenderVolume(true);
sPass.setLightingMethod(ShadowedRenderPass.ADDITIVE);
sPass.addOccluder(rootNode.getChild(“Player”));
passManager.add(sPass);
RenderPass rPass = new RenderPass();
rPass.add(rootNode);
passManager.add(rPass);
Render method:
Renderer r = display.getRenderer();
r.clearStatistics();
r.clearBuffers();
GameTaskQueueManager.getManager().getQueue(GameTaskQueue.RENDER)
.execute();
r.draw(rootNode);
simpleRender();
Renderer renderer = DisplaySystem.getDisplaySystem().getRenderer();
renderer.setBackgroundColor(ColorRGBA.blue);
renderer.clearBuffers();
passManager.renderPasses(renderer);
And update:
passManager.updatePasses(tpf);
Any ideas?
sPass.setRenderVolume(true);
sPass.setRenderVolume(false);
new Thread() {
private SourceFunction lightPassBlendSrcFunction = BlendState.SourceFunction.DestinationAlpha;
private DestinationFunction lightPassDstFunction = BlendState.DestinationFunction.One;
private SourceFunction texPassSrcFunction = BlendState.SourceFunction.SourceAlpha;
private DestinationFunction texPassDstFunction = BlendState.DestinationFunction.SourceColor;
public void run() {
while(ShadowedRenderPass.blended == null
|| ShadowedRenderPass.blendTex == null) {
try {
Thread.sleep(250);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
ShadowedRenderPass.blended.setSourceFunction(lightPassBlendSrcFunction );
ShadowedRenderPass.blended.setDestinationFunction(lightPassDstFunction );
ShadowedRenderPass.blendTex.setSourceFunction(texPassSrcFunction );
ShadowedRenderPass.blendTex.setDestinationFunction(texPassDstFunction );
}
}.start();