quaddamage

Qubizm

Aug 27th, 2016
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #info Mandelbox Distance Estimator (Rrrola's version).
  2. #define providesInit
  3. #include "DE-Raytracer.frag"
  4. #include "MathUtils.frag"
  5. #group Mandelbox
  6.  
  7. /*
  8. The distance estimator below was originalled devised by Buddhi.
  9. This optimized version was created by Rrrola (Jan Kadlec), http://rrrola.wz.cz/
  10.  
  11. See this thread for more info: http://www.fractalforums.com/3d-fractal-generation/a-mandelbox-distance-estimate-formula/15/
  12. */
  13.  
  14. // Number of fractal iterations.
  15. uniform int Iterations;  slider[0,17,300]
  16. uniform int ColorIterations;  slider[0,3,300]
  17.  
  18. uniform float MinRad2;  slider[0,0.25,2.0]
  19.  
  20. // Scale parameter. A perfect Menger is 3.0
  21. uniform float Scale;  slider[-3.0,3.0,5.0]
  22. vec4 scale = vec4(Scale, Scale, Scale, abs(Scale)) / MinRad2;
  23.  
  24. // precomputed constants
  25.  
  26. uniform vec3 RotVector; slider[(0,0,0),(1,1,1),(1,1,1)]
  27.  
  28. // Scale parameter. A perfect Menger is 3.0
  29. uniform float RotAngle; slider[0.00,0,180]
  30.  
  31. mat3 rot;
  32.  
  33. void init() {
  34.      rot = rotationMatrix3(normalize(RotVector), RotAngle);
  35. }
  36.  
  37. float absScalem1 = abs(Scale - 1.0);
  38. float AbsScaleRaisedTo1mIters = pow(abs(Scale), float(1-Iterations));
  39.  
  40.  
  41. // Compute the distance from `pos` to the Mandelbox.
  42. float DE(vec3 pos) {
  43.     vec4 p = vec4(pos,1), p0 = p;  // p.w is the distance estimate
  44.    
  45.     for (int i=0; i<Iterations; i++) {
  46.         p.xyz*=rot;
  47.         p.xyz = clamp(p.xyz, -1.0, 1.0) * 2.0 - p.xyz;  // min;max;mad
  48.         float r2 = dot(p.xyz, p.xyz);
  49.         if (i<ColorIterations) orbitTrap = min(orbitTrap, abs(vec4(p.xyz,r2)));
  50.         p *= clamp(max(MinRad2/r2, MinRad2), 0.0, 1.0);  // dp3,div,max.sat,mul
  51.         p = p*scale + p0;
  52.              if ( r2>1000.0) break;
  53.        
  54.     }
  55.     return ((length(p.xyz) - absScalem1) / p.w - AbsScaleRaisedTo1mIters);
  56. }
  57.  
  58. #preset Inside 1
  59. FOV = 0.62536
  60. Eye = -1.16945,-1.12305,-2.79412
  61. Target = 6.16354,-1.00522,-2.00173
  62. Up = -0.619851,-0.17831,0.764193
  63. AntiAlias = 1
  64. Detail = -3.09736
  65. DetailAO = -0.28574
  66. FudgeFactor = 0.81928
  67. MaxRaySteps = 220
  68. BoundingSphere = 8.5542
  69. Dither = 0.5
  70. AO = 0,0,0,0.7
  71. Specular = 2.4348
  72. SpecularExp = 16
  73. SpotLight = 1,1,1,0.73563
  74. SpotLightDir = -0.52,0.1
  75. CamLight = 1,1,1,1.15384
  76. CamLightMin = 0.15151
  77. Glow = 0.0941176,0.341176,0.87451,0.31507
  78. Fog = 0.5
  79. HardShadow = 0
  80. Reflection = 0
  81. BaseColor = 1,1,1
  82. OrbitStrength = 0.5625
  83. X = 0.411765,0.6,0.560784,-0.21312
  84. Y = 0.666667,0.666667,0.498039,0.86886
  85. Z = 0.666667,0.333333,1,-0.18032
  86. R = 0.4,0.7,1,0.31372
  87. BackgroundColor = 0.6,0.6,0.45
  88. GradientBackground = 0.3
  89. CycleColors = false
  90. Cycles = 7.03846
  91. FloorNormal = 0,0,0
  92. FloorHeight = 0
  93. FloorColor = 1,1,1
  94. Iterations = 10
  95. ColorIterations = 2
  96. MinRad2 = 0.25
  97. Scale = 2.39128
  98. RotVector = 1,1,1
  99. RotAngle = 0
  100. #endpreset
  101.  
  102. #preset Other
  103. FOV = 0.4
  104. Eye = 0.136312,-0.357184,2.20031
  105. Target = -2.1701,4.89792,-1.82586
  106. Up = -0.314748,0.483089,0.817043
  107. AntiAlias = 1
  108. Detail = -2.97353
  109. DetailAO = -0.21074
  110. FudgeFactor = 1
  111. MaxRaySteps = 110
  112. BoundingSphere = 7.5904
  113. Dither = 0.5
  114. AO = 0,0,0,0.7
  115. Specular = 4
  116. SpecularExp = 16
  117. SpotLight = 1,1,1,0.4
  118. SpotLightDir = 0.1,0.1
  119. CamLight = 1,1,1,1
  120. CamLightMin = 0.15151
  121. Glow = 1,1,1,0
  122. Fog = 0.02684
  123. HardShadow = 0.58462
  124. Reflection = 0
  125. BaseColor = 1,1,1
  126. OrbitStrength = 0.8
  127. X = 0.5,0.6,0.6,0.7
  128. Y = 1,0.6,0,0.4
  129. Z = 0.8,0.78,1,0.5
  130. R = 0.4,0.7,1,0.12
  131. BackgroundColor = 0.6,0.6,0.45
  132. GradientBackground = 0.3
  133. CycleColors = false
  134. Cycles = 7.03846
  135. FloorNormal = 0,0,0
  136. FloorHeight = 0
  137. FloorColor = 1,1,1
  138. Iterations = 18
  139. ColorIterations = 3
  140. MinRad2 = 0.0172
  141. Scale = -1.49272
  142. RotVector = 1,1,1
  143. RotAngle = 0
  144. #endpreset
  145.  
  146. #preset Default
  147. FOV = 0.56284
  148. Eye = -1.80087,13.736,2.87241
  149. Target = -1.52812,3.93906,2.87915
  150. Up = -0.296524,-0.00759792,0.954991
  151. AntiAlias = 1
  152. Detail = -2.35396
  153. DetailAO = -0.28574
  154. FudgeFactor = 1
  155. MaxRaySteps = 105
  156. BoundingSphere = 15.093
  157. Dither = 0.5
  158. AO = 0,0,0,0.7
  159. Specular = 4
  160. SpecularExp = 16
  161. SpotLight = 1,1,1,0.4
  162. SpotLightDir = -0.33334,0.1
  163. CamLight = 1,1,1,1
  164. CamLightMin = 0.4697
  165. Glow = 1,1,1,0.17808
  166. Fog = 0
  167. HardShadow = 0
  168. Reflection = 0
  169. BaseColor = 1,1,1
  170. OrbitStrength = 0.8
  171. X = 0.5,0.6,0.6,0.7
  172. Y = 1,0.6,0,0.4
  173. Z = 0.8,0.78,1,0.5
  174. R = 0.4,0.7,1,0.12
  175. BackgroundColor = 0.596078,0.6,0.513725
  176. GradientBackground = 0.3
  177. CycleColors = false
  178. Cycles = 7.03846
  179. FloorNormal = 0,0,0
  180. FloorHeight = 0
  181. FloorColor = 1,1,1
  182. Iterations = 12
  183. ColorIterations = 3
  184. MinRad2 = 0.25
  185. Scale = 2.04344
  186. RotVector = 1,1,1
  187. RotAngle = 0
  188. #endpreset
  189.  
  190. #preset M1
  191. FOV = 0.4
  192. Eye = 3.4315,-5.57625,-2.47321
  193. Target = -1.74219,2.244,1.00192
  194. Up = -0.820324,-0.551717,-0.15059
  195. AntiAlias = 1
  196. Detail = -2.78761
  197. DetailAO = -0.28574
  198. FudgeFactor = 0.916
  199. MaxRaySteps = 112
  200. BoundingSphere = 7.1083
  201. Dither = 0.5
  202. AO = 0,0,0,0.96721
  203. Specular = 1.4167
  204. SpecularExp = 18.8
  205. SpotLight = 1,1,1,0.17391
  206. SpotLightDir = 0.31428,0.1
  207. CamLight = 1,1,1,1.41936
  208. CamLightMin = 0.4697
  209. Glow = 0.835294,0.0784314,0.0784314,0
  210. Fog = 0.45638
  211. HardShadow = 0
  212. Reflection = 0
  213. BaseColor = 1,1,1
  214. OrbitStrength = 0.515
  215. X = 0.6,0.0117647,0.0117647,0.59056
  216. Y = 1,0.6,0,0.44882
  217. Z = 1,1,1,0.49606
  218. R = 0.666667,0.666667,0.498039,0.07936
  219. BackgroundColor = 0.666667,0.666667,0.498039
  220. GradientBackground = 0.3
  221. CycleColors = false
  222. Cycles = 7.03846
  223. FloorNormal = 0,0,0
  224. FloorHeight = 0
  225. FloorColor = 1,1,1
  226. Iterations = 17
  227. ColorIterations = 3
  228. MinRad2 = 0.25
  229. Scale = 3
  230. RotVector = 1,1,1
  231. RotAngle = 0
  232. #endpreset
Advertisement
Add Comment
Please, Sign In to add comment