Issues with Sun and Distant light

Use this forum for general user support and related questions.
Post Reply
CodeHD
Posts: 126
Joined: Tue Dec 11, 2018 12:38 pm

Issues with Sun and Distant light

Post by CodeHD » Tue Feb 26, 2019 10:59 pm

I was just playing around with glass and caustics and noticed the following two things with Sun and Distant light:

Setup (.blend attached):
- Diffuse Plane
- Glass Cylinder vertically above
- Sun source shining down vertically.
- BiDir of course for the caustics, any sampler
- v2.2alpha0 and a late 2.1 daily build

Issue #1:
The cylinder shouldn't cause much attenuation of light as the Sunlight is passing throgh 2 perpendicular surfaces. A bit darker underneath maybe due to Fresnel reflections sending some light back.

With the default Sun this looks as expected:
Sun_size1_BiDir.png
With the relative size set to 0.1, the circle underneath becomes brighter than the plane
Sun_size0p1_BiDir.png
With the distant source, this behaviour seems a bit worse, being visible at a size (half angle) of 0.25 degree, like the Sun.
Distant_size0p25_BiDir.png
Issue #2:
In the image with the distant source, notice how the plane gets darker away from the camera. This shouldn't be the case for a matte surface illuminated homogeneously.

Observations:
- Only happens with BiDir, not Path
- Independent of sampler and its settings.
- Only happens with distant, not Sun
Attachments
DistantSource.blend
(537.98 KiB) Downloaded 15 times

CodeHD
Posts: 126
Joined: Tue Dec 11, 2018 12:38 pm

Re: Issues with Sun and Distant light

Post by CodeHD » Sun Apr 28, 2019 11:58 am

This issue is still open in the latest daily build.

I just played around with issue #2 from my previous post again, there is also an issue with BiDir and the Sun lamp, not just distant. It just wasn't apparent to me in my earlier example scene.

(I could use it as another project to get familir with the code, but again I can't judge if it is something I will be able to crack down quickly...)

Fox
Posts: 228
Joined: Sat Mar 31, 2018 11:17 am

Re: Issues with Sun and Distant light

Post by Fox » Mon Apr 29, 2019 12:00 am

i tested, this is not reflection, but transmission.
It looks like when i enable only red, or only green, or only blue transmission, then it's not brighter.

See that threat viewtopic.php?f=4&t=808&start=10

Can it be related, no issue with mesh emitter of same brightness?

With BiDirVM and random, 300sp
Color MiauMiau.jpg
Gray MiauMiau.jpg
This one is too BiDirVmCpu.jpg

User avatar
Dade
Developer
Developer
Posts: 2383
Joined: Mon Dec 04, 2017 8:36 pm

Re: Issues with Sun and Distant light

Post by Dade » Mon Apr 29, 2019 9:04 am

CodeHD wrote:
Tue Feb 26, 2019 10:59 pm
Issue #1:
The cylinder shouldn't cause much attenuation of light as the Sunlight is passing throgh 2 perpendicular surfaces. A bit darker underneath maybe due to Fresnel reflections sending some light back.
This is a numerical precision problem. If you check the code: https://github.com/LuxCoreRender/LuxCor ... ht.cpp#L40

The sun radius, scaled by the relative size, is divided by earth<->sun distance to compute the sine of the angle. Because of your scale factor, it is a small number divided by a very big one. The number is than squared to compute the sine square and becomes even smaller.

Than, to compute the cosine:

Code: Select all

cosThetaMax = sqrtf(1.f - sin2ThetaMax);
At this point, the cosine of the angle is 1.0 while the sine is > 0.0 and this is clearly very wrong. This happens because: "1.f - sin2ThetaMax" is 1.0 with floating point numbers and square root of 1.0 is 1.0.

Short version: relative size was never intended to be used for values <1.0 so I'm now capping the value to be always >= 1.0. the sun is already large as a pixel at is real world size.

I will check the other issue.
Support LuxCoreRender project with salts and bounties

CodeHD
Posts: 126
Joined: Tue Dec 11, 2018 12:38 pm

Re: Issues with Sun and Distant light

Post by CodeHD » Mon Apr 29, 2019 9:52 am

Dade wrote:
Mon Apr 29, 2019 9:04 am
This is a numerical precision problem. If you check the code: https://github.com/LuxCoreRender/LuxCor ... ht.cpp#L40

[...]

Short version: relative size was never intended to be used for values <1.0 so I'm now capping the value to be always >= 1.0. the sun is already large as a pixel at is real world size.

[...]
Thanks for checking it out!
It sound to me though as if the problem you describe is specific to the sun lamp. I do not see equivalent code in the distant light, which suffers from the same problem.

I personally don't see a problem with size being limited for the Sun-type lamp (why not even remove it entirely?). After all, distant should provide the same features for simulation of optical phenomena.
It would be a shame to not have any source that can be smaller than the Sun, but I don't think that is what you meant to say anyways, since you only spoke of the Sun (?)
(sorry if this is already what you meant by you will check out the other issue)

User avatar
Dade
Developer
Developer
Posts: 2383
Joined: Mon Dec 04, 2017 8:36 pm

Re: Issues with Sun and Distant light

Post by Dade » Mon Apr 29, 2019 10:21 am

CodeHD wrote:
Mon Apr 29, 2019 9:52 am
I personally don't see a problem with size being limited for the Sun-type lamp (why not even remove it entirely?). After all, distant should provide the same features for simulation of optical phenomena.
The relative size parameter was originally intended to be used as an artistic tool in order to exaggerate and render some "dramatic" sunset like:

Image
Support LuxCoreRender project with salts and bounties

User avatar
epilectrolytics
Donor
Donor
Posts: 310
Joined: Thu Oct 04, 2018 6:06 am

Re: Issues with Sun and Distant light

Post by epilectrolytics » Mon Apr 29, 2019 10:58 am

If someone would want to render a Jupiter moon scenery a smaller relative sun size might be desired...
MBPro 15" 16GB i7-4850HQ GT750M, MacOS 10.13.6 & Win10Pro PC 16GB Ryzen 2700X, RTX 2070, GTX 1060

User avatar
B.Y.O.B.
Developer
Developer
Posts: 2505
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: Issues with Sun and Distant light

Post by B.Y.O.B. » Mon Apr 29, 2019 12:14 pm

epilectrolytics wrote:
Mon Apr 29, 2019 10:58 am
If someone would want to render a Jupiter moon scenery a smaller relative sun size might be desired...
You should use the distant light for this. The sun lamp includes simulation of the earth's atmosphere, you would not have this around Jupiter.
The sun lamp is only useful if you need sunlight in a scene located on the earth (behind earth's atmosphere). For everything else you should use distant light (e.g. rendering the ISS over earth, because it's outside the atmosphere).

By the way, you can make pictures like the one linked by Dade purely with relsize = 1. You just need to replicate the camera paremeters used, e.g. use a tele lens (large focal length like 600 mm).
It's purely an artistic parameter for cases where you want a shorter focal length for some reason, but still need a big sun.

Another use case: larger relsize can also be useful to simulate a slightly overcast sky (it makes the shadows softer).
Support LuxCoreRender project with salts and bounties

User avatar
Dade
Developer
Developer
Posts: 2383
Joined: Mon Dec 04, 2017 8:36 pm

Re: Issues with Sun and Distant light

Post by Dade » Mon Apr 29, 2019 12:30 pm

B.Y.O.B. wrote:
Mon Apr 29, 2019 12:14 pm
Another use case: larger relsize can also be useful to simulate a slightly overcast sky (it makes the shadows softer).
A large rel. size parameter can also be used to alleviate caustics fireflies with path tracing (it makes easier for a path to hit the sun) :idea:
Support LuxCoreRender project with salts and bounties

Post Reply