Syntopia
|
|
« Reply #21 on: May 11, 2011, 09:46:24 PM » |
|
Here is a few pictures: Wow! Excellent! Can you show DE() for these samples? My script for the above pictures is a *terrible* mess, but the basic loop is: while (r<10 && n < 14) { if (n==iter)break; if (n<6) { boxFold(z,dz); sphereFold(z,dz); z = Scale*z; dz*=abs(Scale); } else { octo(z,dz); r = length(z); powN2(z,r,dz); } r = length(z); n++; }
If you want to see the whole script, it is here: #include "DE-Raytracer.frag" #include "MathUtils.frag" #group Hybrid // Inspired by the Spudsville systems
uniform float Scale; slider[-5.00,2.0,4.00]
// Scaling center uniform vec3 Offset; slider[(0,0,0),(1,1,1),(5,5,5)]
mat3 rot;
void init() { }
uniform float fixedRadius2; slider[0.1,1.0,2.3] uniform float minRadius2; slider[0.0,0.25,2.3] void sphereFold(inout vec3 z, inout float dz) { float r2 = dot(z,z); if (r2< minRadius2) { float temp = (fixedRadius2/minRadius2); z*= temp; dz*=temp; } else if (r2<fixedRadius2) { float temp =(fixedRadius2/r2); z*=temp; dz*=temp; } }
uniform float foldingValue; slider[0.0,2.0,5.0] uniform float foldingLimit; slider[0.0,1.0,5.0] void boxFold2(inout vec3 z, inout float dz) { if (z.x>foldingLimit) { z.x = foldingValue-z.x; } else if (z.x<-foldingLimit) z.x = -foldingValue-z.x; if (z.y>foldingLimit) { z.y = foldingValue-z.y; } else if (z.y<-foldingLimit) z.y = -foldingValue-z.y; if (z.z>foldingLimit) { z.z = foldingValue-z.z ; } else if (z.z<-foldingLimit) z.z = -foldingValue-z.z; }
uniform float foldingLimit2; slider[0.0,1.0,5.0] void boxFold(inout vec3 z, inout float dz) { z = clamp(z, -foldingLimit, foldingLimit) * 2.0 - z; }
void boxFold3(inout vec3 z, inout float dz) { z = clamp(z, -foldingLimit2,foldingLimit2) * 2.0 - z; }
void mengerFold(inout vec3 z, inout float dz) { z = abs(z); if (z.x<z.y){ z.xy = z.yx;} if (z.x< z.z){ z.xz = z.zx;} if (z.y<z.z){ z.yz = z.zy;} z = Scale*z-Offset*(Scale-1.0); if( z.z<-0.5*Offset.z*(Scale-1.0)) z.z+=Offset.z*(Scale-1.0); dz*=Scale; }
uniform float Scale2; slider[0.00,2,4.00] uniform vec3 Offset2; slider[(0,0,0),(1,0,0),(1,1,1)]
void octo(inout vec3 z, inout float dz) { if (z.x+z.y<0.0) z.xy = -z.yx; if (z.x+z.z<0.0) z.xz = -z.zx; if (z.x-z.y<0.0) z.xy = z.yx; if (z.x-z.z<0.0) z.xz = z.zx; z = z*Scale2 - Offset2*(Scale2-1.0); dz*= Scale2; }
uniform float Power; slider[0.1,8.0,12.3] uniform float ZMUL; slider[-140.0,1,10] void powN2(inout vec3 z, float zr0, inout float dr) { float zo0 = asin( z.z/zr0 ); float zi0 = atan( z.y,z.x ); float zr = pow( zr0, Power-1.0 ); float zo = zo0 * Power; float zi = zi0 * Power; dr = zr*dr*Power*abs(length(vec3(1.0,1.0,ZMUL)/sqrt(3.0))) + 1.0; zr *= zr0; z = zr*vec3( cos(zo)*cos(zi), cos(zo)*sin(zi), ZMUL*sin(zo) ); }
float DE2(vec3 pos) { vec3 z=pos; float r; float dr=1.0; int i=0; r=length(z); while(r<100 && (i<8)) { powN2(z,r,dr); z+=pos; r=length(z); z*=rot; if (i<5) orbitTrap = min(orbitTrap, abs(vec4(z.x,z.y,z.z,r*r))); i++; } return 0.5*log(r)*r/dr; } uniform int MN; slider[0,5,50] float DE(vec3 z, inout float dz, inout int iter) { vec3 c = z; // z = vec3(0.0); int n = 0; //float dz = 1.0; float r = length(z); while (r<10 && n < 14) { if (n==iter)break; if (n<MN) { boxFold(z,dz); sphereFold(z,dz); z = Scale*z; //+c;//+c*Offset; dz*=abs(Scale); } else { octo(z,dz); r = length(z); powN2(z,r,dz); } r = length(z); if (n<2 && iter<0) orbitTrap = min(orbitTrap, (vec4(abs(4.0*z),dot(z,z)))); n++; } if (iter<0) iter = n; return r; }
uniform bool Analytic; checkbox[true]
uniform float DetailGrad;slider[-7,-2.8,7]; float gradEPS = pow(10.0,DetailGrad);
float DE(vec3 pos) { int iter = -1; float dz = 1.0; if (Analytic) { float r = DE(pos, dz, iter); return (r*log(r) / dz); } else { vec3 e = vec3(0.0,gradEPS,0.0); float r = abs(DE(pos, dz, iter)); vec3 grad =vec3( DE(pos+e.yxx, dz, iter), DE(pos+e.xyx, dz, iter), DE(pos+e.xxy,dz, iter) )-vec3(r); return r*log(r)*0.5/ length( grad/gradEPS); } }
float DED(vec3 pos, vec3 dir) { int iter = -1; float dz = 1.0; vec3 e = -dir*gradEPS; float r = abs(DE(pos, dz, iter)); float grad =DE(pos+e, dz, iter)-r; return r*log(r)*0.5/ abs( grad/gradEPS); }
#preset Great FOV = 0.62536 Eye = 2.01082,2.74166,3.98073 Target = 2.33583,-4.84236,4.31657 Up = -9.898e-06,-0.0442387,-0.999018 AntiAlias = 1 AntiAliasBlur = 1 Detail = -3.99665 DetailNormal = -5.99039 DetailAO = 0 FudgeFactor = 0.01573 MaxRaySteps = 530 MaxRayStepsDiv = 3.5 BoundingSphere = 10 Dither = 0.5 AO = 0,0,0,1 Specular = 0 SpecularExp = 16 SpotLight = 1,1,1,0.68478 SpotLightDir = -0.82858,0.1 CamLight = 1,1,1,0.77273 CamLightMin = 0.36449 Glow = 1,1,1,0 Fog = 2 HardShadow = 0 BaseColor = 1,1,1 OrbitStrength = 0.13861 X = 0.498039,0.262745,0.6,0.41732 Y = 1,1,1,0.11812 Z = 0.333333,1,0.258824,0.2756 R = 0.4,0.7,1,0.5873 BackgroundColor = 0.6,0.6,0.45 GradientBackground = 0.3 CycleColors = true Cycles = 4.06318 Scale = -2.07185 Offset = 1.25,0.8456,0.9191 fixedRadius2 = 1.10571 minRadius2 = 0.03871 foldingValue = 2 foldingLimit = 2.01755 foldingLimit2 = 1 Scale2 = 0.79884 Offset2 = 1,1,0 Power = 1.81825 ZMUL = -140 MN = 6 Analytic = true DetailGrad = -2.8 #endpreset
#preset Futura FOV = 0.62536 Eye = 2.01619,2.75179,3.99268 Target = 2.20567,-4.85338,3.42426 Up = -0.0125349,0.0742175,-0.99716 AntiAlias = 1 AntiAliasBlur = 1 Detail = -3.99665 DetailNormal = -5.99039 DetailAO = 0 FudgeFactor = 0.01573 MaxRaySteps = 530 MaxRayStepsDiv = 3.5 BoundingSphere = 10 Dither = 0.5 AO = 0,0,0,1 Specular = 0 SpecularExp = 16 SpotLight = 1,1,1,0.68478 SpotLightDir = -0.82858,0.1 CamLight = 1,1,1,0.77273 CamLightMin = 0.36449 Glow = 1,1,1,0 Fog = 1.91946 HardShadow = 0 BaseColor = 1,1,1 OrbitStrength = 0.13861 X = 0.498039,0.262745,0.6,0.41732 Y = 1,1,1,0.11812 Z = 0.333333,1,0.258824,0.2756 R = 0.4,0.7,1,0.5873 BackgroundColor = 0.6,0.6,0.45 GradientBackground = 0.3 CycleColors = false Cycles = 4.06318 Scale = -2.07185 Offset = 1.25,0.8456,0.9191 fixedRadius2 = 1.10571 minRadius2 = 0.03871 foldingValue = 2 foldingLimit = 2.01755 foldingLimit2 = 1 Scale2 = 0.79884 Offset2 = 1,1,0 Power = 1.81825 ZMUL = -140 MN = 6 Analytic = true DetailGrad = -2.8 #endpreset
#preset p1 FOV = 0.595581 Eye = 1.25125,-0.200486,1.00756 Target = -6.83342,0.316279,4.0991 Up = 0.328927,-0.0522827,0.868915 AntiAlias = 1 AntiAliasBlur = 1 Detail = -2.60582 DetailNormal = -2.42305 DetailAO = 0 AOSpread = 1 FudgeFactor = 0.26168 MaxRaySteps = 652 MaxRayStepsDiv = 2 BoundingSphere = 2 Dither = 0.5 AO = 0,0,0,0.81967 Specular = 0.4167 SpecularExp = 16 SpotLight = 1,1,1,0.72826 SpotLightDir = 0.54286,0.1 CamLight = 1,1,1,0.23656 Glow = 0.356863,1,0.12549,0.50876 Fog = 0.10738 HardShadow = 1 BaseColor = 1,1,1 OrbitStrength = 0.42574 X = 0.411765,0.6,0.560784,0.88976 Y = 0.666667,0.666667,0.498039,0.1496 Z = 1,0,0,0.46456 R = 1,0.666667,0,0.60318 BackgroundColor = 0.203922,0.227451,0.368627 GradientBackground = 0.5 CycleColors = true Cycles = 6.78762 Scale = 2 RotVector = 1,1,1 RotAngle = 0 Offset = 1,1,1 fixedRadius2 = 1 minRadius2 = 0.25 foldingValue = 2 foldingLimit = 2.10525 ZMUL = -0.229 Analytic = false DetailGrad = -3.56146 #endpreset
#preset F FOV = 0.62536 Eye = 2.56637,3.86792,-0.754746 Target = 0.509966,0.674452,1.10844 Up = -0.191611,-0.396206,-0.890571 AntiAlias = 1 AntiAliasBlur = 1 Detail = -3.06572 DetailNormal = -4.03844 DetailAO = 0 FudgeFactor = 0.04673 MaxRaySteps = 583 MaxRayStepsDiv = 1.8 BoundingSphere = 10 Dither = 0.5 AO = 0,0,0,0.7 Specular = 2.4348 SpecularExp = 16 SpotLight = 1,1,1,0.73563 SpotLightDir = -0.52,0.1 CamLight = 1,1,1,0.77273 CamLightMin = 0.18692 Glow = 0,0.666667,0,1 Fog = 1.44966 HardShadow = 1 BaseColor = 1,1,1 OrbitStrength = 0.18812 X = 0.411765,0.6,0.560784,0.30708 Y = 0.666667,0.666667,0.498039,0.40158 Z = 0.666667,0.333333,1,0.02362 R = 0.4,0.7,1,-0.96832 BackgroundColor = 0.6,0.6,0.45 GradientBackground = 0.3 CycleColors = true Cycles = 4.80603 Scale = -2 Offset = 1.25,0.8456,0.9191 fixedRadius2 = 0.5609 minRadius2 = 0.0625 foldingValue = 2 foldingLimit = 1.44735 foldingLimit2 = 1 Scale2 = 2.61764 Offset2 = 1,0,0 Power = 1.03135 ZMUL = -140 MN = 7 Analytic = true DetailGrad = -2.8 #endpreset
#preset Ville FOV = 0.62536 Eye = 4.36274,2.40381,0.932371 Target = -2.8913,-0.351315,0.36855 Up = 0.0793765,-0.00854807,-0.979476 AntiAlias = 1 AntiAliasBlur = 1 Detail = -3.06572 DetailNormal = -4.03844 DetailAO = 0 FudgeFactor = 0.04673 MaxRaySteps = 583 MaxRayStepsDiv = 1.8 BoundingSphere = 10 Dither = 0.5 AO = 0,0,0,0.7 Specular = 2.4348 SpecularExp = 16 SpotLight = 1,1,1,0.73563 SpotLightDir = -0.52,0.1 CamLight = 1,1,1,0.77273 CamLightMin = 0.18692 Glow = 1,1,1,0 Fog = 0.24162 HardShadow = 1 BaseColor = 1,1,1 OrbitStrength = 0.16832 X = 0.411765,0.6,0.560784,0.30708 Y = 0.666667,0.666667,0.498039,0.40158 Z = 0.666667,0.333333,1,0.02362 R = 0.4,0.7,1,-0.96832 BackgroundColor = 0.6,0.6,0.45 GradientBackground = 0.3 CycleColors = false Cycles = 18.1816 Scale = -2 RotVector = 1,1,1 RotAngle = 0 Offset = 1.25,0.8456,0.9191 fixedRadius2 = 1 minRadius2 = 0.0625 foldingValue = 2 foldingLimit = 2.01755 Scale2 = 2 Offset2 = 1,0,0 Power = 2.05554 ZMUL = -9.084 Analytic = true DetailGrad = -2.8 #endpreset
#preset MN FOV = 0.62536 Eye = 1.82748,2.819,3.89641 Target = -0.157115,10.1441,5.24904 Up = -0.230691,-0.235678,0.937828 AntiAlias = 1 AntiAliasBlur = 1 Detail = -3.57665 DetailNormal = -4.03844 DetailAO = 0 FudgeFactor = 0.04673 MaxRaySteps = 843 MaxRayStepsDiv = 1.8 BoundingSphere = 10 Dither = 0.5 AO = 0,0,0,0.7 Specular = 2.4348 SpecularExp = 16 SpotLight = 1,1,1,0.73563 SpotLightDir = -0.52,0.1 CamLight = 1,1,1,0.77273 CamLightMin = 0.18692 Glow = 1,1,1,0 Fog = 0.24162 HardShadow = 1 BaseColor = 1,1,1 OrbitStrength = 0.16832 X = 0.498039,0.262745,0.6,0.30708 Y = 0.666667,0.121569,0.121569,0.25984 Z = 0.333333,1,0.258824,0.38582 R = 0.4,0.7,1,-0.96832 BackgroundColor = 0.6,0.6,0.45 GradientBackground = 0.3 CycleColors = true Cycles = 8.27397 Scale = -2.25185 Offset = 1.25,0.8456,0.9191 fixedRadius2 = 1.08472 minRadius2 = 0.1832 foldingValue = 2 foldingLimit = 2.01755 foldingLimit2 = 1 Scale2 = 1.55884 Offset2 = 1,1,0 Power = 2.42825 ZMUL = -140 MN = 6 Analytic = true DetailGrad = -2.8 #endpreset
#preset Abstraction FOV = 0.62536 Eye = 2.03979,2.41975,3.79673 Target = 0.259702,-1.54583,-2.44596 Up = 0.835361,0.323895,-0.443951 AntiAlias = 1 AntiAliasBlur = 1 Detail = -4.08758 DetailNormal = -3.63461 DetailAO = 0 FudgeFactor = 0.01573 MaxRaySteps = 357 MaxRayStepsDiv = 3.5 BoundingSphere = 10 Dither = 0.5 AO = 0,0,0,1 Specular = 9.25 SpecularExp = 32.292 SpotLight = 1,1,1,0.68478 SpotLightDir = -0.82858,0.1 CamLight = 1,1,1,0.51612 CamLightMin = 1 Glow = 1,0.85098,0,0.21053 Fog = 0.79194 HardShadow = 0 BaseColor = 1,1,1 OrbitStrength = 0.13861 X = 0.498039,0.262745,0.6,0.41732 Y = 1,1,1,0.11812 Z = 0.333333,1,0.258824,0.2756 R = 0.4,0.7,1,0.5873 BackgroundColor = 0.6,0.6,0.45 GradientBackground = 0.3 CycleColors = true Cycles = 4.06318 Scale = -2.07185 Offset = 1.25,0.8456,0.9191 fixedRadius2 = 1.10571 minRadius2 = 0.03871 foldingValue = 2 foldingLimit = 2.01755 foldingLimit2 = 1 Scale2 = 0.35296 Offset2 = 0,0.72308,0.26154 Power = 1.81825 ZMUL = -140 MN = 8 Analytic = true DetailGrad = -2.8 #endpreset
I'll include the script in a clean version in next release of Fragmentarium.
|