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, 03:04:50 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: Mandelbox render glitch  (Read 2951 times)
Description: HLSL mandelbox rendering
0 Members and 1 Guest are viewing this topic.
lapinot
Alien
***
Posts: 25


« on: September 19, 2015, 03:16:56 AM »

Hi,

Im trying to render the Mandelbox with http://blog.hvidtfeldts.net/index.php/2011/11/distance-estimated-3d-fractals-vi-the-mandelbox/ formula but it seems I don't cut it.

Here's my almost unmodified code (HLSL) (FScale = 2.2) :

Code:
float fixedRadius2 = 1.0 * 1.0;
float minRadius2 = 0.5 * 0.5;
float foldingLimit = 1;

void sphereFold(inout float3 z, inout float dz) {
float r2 = dot(z,z);
if (r2 < minRadius2) {
// linear inner scaling
float temp = (fixedRadius2/minRadius2);
z *= temp;
dz*= temp;
}
else if (r2 < fixedRadius2) {
// this is the actual sphere inversion
float temp =(fixedRadius2/r2);
z *= temp;
dz*= temp;
}
}

void boxFold(inout float3 z, inout float dz) {
z = clamp(z, -foldingLimit, foldingLimit) * 2.0 - z;
}

float DE(float3 z) {

float3 offset = z * FScale;
float dr = FScale;

for (int i = 0; i < FMaxIterations; i++) {
boxFold(z,dr);       // Reflect
sphereFold(z,dr);    // Sphere Inversion

z = FScale * z + offset;  // Scale & Translate
dr = dr * abs(FScale) + 1.0;
}
float r = length(z);
return r / abs(dr);
}

Alternatively I tried with (Buddhi's ?) :

Code:
float3 z = pos * FScale;
float DEfactor = FScale;
float fixedRadius = 1.0;
float fR2 = fixedRadius * fixedRadius;
float minRadius = 0.5;
float mR2 = minRadius * minRadius;

for (int i = 0; i != FMaxIterations; i++) {

if (pos.x > 1.0) pos.x = 2.0 - pos.x;
else if (pos.x < -1.0) pos.x = -2.0 - pos.x;
if (pos.y > 1.0) pos.y = 2.0 - pos.y;
else if (pos.y < -1.0) pos.y = -2.0 - pos.y;
if (pos.z > 1.0) pos.z = 2.0 - pos.z;
else if (pos.z < -1.0) pos.z = -2.0 - pos.z;

float r2 = pos.x * pos.x + pos.y * pos.y + pos.z * pos.z;

if (r2 < mR2) {
pos *= fR2 / mR2;
DEfactor = DEfactor * fR2 / mR2;
}
else if (r2 < fR2) {
pos *= fR2 / r2;
DEfactor *= fR2 / r2;
}

pos = pos * FScale + z;
DEfactor *= FScale;
}

return min(2.0, sqrt(pos.x * pos.x + pos.y * pos.y + pos.z * pos.z) / abs(DEfactor));

but no good results either.

Anything obvious ? Thanks for your time.
Logged
mclarekin
Fractal Senior
******
Posts: 1739



« Reply #1 on: September 19, 2015, 04:09:25 AM »

To confuse you here it is in Buddhi's openCL code
NOTE:-

Initial Conditions outside the loop
Initial DE = 1.0f;
Initial z = point


Inside the loop
DE = DE * fabs( m ) +  1.0f;
and the  adding the addition constant multiplier in    z =  z * m + c ;
 c = point * constant multiplier . The constant multiplier is a default of 1.0f for standard Mboxes,
BTW it is more fun setting up the constant multiplier as a vector of so you can tweak  z.x, z.y & z.z by individual constant multipliers

BTW   z =  z * m + c + cj, is even more fun, with cj being a vector3 of simple addition constants (julia)


Hope this helps
 
Code:
int3 cond1, cond2;

//Box fold
cond1 = isgreater(z, foldingLimit);
cond2 = isless(z, -foldingLimit);
z = select(z,  foldingValue - z, cond1);
z = select(z,  -foldingValue - z, cond2);

//Spherical fold
float rr = dot(z,z);
float m = scale;
if (rr < mr2) m *= native_divide(fr2, mr2);
else if (rr < fr2) m *= native_divide(fr2,rr);

Applying spherical fold (modified m)  and adding the addition constant multiplier
z =  z * m + c ;

DE = DE * fabs( m ) +  1.0f;

r = distance(z, orbitTrap);

colourMin += fabs(m  );

//Bailout
if(r>1024.0f)
 
« Last Edit: September 19, 2015, 04:44:33 AM by mclarekin, Reason: added second BTW » Logged
lapinot
Alien
***
Posts: 25


« Reply #2 on: September 19, 2015, 02:21:42 PM »

Okay better now.  grin



Not sure what the culprit was - half my rendering code and not setting init values for DEfactor / z correctly.

Thanks for the help.

-Lap
Logged
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
glitch 3D Fractal Generation lycium 0 1636 Last post February 26, 2008, 12:50:25 AM
by lycium
1.7.3 Animation glitch? Mandelbulb 3d muchogrande 4 9317 Last post August 04, 2011, 12:42:30 AM
by Jesse
Pause render, save project and continue render from the same spot, possible? Mandelbulb 3d dissolvingstudios 5 8160 Last post January 25, 2012, 06:33:32 AM
by taurus
Mandelbox 'speed render' Movies Showcase (Rate My Movie) khyperia 5 3001 Last post May 25, 2012, 11:05:42 PM
by khyperia
Mandelbuld render glitch Programming « 1 2 » lapinot 18 4429 Last post February 17, 2015, 06:24:17 PM
by lapinot

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.136 seconds with 23 queries. (Pretty URLs adds 0.008s, 2q)