jmonkeyengine icon indicating copy to clipboard operation
jmonkeyengine copied to clipboard

wireframe materials render as solid on Android

Open stephengold opened this issue 5 years ago • 5 comments

This has come up a couple times at the Forum:

  • https://hub.jmonkeyengine.org/t/physicsdebuggeometry-drawn-solid/24341
  • https://hub.jmonkeyengine.org/t/minie-for-androids/43060/80

stephengold avatar Apr 12 '20 14:04 stephengold

Hi,

This topic is not easy to address, could be done in two different ways: using barycentric coordinates or using geometry shaders each of them with their advantages/disadvantages

  • barycentric: Is a more compatible way of implementing it as doesn't rely on newer GLES functionality (>=3.2) but requires CPU code for the coordinates. Also you need to rework the mesh to send each vertex of each triangle in addition to the new coordinate. For example, if you have a mesh of two triangles with four vertices, two of them are shared among the tris, the usual way is to index them and just send to GPU 4 vertices + indexes. Using this method you need to send the shared vertices information twice (one for each triangle) and keep this in memory, so RAM usage is *2.5-*3 for each mesh (incl bary coords)

  • geometry shader: Simpler from jME integration and doesn't add any CPU/RAM usage but requires GLES 3.2 (Oct/2019 standard) and API level 24 (android 7.0) so there's a wide range of devices left behind. Other issue here could be the performance of geometry shaders on mobile devices which could be slow (not tested)

So finally I just spent some time on it and I implemented a wireframe material based on geometry shaders. You can find it at https://github.com/joliver82/jME3-GLES-wireframe

If you feel like integrating it into jme core, tell me and I'll prepare a PR for it

joliver82 avatar Jan 21 '21 15:01 joliver82

Thank you for your contribution.

The barycentric approach sounds good for physics debug meshes, which are software-generated but need to work on older hardware.

The geometry-shader approach sounds better for the long term, since it should work with arbitrary meshes.

For now, I'm satisfied with this as an add-on library, not integrated into the Engine itself. But if someone integrated it, I wouldn't object.

stephengold avatar Jan 21 '21 21:01 stephengold

Yes, for sure barycentric is better for debug output as it will work in any hardware. My concern here is that, if it's integrated into jme, people could use this material having CPU and memory impact.

Anyway, I'll implement barycentric also

joliver82 avatar Jan 22 '21 02:01 joliver82

I have implemented barycentric already. It's at the same repository

joliver82 avatar Jan 22 '21 13:01 joliver82

@joliver82 Hello there, what's the status of this issue, are you still working on it ?

pavly-gerges avatar May 21 '22 21:05 pavly-gerges