Logo by chaos_crystal - 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: Did you know ? you can use LaTex inside Postings on fractalforums.com!
 
*
Welcome, Guest. Please login or register. April 23, 2024, 12:49:55 PM


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: A vector running derivative for a multi-scaled box.  (Read 3260 times)
Description: Care to help me understand how best to use a vector running derivative?
0 Members and 1 Guest are viewing this topic.
eiffie
Guest
« on: December 15, 2011, 06:34:59 PM »

After reading Syntopia's excellent post on using dual numbers to create a multi-scale box ...
http://www.fractalforums.com/new-theories-and-research/dual-numbers-for-creating-distance-estimators/
I decided to dust off an old script that used a vector derivative for doing same. (When dual numbers become standard types I will abandon this quest.) The idea is simple and I am sure others have tried it and I'm hoping they can explain it to me! I simply changed all the scalars to vectors so the code looks much the same (in glsl).
Code:
const vec3 minRadius=vec3(0.25,0.25,0.25);
const vec3 fixRadius=vec3(1.0,1.0,1.0);
const vec3 foldLimit=vec3(1.0,1.0,1.0);
const vec3 SCALE=vec3(-2.5,-2.5,-2.5);
const vec3 scale=SCALE/minRadius;
const vec3 boundingVolume=abs(SCALE*foldLimit)*3.0;//????
const vec3 dc=vec3(1.0,1.0,1.0);
float DE(vec3 z0)
{
vec3 z=z0;
vec3 dz=dc;
for (int n=0;n<iters;n++) {
z=clamp(z,-foldLimit,foldLimit)*2.0-z;
vec3 scl=scale*clamp(minRadius/dot(z,z),minRadius,fixRadius);
z*=scl;dz*=abs(scl);
z+=z0;dz+=dc;
}
return length(z)/length(dz);
//...or for a rect signed value
//z=(abs(z)-boundingVolume)/dz;
//return max(z.x,max(z.y,z.z));
}
All the constants minRadius,fixRadius,foldLimit and SCALE can be different in each dimension.
The code above "works" but it raises more questions.
First what should the return value be for a signed and scaled sphere?
Should dz really be initialized to vec3(1.0) or normalize(vec3(1.0))?
I assumed if I rotate z I must also rotate dz. This isn't true and creates a worse estimate. Why?
If we now have an idea of how the function is changing in each dimension can we use the ray march direction to look only at the change in the direction we are marching???

Has anyone tried this and can give their insight?

Here's the output...
<a href="http://www.youtube.com/v/mmmRg-oVOoM&rel=1&fs=1&hd=1" target="_blank">http://www.youtube.com/v/mmmRg-oVOoM&rel=1&fs=1&hd=1</a>
« Last Edit: December 15, 2011, 06:37:10 PM by eiffie » Logged
Syntopia
Fractal Molossus
**
Posts: 681



syntopiadk
WWW
« Reply #1 on: December 16, 2011, 05:11:19 PM »

Well, I'm surprised that works! Now, if only we could get to know why :-)

Quote
I assumed if I rotate z I must also rotate dz. This isn't true and creates a worse estimate. Why?

Your 'dz' vector doesn't seem to be directional - it is certainly not a gradient of length(z). If I use the normalized dz vector as color, it seems to point in the same directions at all points in the Mandelbox - only the length changes.


Quote
If we now have an idea of how the function is changing in each dimension can we use the ray march direction to look only at the change in the direction we are marching???

I've also thought about this. David Makin has some comments about why a four point method is beter than a two point directional method here: http://blog.hvidtfeldts.net/index.php/2011/09/distance-estimated-3d-fractals-v-the-mandelbulb-different-de-approximations/
Logged
eiffie
Guest
« Reply #2 on: December 16, 2011, 05:31:58 PM »

Good insite. It may only work because length(vec3(1.0)) is already greater than 1.0 so dividing by length(dz) at the end is just a big enough fudge factor. I definitely need to experiment with it more!
Logged
eiffie
Guest
« Reply #3 on: December 20, 2011, 04:48:23 PM »

In keeping with my origin "logic" smiley of keeping a running derivative in each dimension seperately the return value should be:
return length(z/dz);
Logged
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Getting derivative for plankton mandelbulbs etc.. Theory mrrgu 2 1768 Last post December 31, 2009, 11:40:08 AM
by mrrgu
A very strange idea; vector to the Mandelbrot Let's collaborate on something! Timeroot 8 10937 Last post January 23, 2010, 07:44:58 AM
by Timeroot
Derivative of the Amazing fractal, or how to render it ? 3D Fractal Generation « 1 2 3 » cKleinhuis 30 8653 Last post March 25, 2010, 10:56:27 PM
by David Makin
Vector Control Mandelbulb3D Gallery lenord 1 3488 Last post June 25, 2011, 04:52:17 PM
by DarkBeam
Running derivative General Discussion lapinot 3 2073 Last post December 14, 2016, 07:54:53 PM
by DarkBeam

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.191 seconds with 25 queries. (Pretty URLs adds 0.007s, 2q)