Logo by AGUS - 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: Support us via Flattr FLATTR Link
 
*
Welcome, Guest. Please login or register. April 25, 2024, 10:03:07 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: Raymarching misses fractal?  (Read 2744 times)
0 Members and 1 Guest are viewing this topic.
fractalnoob
Forums Newbie
*
Posts: 1


« on: June 08, 2013, 10:47:14 AM »

Hi

I hope this is the right place to ask.
I'd like to reproduce the fractal from this blog post: http://blog.hvidtfeldts.net/index.php/2011/08/distance-estimated-3d-fractals-iii-folding-space/comment-page-1/#comment-20302 section "A Real Fractal". The post uses Raymarchiing and a distance function.
The problem is, that my ray misses the fractal. I don't know what sensible values for "Iteration" and "scale" to set and I guess, that may ray construction is also a little bit off...

Here is my code:

Constants:
Code:
const float Iterations = 4;
const float Scale = 5.0;

Fractal DE:
Code:
float distanceFromPoint(vec3 z) {
        vec3 a1 = vec3(1,1,1);
vec3 a2 = vec3(-1,-1,1);
vec3 a3 = vec3(1,-1,-1);
vec3 a4 = vec3(-1,1,-1);
vec3 c;
int n = 0;
float dist, d;
while (n < Iterations) {
c = a1; dist = length(z-a1);
       d = length(z-a2); if (d < dist) { c = a2; dist=d; }
d = length(z-a3); if (d < dist) { c = a3; dist=d; }
d = length(z-a4); if (d < dist) { c = a4; dist=d; }
z = Scale*z-c*(Scale-1.0);
n++;
}

  return = (length(z) ) * pow(Scale, -float(n));

Construction of rays
Code:
  vec2 q = gl_FragCoord.xy / u_ws.xy;
  q = -1.0 + 2.0 * q;
  q.x *= u_aspect;
  vec3 planePoint = vec3(q.xy, 0.0);
  vec3 ro = vec3(0.0, 0.0, 1.3); //eye-position
  vec3 rd = normalize(planePoint - ro);

  vec4 debugColor = vec4(vec3(0.1).xyz, 1.0);
  vec4 color = vec4(trace(ro, rd));

I hope someone can give me a hint.

« Last Edit: June 08, 2013, 02:50:06 PM by fractalnoob » Logged
AndyAlias
Forums Newbie
*
Posts: 9


acaudwell
« Reply #1 on: June 21, 2013, 06:35:43 AM »

I found that scale 2.0 produces the Sierpinski Pyramid.

Also, length(z) on the last line of the distance function is the distance to a point in space.

Unless you have a very high iteration count you wont see anything as most rays wont get close enough to any points.

Use (length(z)-radius) to get the distance to a sphere instead (radius 1.5 seems to be about optimal for this one).
Logged

Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Major Raymarching Optimization Mandelbulb Implementation keldor314 8 13959 Last post December 27, 2013, 08:48:22 PM
by Syntopia
raymarching optimization using golden ratio ... General Discussion cKleinhuis 4 8472 Last post December 29, 2012, 12:21:32 PM
by cKleinhuis
Fast fake montecarlo for raymarching - Now with fragmentarium script! Fragmentarium « 1 2 3 4 » eiffie 45 32982 Last post December 20, 2013, 05:44:53 PM
by SCORPION
VTune Results; cRenderWorker::RayMarching -> OpenMP or Threading Building Blocks Mandelbulber mancoast 8 2776 Last post July 31, 2016, 02:57:32 PM
by mancoast
VTune Results; cRenderWorker::RayRecursion; VolumetricShader vs. RayMarching Mandelbulber mancoast 6 6717 Last post August 02, 2016, 11:26:17 PM
by Buddhi

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.217 seconds with 24 queries. (Pretty URLs adds 0.012s, 2q)