Author Topic: Drawing objects with no light influence?  (Read 4187 times)

Offline nabz32

  • Community Developer
  • Dr. Type
  • ******
  • Posts: 307
    • View Profile
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?

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10713
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Drawing objects with no light influence?
« Reply #1 on: 2016-Jun-17 »
Yes. Just set a spotlight with opeming angle=0.

Offline nabz32

  • Community Developer
  • Dr. Type
  • ******
  • Posts: 307
    • View Profile
Re: Drawing objects with no light influence?
« Reply #2 on: 2016-Jun-17 »
K thx. :good:
This should also erase my transparency Problems with non light affected objects
« Last Edit: 2016-Jun-17 by nabz32 »

Offline kanonet

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1142
    • View Profile
    • My GLBasic code archiv
Re: Drawing objects with no light influence?
« Reply #3 on: 2016-Jun-18 »
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

Offline nabz32

  • Community Developer
  • Dr. Type
  • ******
  • Posts: 307
    • View Profile
Re: Drawing objects with no light influence?
« Reply #4 on: 2016-Jun-20 »
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?
« Last Edit: 2016-Jun-20 by nabz32 »

Offline kanonet

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1142
    • View Profile
    • My GLBasic code archiv
Re: Drawing objects with no light influence?
« Reply #5 on: 2016-Jun-28 »
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

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3678
    • View Profile
    • Space Fractal
Re: Drawing objects with no light influence?
« Reply #6 on: 2016-Jun-29 »
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.
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline matchy

  • Prof. Inline
  • *****
  • Posts: 1543
    • View Profile
Re: Drawing objects with no light influence?
« Reply #7 on: 2016-Jul-01 »
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.

Offline nabz32

  • Community Developer
  • Dr. Type
  • ******
  • Posts: 307
    • View Profile
Re: Drawing objects with no light influence?
« Reply #8 on: 2016-Jul-03 »
@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?

Offline kanonet

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1142
    • View Profile
    • My GLBasic code archiv
Re: Drawing objects with no light influence?
« Reply #9 on: 2016-Jul-12 »
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

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3678
    • View Profile
    • Space Fractal
Re: Drawing objects with no light influence?
« Reply #10 on: 2016-Jul-12 »
iOS version use OpenGL as im remember, so this could been possible to use Regal.
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline nabz32

  • Community Developer
  • Dr. Type
  • ******
  • Posts: 307
    • View Profile
Re: Drawing objects with no light influence?
« Reply #11 on: 2016-Jul-12 »
Thx Kanonet, I will try this. :good:

Offline nabz32

  • Community Developer
  • Dr. Type
  • ******
  • Posts: 307
    • View Profile
Re: Drawing objects with no light influence?
« Reply #12 on: 2016-Aug-31 »
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

 
« Last Edit: 2016-Aug-31 by nabz32 »

Offline kanonet

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1142
    • View Profile
    • My GLBasic code archiv
Re: Drawing objects with no light influence?
« Reply #13 on: 2016-Sep-13 »
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