Caustics and memory issues

Since I dont consider this a bug but rather a underwork I post this here.
When having a scene with multiple objects casting caustics, vray tends to perform big memory jumps on calculating caustics map. In this example I have 780 boxes casting causctis onto a plane in image 1. Spot light with decay and its cone is spreading well beyond the plane which makes light hit all the boxes with no occlusions. Quasi for gi. Caustics map is calculated at 400 mb in memory.

Next I narrow down the hotspot and fall off of spot light towards the center of the boxe’s location. So that the falloff occludes some of the boxes. This makes an intense hit on the caustics calculation, firing the photon map to be in 1.8 gb of ram and pushing this render to 2.5 gb of memory. I got 3gb switch so I can still render this, but barely.

I did same setup in brazil and brazil was able to render this scene with similar settings with memory under 1 gb.

Hmm that is pretty damn weird.

Im guessing that if your casting say 3000 caustic subdivs and the spot light is much bigger than your scene you are loosing alot of the subdivs?
And when you restrict it to purely around the glass boxes your focusing all the subdivs into caustics?

MAybe thats how it works..not sure to be honest. It is odd tho.

well…in my understanding if the objects are occluded and cast no caustics and vray precalculatest that then it should be less memory less time?..
I got 2500 caustic subdivs which is default. The same thing happens when there is 200 boxes in the scene.

hmm Maybe, have you tried with just one bax, and have the spot light really big and render, then focus the spotlight just onto that one box and render…any time difference?

of course maybe it is just a bug :smile:

I think DaForce was right, in the first example many the subs are spread out and only a portion are hitting the objects. I usually use a direct light for better control of the distribution. The brazil caustics do look nice especially for less memory overhead.

Yep seems i was right, just did a little test and the results speak for themselves.

Caustics light subdivs set to 3000 for both tests.
Spotlight hotspot @ 52mm Just enough to cover cup
Caustics map size 684.4mb
Total render time 3m45s

Spotlight hotspot @ 333mm Way to big but just trying to prove a point
Caustics map size 19.1mb
Total render time 1m18s

And as you can see there is a noticeable difference in the caustics

So the caustic subdivs are evenly divided over the light area, so the best way to use caustics was the way i did it with a direct light and set the hotspot/falloff to be big enough to just cover the caustics emitting objects. That way you can use lower subdivs but still keep the quality and thus have a lower caustic map size.

interesting daforce.

Yeah i thought so.
Although …really.. it makes perfect sense. The light cast the caustic rays at the scene, for each ray that hits a caustic generating mesh its added to the caustic map, for each ray that doesnt hit a caustic generating mesh it gets discarded.
And obvously the geneartion of the caustic map is alot quick when alot of it is discarded.

Im curious and want to test out, if it really is worthwhile narrowing the hotspot to encompass just the caustic generating mesh or if you can make it big enough to cover the whole scene and then just up the subdivs, since alot of them get throw away it should be any longer in rendertime to get similar results.
Although I cant help but thing that casting extra caustic rays has to take longer atleast a little bit and calculating the lost ones also must add abit of time to the equation.

So i might run a little test when i get the change.

Have a direct light with a square falloff and a glass cube on a plane.
Set the hotspot to just encompass the cub and set the caustic subdivs at a nominal level. and render.

Then double the area of the hostspot and double the caustic subdivs, and render. Now this should roughtl give the same caustic map size as roughly the same amount of caustic rays are being used to create the caustic map. But will the render time be any different? Im thinking it will by only a little because of the extra initial calculation time of casting and remove those unused caustic rays.

I guess the best way is to have the tight hotspot around the object especially for the point of repeatablility…cause you would know what subdivs worked best, where if you had the larger hotspot your not really sure just how many rays/subdivs are being used for the caustics map

Mmm somwhat interesting.

wow…really fleshed that post out didnt I.

V-Ray may use more memory for photons than other engines, since it stores some additional information for each photon. You can limit the number of photons (and thus the RAM for the photon map) by adjusting the Max. density parameter. Using the Max. density wisely you can shoot as many photons as you like.

Best regards,
Vlado

i see…imo its an underworked area of vray which needs some love.

How does the max density work any differnet to having a focused hotspot and lowering the number of subdivs/photons.

Doesnt max density just discard and photons over a certain amount thus making it pointless casting “as may photons” as you want anyway?

Although i get the feeling im just not understanding the way max density works.
Certainly the times i have used it its given similar effects to just turning down the subdivs.

It depends on the values that you type. Even if you use the Max. density, shooting more photons still reduces the noise in the resulting photon map, so subdivs still matter.

Best regards,
Vlado

ok it reduces the noise but does it make the actual caustics map more accurate? or is it kind of like blurring it out?
Does max density work in a way where it makes the caustics map have less details but still allows you to lower the noise?

Yep.

Best regards,
Vlado

Ahh I see. But for the most accurate you either need a really high max density…in which case why use it. Or just dont use it and increase the subdivs.

Cool. Thanks for you help on this Vlado :smile:

further testing, here is brazil closeup and console info:

PHT: generating caustic photon map
PHT: emitting 10000000 total photons from 1 light
PHT: 668 Mb allocated for photon map
PHT: creating 2 threads
LIT: Brazil Light01 Emitting 10000000 photons…
PHT: terminating threads
PHT: main pass stored 24509902 photons
PHT: 24509902 photons stored

Here is vray closeup and console info:

Building caustic photon map.
[2005/Sep/1|11:41:24] Setting up 2 thread(s)
[2005/Sep/1|11:53:20] Threads completed
[2005/Sep/1|11:53:50] Number of caustic photons stored: 6449872
[2005/Sep/1|11:53:50] Caustic photon map takes 646012920 bytes (616.1 MBytes)
[2005/Sep/1|11:53:50] Photon size is 56 bytes.

At this point, I have used max density at 0.1, search radius at 0.28, maximum photons 160 and caustic subdivisions at 4000. Now the memory is around 1 gb but as you can see brazil is casting 12 million photons and vray almost 6 million (all tho it should cat 12, but max density cuts it by half) and the presicion differences of caustics now is greatly noticeble. The render time is close, vray 13 min brazil 15 min.

The Brazil console says it’s casting 10 million photons, not 12; also 4000 subdivs in V-Ray mean that it is casting 16 million photons, not 6. Also, it seems that the Brazil material is casting transparent shadows - you should disable that, since the caustics already account for the light passing through the objects…

Best regards,
Vlado

If im understanding it corrently brazil stored 24.5million photons whereas vray only stored 6.4million

sorry i redid last post from an older version and messed up the numbers. Yes brazil light is castin 10mil photons but stored is 24 which is way way more then vra as it says 6 million 449,872. Thats how Im seeing it. Anyway, its an iteresting test imo.
I also tried it in mental ray, whats funny that it uses same principal exept 1 thing. It casts a certain amount of photons in render globals called avarage photons per light. Then it breaks it up between objects that cast caustics. So if you have 2 objects with cau and 50000 photons that would be 25000 per object. Weird.