cdev-tux / q3lite

Q3lite, an OpenGL ES port of Quake III Arena for embedded Linux systems.
GNU General Public License v3.0
93 stars 16 forks source link

Portals and mirrors #9

Closed emileb closed 5 years ago

emileb commented 5 years ago

Any idea why the portals and mirrors have HOM effect on GLES1? Testing on Android devices. Looking to fix myself but just checking if you a hint as to the reason? Thanks!

cdev-tux commented 5 years ago

You can see through portals and mirrors by turning off ‘r_fastsky’ (r_fastsky=0). There’s a workaround mentioned in the included autoexec.cfg file.

https://github.com/cdev-tux/q3lite/blob/dev/misc/q3lite/autoexec.cfg#L547

There’s a performance hit associated with turning r_fastsky off, so that’s why it’s on by default. It may be possible to modify the GLES renderer to render portals and mirrors differently, but that’s currently beyond my programming ability. It’s also possible that there’s a bug in the renderer or some missing code that prevents this from working as it does on OpenGL.

emileb commented 5 years ago

Thank you very much for the quick reply! OK it seems r_fastsky was already 0, when I turn it on the mirror goes black instead (as expected). This is actually a rendering issue it seems, BUT I have just tested on another device and it works OK so there is something which the first device does not support, or behaves differently somehow. Now I have a working example I can try and find the difference. Will let you know if there is any fix in the code. Thanks again.

emileb commented 5 years ago

OK, I think this may be the issue: https://issuetracker.google.com/issues/36983742 Possible bug in this device GPU swapping the clip plane axis. Just need to find the magic formular to swap the equation around.

cdev-tux commented 5 years ago

You might have some luck playing around with the code in this section to see if it changes anything.

https://github.com/cdev-tux/q3lite/blob/dev/code/renderergles1/tr_backend.c#L474

Also, searching the source code for these terms may point you to the relevant code.

https://github.com/cdev-tux/q3lite/blob/dev/code/renderergles1/tr_local.h#L469-L470

Hope that helps.

emileb commented 5 years ago

Hi, Yes you were correct, this was the fix:

Remove clip plan code https://github.com/emileb/q3lite/blob/a03ea6fcabf5a3816cc0264cc73bbbd801a1a920/code/renderergles1/tr_backend.c#L478

And then: https://github.com/emileb/q3lite/blob/a03ea6fcabf5a3816cc0264cc73bbbd801a1a920/code/renderergles1/tr_main.c#L997

It wasn't my fix, I found it in another implementation. Looks like they reimplemented the equivilent clip plane using znear. I don't think this fix is necessary for this repo as it's only needed for a subset of Android devices. Thanks again for getting back, much appreciated!

cdev-tux commented 5 years ago

Great, glad that you were able to get it working.