BASIC

Author Topic: X_AMBIENT_LT observations and tips.  (Read 9065 times)

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1579
  • Particle Hawk
    • View Profile
X_AMBIENT_LT observations and tips.
« on: 2012-Jul-01 »
Hi gang,

I just made an interesting dicovery about the glbasic ambient light system.
Not only does it rotate inversely, it rotates double of the rotation of the cam.
In the screnshot below you can see the ambient light on the right side of the sphere.
That light is fixed to that vector no matter which way the camera turns.
Also you can observe my spotlights shining to the top of the object.
No matter which way the cam turns, the light is fixed to the camera view of the object.

Note: X_AMBIENT_LT may not function like this in the future, as it may change due to updates in V11.


EDIT: The solution for proper looking ambient light, can be emulated with GLBasic:
Code: GLBasic [Select]
        IF Ambient
                X_SPOT_LT 1, 0xffffff, cx,cy,cz,-cx,-cy,-cz, 360
        ENDIF

This is proper looking, yet, it is not really ambient light...it is emulated.

This image below shows how glbasic is using the x_ambient currently without any code fixes.

[attachment deleted by admin]
« Last Edit: 2012-Oct-28 by Hemlos »
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline kanonet

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1142
    • View Profile
    • My GLBasic code archiv
Re: X_AMBIENT_LT observations and tips.
« Reply #1 on: 2012-Jul-01 »
Which just proves me right: ambient light is totally broken. Per definition an ambient light should shine from all sides/angles with the same intensity. So if X_AMBIENT_LT shines just from one side, its working wrong, obviously.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1579
  • Particle Hawk
    • View Profile
Re: X_AMBIENT_LT observations and tips.
« Reply #2 on: 2012-Jul-01 »
if you face the object from positive Z, toward negative Z....one time....
Then turn off the light by not calling, it will make all objects with the light facing the camera.
Essentially giving you the effect you described.

« Last Edit: 2012-Jul-01 by Hemlos »
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4147
    • View Profile
    • Portfolio
Re: X_AMBIENT_LT observations and tips.
« Reply #3 on: 2012-Jul-01 »
Maybe it is not a bug?
But a way to control the ambient light on which direction it should light globally? (or which direction it should not light)
It makes sense to me, only, if some sort of fast occlusion shader or raytrace per object is going on.

Since a per object occlusion will usually light it all around, maybe having a forced no light from down to up could actually make sense that the object is on an environment, like ground, as it will not be lighted too much under to the point it looks realistic in place.

Quite similar to a global image illumination, where the image has half up lit and half down not, degrade wise. 

That way, theoretically, you can keep things more realistic?

This is just a general idea, I never ever strived too deep into GLB 3d to actually know anything about. :P
I doubt I made any sense at all on what I wrote :(

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1579
  • Particle Hawk
    • View Profile
Re: X_AMBIENT_LT observations and tips.
« Reply #4 on: 2012-Jul-01 »
A bug IMO too.

1. You cant turn it off.
2. And worse...if you change the color, the orientation of the ambient light will be different according to the camera vector.
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline kanonet

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1142
    • View Profile
    • My GLBasic code archiv
Re: X_AMBIENT_LT observations and tips.
« Reply #5 on: 2012-Jul-01 »
I dont know what GLB does internally, but i guess it just pins a spotlight with cutoff 180 at the camera, pointing at direction of camera vector. So this is obviously no ambient light, just a fake. If you use this to get the effect that you described, you just use a bug, that works now, but may get fixed in the future. Just use a X_SPOT_LIGHT with cutoff 180 and you get exactly the same.
Btw. A real opengl ambient light gets calculated faster than a (faked one with) spotlight, cuz it doesnt have a position, nor a direction and it ignores normals.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1579
  • Particle Hawk
    • View Profile
Re: X_AMBIENT_LT observations and tips.
« Reply #6 on: 2012-Jul-01 »
Yup youre right, this method is using a bug.
In the current state of x_ambient light, you cant turn it off.
So if you need to turn it off at some point, dont turn it on in the first place!


Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline kanonet

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1142
    • View Profile
    • My GLBasic code archiv
Re: X_AMBIENT_LT observations and tips.
« Reply #7 on: 2012-Jul-01 »
Hmm i just tested a real ambient light from my light fixes and its the same, if you activate it once its stays activated - which shows me, that i always used ambient light wrong, you dont need to call it every loop, just call it one time.

Of cause you can deactivate both easily, just call them with the color RGB(0,0,0).
EDIT: RGB(0,0,0) will 'turn off' our ambient light - but before you set one, it is activated and set to a standard value that is something brighter than black, someone need to figure out what it is, so you can turn back to 'normal'.
« Last Edit: 2012-Jul-01 by kanonet »
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1579
  • Particle Hawk
    • View Profile
Re: X_AMBIENT_LT observations and tips.
« Reply #8 on: 2012-Jul-01 »
Again, thats using some sort of bug.

Keep in mind, you will need to realign the camera, if you want to turn it back on.
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline kanonet

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1142
    • View Profile
    • My GLBasic code archiv
Re: X_AMBIENT_LT observations and tips.
« Reply #9 on: 2012-Jul-01 »
Which is just an other point why you should not use this bug, but just use a spot light with cutoff 180 - you get same effect, but can change it/turn it off any time without problems.

Btw plz. see my edit in last post.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Offline Xaron

  • Mr. Drawsprite
  • **
  • Posts: 50
    • View Profile
    • CodeKnitters
Re: X_AMBIENT_LT observations and tips.
« Reply #10 on: 2012-Oct-04 »
Which just proves me right: ambient light is totally broken. Per definition an ambient light should shine from all sides/angles with the same intensity. So if X_AMBIENT_LT shines just from one side, its working wrong, obviously.

Is that still the case?

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1579
  • Particle Hawk
    • View Profile
Re: X_AMBIENT_LT observations and tips.
« Reply #11 on: 2012-Oct-04 »
I believe this command still functions the same way.
There was a very brief discussion about this, and it turned out to be an intentional thing.
However, the notion that it would be fixed to work proper in V11 was mentioned.
If this is already done or not in v11, i do not know, i dont have that version.


I use this function with my camera, to emulate ambient light, a mediocre fix at best:


Code: GLBasic [Select]
        IF Ambient
                X_SPOT_LT 1, 0xffffff, cx,cy,cz,-cx,-cy,-cz, 360
        ENDIF
« Last Edit: 2012-Oct-04 by Hemlos »
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline kanonet

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1142
    • View Profile
    • My GLBasic code archiv
Re: X_AMBIENT_LT observations and tips.
« Reply #12 on: 2012-Oct-04 »
As far as I know this did not get fixed till now, ambient light is still faked by using a spot light just like Hemlos did. I did send Gernot code how to make a proper light, but I did not get an answer, so I dont know if he will implement it or not.

If you want to try my fixes you can find them here: http://www.kanonet.de/downloads/lightsfixes
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Offline mentalthink

  • Prof. Inline
  • *****
  • Posts: 3341
  • Integrated Brain
    • View Profile
Re: X_AMBIENT_LT observations and tips.
« Reply #13 on: 2012-Oct-04 »
Hi Kano, thanks for this library... I have to try when I have free time...

I think this it´s very Usefull!!!

Regards,

Offline sf-in-sf

  • Mr. Drawsprite
  • **
  • Posts: 93
  • Artist F.P. Brixey
    • View Profile
    • My computed art project
Re: X_AMBIENT_LT observations and tips.
« Reply #14 on: 2013-May-09 »
Same for me here. I tried the donut with only a blue ambient light, and it's clear that the lighting is next to the camera. The shadows shouldn't exist and they are way too dark.
Who knows a good reference/tutorial for the direct openGL calls like
glNewList(2, GL_COMPILE)
glColor3f(0.0, 1.0, 0.0)
glTexCoord2f(   0,    0)
glVertex3f( -50,  80, 0)
glCallList(2)  ..........................etc? Thank you!

(quoted from testOGL on this forum)
« Last Edit: 2013-May-09 by sf-in-sf »
On the day the atom is a cube I will start believing in the square pixel.