What lighting and shadowing technique support on Android?
I think it is better for beginner if there is a feature table for desktop and mobile.
Most of them, question is how fast they work so it will always be your decision if you can use them or not.
But which of them not work? It is hard to guess and very time consuming to try them one by one.
There arenāt multiple lighting techniques, idk what you are talking about?
This is potentially a related question, so thought I would post here;
Iāve copied the DirectionalLight code straight from this tutorial ( https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:light_and_shadow ) and put it in the initialisation of the app on Android.
[java]
final int SHADOWMAP_SIZE=512;
DirectionalLightShadowRenderer dlsr = new DirectionalLightShadowRenderer(assetManager, SHADOWMAP_SIZE, 3);
dlsr.setLight(sun);
viewPort.addProcessor(dlsr);
[/java]
When a couple objects with ShadowMode.Cast are loaded the GLThread throws a RendererException, citing the PostShadow.frag file - āThe fragment shader failed to compileā
The PostShadow.frag (and others) are definitely available within the Assets directory.
Is there a known issue with shadow rendering on Android, or am I being far too simplistic in my implementation?
Thanks.
Could be there is a bugā¦ I think weād have to see the whole error to know for sureā¦ I donāt know how to do that on Android as Iāve never done anything there.
@pspeed; Stack trace for the error
[java]
Exception thrown in Thread[GLThread 13888,5,main]
com.jme3.renderer.RendererException: compile error in: ShaderSource[name=Common/MatDefs/Shadow/PostShadow.frag, defines, type=Fragment, language=GLSL100]
Fragment shader compilation failed.
ERROR: 0:41: āsampler2DShadowā : Reserved word.
ERROR: 0:41: āsampler2DShadowā : Syntax error: syntax error
ERROR: 2 compilation errors. No code generated.
at com.jme3.renderer.android.OGLESShaderRenderer.updateShaderSourceData(OGLESShaderRenderer.java:895)
at com.jme3.renderer.android.OGLESShaderRenderer.updateShaderData(OGLESShaderRenderer.java:920)
at com.jme3.renderer.android.OGLESShaderRenderer.setShader(OGLESShaderRenderer.java:978)
at com.jme3.material.Material.render(Material.java:1167)
at com.jme3.renderer.RenderManager.renderGeometry(RenderManager.java:525)
at com.jme3.renderer.queue.RenderQueue.renderGeometryList(RenderQueue.java:322)
at com.jme3.renderer.queue.RenderQueue.renderShadowQueue(RenderQueue.java:331)
at com.jme3.shadow.AbstractShadowRenderer.postFrame(AbstractShadowRenderer.java:478)
at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1005)
at com.jme3.renderer.RenderManager.render(RenderManager.java:1047)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:252)
at com.augtech.awilaSDK.AwilaARView.update(AwilaARView.java:548)
at com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:361)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1523)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
[/java]
Shadows are not really meant to work on Android. That said, it could, I never really tested them on it.
The thing is, usually shadows are already pretty expensive on desktop and are going to drastically bump down your fps on android. Usually youāll want to use more basic shadows like semi-transparent textured quads on the ground. (Iām playing Chaos Ring 2 these times by Square Enix and thatās what they use).
Thatās a reason why this has never been a priority.
The error here seems pretty weird, guess sampler2DShadow is not supported on onpenglES. Iāll look into it eventually.
Thats a shame, but thanks for confirming.
Fps is already a bit of a concern with the terrain loaded, so if they are really going to hurt then it will be best to leave it then.
You could generate a lightmap for the terrains static parts either by hand or in an external application.
Could you define a lightmap?
All the terrain is static as its come from a real-world DTMā¦
A lightmap is a static shadow map, usually generated in a 3D modeling software by artists. The main disadvantage is that they are static, so you canāt have dynamic lighting (moving lights), but the main advantage is that they are very cheap, and high quality.
I know this thread is a bit old.
When I stumbled across JMonkey a few years ago, I was very impressed by how easy it is to add dynamic shadows and how impressive they look. Since at that time I mainly wanted to develop something that also runs on my Android smartphone, I was also slightly saddened to miss out on this impressive function there.
In the meantime I work on a somewhat stammed Linux computer. which mainly uses Mesa drivers because it doesnāt have an extra graphics card. If I donāt limit the fps, the games on my smartphone run at least twice as fast as on the computer. The only thing that makes a difference is RAM.
So when I came across this old thread, I wanted to ask if there is a new status on the subject of shadows under Android?
I think there were some shadow related bugfixes on Android in this PR since then
By the way, for a simple and more performant shadow on Android, you may consider using DropShadowFilter from SimFX:
Iāll test the shadows again for the next Android migration.
@Ali_RS Thanks for the link!