Logo by mclarekin - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Visit the official fractalforums.com Youtube Channel
 
*
Welcome, Guest. Please login or register. April 25, 2024, 08:52:56 AM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: [1]   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: Volumetric light  (Read 3627 times)
0 Members and 1 Guest are viewing this topic.
JosLeys
Strange Attractor
***
Posts: 258


WWW
« on: April 14, 2013, 01:53:15 PM »

What method is used in M3D to realize VL?
Logged
Sockratease
Global Moderator
Fractal Senior
******
Posts: 3181



« Reply #1 on: April 14, 2013, 02:08:40 PM »

What method is used in M3D to realize VL?

I have no idea, but if I know Jesse - it's in the ReadMe file enclosed with the program   alien
Logged

Life is complex - It has real and imaginary components.

The All New Fractal Forums is now in Public Beta Testing! Visit FractalForums.org and check it out!
Jesse
Download Section
Fractal Schemer
*
Posts: 1013


« Reply #2 on: April 15, 2013, 09:04:28 PM »

What method is used in M3D to realize VL?

I tried to find the origin post where the lightmap method was presented, but eben with sitesearch on a big searchengine does not helped  sad

But the basic method is simple:
Precalculate a lightmap for a positional light as example.  Store the maximal distance of rays from the lightsource until they hit an object in a spherical map or in 6 sides of a boxmap (just what you like to, you only have to cover the directions to the scene you have to test later).
In the usual raymarcheer you test then for each raysteps (use substeps to get a better resolution) if the light is visible by testing if the stored distance is bigger then the actual distance to the current rayposition and add then the light amount.

For global lights i make a rotationmatrix from the light angles and define a center point of the current scene.
Then one map is calculated with an offset towards the center according to the [x,y] map position and towards the light to start the lightray marching.  The maximum ray distance with offset subtracted is then stored to the map.
On usual raymarching the center is subtracted from the actual position and this vector is rotated.
One vector component can be directly used for distance comparison, the other orthogonal components are multiplied to get from scene size to the map size, beeing the pixel coords for the map to get the max distance.
« Last Edit: April 15, 2013, 10:03:51 PM by Jesse » Logged
Jesse
Download Section
Fractal Schemer
*
Posts: 1013


« Reply #3 on: April 15, 2013, 10:07:35 PM »

I have no idea, but if I know Jesse - it's in the ReadMe file enclosed with the program   alien

No, but i want to spend some more time to the readme in future, also to list all the useful links to this forum that are getting lost that fast...
Logged
JosLeys
Strange Attractor
***
Posts: 258


WWW
« Reply #4 on: April 17, 2013, 08:12:40 PM »

Here is what I think is a cheaper alternative:

Define a spotlight with a source point, a direction vector and an angle to define the cone of light projected by this spotlight.
For every ray it is not too difficult to find the intersection points (if any) with the cone of light. (be careful to only take those points on the cone on the side of the direction vector)

As the light in the cone may be partly shadowed, take n reference points on the ray equally spaced between the two intersection points, and run the DE algorithm starting from the spotlight source in the direction of the reference point on the ray. If we reach the point there is no obstruction, and that point on the ray earns 1 'point'. If none of the n points on the ray experience any obstruction, we have a total score of n. This normally is very cheap to calculate, just stop the ray marching if we get further than the reference point on the ray.

We then blend the colour of the endpoint of the main ray (from the viewpoint) with the colour of the light, taking into account the score that we just obtained for the ray in question.

A possible way to do this is :
define k=1-exp(0.25*(tcone1-tcone2)*score/n) where tcone1 and tcone2 are the distances on the ray to the intersection points (tcone2>tcone1)

Then blend the colours : if k=1 you get the light colour, if k=0 you get the colour of the ray's endpoint, (so no change).

Here's an example :





* 4D_test_127a.jpg (186.81 KB, 1280x1280 - viewed 281 times.)
Logged
Jesse
Download Section
Fractal Schemer
*
Posts: 1013


« Reply #5 on: April 18, 2013, 12:16:09 AM »

Here is what I think is a cheaper alternative:

Define a spotlight with a source point, a direction vector and an angle to define the cone of light projected by this spotlight.
For every ray it is not too difficult to find the intersection points (if any) with the cone of light. (be careful to only take those points on the cone on the side of the direction vector)

Yes, a spotlight would have the advantage of a small cone, so you would only need to calculate fewer rays, and/or you can get a high resolution with a relative small map.

Quote
As the light in the cone may be partly shadowed, take n reference points on the ray equally spaced between the two intersection points, and run the DE algorithm starting from the spotlight source in the direction of the reference point on the ray. If we reach the point there is no obstruction, and that point on the ray earns 1 'point'. If none of the n points on the ray experience any obstruction, we have a total score of n. This normally is very cheap to calculate, just stop the ray marching if we get further than the reference point on the ray.

But this is the great advantage of maps, once you have calculated the distances from the lightsource, you don't need to do any further steps, just compare the distance to the light to the one stored in the map! (the map position is given by the angle to the light)
This way you calculate only one ray for every direction of light send out by the source.
Logged
JosLeys
Strange Attractor
***
Posts: 258


WWW
« Reply #6 on: April 18, 2013, 08:38:37 AM »

Well, I have no map to calculate and store, which I presume takes time also, does it not?

Forgot to mention that I'm using Ultrafractal for all this.
Logged
Jesse
Download Section
Fractal Schemer
*
Posts: 1013


« Reply #7 on: April 18, 2013, 12:16:08 PM »

Well, I have no map to calculate and store, which I presume takes time also, does it not?

Of course, the overall rendering time inclusive map calculation is about 2 to 3 times higher then without volumetric fog.
I think this is still quite fast.  What is the time difference in your image about?

Quote
Forgot to mention that I'm using Ultrafractal for all this.

Ok, without prestoring option this map-method is not possible.
With good DE's you might skip some raysteps when all DE's towards the lightsource exceeds the limit for the next step...
it would depend on the actual scene if this improves the speed much.
Logged
JosLeys
Strange Attractor
***
Posts: 258


WWW
« Reply #8 on: April 18, 2013, 02:24:43 PM »

The image I posted took about 3 seconds without the volumetric spotlight, and 20 secs when I add the spotlight with n=20, so checking for obstruction on 20 points on every ray when it passes through the light cone. For n=5 the time goes down to about 12 secs.
I'll have to read up on how to do your light map as it appears very efficient.
Logged
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Volumetric light Mandelbulber Gallery Buddhi 1 1227 Last post May 16, 2011, 03:11:33 AM
by Tglad
Volumetric light 2 Mandelbulber Gallery Buddhi 0 1124 Last post May 22, 2011, 06:48:38 PM
by Buddhi
Volumetric light and reflections bug reporting Madman 5 8730 Last post April 25, 2013, 10:05:49 PM
by Madman
New Volumetric light Tutorial Tutorials Stonevoice 4 4843 Last post March 22, 2015, 08:43:42 PM
by Madman
V 2.12 OpenCL Crash using volumetric light 1 Bug Reporting Kyzia 3 1569 Last post December 07, 2017, 10:15:02 AM
by Kyzia

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.159 seconds with 25 queries. (Pretty URLs adds 0.007s, 2q)