Logo by wmauzey - 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 us on facebook
 
*
Welcome, Guest. Please login or register. April 19, 2024, 03:25:09 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 ... 5 6 [7] 8   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: Rendering 3D fractals without distance estimators  (Read 26380 times)
0 Members and 1 Guest are viewing this topic.
cbuchner1
Fractal Phenom
******
Posts: 443


« Reply #90 on: November 21, 2012, 12:55:28 AM »

I did it, converted the CUDA code for my "voxel plancton" fractals to the GLSL based non-DE raytracer. Left side is the voxel renderer, and right hand side is Fragmentarium. The CUDA version has a limited spatial resolution (here 256x256x256 voxels), whereas Fragmentarium doesn't have that restriction any more.

I will post code soon, with some presets.

I haven't quite understood how to add coloring with orbit traps yet - I need to inspect the code from the RotJulia.frag program that was posted earlier.

Christian


* Plancton2.jpg (207.28 KB, 1432x657 - viewed 402 times.)
« Last Edit: November 21, 2012, 01:34:03 AM by cbuchner1 » Logged
M Benesi
Fractal Schemer
****
Posts: 1075



WWW
« Reply #91 on: November 21, 2012, 04:40:21 AM »

@cbuchner-  It might work if you remove the "define providesColor" statement (in your code), and cut and paste the orbitTrap statement into your iteration.  If you decide to play with the one below, you'll need the various parts (cycle, color, and the orbitTrap statement, in addition to the "define providesColor" statement, the whole Palette group, and the color iterations and "cycle" button....... it's a mess).  


update: removed code.  Updating it with a better palette management and animation management system. 
« Last Edit: November 23, 2012, 09:39:47 AM by M Benesi » Logged

cbuchner1
Fractal Phenom
******
Posts: 443


« Reply #92 on: November 21, 2012, 09:46:13 PM »

Here's my weird plancton formula with three colorful presets. Let it render in continuous mode with at least 20 subframes.

This formula produces lots of whipped cream if you're not careful. High iteration counts generally lead to a lot of pixel noise that does not seem to disappear even when letting it render many subframes. A nice combination is low power with higher iteration counts (see Parrot preset).

Generally vary theta and phi in the RotaBulb parameters. For theta = 0 and theta = 180 degrees, this formula converges towards a mandelbulb - anything else is uncharted territory.

Here's my code, save it as RotaBulb.frag

Code:
#info Mandelbulb without Distance Estimator

#define providesInside

#include "Brute-Raytracer.frag"
#include "MathUtils.frag"
#include "Complex.frag"

#group RotaBulb

// Number of fractal iterations.
uniform int Iterations;  slider[0,10,100]

// Number of color iterations.
uniform int ColorIterations;  slider[0,5,100]

// Mandelbulb exponent (8 is standard)
uniform float Power; slider[-10,3,10]

// Bailout radius
uniform float Bailout; slider[0,2,30]

uniform float theta; slider[0.0,0,180]
uniform float phi; slider[0.0,0,360]

/*
vec3 color(vec3 p) {
return abs(vec3(p));
}
*/

#define D2R 0.01745329251994329576923690768489

// return what I call the "pole vector"
vec3 PVec()
{
    return vec3(cos(D2R*phi)*sin(D2R*theta), sin(D2R*phi)*sin(D2R*theta), cos(D2R*theta));
}

vec3 QVec()
{
    return vec3(1.0, 0.0, 0.0);
}

vec3 RVec()
{
    return vec3(0.0, 0.0, 1.0);
}

// create quaternion from rotation axis v and the given angle
vec4 describe_rotation(in vec3 v, in float angle)
{
    float sina_2 = sin(angle/2.0);
    float cosa_2 = cos(angle/2.0);
    return vec4(cosa_2, sina_2*v.x, sina_2*v.y, sina_2*v.z);
}

// perform a rotation of vector v using the given quaternion q
vec3 rotate(in vec3 v, in vec4 q)
{
    float t2 =   q.x*q.y;
    float t3 =   q.x*q.z;
    float t4 =   q.x*q.w;
    float t5 =  -q.y*q.y;
    float t6 =   q.y*q.z;
    float t7 =   q.y*q.w;
    float t8 =  -q.z*q.z;
    float t9 =   q.z*q.w;
    float t10 = -q.w*q.w;
    return vec3(2.0*( (t8 + t10)*v.x + (t6 -  t4)*v.y + (t3 + t7)*v.z ) + v.x,
                           2.0*( (t4 +  t6)*v.x + (t5 + t10)*v.y + (t9 - t2)*v.z ) + v.y,
                           2.0*( (t7 -  t3)*v.x + (t2 +  t9)*v.y + (t5 + t8)*v.z ) + v.z);
}

vec3 powN(in vec3 z, float magnitude, vec3 P) {

    orbitTrap=10000;
    vec3 z_power = z;

    float costheta = dot(z, P) / magnitude;
    float costheta2 = costheta * costheta;
    float sintheta2 = 1.0 - costheta2;
    float sintheta = sqrt(sintheta2);

    vec3 N = cross(P, z) / (magnitude * sintheta);

    // Step 1
    // generate a vector that is situated in the plane spanned by
    // origin, the pole and z and has an resulting angle of power*theta
    // with respect to the pole.
    float theta = acos(costheta);
    vec4 rot = describe_rotation( N, (Power-1.0)*theta );
    z_power = rotate(z_power, rot) * pow(magnitude, Power-1.0);

    // Step 2: Perform rotation around pole axis by an angle of (power-1)*phi
    vec3 z_normal = z_power -  RVec() * dot(z_power, RVec());
    float cosphi = dot(z_normal, QVec()) / length(z_normal);
    float phi = acos(cosphi);
    if ( dot(cross(QVec(), z_normal), RVec()) < 0.0 )
        phi = 6.2831853071 - phi;  // 2*PI - phi

    vec4 rot2 = describe_rotation( RVec(), Power*phi - phi );
    z_power = rotate(z_power, rot2);

    return z_power;
}

bool inside(vec3 z) {

    vec3 P = PVec();
    vec3 c=z;
    float r=length(z);

    int i=0;
    while(r<Bailout && (i<Iterations)) {
        z = powN(z,r,P) + c;
        i++;
        r=length(z);
        if (i<ColorIterations) orbitTrap = min(orbitTrap, abs(vec4(z.x,z.y,z.z,r*r)));
    }

    return (r<Bailout);
}


#preset Default
FOV = 0.77
Eye = 0,0,2
Target = 0,0,0
Up = 0,1,0
EquiRectangular = false
Gamma = 1
ToneMapping = 1
Exposure = 1
Brightness = 1
Contrast = 1
Saturation = 1
NormalScale = 1
AOScale = 1
Glow = 0
AOStrength = 1
Samples = 50
Stratify = true
DebugInside = false
CentralDifferences = true
SampleNeighbors = true
Near = 0
Far = 5
ShowDepth = false
DebugNormals = false
Specular = 0.5208
SpecularExp = 20
SpotLight = 1,1,1,0.23529
SpotLightDir = -0.18518,-0.18518
CamLight = 1,1,1,0
CamLightMin = 0
Fog = 0
BaseColor = 1,1,1
OrbitStrength = 1
X = 0.333333,0,0,1
Y = 0.333333,0.333333,0,1
Z = 0.666667,0.333333,0,1
R = 1,1,1,0
BackgroundColor = 1,1,1
GradientBackground = 0.97825
CycleColors = false
Cycles = 14.0735
Iterations = 4
ColorIterations = 100
Power = 3
Bailout = 2
theta = 80
phi = 90
#endpreset

#preset Parrot
FOV = 0.5
Eye = 0.153051,0.144426,0.599367
Target = -0.758841,-1.3586,-2.21299
Up = 0.274098,0.953879,0.12241
EquiRectangular = false
Gamma = 1
ToneMapping = 1
Exposure = 1
Brightness = 1
Contrast = 1
Saturation = 1
NormalScale = 1
AOScale = 1
Glow = 0
AOStrength = 1
Samples = 50
Stratify = true
DebugInside = false
CentralDifferences = true
SampleNeighbors = true
Near = 0
Far = 5
ShowDepth = false
DebugNormals = false
Specular = 1
SpecularExp = 18
SpotLight = 1,1,1,0.25
SpotLightDir = 0.35802,0.50618
CamLight = 1,1,1,0
CamLightMin = 0
Fog = 0
BaseColor = 1,1,1
OrbitStrength = 0.8
X = 0.333333,0.666667,0.498039,1
Y = 1,0.666667,0,1
Z = 1,0,0,1
R = 1,1,1,0
BackgroundColor = 1,1,1
GradientBackground = 1.08695
CycleColors = false
Cycles = 1
Iterations = 60
ColorIterations = 99
Power = 1.1
Bailout = 2
theta = 40
phi = 250
#endpreset

#preset Fossil
FOV = 0.5
Eye = 0.907837,0.501134,1.85441
Target = -0.35304,-1.11791,-0.751134
Up = 0.76982,0.637907,0.0212406
EquiRectangular = false
Gamma = 1
ToneMapping = 1
Exposure = 1
Brightness = 1
Contrast = 1
Saturation = 1
NormalScale = 1
AOScale = 1
Glow = 0
AOStrength = 1
Samples = 50
Stratify = true
DebugInside = false
CentralDifferences = true
SampleNeighbors = true
Near = 0
Far = 5
ShowDepth = false
DebugNormals = false
Specular = 1
SpecularExp = 18
SpotLight = 1,1,1,0.25
SpotLightDir = 0.35802,0.50618
CamLight = 1,1,1,0
CamLightMin = 0
Fog = 0
BaseColor = 1,1,1
OrbitStrength = 0.8
X = 0.666667,0,0,1
Y = 0,0.666667,1,1
Z = 1,1,0.498039,1
R = 1,1,1,0
BackgroundColor = 1,1,1
GradientBackground = 1.08695
CycleColors = false
Cycles = 1
Iterations = 11
ColorIterations = 99
Power = 1.35
Bailout = 2
theta = 51.4278
phi = 129.229
#endpreset

* RotaBulb.frag (5.82 KB - downloaded 203 times.)
« Last Edit: November 21, 2012, 09:49:03 PM by cbuchner1 » Logged
M Benesi
Fractal Schemer
****
Posts: 1075



WWW
« Reply #93 on: November 22, 2012, 06:46:34 AM »

  Here is some slightly improved Palette mode code.  Has 3 presets (lava is a bit iffy... but the preset is nice and bright the way it is- should add a dark part to it).

  Code is long.  cheesy  3 Presets.. etc. etc.   the frag is attached.  Will rename it when I'm done experimenting....


  Removed this code.  Will change the palette and animation settings tomorrow or the next day.  It'll be MUCH better.

  Fixed code.  Palette and animation settings are as below.  Fixed the Palette Rotation Bug (that was in the formula in the post below this one).  

  All of the presets are with 100% zeropercent type- you need to lower the zeropercentage to get variation when you change magPower!!!!

* Mag Mandy OFFICIAL EXP colorwrap.frag (22.41 KB - downloaded 186 times.)
« Last Edit: November 24, 2012, 07:11:04 AM by M Benesi » Logged

M Benesi
Fractal Schemer
****
Posts: 1075



WWW
« Reply #94 on: November 23, 2012, 04:53:20 AM »

  Here is the "Mandy Mag" type, Updated.  Greatly improved the palette tab, made 2 good presets to start you out.

  The palette tab now lets you pick colors, like you can in the color tab.  I only put in 6 colors to switch between, although they still can be varied by having different "Distance" settings for the red, green, and blue values (between each selected color- look at the math, I'm tired, you figure it out).  

  The animation tab currently has 5 "time" variables.  I will rename them later, for now, they are commented at the top of the code, and here:

time1:  angle of rotation one: spins the old gears.
time2:  changes the magPower setting
time3:  changes the zeropercent setting
time4:  changes colorSpeedNumerator
time5:  Rotates the palette   (didn't even use this one on the following animation- used colorSpeedNumerator one)

UPDATE:  CORRECTED PALETTE ROTATION CODE.  IT NOW WORKS CORRECTLY.  Palette rotation of 1, with paletterotationspeed=1, is a full rotation of the palette.  It rotates one more time by palette rotation 2.  If you set rotation speed lower, the palette rotation rotates slower.  You can set it to negative values as well.  have fun...

20 second 640x480 video is taking quite some time to upload, because I didn't bother compressing it~ .5 gig.  I find that if I do so, then upload it to youtube, the 2nd compression swipe from youtube really blurs the animation up.  

It'll be here after youtube processes it.  VLC could play it, so I assume youtube will be able to do it as well.  I'm attaching the greatly improved Mandy Mag code to this message.    

  All right, as far as I can tell, youtube made it pretty blurry.  It looks decent on my computer.  

<a href="http://www.youtube.com/v/ycFRqb1BUkU&rel=1&fs=1&hd=1" target="_blank">http://www.youtube.com/v/ycFRqb1BUkU&rel=1&fs=1&hd=1</a>

  A couple more code changes are in the works, a couple ideas to try (blending more than one mag z^n with a z^0, or simply with eachother).  And I still have to get around to making additional movement options (rotate around viewpoint and rotate around eye).  


  UPDATE Nov. 24 2012 12:45 AM EST: Fixed Palette rotation bug.  Keep in mind that all presets have the "zeropercentage" maxed out (first slider on the mutations tab).  Set it lower to play with magPower.  You might want to move OUTSIDE of the fractal (move the eye away from 0,0,0 to something like 0,0,-2.6 or something).

  I've got stuff to do for the weekend, so will work on the other things I mentioned a bit later.  Maybe make a decent exterior preset or 2 now.  The presets can be used in either Mandy Mags or Mag Mandys (Mandy Mag is this post, Mag Mandy is the one above).


* Mandy mag experimental times.frag (21.84 KB - downloaded 183 times.)
« Last Edit: November 24, 2012, 07:11:26 AM by M Benesi » Logged

richardrosenman
Conqueror
*******
Posts: 104



WWW
« Reply #95 on: December 17, 2012, 07:39:30 AM »

Hey gang;

Just wanted to let you know I finished and posted my image set created with Fragmentarium:

http://www.fractalforums.com/images-showcase-(rate-my-fractal)/fragmentarium-fractal-image-set/

It was a pleasure working with the software. wink

-Rich
Logged

folded
Forums Newbie
*
Posts: 7


« Reply #96 on: February 11, 2013, 11:29:06 AM »

Hi,

I have a question about the brute-force renderer. I lifted the .frag files from the github repo, and added them to 0.9.12b (the current mac binary) and it works beautifully with the depth buffer shader, but despite all my best efforts, I get nothing but black (or background) when the depth buffer shader is turned off, despite the fact that there's clearly geometry in frame.

Did supporting the brute-force renderer require some code tweaks, as well as the shader? I've tried to build the current head on OSX, but it doesn't like the macports installed Qt4 at all.

Thanks a lot, though. It's great to be able to see the shape of things I want to construct meshes for in almost realtime, but staring at depth buffers is leaving me feeling like a miner whose torch is failing!

Tobias.
Logged
Syntopia
Fractal Molossus
**
Posts: 681



syntopiadk
WWW
« Reply #97 on: February 11, 2013, 09:30:05 PM »

Did supporting the brute-force renderer require some code tweaks, as well as the shader? I've tried to build the current head on OSX, but it doesn't like the macports installed Qt4 at all.

Yes it does require some code tweaks. If I recall correctly, the 'pixelSize' var was not set in the final shader.

However, if you modify the 'DepthBufferShader.frag' and remove the 'viewCoord.x*= pixelSize.y/pixelSize.x;' line, I think it may work. Of course, your image will render most correctly for a square viewport :-)

Logged
Buddhi
Fractal Iambus
***
Posts: 895



WWW
« Reply #98 on: May 06, 2013, 10:16:04 PM »

This topic remember me beginning of story about rendering 3D fractals. In 2009 I had no idea how to implement DE, so all images were rendered by brute-force algorithm on CPU. Of course it was terribly slow (10 hours to render one image) but results were very nice because of nice impression of fractal details. Here you have some of my historical renders:
http://fav.me/d2ezw09
http://fav.me/d2dwoiq
http://fav.me/d2a3a6q
http://fav.me/d2a3at0
http://fav.me/d2ekinu
http://fav.me/d2ev3h2
Logged

cbuchner1
Fractal Phenom
******
Posts: 443


« Reply #99 on: May 07, 2013, 01:12:46 PM »

This topic remember me beginning of story about rendering 3D fractals. In 2009 I had no idea how to implement DE, so http://fav.me/d2ezw09

2009, really? I thought the Mandelbulb is less than 3 years old. Hmm. Or maybe I was just getting older faster than I remember wink
Logged
hobold
Fractal Bachius
*
Posts: 573


« Reply #100 on: December 11, 2013, 09:02:28 PM »

Sorry for necro'ing this thread, but I wanted to follow up with perhaps a small improvement to the brute force raytracing method. In order to reduce the noise on smooth surfaces, I biased the random number distribution towards the closest hit found so far. The following image is a comparison between two brute force renders with 300 samples per ray each. Left side is with sampling bias, right side is uniform sampling along the ray:



As you can see, the difference is quite striking. The sampling bias is implemented very cheaply as a second degree polynomial function applied to the uniform random numbers between 0.0 and 1.0, like this:

where = randomGenerator();
where = (2.0f - where) * where; // parabola p with p(0) = 0, p(1) = 1, p´(1) = 0; so bias samples towards hit
where = closestHit * where;

This mapping will necessarily mean that fewer samples will be taken near the camera. The first derivative of the parabola at 0.0 is 2.0. So the samples will always be at least half as dense as without the bias. Thus far the reduced sampling density at the near end does not seem to cause additional artifacts.
Logged
Buddhi
Fractal Iambus
***
Posts: 895



WWW
« Reply #101 on: December 11, 2013, 10:22:28 PM »

This mapping will necessarily mean that fewer samples will be taken near the camera. The first derivative of the parabola at 0.0 is 2.0. So the samples will always be at least half as dense as without the bias. Thus far the reduced sampling density at the near end does not seem to cause additional artifacts.

Idea is very interesting but I think you did some wrong assumption. This will work only when object will be far from the camera. If you have on the same stage objects in foreground (e.g. in distance 1.0e-5) and also in background (e.g in distance 1.0) then objects which are close will be very noisy or event not visible
Logged

hobold
Fractal Bachius
*
Posts: 573


« Reply #102 on: December 11, 2013, 10:41:23 PM »

If you have on the same stage objects in foreground (e.g. in distance 1.0e-5) and also in background (e.g in distance 1.0) then objects which are close will be very noisy or event not visible

This should not be a problem. Each ray is sampled independently. A ray that hits a nearby object will get a small value for the "closestHit" variable; then it will continue to refine the hit distance of this near surface.

Another ray in the same image which hits a distant object will have a large value for the "closestHit" variable, and will then concentrate sample points near that far surface.

If at any time the long ray finds a closer object (remember that there will still be samples along the whole ray, albeit with perhaps half the sample density as without the bias), the situation will adapt as described in the first case.
Logged
Buddhi
Fractal Iambus
***
Posts: 895



WWW
« Reply #103 on: December 13, 2013, 09:52:47 PM »

Today I tested this algorithm. You are partially right about this parabolic function. If it hits object then probability of finding object for next hits is higher. However it is like I thought. When on the scene there are objects very far and also some small objects which are near, then there is very low probability that it hits even one time the object which is small and near. Some example:
- two spheres on the scene: first at distance 2.0 and diameter 0.5, second at distance 0.001 and diameter 0.0005 (small, but at this distance should take about half of image)
- initial scan range is 10.0
- it hits object at distance 1.0 probably in about 20 hits
- now closestHit will be about 2.0. After few next trials it will go to distance about 1.75 (parabolic function increases probability to hit the object just in front of closestHit)
- then there is only this small object in the front. Now probability to find this object is very low. Even if the random function will be linear the probability will about 0.000028 (0.0005 / 1.75). In 300 trials is not possible to hit this object (probability about 8%). For parabolic function is much worse.
Logged

knighty
Fractal Iambus
***
Posts: 819


« Reply #104 on: December 13, 2013, 11:06:55 PM »

Isn't this a quite extreme example?  cheesy
Logged
Pages: 1 ... 5 6 [7] 8   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Distance Estimators Comparison 3D Fractal Generation David Makin 0 2426 Last post October 24, 2009, 10:02:58 PM
by David Makin
Dual numbers for creating distance estimators (new) Theories & Research Syntopia 2 1353 Last post December 14, 2011, 08:19:02 PM
by eiffie
Mandelbrot Set Distance Estimator Rendering Problem UltraFractal aleph0 5 11104 Last post April 30, 2014, 01:08:45 AM
by aleph0
Wooscripter noisy distance estimators 3D Fractal Generation dom767 5 3284 Last post February 14, 2015, 03:47:34 PM
by dom767
Error estimation of distance estimators (Mandelbulb improvement found!) (new) Theories & Research mermelada 6 887 Last post July 28, 2017, 09:52:19 AM
by mclarekin

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