Welcome to Fractal Forums

Fractal Software => Mandelbulb 3d => Topic started by: bib on October 31, 2010, 08:23:40 AM




Title: Hard shadows in M3D
Post by: bib on October 31, 2010, 08:23:40 AM
I find sometimes hard shadows very long to calculate, almost as long as the main rendering, especially since the 1.6 version where main rendering has been notably enhanced. I noticed that the light angle has a strong influence on calc time: the more you want elongated shadows, the longer it will take. Of course the number of light sources for which HS are calculated as well.

Is there any tip to accelerate hard shadows without changing too much the light angles? Do the parameters in the Calculation tab in the main window have an influence on HS calc time?

Other question : I'm not sure about the usage of the "Set light diff-function to Cos", what does it do?


Title: Re: Hard shadows in M3D
Post by: hobold on October 31, 2010, 09:34:02 AM
I don't know the exact method that Jesse uses to compute hard shadows. I would guess that it's done the usual way: you trace a ray from the current surface point to the light source, and check if it hits something other than the light source. If the path between surface and light source is unobstructed, then the point is illuminated by the light source, otherwise it's in shadow.

That means for dramatic elongated shadows, most shadow feeler rays will graze across the fractal surface for long distances. In close proximity to the surface, however, step size is small (proportional to distance to the surface).

Or another way to explain it: elongated shadows means that the shadow outline is an enlarged outline of the fractal. So to be accurate, the computer has to spend quite a bit of effort to compute this outline in great detail. Even if it retains just one bit (in shadow/in light) of that information.


Grazing shadows are a worst case for DE based ray marching, unfortunately. There are several other algorithms for generating shadows, but they all have their own problems and inaccuracies.


Title: Re: Hard shadows in M3D
Post by: Jesse on October 31, 2010, 11:34:12 AM
Hobold explained it very well, i have tried to make some speedups because of the fact that the rays
from the surface are parallel or getting closer towards the lightsource, so you can use some facts of
the previous calculated ray on the current one.
But that unfortunately also fails when the rays are following nearby structures.

I could only reduce the maximum length of the Rays beeing calculated, what can lead to artifacts of
course.


Missed the second question:

The "Set light diff-function to Cos" makes exactly what it says, you have in the light adjustments tab
the "Diffuse:" parameter with 4 choices, if it would be set to one of the lower 2 choices the edges
where the hard shadow will start, for example on a marble, could have a step in the ligh curve what
looks bad.

So if this option in the HS function is set, the light function from what the HS are calculated will be set
automatically to this diffuse function.


Title: Re: Hard shadows in M3D
Post by: Jesse on November 08, 2010, 11:15:59 PM
Just found a kind of bug with the hard shadows: applied the raystep multiplier twice, that explains the long time especially for low values of the multiplier!!
So you were absolutely right bib  :)


Title: Re: Hard shadows in M3D
Post by: MarkJayBee on November 17, 2010, 05:16:34 PM
@Jesse,
Bearing in mind that I am in no way a programmer, would it be practical
in some future version of M3D to have a variable 'soft shadow' option?
By this I mean the ability to simulate, say, an overcast day where the
shadow edges are fairly undefined, but allowing control of the level of
edge 'softness'?
Of course, I could be asking too much, as the amount of work which
has gone into refining the current hard shadows function beggars belief!
Still, I live in hope.... :D


Title: Re: Hard shadows in M3D
Post by: bib on November 17, 2010, 05:36:24 PM
@Markjaybee, to modify the edge softness, try to play with the 'Diffuse' parameter


Title: Re: Hard shadows in M3D
Post by: Jesse on November 17, 2010, 10:13:35 PM
If you only want to change the direct light amount around edges then you can do what bib said... the diffuse light function gives some options for different light amounts depending on the light angle on the surface.

But i guess you want also some soft shadows from objects falling on other surfaces, what is not that easy.
Was already thinking of modifying the ambient shadows to give different weights for the specific angles with respect to the light positions...

Another one is to use lightmaps for ambient, and maybe putting in the light sources.  Sounds not bad, but i am currently stuck with to much other thingys.   :-\