mclarekin
|
|
« on: November 22, 2016, 05:02:19 AM » |
|
|
|
|
Logged
|
|
|
|
mclarekin
|
|
« Reply #1 on: November 22, 2016, 10:28:16 AM » |
|
Here is an untested attempt. I will test it and the openCL version when next in WindosOS // aBoxModKaliEiffie // reference http://www.fractalforums.com/new-theories-and-research/aboxmodkali-the-2d-version/ // Created: 22/11/16 #define providesInit #include "MathUtils.frag" #include "de-Raytracer.frag"
// #group MixPinski //MAIN
uniform bool swapXZ; checkbox[true] //uniform bool bla bla; checkbox[false] // TODO later
uniform vec3 Offset1; slider[(-5.0,-5.0,-5.0),(1.0,1.0,1.0),(5,5,5)] uniform vec3 cJ; slider[(-5.0,-5.0,-5.0),(0.0,0.0,0.0),(5,5,5)] // jula constant Uniform vec3 c3; slider[(-5.0,-5.0,-5.0),(1.0,1.0,1.0),(5,5,5)] // addCpixel constant multiplier c3 = pos * c3; // ??
uniform float minR2; slider[-5.00,0.25,5.00] uniform float Scale1; slider[-5.00,1.50,5.00] float mdR2 = Scale1/minR2;
uniform int i; float Dd = 1.0f; // using Dd for internal DE calc
uniform int MI; slider[0,60,250] uniform float Bailout, slider[0,100,250] uniform int ColorIterations; slider[0,10,250]
//Rotations uniform int RotAStart; slider[0,1,15] uniform vec3 RotAVector; slider[(0,0,0),(1,1,1),(1,1,1)] uniform float RotAAngle; slider[0.00,0,180] uniform int RotBStart; slider[0,1,15] uniform vec3 RotBVector; slider[(0,0,0),(1,1,1),(1,1,1)] uniform float RotBAngle; slider[0.00,0,180]
mat3 fracRotation1; mat3 fracRotation2; void init() { fracRotation1 = rotationMatrix3(normalize(RotAVector), RotAAngle); fracRotation2 = rotationMatrix3(normalize(RotBVector), RotBAngle); }
float DE(vec3 z) { float r2=0.;
int i=0; for(; i<MI; i++) {
z = abs(z + Offset1) - abs(z - Offset1) - z;// tglad fold
if (swapXZ)// default ON { z = vec3(z.z, z.y, z.x); // swizzle swap } if(i>=RotAStart) z.xyz*=fracRotation1;
if (z.y > z.x) z = vec3(z.y, z.x, z.z); // conditional swizzle
// Abox type spherical fold, NO fixed radius // no DE adjustment as we are modifying the scale value instead float r2 = dot(z,z); float m = Scale1; if (r2 < minR2) m = mdR2;
else if (r2 < 1.0f) m = m / r2;
z = z * m + c3 + cJ;// z * scale + addCpixel + addJuliaConstant
if(i>=RotBStart) z.xyz*=fracRotation2;
//part of distance estimation calculation
Dd = Dd * abs(m) + 1.0f;
//for Bailout r2 = dot(z,z);
if(r2>Bailout) { float r = sqrt(r2); return = r / abs(Dd); }
|
|
|
Logged
|
|
|
|
Sabine
|
|
« Reply #2 on: November 22, 2016, 10:52:46 AM » |
|
For you all to have a laugh , but this is what I came up with, and it sort of generates.. something... rather faulty... This is supposed to be a very basic ABoxKali from mb3d... I'd be really grateful if someone could tell me if I am at least on the right track as it's my very first attempt? Or if I am heading nowhere P.S. Stole the DE from mixpinski cause I have no clue about it! #include "DE-Raytracer.frag"
uniform int MI; slider[1,5,100] uniform int bailout; slider[1,16,1024] uniform float Scale; slider[-5,2,5] uniform float Min_R; slider[0,0.5,5] uniform float X_add; slider[-5,0,5] uniform float Y_add; slider[-5,0,5] uniform float Z_add; slider[-5,0,5] uniform float Julia_Cx; slider[-5,0,5] uniform float Julia_Cy; slider[-5,0,5] uniform float Julia_Cz; slider[-5,0,5]
float DE(vec3 p) { vec3 z=vec3(p); float m; float rr=0.; float Dd = 1.0;
for(int i=0; i<MI && rr<bailout; i++){ z.x = X_add - abs(z.x); z.y = Y_add - abs(z.y); z.z = Z_add - abs(z.z); rr = z.x*z.x + z.y*z.y + z.z*z.z; if (rr < sqrt(Min_R)) {m = Scale/sqrt(Min_R); }; if (rr < 1) {m = Scale/rr;} else { m = Scale; }; z.x = z.x * m + Julia_Cx; z.y = z.y * m + Julia_Cy; z.z = z.z * m + Julia_Cz; Dd *= Scale; // for DE calc } float r = sqrt(rr); return (r) / abs(Dd); }
#preset default FOV = 0.4 Eye = 0.2248197,-0.1026156,-1.696023 Target = -2.466143,0.075118,7.93347 Up = -0.0682873,0.9969614,-0.0374841 AutoFocus = false Gamma = 2 ToneMapping = 4 Exposure = 1 Brightness = 1 Contrast = 1 Saturation = 1 GaussianWeight = 1 AntiAliasScale = 2 DepthToAlpha = false Detail = -3.2932 FudgeFactor = 0.1545559 Dither = 0.5 NormalBackStep = 1 CamLight = 1,0.9647059,0.9215686,1 BaseColor = 1,0.9803922,0.9411765 OrbitStrength = 0.8399072 X = 0.5,0.6,0.6,0.4040632 Y = 1,0.6,0,0.4 Z = 0.8,0.78,1,0.5 R = 0.4,0.7,1,0.12 BackgroundColor = 0.6,0.6,0.45 GradientBackground = 0.3 CycleColors = false Cycles = 1.1 EnableFloor = false FloorNormal = 0,0,1 FloorHeight = 0 FloorColor = 1,1,1 EquiRectangular = false FocalPlane = 1 Aperture = 0 ShowDepth = false DepthMagnitude = 1 DetailAO = -1.166667 MaxDistance = 100 MaxRaySteps = 1669 AO = 0,0,0,0.928489 Specular = 0.4 SpecularExp = 16 SpecularMax = 10 SpotLight = 1,0.9607843,0.9215686,0.5639188 SpotLightDir = 1,0.1 CamLightMin = 0 Glow = 1,0.8862745,0.8078431,0.0849825 GlowMax = 222 Fog = 0.1160714 HardShadow = 0.7913247 NotLocked ShadowSoft = 19.76471 QualityShadows = false Reflection = 0 NotLocked DebugSun = false NotLocked MI = 16 Scale = 2.152391 Min_R = 0.5 X_add = 0.0223714 Y_add = 0 Z_add = 0.3131991 bailout = 1024 Julia_Cx = 0.4072398 Julia_Cy = 1.289593 Julia_Cz = 1.237288 #endpreset
And a better preset maybe: #preset 1 FOV = 0.4 Eye = -2.107985,0.0854123,-0.2484874 Target = -11.64699,1.814691,2.204474 Up = 0.1201045,0.9689693,-0.216041 AutoFocus = false Gamma = 2 ToneMapping = 4 Exposure = 1 Brightness = 1 Contrast = 1 Saturation = 1 GaussianWeight = 1 AntiAliasScale = 2 DepthToAlpha = false Detail = -3.06795 FudgeFactor = 0.1242673 Dither = 0.4180791 NormalBackStep = 0 CamLight = 1,0.9647059,0.9215686,1 BaseColor = 1,0.9803922,0.9411765 OrbitStrength = 0.8399072 X = 0.5,0.6,0.6,0.4040632 Y = 1,0.6,0,0.4 Z = 0.8,0.78,1,0.5 R = 0.4,0.7,1,0.12 BackgroundColor = 0.6,0.6,0.45 GradientBackground = 0.3 CycleColors = false Cycles = 1.1 EnableFloor = false FloorNormal = 0,0,1 FloorHeight = 0 FloorColor = 1,1,1 EquiRectangular = false FocalPlane = 1 Aperture = 0 ShowDepth = false DepthMagnitude = 1 DetailAO = -1.166667 MaxDistance = 100 MaxRaySteps = 502 AO = 0,0,0,0.928489 Specular = 0.4 SpecularExp = 16 SpecularMax = 10 SpotLight = 1,0.9607843,0.9215686,0.5639188 SpotLightDir = 1,0.1 CamLightMin = 0 Glow = 1,0.8862745,0.8078431,0.0849825 GlowMax = 222 Fog = 0.1160714 HardShadow = 0.7913247 NotLocked ShadowSoft = 19.76471 QualityShadows = false Reflection = 0 NotLocked DebugSun = false NotLocked MI = 16 bailout = 16 Scale = 1.915254 Min_R = 0.5 X_add = 0 Y_add = 0 Z_add = 0 Julia_Cx = 2.678161 Julia_Cy = 0.6206897 Julia_Cz = 0.6716418 #endpreset
|
|
« Last Edit: November 22, 2016, 11:14:28 AM by Sabine »
|
Logged
|
sabine62.deviantart.com
|
|
|
mclarekin
|
|
« Reply #3 on: November 22, 2016, 11:27:28 AM » |
|
You can try
put offset defaults to (0.5,0.5,0.5)
the bailout rr for bailout check is taken form the middle of the iteration, that can make a difference I think. And if it works you save on having to recalculate rr at the end of the loop. Try all the ways and see.
I dont understand the maths but with surf&box types the Dd calc adjustment looks like this Dd = Dd * abs(m) + 1.0f;
when you make your first modification version of Kali's formula replace "sqrt(Min_R)" with "Min_R".
|
|
|
Logged
|
|
|
|
mclarekin
|
|
« Reply #4 on: November 22, 2016, 11:52:07 AM » |
|
and scale at 1.5 default
|
|
|
Logged
|
|
|
|
Sabine
|
|
« Reply #5 on: November 22, 2016, 01:45:54 PM » |
|
Thank you for that, mclarekin! Forgot to check with Luca's initial settings in mb3d The bailout I yet have to test in another place. The DE: Can't find a box to sneak a peak at your DE-suggestion. What is the f you refer to? ...and 1.0*f=f, I'd think in my innocence? If I just chop off the 1.0*f, I already get a much better DE, though
|
|
|
Logged
|
sabine62.deviantart.com
|
|
|
Sabine
|
|
« Reply #6 on: November 22, 2016, 02:40:39 PM » |
|
Looks almost like the real thing... But initial view with Julia=off is empty Also made another mistake in the first attempt, if-statement within if-statement read as two seperate if-statements
|
sabine62.deviantart.com
|
|
|
Crist-JRoger
|
|
« Reply #7 on: November 22, 2016, 03:21:11 PM » |
|
|
|
|
Logged
|
|
|
|
Sabine
|
|
« Reply #8 on: November 22, 2016, 07:39:19 PM » |
|
@mclarekin I think it's coming along nicely now, at least that's how it looks :} Still no clue about the illusive 1.0f, but I stole it from your frag and it seems to work. Fixed some more errors I only found when trying to understand what is actually happening... On conditional Julia I had no else, for instance That's why nothing happened as soon as I switched off Julia. Also did some optimalisation... I think Played with bailout location, not yet found a better place, but will investigate some more. I know this is only a simple exercise on my side and all can be done much better, I am sure, and definitely more elegant, and of course does not by far compare to anything you are doing (I really am utterly impressed by what you can set up so quickly!), but that I should have built a frag from looking at Luca's formula in mb3d and with your help on the DE should get something that does Anything at all, to me is a small miracle Thanks again and if you have more tips or see things that are not done right, please, by all means!
|
|
« Last Edit: November 22, 2016, 09:41:00 PM by Sabine »
|
Logged
|
sabine62.deviantart.com
|
|
|
mclarekin
|
|
« Reply #9 on: November 22, 2016, 11:29:10 PM » |
|
@sarbine 1.0f just means 1.0float. It is a coding style, I guess to show it is a float not a double. DE = DE *Scale + 1.0; the offset is set at 1.0 (I assume for some maths reason). Now if we replace this with a generic simple DE adjustment DE = (DE * Scale * DE tweak) + DE offset, we can test the DE calc on a new formula, and we sometimes find the "+ DE offset" has no apparent effect in some situations. I still have a lot learn about DE.
|
|
|
Logged
|
|
|
|
Sabine
|
|
« Reply #10 on: November 22, 2016, 11:46:15 PM » |
|
Thanks you, mclarakin! I still have a lot learn about DE.
...and I even more
|
|
|
Logged
|
sabine62.deviantart.com
|
|
|
mclarekin
|
|
« Reply #11 on: November 23, 2016, 12:14:19 AM » |
|
Sarbine so now you have a working Aboxkali z = xyzAdd - abs(z); // you can add Tglad fold and other fold options to make other box types, you can even do different fold types on each axis. but as a general rule , the more you deviate away from the original formulas the greater the chance of having bad DE. if (rr < sqrt(MinR)) {m = Scale/sqrt(MinR); } else if (rr < 1) {m = Scale/rr;} else { m = Scale; }; if (Julia) {z = z * m + Julia_C; } else {z = z * m;}; When you look at the posts of how all the surf& box types evolved you notice the optimisations that were not present in the original formulas This we can rewrite Initial Conditions:float MinR2; slider float Scale; slider float m = Scale; float minF = m/MinR2 In The Loopif (rr <MinR2)) {m = minF); } else if (rr < 1.0) {m = m/rr;} // else { m = Scale; }; not needed z *= m; if (Julia) {z += Julia_C; }
|
|
|
Logged
|
|
|
|
mclarekin
|
|
« Reply #12 on: November 23, 2016, 02:17:18 AM » |
|
Lets look at the KaliBox (re - Crist's post yesterday.) The formula has evolved, the sqrt(minR) has been removed, And the spherical fold has been recoded. We have a rot at the beginning and the "AbsScaleRaisedTo1mIters" stuff (that I yet to implement in some formulas). float absScalem1 = abs(Scale - 1.0); float AbsScaleRaisedTo1mIters = pow(abs(Scale), float(1-Iterations)); vec4 scale = vec4(Scale, Scale, Scale, abs(Scale)) / MinRad2; float DE(vec3 pos) { vec4 p = vec4(pos,1); for (int i=0; i<Iterations; i++) { p.xyz*=rot; p.xyz=abs(p.xyz)+Trans; float r2 = dot(p.xyz, p.xyz); p *= clamp(max(MinRad2/r2, MinRad2), 0.0, 1.0); p = p*scale + vec4(Julia,0); } return (length(p.xyz) - absScalem1) / p.w - AbsScaleRaisedTo1mIters; // (here the DE calc stuff is p.w of the vect4 p, which is a cool way of doing it in 3D) //which is the same a return (r - absScalem1) / Dd - AbsScaleRaisedTo1mIters; (so we haven’t got and Dd = Dd * scale + 1.0 in this code ) } So any surf box type can be made this way. Box Fold, Spherical Fold, Scale, add constant(s), then add in a Rotation (or two) R, B, R, Sph, S, R, Julia-C, R, addCpixel, R and then you can swap some of not_rotations tranforms around and add more same or different transforms to the mix ( "you can mix and add, until the DE goes bad"). Then you can start modifying parameter values over iteration-count, and or implement late start/ early finish iteration controls for the separate transforms within the formula. Infinity upon infinity.
|
|
|
Logged
|
|
|
|
mclarekin
|
|
« Reply #13 on: November 23, 2016, 02:59:24 AM » |
|
When we look at the AboxModKaliEiffie we see it is a standard sort of ABox with a swizzle and a conditional swizzle added. if (swapXZ == 1)// default ON { z = (float3){z.z, z.y, z.x}; // X & Z swizzle every iteration. Note, if this is ON you // cannot make offset.z 0 and get an ASurf type } if (z.y > z.x) z = (float3){z.y, z.x, z.z}; // X &Y swizzle when Y > X, IN OpenCL // aBoxModKaliEiffie // reference http://www.fractalforums.com/new-theories-and-research/aboxmodkali-the-2d-version/ // Created: 22/11/16 // INITIAL CONDITIONS
int swapXZ = consts->fractal.custom[14]; float3 Offset1 = (float3){consts->fractal.custom[6], consts->fractal.custom[7], consts->fractal.custom[8]}; float minR2 = consts->fractal.custom[9]; //default 0.25f (was 0.5)
float Scale1 = consts->fractal.mandelbox.scale; //default 1.5f
float mdR2 = Scale1/minR2;
// addC, c3 default (0,0,0), cJ default (0,0,0) float3 c3 = (float3){consts->fractal.custom[0], consts->fractal.custom[1], consts->fractal.custom[2]};
c3 = point * c3; // applying a scale factor to original position c
float3 cJ = (float3){consts->fractal.custom[3], consts->fractal.custom[4], consts->fractal.custom[5]};// julia_C
float minimumR = 100.0f; // for coloring calculation
float DE = 1.0f; // aBoxModKaliEiffie // reference http://www.fractalforums.com/new-theories-and-research/aboxmodkali-the-2d-version/ // Created: 22/11/16 // ITERATION LOOP
//a box fold z = fabs(z + Offset1) - fabs(z - Offset1) - z;// tglad fold
// the swizzling if (swapXZ == 1)// default ON { z = (float3){z.z, z.y, z.x}; // swizzle swap }
if (z.y > z.x) z = (float3){z.y, z.x, z.z}; // conditional swizzle
// a randomly placed 3D rotation z = Matrix33MulFloat3(consts->fractal.mandelbox.mainRot, z);
// Abox type spherical fold, NO fixed radius // no DE adjustment as we are modifying the scale value instead float r2 = dot(z,z); float m = Scale1; if (r2 < minR2) m = mdR2; else if (r2 < 1.0f) m = m / r2;
z = z * m + c3 + cJ;// z * scale + addCpixel + addJuliaConstant //part of distance estimation calculation DE = DE * fabs(m) + 1.0f;
//for Bailout r2 = dot(z,z); // for coloring if (r2 < minimumR) minimumR = r2; // to be checked calibrated
//needed for calculation of fake lights based on orbit traps #if _orbitTrapsEnabled if (i >= consts->fractal.fakeLightsMinIter && i <= consts->fractal.fakeLightsMaxIter) distFromOrbitTrap += (1.0f/(r2)); #endif
if(r2>100.0f|| any(isinf(z))) { float r = sqrt(r2); dist = r / fabs(DE);
out.colourIndex = minimumR * 5000.0f; break; } I randomly place the Rotation in the loop, you can try relocating it. I forgot to make my .frag version available to me in Windows OS, but will try my frag version soon.
|
|
|
Logged
|
|
|
|
Sabine
|
|
« Reply #14 on: November 24, 2016, 10:22:14 PM » |
|
@mclarekin Thanks a bunch for your elaborate replies!! Won't be until the weekend that I can get some quiet time to study them in detail, but I'm already looking forward to it!
|
|
|
Logged
|
sabine62.deviantart.com
|
|
|
|