My shadows are a little messed up. There seems to be lines on the entire object and my performance sucks:
My shadow code is the same but I imported the object from a .blend file into jMP. And of course jME updated.
[java]pssmRenderer = new PssmShadowRenderer(assetManager, 768, 2);
pssmRenderer.setDirection(new Vector3f(-1, -1, -1));
pssmRenderer.setLambda(0.55f);
pssmRenderer.setShadowIntensity(0.6f);
pssmRenderer.setFilterMode(FilterMode.Dither);
// pssmRenderer.setFilterMode(FilterMode.PCF4);
viewPort.addProcessor(pssmRenderer);[/java]
How do I fix this?
Not sure if its related but make sure to normalize the light direction before passing it to the pssm renderer
Could it have something to do with the model in Blender? When I use the same shadow mode on the floor (which is a box) there is no problem.
What filtering do you use? PCF?
If you use PCF8 try PCF4. I already noticed some glitches with this filtering
It happens with dithering and default too.
uh oh i didn’t notice that you posted the code.
could you try with a power of 2 size for the shadow map?
To me this looks like an issue with poly offset being too low
It must be a problem with the model because the code didn’t change (it happens with 256 resolution as well). Is the polygon offset related to something I can change (e.g. in Blender) or is it because of the shape of the model?
This happens even with the pssm settings from the example test file so I think it is related to the asset import from Blender rather than my code. I uploaded a .blend file of a textured box that gives me the same problem:
http://www.mediafire.com/file/dsvd6u8828868sb/box.blend
And here is my code anyway (I now just use the jMP option to enable the shadows).
[java] PssmShadowRenderer pssmRenderer = new PssmShadowRenderer(assetManager, 1024, 3);
pssmRenderer.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
pssmRenderer.setLambda(0.55f);
pssmRenderer.setShadowIntensity(0.6f);
pssmRenderer.setCompareMode(CompareMode.Software);
pssmRenderer.setFilterMode(FilterMode.Bilinear);
pssmRenderer.displayDebug();
viewPort.addProcessor(pssmRenderer);[/java]
[java] Node mesh = (Node)stage.getAssetManager().loadModel(“Models/box/box.j3o”);
TangentBinormalGenerator.generate(mesh);
stage.getStemNode().attachChild(mesh);[/java]
I guess if I just use 2.49 and ogre exporter it will work fine, but I’m confused that nobody else has this problem.
ok i have the same issue.
There must be an issue with the material…
In this shot, the ground is the box loaded with the blender loader and with the embed material generated. The metal box usesa material i made from scratch using the images extracted from your blend file. the yellow cube use a basic lighting material with a diffuse color.
The problem appears with the embed material…but not with the others. There may be an issue in the blender loader, when i tried to create a j3m file from the embed material i got an error, i’m gonna investigate this a bit more.
As a workaround you can do as i did, extract the textures from blender, and create a material with jmp and assign it to the box.
ok I found the issue, the embed material is created with a polyOffset of 0.0 0.0. This causes this issue (i don’t know why), the problem is that the poly offset is enabled even with 0 values and there is no way to disable it in the renderState
@Momoko_Fan maybe we should disable the polyOffset in the render state if the values are 0.0 0.0.
On a side note @Kaelthas and @normen there is an issue with blender embed textures, they are created without TextureKey. So when trying to create a j3m file in jmp with a material referencing this texture, there are NPE. Also the texture key holds the path of the texture, so even when catching those NPE, the material file does not work.
Is there a way in this case to extract the texture data and to create a file and the corresponding texture key?
@Momoko_Fan maybe we should disable the polyOffset in the render state if the values are 0.0 0.0.
Thats exactly what we are doing and this is what causes the OPs problem (setting poly offset to 0.0 is the same as disabling it). Materials that specify they want the polyoffset to be 0.0 override it when it is set by the J3MD, in this case its Lighting.j3md, with technique PreShadow. Obviously its not intended that the poly offset be applied to all techniques, but only the default, however there's no way of specifying that. The correct solution would be to remove the AdditionalRenderState block in JMP if no render states are overriden by the user. Specifying an AdditionalRenderState block in the J3M is incorrect behavior because it overrides any render states specified in the J3MD causing issues similar to this.
On a side note @Kaelthas and @normen there is an issue with blender embed textures, they are created without TextureKey. So when trying to create a j3m file in jmp with a material referencing this texture, there are NPE. Also the texture key holds the path of the texture, so even when catching those NPE, the material file does not work.
Is there a way in this case to extract the texture data and to create a file and the corresponding texture key?
jMP uses MatParam.getValueAsString() to retrieve the parameter value and thats where the NPE occurs. I have fixed it so a proper UnsupportedOperationException is thrown if the parameter value cannot be generated. The only valid solution I see in this case is catching the exception and then extracting the generated texture data into some file and then setting the proper TextureKey on the texture based on the file's path in the AssetManager's file system.
Momoko_Fan said:
Thats exactly what we are doing and this is what causes the OPs problem (setting poly offset to 0.0 is the same as disabling it). Materials that specify they want the polyoffset to be 0.0 override it when it is set by the J3MD, in this case its Lighting.j3md, with technique PreShadow. Obviously its not intended that the poly offset be applied to all techniques, but only the default, however there's no way of specifying that. The correct solution would be to remove the AdditionalRenderState block in JMP if no render states are overriden by the user. Specifying an AdditionalRenderState block in the J3M is incorrect behavior because it overrides any render states specified in the J3MD causing issues similar to this.
You don't get it....it's not a j3m file, it's a material in a j3o file. I only transformed it to j3m to see what was happening. I agree with that render state block shouldn't be added to the file if none has been overridden, but that's another issue.
Maybe the problem here is in the blender loader it should not set the polyoffset on embed materials.
Momoko_Fan said:
jMP uses MatParam.getValueAsString() to retrieve the parameter value and thats where the NPE occurs. I have fixed it so a proper UnsupportedOperationException is thrown if the parameter value cannot be generated. The only valid solution I see in this case is catching the exception and then extracting the generated texture data into some file and then setting the proper TextureKey on the texture based on the file's path in the AssetManager's file system.
I agree
Maybe the problem here is in the blender loader it should not set the polyoffset on embed materials.
I did a search on the loader and it doesn't seem like its doing that. I might have to check this model myself