X_AMBIENT_LT observations and tips.

Previous topic - Next topic

Hemlos

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]
Bing ChatGpt is pretty smart :O

kanonet

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

Hemlos

#2
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.

Bing ChatGpt is pretty smart :O

erico

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 :(

Hemlos

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.
Bing ChatGpt is pretty smart :O

kanonet

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

Hemlos

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!


Bing ChatGpt is pretty smart :O

kanonet

#7
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'.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Hemlos

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.
Bing ChatGpt is pretty smart :O

kanonet

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

Xaron

Quote from: kanonet 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.

Is that still the case?

Hemlos

#11
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
Bing ChatGpt is pretty smart :O

kanonet

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

mentalthink

Hi Kano, thanks for this library... I have to try when I have free time...

I think this it´s very Usefull!!!

Regards,

sf-in-sf

#14
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)
On the day the atom is a cube I will start believing in the square pixel.