Odd rendering errors on Android

All topics about ZGameEditor goes here.

Moderator: Moderators

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.34 KiB) Viewed 11492 times
Screenshot_2016-09-01_14-35-05.png
Screenshot_2016-09-01_14-35-05.png (267.19 KiB) Viewed 11492 times

User avatar
VilleK
Site Admin
Posts: 2105
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: 2105
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.54 KiB) Downloaded 246 times

User avatar
VilleK
Site Admin
Posts: 2105
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: 319
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: 2105
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: 1740
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: 2105
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: 319
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
(253.21 KiB) Downloaded 120 times

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

Re: Odd rendering errors on Android

Post by Ats » Wed Mar 17, 2021 3:35 pm

Hi VilleK,
I'm experiencing a new bug on a new Android phone that my father bought recently. ZGE applications don't even open on it.
It's a Huawei mate 20 pro (LYA-L29).
I compiled the latest libzgeandroid.so, and it's working perfectly on other phones.

So I launched the ADB to see what's going on. Here's the result:

Code: Select all

03-17 15:52:28.393 13643 13643 E ZgeAndroid: /storage/emulated/0
03-17 15:52:28.393 13643 13643 E ZgeAndroid: /data/user/0/com.txori.omeganaut/files/
03-17 15:52:28.393 13643 13643 E ZgeAndroid: /data/user/0/com.txori.omeganaut/lib/
03-17 15:52:28.416 13643 13643 E ZgeAndroid: Found JNI_OnLoad function, calling now...
03-17 15:52:28.416 13643 13643 E ZgeAndroid: glDepthRange
03-17 15:52:28.417 13643 13643 E ZgeAndroid: glGenLists
03-17 15:52:28.417 13643 13643 E ZgeAndroid: glMateriali
03-17 15:52:28.417 13643 13643 E ZgeAndroid: glIndexMask
03-17 15:52:28.417 13643 13643 E ZgeAndroid: glListBase
03-17 15:52:28.417 13643 13643 E ZgeAndroid: glBegin
03-17 15:52:28.417 13643 13643 E ZgeAndroid: glCallList
03-17 15:52:28.418 13643 13643 E ZgeAndroid: glColor3f
03-17 15:52:28.418 13643 13643 E ZgeAndroid: glColor3fv
03-17 15:52:28.418 13643 13643 E ZgeAndroid: glColor4fv
03-17 15:52:28.418 13643 13643 E ZgeAndroid: glEnd
03-17 15:52:28.418 13643 13643 E ZgeAndroid: glColorMaterial
03-17 15:52:28.419 13643 13643 E ZgeAndroid: glDeleteLists
03-17 15:52:28.419 13643 13643 E ZgeAndroid: glDrawBuffer
03-17 15:52:28.419 13643 13643 E ZgeAndroid: glGetTexImage
03-17 15:52:28.419 13643 13643 E ZgeAndroid: glPolygonMode
03-17 15:52:28.419 13643 13643 E ZgeAndroid: glPopAttrib
03-17 15:52:28.419 13643 13643 E ZgeAndroid: glPushAttrib
03-17 15:52:28.419 13643 13643 E ZgeAndroid: glRasterPos2f
03-17 15:52:28.419 13643 13643 E ZgeAndroid: glTexCoord2f
03-17 15:52:28.419 13643 13643 E ZgeAndroid: glVertex2f
03-17 15:52:28.419 13643 13643 E ZgeAndroid: glVertex3f
03-17 15:52:28.419 13643 13643 E ZgeAndroid: glTexGeni
03-17 15:52:28.421 13643 13643 E ZgeAndroid: glTexImage2DMultisample
03-17 15:52:28.421 13643 13643 E ZgeAndroid: File missing: /data/user/0/com.txori.omeganaut/files/config.dat
03-17 15:52:28.421 13643 13727 E ZgeAndroid: audiocallback started
03-17 15:52:28.423 13643 13643 E ZgeAndroid: JNI_OnLoad
03-17 15:52:28.426 13643 13643 E ZgeAndroid: Found JNI_OnLoad function, calling now...
03-17 15:52:28.440 13643 13643 E ZgeAndroid: CPUs: 8
03-17 15:52:28.445 13643 13643 E ZgeAndroid: JNI_OnLoad
03-17 15:52:28.598 13643 13643 E ZgeAndroid: GLBase: 1.1
03-17 15:52:28.634 13643 13751 E ZgeAndroid: Found JNI_OnLoad function, calling now...
03-17 15:52:28.635 13643 13751 E ZgeAndroid: glDepthRange
03-17 15:52:28.636 13643 13751 E ZgeAndroid: glGenLists
03-17 15:52:28.636 13643 13751 E ZgeAndroid: glMateriali
03-17 15:52:28.636 13643 13751 E ZgeAndroid: glIndexMask
03-17 15:52:28.636 13643 13751 E ZgeAndroid: glListBase
03-17 15:52:28.636 13643 13751 E ZgeAndroid: glBegin
03-17 15:52:28.636 13643 13751 E ZgeAndroid: glCallList
03-17 15:52:28.637 13643 13751 E ZgeAndroid: glColor3f
03-17 15:52:28.637 13643 13751 E ZgeAndroid: glColor3fv
03-17 15:52:28.638 13643 13751 E ZgeAndroid: glColor4fv
03-17 15:52:28.638 13643 13751 E ZgeAndroid: glEnd
03-17 15:52:28.638 13643 13751 E ZgeAndroid: glColorMaterial
03-17 15:52:28.638 13643 13751 E ZgeAndroid: glDeleteLists
03-17 15:52:28.638 13643 13751 E ZgeAndroid: glDrawBuffer
03-17 15:52:28.638 13643 13751 E ZgeAndroid: glGetTexImage
03-17 15:52:28.638 13643 13751 E ZgeAndroid: glPolygonMode
03-17 15:52:28.638 13643 13751 E ZgeAndroid: glPopAttrib
03-17 15:52:28.638 13643 13751 E ZgeAndroid: glPushAttrib
03-17 15:52:28.639 13643 13751 E ZgeAndroid: glRasterPos2f
03-17 15:52:28.639 13643 13751 E ZgeAndroid: glTexCoord2f
03-17 15:52:28.639 13643 13751 E ZgeAndroid: glVertex2f
03-17 15:52:28.639 13643 13751 E ZgeAndroid: glVertex3f
03-17 15:52:28.639 13643 13751 E ZgeAndroid: glTexGeni
03-17 15:52:28.651 13643 13751 E ZgeAndroid: glTexImage2DMultisample
--------- beginning of crash
Do you have an idea what might happen?

(It's even crashing with old ZGE android tests)



Edit:

The only occurence of glTexImage2DMultisample in ZGE is in ZOpenGL.pas line 1481
glTexImage2DMultisample : procedure(target: GLenum; samples: GLsizei; internalformat: GLint; width: GLsizei; height: GLsizei; fixedsamplelocations: GLboolean); {$IFDEF WIN32}stdcall; {$ELSE}cdecl; {$ENDIF}

While the glTexImage2DMultisample internet definition state:
void glTexImage2DMultisample( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);

Could that be related?

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

Re: Odd rendering errors on Android

Post by VilleK » Thu Mar 18, 2021 8:50 am

If you try building an empty ZGE app, or with just a "trace("test");" in OnLoaded does it work?

What are the crash messages?

Post Reply