Author Topic: HDRI/Environment sampling causing Shadow artefacts  (Read 6733 times)

2022-02-28, 16:19:45

Phasma

  • Active Users
  • **
  • Posts: 112
    • View Profile
Hello.

I made a little test regarding HDRI Sampling and shadow casting as a collegue of mine always reports some issues in this regard. If Corona Sun/Sky is rendered, you get blurry 'bokeh' looking shadows casted. with an HDRI however the shadows appear pixelated. I tried different environment sampling options and it seems that nothing is changing this. I guess it is some kind of bug but I hope I'm wrong here. so If anyone could help/fix, it would be nice.

here is a comparison:

https://cloud.morietbrro.com/f/e3f83fea69b4421c820b/


2022-02-28, 16:31:17
Reply #1

hurrycat

  • Active Users
  • **
  • Posts: 111
    • View Profile
Do you get the same result with different HDRI Maps? Poly Haven is a good source.

2022-02-28, 16:40:12
Reply #2

Phasma

  • Active Users
  • **
  • Posts: 112
    • View Profile
yes. it is a general HDRI sampling thing. It is of course much more pronounced if there is a high contrast/sunny situation with real dynamic range (unclipped full dynamic range) and not just some ldr hdri.

2022-02-28, 17:45:25
Reply #3

pokoy

  • Active Users
  • **
  • Posts: 1850
    • View Profile
I guess the cause is a low-res HDR and what you see there is the effect of a pixel (or a rectangular area) being the main light source. Similar to how a camera works, the window acts as a lens and the shadows produce the blurry effect based on the shape of the light source, which is a circle. Similar to how shadow highlights get a crescent shape during a sun eclipse. So probably not a bug but rather the effect of accurate light simulation, and a low res HDR.

2022-02-28, 18:03:09
Reply #4

Phasma

  • Active Users
  • **
  • Posts: 112
    • View Profile
I now testet multiple HDRI's. our own 20k ones, but also 16k polyheaven hdri's. the effect with the polyheaven is still there, however they are a lot less intense and far away from beeing realistic reg. exposure range/colors. so all hdri's do this and the effect also gets more intense as resolution increases. in lowres the effect is more blurry and gets less 'edgy'

https://cloud.morietbrro.com/f/0e19aa371f8748e0bf3f/

left is sun/sky, right is an unrealistic polyheaven hdri
« Last Edit: 2022-02-28, 18:08:19 by Phasma »

2022-02-28, 19:35:33
Reply #5

pokoy

  • Active Users
  • **
  • Posts: 1850
    • View Profile
Things you could try is to disable adaptive enviro sampler, or check whether different filter setting in the bitmap/HDR map help.

2022-02-28, 19:35:53
Reply #6

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8779
  • Let's move this topic, shall we?
    • View Profile
    • My Models
I don't see what's wrong in your last comparison, it looks normal to me. Of course, it's not realistic to expect same fidelity from limited resolution HDRI than you get from matematically perfect Corona sun. That's why you need filterring - to blur out those jagged pixels. My guess is that you turned down filterring blurring to absolute minimum, or even completely disabled it in the first example and that what's give you that unwanted result. Or it could be that that particular HDRI is flawed, or non-standard - there were cases when Corona bitmap couldn't handle some HDRIs properly, but usually after you provide such HDRI example to the team, they are able to fix something in the code and the issue would be gone.
I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2022-03-01, 10:42:50
Reply #7

Phasma

  • Active Users
  • **
  • Posts: 112
    • View Profile
Hi. thanks for all the input.

I tried all bitmap filtering options as well as all environment sampling options together now in a test scene. also testing out coronabitmaps and standard bitmap textures. nothing works.

this time I try to give you better insights of the test setup:

This test scene has a perforated part with some holes in it. the shadow on the inside wall is recorded by one camera, the sun is recorded also directly.

note that the hdri is 20k in size. the sun disk is perfectly round and has lots of pixel to be drawn round. the corona sun is obviously sharper but that does not explain why the shadows are square. suns are round, holes are round so shadows need to be as well for the hdri. examples below are all with default filtering and blur 1.0 - if I blur more, see the last image of still rectangular shadows - something here is really strange.

« Last Edit: 2022-03-01, 11:17:43 by Phasma »

2022-03-01, 11:30:58
Reply #8

pokoy

  • Active Users
  • **
  • Posts: 1850
    • View Profile
By environment sampler I meant the 'Adaptive Light solver', sorry for the confusion.

I tested this here, too, with a Corona Sun, an HDR (8Kx4K, Bitmap and CBitmap with both spherical and dome mode) and even a crescent shape with a Light Mtl, all aligned to produce the shadow in the same exact spot. Two holes in a box, one round, the other square shaped, same size... it works correctly, even the crescent shape producing (almost) same result for both holes, correctly picking up the light source shape.

I wonder if this has to do with units (mine are set to meters) but why should it matter.
Also, as this has helped others in similar weird cases, maybe reset Corona settings.

Other than that, I have no idea, a dev might have some more insight here.

I could imagine having your repro scene that produces wrong results would be good to have for others to test.

2022-03-01, 11:45:58
Reply #9

Phasma

  • Active Users
  • **
  • Posts: 112
    • View Profile
Hello

I also tried disabeling the Adaptive Light solver, no change

When it comes to the test scene: make sure the shadow casting is far away from the holes (and make the holes small). This is all about blurry shadows not beeing rendered correctly (such as outside trees casting nice fluffy shadows on interior walls) - in general the shadow casting works as expected. the blurrier the shadows get however, the more square they get as well. this is not happening with a corona sun that produces nice, almost - background out of focus 'bokeh' - like shadows. I would really like to see this with HDRI's as well

2022-03-01, 12:25:44
Reply #10

pokoy

  • Active Users
  • **
  • Posts: 1850
    • View Profile
That's why I said you should provide your repro scene so people/devs have the right setup.

I can confirm it - with tiny holes I'm seeing it, too. Sun and Crescent shape with LightMtl still work fine, but the HDR produces a rectangular light spot.

A workaround you probably thought about yourself already would be to clamp the HDR (so the HDR only produces ambient light but not sunlight) and place a Corona Sun in the same spot. I guess probably wanted to avoid that, it's making it all more cumbersome.

2022-03-01, 12:58:26
Reply #11

Phasma

  • Active Users
  • **
  • Posts: 112
    • View Profile
That's why I said you should provide your repro scene so people/devs have the right setup.

sorry - the scene itself would not be an issue. but the hdri itself and the creation of it is something bigger that i can not just give away atm. so i might only upload the scene then...

good that you can confirm it now. I also tested the HDRI mapped on a sphere now and this seems to work fine - however it renders a loooot longer and therefore is no excaptable workaround.

So I guess this is some kind of bug/limitation and I would kindly ask to fix it please :-) - We are planning to make a whole hdri/light/camera system commercially avalible and the hdris that we scan ourselves should be spot on in corona as well (yes, the cromatic aberations will be removed for the sun :-) )

2022-03-02, 13:49:54
Reply #12

Phasma

  • Active Users
  • **
  • Posts: 112
    • View Profile
Works in fStorm...


2022-03-03, 12:00:13
Reply #13

silverprop

  • Users
  • *
  • Posts: 1
    • View Profile
UP!
I want to see some dev. involvement. I have had this exact same issue before, specially noticeable in interior images when using image base lighting only. It would be nice not having to resort to cumbersome workarounds (Im already cutting holes into my backplates to let the sun pass in order to avoid shader artifacts on reflective objects...).

2022-03-09, 17:45:02
Reply #14

Phasma

  • Active Users
  • **
  • Posts: 112
    • View Profile
Still no reaction from the devs? I kinda think it is sad, that such an everyday thing like area shadows do not work properly in Corona....

2022-03-24, 15:53:36
Reply #15

Phasma

  • Active Users
  • **
  • Posts: 112
    • View Profile

2022-03-25, 09:06:19
Reply #16

GeorgeK

  • Corona Team
  • Active Users
  • ****
  • Posts: 838
  • George
    • View Profile
UP!

Hi and apologies for not replying promptly, I will be reporting this task to the dev. team, please allow for some time to investigate the issue further and get a breather from the release schedule. Hopefully this is something that can be improved!

(Report ID=CRMAX-1446)

« Last Edit: 2022-03-25, 09:18:07 by GeorgeK »
George Karampelas | chaos-corona.com
Chaos Corona QA Specialist | contact us

2022-03-25, 12:06:11
Reply #17

Phasma

  • Active Users
  • **
  • Posts: 112
    • View Profile

2022-05-26, 09:25:44
Reply #18

dj_buckley

  • Active Users
  • **
  • Posts: 872
    • View Profile
Any updates on this?  Now it's been mentioned I'm seeing it more and more, to be honest I hadn't paid attention to it much before and just assumed things were working correctly, it's clear its not right though now I've inspected it.  Attached is a good example of PGSKIES 1714 casting light through some tropical planting and casting shadows onto the building facade.  This is in Max 2021 and Corona 8 Official Stable Release

2022-07-22, 10:30:22
Reply #19

Phasma

  • Active Users
  • **
  • Posts: 112
    • View Profile
exactly these kind of results are really showing how often this is a problem. thanks for sharing and pushing the topic dj_buckley

2022-07-22, 11:55:59
Reply #20

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 12711
  • Marcin
    • View Profile
Any updates on this?  Now it's been mentioned I'm seeing it more and more, to be honest I hadn't paid attention to it much before and just assumed things were working correctly, it's clear its not right though now I've inspected it.  Attached is a good example of PGSKIES 1714 casting light through some tropical planting and casting shadows onto the building facade.  This is in Max 2021 and Corona 8 Official Stable Release

This looks like a physically-correct effect of sunlight passing through holes (I am guessing foliage) which are square-shaped. This would happen in real life as well.
If you replace the object which is casting shadows with something that has round holes in it - does the issue disappear?
Marcin Miodek | chaos-corona.com
3D Support Team Lead - Corona | contact us

2022-07-22, 12:01:47
Reply #21

dj_buckley

  • Active Users
  • **
  • Posts: 872
    • View Profile
I've not got the scene open, but when I get chance I'll test it with the default corona sun/sky, because I'm pretty sure the effect disappeared when I ran that test at the time, which is what prompted me to post the screenshot.

I'd understand your thought process if the resulting rendered tree(s) has visible square holes, but they don't?

Also if anyone can post a real world example of this happening, that would clear a lot of the doubts up.

2022-07-22, 14:58:37
Reply #22

Phasma

  • Active Users
  • **
  • Posts: 112
    • View Profile
As i showed in the examples above, this happens with small holes of any shape - the holes have been round in my example scene, still the projected light was square. this only happens with hdri's, not with the corona sun, I also showed examples above regarding that.

to compare it with something photographic... background bokeh also always has the shape of the lens entrance pupil. It has nothing to do with the shape of the light. in case of the hdri sampling in corona it seems that the sun is only somehow sampled by one -square- pixel... even if hdri resolution is high and sun shape is actually round. I also showed that in my examples.

by the way, it works as expected when the hdri is mapped on a sphere.... takes ages to render though... . It is also independent from the birmap filtering and bitmap blur settings. So there is clearly something wrong with the light sampling of hdri's - something that is not visible when then hdri is directly seen in the background.
« Last Edit: 2022-07-22, 15:06:43 by Phasma »

2022-07-22, 15:46:47
Reply #23

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 12711
  • Marcin
    • View Profile
I've not got the scene open, but when I get chance I'll test it with the default corona sun/sky, because I'm pretty sure the effect disappeared when I ran that test at the time, which is what prompted me to post the screenshot.

I'd understand your thought process if the resulting rendered tree(s) has visible square holes, but they don't?

Also if anyone can post a real world example of this happening, that would clear a lot of the doubts up.

Yes, I was thinking that maybe the trees were modelled incorrectly and have some square-shaped holes. But then I checked the previous examples and it definitely can be a bug.
As for real world examples - I only mean that this would happen if the holes were square-shaped, like in the case of bokeh getting the shape of the aperture, basically a pinhole camera effect.

We will look into this. Something is definitely wrong.
Marcin Miodek | chaos-corona.com
3D Support Team Lead - Corona | contact us

2022-07-22, 16:32:47
Reply #24

Phasma

  • Active Users
  • **
  • Posts: 112
    • View Profile
We will look into this. Something is definitely wrong.

nice! thank you very much

2022-07-22, 16:50:55
Reply #25

dj_buckley

  • Active Users
  • **
  • Posts: 872
    • View Profile
We will look into this. Something is definitely wrong.

nice! thank you very much

To be honest I thought we'd established that it was a problem already, as per George K's post.  My post was merely to see if there was an update on the investigation rather and to provide a further example of the already identified problem.

2022-07-25, 08:55:03
Reply #26

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 12711
  • Marcin
    • View Profile
We will look into this. Something is definitely wrong.

nice! thank you very much

To be honest I thought we'd established that it was a problem already, as per George K's post.  My post was merely to see if there was an update on the investigation rather and to provide a further example of the already identified problem.

Yes we have, and I thought we were looking at something else later. So I just wanted to confirm - we have the issue logged and we will properly look into it.
Marcin Miodek | chaos-corona.com
3D Support Team Lead - Corona | contact us

2024-01-29, 01:20:29
Reply #27

dj_buckley

  • Active Users
  • **
  • Posts: 872
    • View Profile
Just wondering if this ever got solved?

2024-01-29, 09:50:22
Reply #28

pokoy

  • Active Users
  • **
  • Posts: 1850
    • View Profile
I wondered if this has something to do with the fact that internally Corona downsizes a HDR quite drastically for lighting, basically resulting in the sun being a super bright pixel which would then display as a tiny square light source. Earlier tests might not have looked like this because this behavior might have been introduced at a later point.

2024-02-06, 10:33:35
Reply #29

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 12711
  • Marcin
    • View Profile
So far, we did not get clear answers whether this is a bug or not, sorry. We need to look into it some more - thank you for the reminder.
If anyone has a scene which is clearly showing the issue, please share it with us (i.e. there is a round aperture (hole) and the projection comes out pixelated).
Marcin Miodek | chaos-corona.com
3D Support Team Lead - Corona | contact us

2024-02-06, 11:50:45
Reply #30

pokoy

  • Active Users
  • **
  • Posts: 1850
    • View Profile
I remembered I had a camera obscura test setup for it and tested now with the string option:

int lights.envResolution = {value}

And yes, it actually is the reason why HDR environment maps produce a 'pixelated' sun shape or shadows.
Setting it to 1000 - which I believe is the default value - will produce a square shaped sun in a camera obscura, setting it to the map's original resolution (8000 in my case) will produce a rounded shape.

Not really a bug but a side effect of Corona downsizing HDR images internally. This should probably be added to the online help with instructions how to use the string option.


2024-02-06, 11:58:15
Reply #31

pokoy

  • Active Users
  • **
  • Posts: 1850
    • View Profile
Below my tests of different values...

int lights.envResolution = 1000 vs int lights.envResolution = 8000

Green = sun object, red = HDR image aligned to the sun.
Left is a circle shaped hole, right is a square shaped hole in the camera obscura's wall facing the lights.
« Last Edit: 2024-02-06, 12:12:28 by pokoy »

2024-02-06, 12:02:26
Reply #32

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 12711
  • Marcin
    • View Profile
(started writing before pokoy's last message)

I was able to reproduce the issue and it is definitely related to the internal environment resolution that Corona uses.
The string option is int lights.envResolution = 5000 and you can learn more about string options here - https://support.chaos.com/hc/en-us/articles/4528609584017
The default value is 1000

I will now re-report it to devs. It is expected, but can lead to some unwanted results like the example with tree canopy here https://forum.corona-renderer.com/index.php?topic=35753.msg199373#msg199373


(Internal ID=1297189417)
Marcin Miodek | chaos-corona.com
3D Support Team Lead - Corona | contact us

2024-02-06, 12:21:52
Reply #33

dj_buckley

  • Active Users
  • **
  • Posts: 872
    • View Profile
Out of interest, why does Corona downsample like that?  Speed purposes?

For things like that, where stuff is happening behind the scenes that we're unaware of and at the cost of quality, it would be better to give the user a choice? "Keep Original Environment Map Resolution" as a tickbox for example?