Odd rendering errors on Android

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
Imerion
Posts: 198
Joined: Sun Feb 09, 2014 4:42 pm

Odd rendering errors on Android

Post by Imerion » Thu Sep 01, 2016 12:42 pm

I have pretty much finished a new game! But when running it on Android some weird things happen. It seems transparency isn't rendered correctly. (Or things are rendered in an incorrect order. Below is a screenshot of how it looks on my PC and one of how it looks on my Galaxy Tab 3. Any idea what might be causing this?
Attachments
Screenshot_2016-09-01-14-32-09.png
Screenshot_2016-09-01-14-32-09.png (177.88 KiB) Viewed 7916 times
Screenshot_2016-09-01_14-35-05.png
Screenshot_2016-09-01_14-35-05.png (268 KiB) Viewed 7916 times

User avatar
VilleK
Site Admin
Posts: 2077
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Odd rendering errors on Android

Post by VilleK » Thu Sep 01, 2016 4:36 pm

Not sure what is going on. Can you tell me how that planet in the bottom right corner is rendered. Is it one mesh with transparent texture on top of another mesh?

Imerion
Posts: 198
Joined: Sun Feb 09, 2014 4:42 pm

Re: Odd rendering errors on Android

Post by Imerion » Thu Sep 01, 2016 8:31 pm

Exactly. There is also a transparent sprite on top of it (the aura-effect). This seems to hide the asteroids behind it. (Which are normal meshes.)

User avatar
VilleK
Site Admin
Posts: 2077
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Odd rendering errors on Android

Post by VilleK » Fri Sep 02, 2016 7:44 am

Can you please make a new small test project that shows this problem with as few components as possible and upload it here? I would greatly simplify for me when trying to debug this.

Imerion
Posts: 198
Joined: Sun Feb 09, 2014 4:42 pm

Re: Odd rendering errors on Android

Post by Imerion » Sun Sep 04, 2016 2:19 am

Here you go! This shows the same effect. Also, any other objects behind those auras seem to be hidden. Perhaps the problem is with the rendering order.

Thanks for helping me! :)
Attachments
GfxTest.zgeproj
(472.63 KiB) Downloaded 176 times

User avatar
VilleK
Site Admin
Posts: 2077
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Odd rendering errors on Android

Post by VilleK » Mon Sep 05, 2016 1:16 pm

I checked the ZGE sources and note that depthsorting is not implemented correctly for Android and I'm not sure when I have time to fix that.

If you still want this to work, I would try the following
1. Use the ANDROID define (it is defined when building for Android) to disable certain effects.
Example:

Code: Select all

if(!ANDROID)  //Only create halo when not on Android
  createModel(HaloModel);
2. Take advantage of the fact that the default render order in ZGE is based on categories. So if you keep your "background" models as category 0 then you can be certain they are rendered before any other categories. Then use larger Category values for foreground models.

There is possibly some other problems going on in that screenshot you posted. I'll see if I have time to test some more.

Imerion
Posts: 198
Joined: Sun Feb 09, 2014 4:42 pm

Re: Odd rendering errors on Android

Post by Imerion » Mon Sep 05, 2016 6:16 pm

I see. Thanks for having a look!

So if I re-sort things to use categories instead, transparent textures should work? In that case that shouldn't be a problem. :)

zondarg
Posts: 13
Joined: Fri Jan 01, 2016 12:17 pm

Re: Odd rendering errors on Android

Post by zondarg » Tue Sep 06, 2016 8:51 pm

I checked the ZGE sources and note that depthsorting is not implemented correctly for Android and I'm not sure when I have time to fix that.
..yes, this would be great... I noticed strange behaviour of transparent images when stacked, on Android only, on Windows it looks good.
Thanks for the workaround, I'll see if I can make use of it :)

User avatar
Ats
Posts: 277
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Odd rendering errors on Android

Post by Ats » Mon Jun 08, 2020 11:32 am

Where in the code can I investigate depthsorting for Android?
Because each time I release a PC and Android version, I remember why I had to make weird choices in order to make it kind of work on both versions... And it's not helping me advancing :roll:

User avatar
VilleK
Site Admin
Posts: 2077
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Odd rendering errors on Android

Post by VilleK » Mon Jun 08, 2020 1:10 pm

The depth sort is happening in ZApplication.pas, in procedure TZApplication.RenderModels.

The problem iirc is that these lines are not supported on GLES:

glGetFloatv(GL_PROJECTION_MATRIX, @Matrix);
glGetFloatv(GL_MODELVIEW_MATRIX, @TmpM);

Maybe Kjell has some knowledge that could help solve this?

User avatar
Kjell
Posts: 1731
Joined: Sat Feb 23, 2008 11:15 pm

Re: Odd rendering errors on Android

Post by Kjell » Mon Jun 08, 2020 1:25 pm

Hej Ville,
VilleK wrote:
Mon Jun 08, 2020 1:10 pm
The problem iirc is that these lines are not supported on GLES:

glGetFloatv(GL_PROJECTION_MATRIX, @Matrix);
glGetFloatv(GL_MODELVIEW_MATRIX, @TmpM);
Those calls are supported in ES 1.1, so that shouldn't be the problem ( since i think Ats is using "Compatible" GLBase ). Regardless, you should "route" those calls through GLDrivers.pas .. so that ES 2.0 uses GLDriverProgrammable / MPtrs.

K

User avatar
VilleK
Site Admin
Posts: 2077
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Odd rendering errors on Android

Post by VilleK » Tue Jun 09, 2020 7:56 am

Thanks Kjell.

@Ats: What happens if you change the code from this (line 690 in ZApplication.pas):

Code: Select all

  {$ifndef android}
  glGetFloatv(GL_PROJECTION_MATRIX, @Matrix);
  glGetFloatv(GL_MODELVIEW_MATRIX, @TmpM);
  Matrix := MatrixMultiply(TmpM,Matrix);
  {$else}
  Matrix := IdentityHmgMatrix;
  {$endif}
To simply this:

Code: Select all

  glGetFloatv(GL_PROJECTION_MATRIX, @Matrix);
  glGetFloatv(GL_MODELVIEW_MATRIX, @TmpM);
  Matrix := MatrixMultiply(TmpM,Matrix);
edit: Or update from github, I just made a new commit.

User avatar
Ats
Posts: 277
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Odd rendering errors on Android

Post by Ats » Tue Jun 09, 2020 10:39 am

It works perfectly. Thanks :)
Here's the new Android lib
Attachments
libzgeandroid.zip
(254.1 KiB) Downloaded 47 times

Post Reply