Drawing objects with no light influence?

Previous topic - Next topic

nabz32

Hi I want to rewrite my drawing routine, so that all drawable 3D Objects are sorted by the distance to the camera first and then drawn in that order.
Mainly I wanted to improve the rendering on android, to avoid some of the z-buffer problematic.

In the old draw routine I drew objects without light influence before light was enabled,
but if I sort every drawable object by its camera distance, I have to find some other way to disable light for certain objects.

Can light be turned off and on again for not lighting affected objects?

Kitty Hello

Yes. Just set a spotlight with opeming angle=0.

nabz32

#2
K thx. :good:
This should also erase my transparency Problems with non light affected objects

kanonet

Actually enabling and disabling light for every 2nd object can cost you quite some performance. I would instead sort all non light object draw them, draw lights and then draw all light objects.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

nabz32

#4
Hm good Call kanonet.
This was the way i did it before.
With this method objects without light have can not know objects behind them if they are transluscent
Edit: also the android zbuffer problem would still remain unsolved for my project..
Maybe I could brighten objects using a shader?

kanonet

GLBasic is stuck on GLES 1.1 on mobiles, so no shaders for you.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

spacefractal

IS GLES 1.1 actuelly used today? Im mean most, if not all today, support newer versions. so its should been just in time to support GLES 2.X as least without penaty and might fix issues like those.

Also its seen OpenGL and GLES do have some differens.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

matchy

What exactly is the lighting issue? I mean post a screenshot example!

What I did to try and solve, from an existing game, the lack of zbuffering on Android was draw the objects in the view sector, scanning radius left to right inwards.

nabz32

@Matchy:
Basically the problem results from the solution method you used for the not working z-buffer.
When sorting all objects this way before drawing and some objects should not use light but others do,
I have to turn out the lights for those objects, turn it on again for others, etc.
The problem is that switching the lights on and off again and again will be quite costy on the performance.

@kanonet:
So no shaders on mobile because only GLES 1.1 is supported, thats pretty hard to work around.

I will focus on the PC Version then and hope the z-buffer issue will be resolved someday.
By the way the same z-buffer strangeness can occur when running the wrong gpu drivers on the Pandora.
Maybe the Z-Buffer is addressed incorrectly for the Android OS GPU drivers?

kanonet

Spacefractal GLBasic update to GLES2 will not happen, because this is not backward compatible to GLES1.1, so the complete Engine would need to be rewritten in shaders. GLBasic uses old fixed function stuff on all platforms, rewriting it would probably the biggest project in history of GLBasic. I dont think Gernot has time for this and probably also not enough experience with modern OpenGL.
But maybe he could create a GLES2 context and then use his old graphic engine with the help of Regal or one if its forks.

Nabz when disabling lights, you could try the OpenGL wrapper and directly call glEnable/glDisable(GL_LIGHTING), this should be faster, than enabling/disabling each individual lights manually. In the end you need to simply test it, to tell if any approach works for you.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

spacefractal

iOS version use OpenGL as im remember, so this could been possible to use Regal.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

nabz32

Thx Kanonet, I will try this. :good:

nabz32

#12
There are no noticable performance issues with this,
at least while trying it with the PC version.

Here is the code if anyone is interested how to do this in detail:

Code (glbasic) Select

INLINE
    };  // close GLBasic namespace

    extern "C"{
    void __stdcall glEnable( int );
    void __stdcall glDisable( int );
    }
        #define GL_LIGHTING 0xB50  // <- this took me long to find (-;
    namespace __GLBASIC__ {         // open GLBasic namespace

ENDINLINE

FUNCTION switchAllLights: on%
INLINE
    if( on == true ) glEnable(GL_LIGHTING) ;
    else glDisable(GL_LIGHTING);
ENDINLINE
ENDFUNCTION



kanonet

That's what I was talking about. How does it work on Pandora?
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64