Welcome to Fractal Forums

Fractal Math, Chaos Theory & Research => Mandelbrot & Julia Set => Topic started by: lechoo on November 13, 2011, 03:46:40 PM




Title: 4D Quaternion Julia Set ray tracing and inverse method
Post by: lechoo on November 13, 2011, 03:46:40 PM
Hi,
I wrote shader for VRay renderer which renders 4D Quaternion Julia Set. Works flawlessly. I also wanted to give user some preview in viewport using inverse method similar to proposed by John C. Hart. Works too but problem is that it gives slightly different results. When I change first 3 components of quaternion both methods give exactly same result, they stop matching as soon as I change last comoponent, w in my case.

Code:
Quaternion c; //constant
//set c
for (int r=0;r<iNRots;++r)
{
//initial point
q.x = 0.0f;
q.y = sin((rot/iNRots) * PI);
q.z = cos((rot/iNRots) * PI);
q.w = 0.0f;

//now i'm iterating backwards
q1 = sqrt(q - c));
q2 = -sqrt(q - c));
}

Points are drawn using first 3 components of a quaternion. I've tried different aproaches but neither of them works. Ray tracing part of my code is rather ok because my results are consistent with examples I've found on various sites. I hope I gave enough information. I'll apprecitate any help.


Title: Re: 4D Quaternion Julia Set ray tracing and inverse method
Post by: David Makin on November 14, 2011, 12:41:17 AM
Why would you use the inverse method ?
The normal distance estimation method on GPU even in plain shader 2 should be at least interactive speed (even on iOS or Android).


Title: Re: 4D Quaternion Julia Set ray tracing and inverse method
Post by: lechoo on November 14, 2011, 08:27:01 AM
It is easier to implement. You do all calculations once (not per viewport) and you don't have to recalculate everyting when user moves camera in 3d scene. Any idea why these methods don't give consistent results?


Title: Re: 4D Quaternion Julia Set ray tracing and inverse method
Post by: knighty on November 14, 2011, 10:49:06 AM
Slice vs projection.
When raytracing you do it in a 3D slice of the 4D quaternion space but in the inverse method you are projecting 4D points onto a 3D space.


Title: Re: 4D Quaternion Julia Set ray tracing and inverse method
Post by: David Makin on November 14, 2011, 10:48:12 PM
Hmmm - I must be missing something here, obviously "Hart's" inverse method and standard contractive IFS must be completely different animals even though it appears that that's what is used.


Title: Re: 4D Quaternion Julia Set ray tracing and inverse method
Post by: David Makin on November 14, 2011, 10:57:19 PM
Slice vs projection.
When raytracing you do it in a 3D slice of the 4D quaternion space but in the inverse method you are projecting 4D points onto a 3D space.

If that's correct then it's fairly obvious why it doesn't look the same as viewing 3D slices (the conversion from 4D to 2D is so different that the appearance will definitely vary - one completely ignores a dimension and the other doesn't - since using the inverse method the 4D projection to 3D is then projected to 2D to give the viewport image but using the DE method a dimension is completely ignored and the remaining 3 projected to 2 for the viewport image).
Did I understand that correctly ?


Title: Re: 4D Quaternion Julia Set ray tracing and inverse method
Post by: knighty on November 15, 2011, 12:03:40 PM
Yes, exactly. :)


Title: Re: 4D Quaternion Julia Set ray tracing and inverse method
Post by: lechoo on November 18, 2011, 04:06:34 AM
Thanks guys, I think I understand it a little bit :) Are there other methods that I could use to avoid using ray tracing? I'm looking for solution which isn't view dependant. That's why I choose Hart's method.


Title: Re: 4D Quaternion Julia Set ray tracing and inverse method
Post by: knighty on November 18, 2011, 04:38:31 PM
I strongly recommend this online book (http://www.evl.uic.edu/hypercomplex/html/book/book.pdf) which describes rendering methods of julia sets both using sphere tracing and inverse iteration.


Title: Re: 4D Quaternion Julia Set ray tracing and inverse method
Post by: David Makin on November 18, 2011, 09:07:54 PM
Thanks guys, I think I understand it a little bit :) Are there other methods that I could use to avoid using ray tracing? I'm looking for solution which isn't view dependant. That's why I choose Hart's method.

Voxel - using DE to decide very quickly if each box needs subdividing - of course just to be sure to use a min DE threshold of say 2.5* to 3* the voxel size at each sub-division level to be sure of not missing anything - compared to doing an old-fashioned voxel method (i.e. not using DE) this should be both fast and accurate and of course voxel gives you a complete model for fast rendering from any direction - provided you use 4D voxels rather than 3D of course ;)



Title: Re: 4D Quaternion Julia Set ray tracing and inverse method
Post by: lechoo on November 18, 2011, 10:05:08 PM
Thanks a lot guys!


Title: Re: 4D Quaternion Julia Set ray tracing and inverse method
Post by: David Makin on November 18, 2011, 10:26:56 PM
Whoops - missed that other post - a clever algorithm could combine surface tracing with DE to generate voxels *very* quickly indeed - especially good if the fractal to be rendered is guaranteed "connected" :)


Title: Re: 4D Quaternion Julia Set ray tracing and inverse method
Post by: lechoo on November 20, 2011, 02:35:46 PM
Just implemented it. Woks great!