Title: Distance Estimated Menger Sponge Normal Calculation Post by: Geometrian on March 16, 2013, 12:34:46 AM Hi,
I can raytrace Menger sponges using the distance estimator: Code: //http://www.fractalforums.com/ifs-iterated-function-systems/revenge-of-the-half-eaten-menger-sponge/15/ Code: vec3 calculate_normal(vec3 pos) {(http://img248.imageshack.us/img248/304/mengerproblem.png) This normal calculation works just fine for other fractals. -G Title: Re: Distance Estimated Menger Sponge Normal Calculation Post by: makc on March 16, 2013, 04:02:59 AM right, but you can't seriously expect smooth normals from code that has "min" and "max" in it :tease:
Title: Re: Distance Estimated Menger Sponge Normal Calculation Post by: Geometrian on March 16, 2013, 05:36:57 AM Mmmm; the above was more by way of asking, what can be changed about how the DE or normal are calculated so as to get the correct effect?
Title: Re: Distance Estimated Menger Sponge Normal Calculation Post by: Syntopia on March 16, 2013, 01:45:43 PM If the distance estimate is correct, I can not see why the normal calculation should fail?
If I do it, I get this:. (http://blog.hvidtfeldts.net/media/cut.png) This was done by placing this at the end of the DE-calculation: Code: dist = max(dist, dot(inputPoint,normalize(cutPlaneNormal))); Title: Re: Distance Estimated Menger Sponge Normal Calculation Post by: makc on March 16, 2013, 01:51:44 PM aye but your normal comes from cutting plane; what he did, I think, was using DE as if whole sponge was there.
Title: Re: Distance Estimated Menger Sponge Normal Calculation Post by: eiffie on March 16, 2013, 04:45:05 PM I think if he accurately put the cut plane in the DE function then he would get Syntopia's result - he doesn't show how he cut the sponge???
Title: Re: Distance Estimated Menger Sponge Normal Calculation Post by: Geometrian on March 16, 2013, 06:31:39 PM aye but your normal comes from cutting plane; what he did, I think, was using DE as if whole sponge was there. Indeed.The algorithm begins with a cube, with 3D texture coordinates defined for each vertex corresponding to the 3D position. The ray tracer shades each pixel on the cube by computing a ray from the camera through that pixel based on the texture coordinates of that point. So when the rasterizer draws a fragment with texture coordinate (1,1,1), the fragment program traces an eye ray from the camera through the virtual point (1,1,1). To achieve cutting, I simply cut the cube. This naturally changes the texture coordinates, and thus the fractal produced. I would like the planes to be arbitrary and unlimited in number. In particular, in order to draw with the camera inside the fractal, the cube must be clipped by the camera' near plane. It occurs to me that any such irregular normal is necessarily on the surface of the clipped cube (the ray has traveled zero distance). Yet, as far as the distance estimate is concerned, any point on the diagonal is "inside" the sponge! It's pretty easy to just specify the surface normal of the clipped cube at each surface point, so perhaps is the distance estimator is negative, one immediately stops and uses the surface's normal? Edit: the result of doing so is the quite lovely: (http://img834.imageshack.us/img834/3323/mengercutsm.png) However, shadow calculation is now broken. Since points on the diagonal start "inside" (according to the distance estimator), shadow rays are automatically occluded! Title: Re: Distance Estimated Menger Sponge Normal Calculation Post by: David Makin on March 16, 2013, 10:13:08 PM You simply flag the cut point as "cut to plane" (which plane or other cutting surface if necessary) and calculate the normal of the cutting surface at that point (which should be incredibly simple compared to getting a normal for the actual uncut fractal surface).
Or you don't use the DE at all and use the nearby adjacent surface point method - which is guaranteed to work whether it's a cut point or part of the fractal surface. Anything else is only useful in the sense of artistic license ;) Title: Re: Distance Estimated Menger Sponge Normal Calculation Post by: cKleinhuis on March 17, 2013, 01:30:09 AM ehrm, people ? those star structures happen to be just the cuts through the menger spone ? interesting....
Title: Re: Distance Estimated Menger Sponge Normal Calculation Post by: tit_toinou on March 17, 2013, 03:30:21 PM Awesome star & cube structure ! 3D Print this !
Title: Re: Distance Estimated Menger Sponge Normal Calculation Post by: kram1032 on March 17, 2013, 07:02:19 PM Nice cut-throughs indeed.
I wonder, can somebody come up with a direct 2D description to obtain this? Title: Re: Distance Estimated Menger Sponge Normal Calculation Post by: Geometrian on March 20, 2013, 03:24:08 AM Is there a better, special way to calculate normals for the Menger Sponge in particular? I'm finding that sharp corners are incorrectly handled by the gradient calculation above.
Title: Re: Distance Estimated Menger Sponge Normal Calculation Post by: makc on March 20, 2013, 09:54:39 AM you would need to change DE to return direction vector instead of distance. then old DE = length of that vector, and normal = -that vector.
Title: Re: Distance Estimated Menger Sponge Normal Calculation Post by: tit_toinou on April 02, 2013, 10:10:25 AM I've created this model for 3D printing since nobody was doing it !
(http://images1.sw-cdn.net/model/picture/674x501_1006153_910614_1364824047.jpg) Étoile de Menger 8cm (http://www.shapeways.com/model/1006153/etoile-de-menger.html) (http://images1.sw-cdn.net/model/picture/674x501_1006224_910698_1364827157.jpg) Triangle de Menger (http://www.shapeways.com/model/1006224/triangle-de-menger.html) (http://images1.sw-cdn.net/model/picture/674x501_1006218_910694_1364826894.jpg) Losange de Menger (http://www.shapeways.com/model/1006218/losange-de-menger.html) http://www.fractalforums.com/format-printing-and-post-production/3d-printed-cross-sections-of-the-menger-sponge/ (http://www.fractalforums.com/format-printing-and-post-production/3d-printed-cross-sections-of-the-menger-sponge/). Nice cut-throughs indeed. Why "2D" ?I wonder, can somebody come up with a direct 2D description to obtain this? I didn't use any distance estimation thing. I created all the faces of the littles cubes and the faces intersecting with the plane. (is that what you mean by direct description ?) Title: Re: Distance Estimated Menger Sponge Normal Calculation Post by: kram1032 on April 02, 2013, 01:27:32 PM I simply meant, I'd like to see a purely 2-dimensional iteration formula that exactly describes the Menger Star cut.
Awesome 3Dprintables :) Title: Re: Distance Estimated Menger Sponge Normal Calculation Post by: makc on April 02, 2013, 11:23:14 PM Like that is something hard to do :)
Using code from original thread: Code: bool mengerSponge(double x2d, double y2d) {p.s. I happened to have this swf that renders random menger sponge cuts as you move your mouse around: http://swf.wonderfl.net/swf/usercode/5/53/536d/536dfb5d15b061017191a4ec6bdcb2f40512deff.swf Title: Re: Distance Estimated Menger Sponge Normal Calculation Post by: cKleinhuis on April 03, 2013, 01:11:44 AM try this, in 3d view you can rotate the axis, it is from jesse the formula combination, i changed it to menger3, can be useful for other (fractal) cuttings for sure
^-^ Code:
Title: Re: Distance Estimated Menger Sponge Normal Calculation Post by: makc on April 03, 2013, 03:36:58 AM Wait
Code: plane normal is 1/√3,1/√3,1/√3, therefore vectors 1,-1,0 and 0,1,-1 are good 2D basis It's not, vectors are at right angle to normal but not to each other :( So let's keep 1,-1,0 then 2nd vector must be cross with normal = -1,-1,2. Now we have vectors of different length, √2 and √6, so we also need to scale one: 1,-1,0 now turns into √3,-√3,0. In the end it gives x = 0.5 + 1.732 x2d - y2d y = 0.5 - 1.732 x2d - y2d z = 0.5 + 2 y2d I am sleepy, so I could still mess it up, but you get the idea, right? Title: Re: Distance Estimated Menger Sponge Normal Calculation Post by: kram1032 on April 03, 2013, 10:36:02 PM makc, that's really nice, but you're still using a 3D Menger sponge that you then cut with a plane.
I was wondering about a formulation that never even builds a 3D Version. Title: Re: Distance Estimated Menger Sponge Normal Calculation Post by: makc on April 03, 2013, 10:43:47 PM I don't get it.
Suppose there is (squared) length of 3D vector, L1 = x*x+y*y+z*z. It's 3D, no problem here. Suppose there is (squared) length of 2D vector, L2 = a*a+b*b. It's 2D, no problem here. Now, I want to calculate L1, where x = a, y = b and z = 0. Is it 3D or 2D? From my perspective, there is no difference, I mean I just substitute variables in some expression. What could be a problem with that? Title: Re: Distance Estimated Menger Sponge Normal Calculation Post by: tit_toinou on April 04, 2013, 04:36:48 PM There is two fractals hiding in this image.
The first one is an hexagon that divides into 6 hexagons and 6 equilateral triangles. The second one is an equilateral triangle that divides into 9 hexagons and 15 equilateral triangles (see my "Triangle de Menger" preview image). Title: Re: Distance Estimated Menger Sponge Normal Calculation Post by: Geometrian on April 17, 2013, 03:52:30 AM So, I've gotten a new render (direct link (http://img716.imageshack.us/img716/1475/compr.png)) (Fractal Forums art thread (http://www.fractalforums.com/images-showcase-%28rate-my-fractal%29/mengerbulb/)), but it still has a few problems.
In particular, it is using the distance estimator to calculate shadows, which mostly works. However, there's still some nasty banding artifacts in some places that I'm pretty sure are erroneous. Ideas as to what these might be caused by? Title: Re: Distance Estimated Menger Sponge Normal Calculation Post by: cKleinhuis on April 17, 2013, 09:31:51 AM Hey kram i think the pure 2d version should not be too hard to implement
i have made a 2d version of the kifs in ultrafractal but for this cut i think it should be extended to a 3d cut slice with 3d rotation possibility right now i am busy with other stuff but i plan to make a review of the kifs soon you can find my kifs 2d variant in the uf formula database Title: Re: Distance Estimated Menger Sponge Normal Calculation Post by: kram1032 on April 17, 2013, 12:41:03 PM makc, well, the 2D-sierpinsky carpet is built from squares. The 3D-menger sponge is built from cubes.
This cut-plane seems to be built from triangles with 6-pointed star shapes (that is, 12 smaller triangles in a certain configuration) being taken out of them. I'm wondering about having a way to build it without using cubes that you then cut through at all. Title: Re: Distance Estimated Menger Sponge Normal Calculation Post by: makc on April 17, 2013, 07:11:51 PM kram, well:
(http://i50.tinypic.com/358t0d4.png) the whole thing is just a triangle without corners Title: Re: Distance Estimated Menger Sponge Normal Calculation Post by: tit_toinou on April 18, 2013, 10:43:17 AM Quote from: me There is two fractals hiding in this image. Oops I was wrong (too complicated), an equilateral triangle divides into 1 hexagon and 3 little equilateral triangles, thx makc ^^ for the image.The first one is an hexagon that divides into 6 hexagons and 6 equilateral triangles. The second one is an equilateral triangle that divides into 9 hexagons and 15 equilateral triangles (see my "Triangle de Menger" preview image). @kram1032: I think my description is enough to create the fractal.. Title: Re: Distance Estimated Menger Sponge Normal Calculation Post by: cKleinhuis on April 18, 2013, 10:49:42 AM the triangle is split into 1 hexagon and 3 triangles, but into what is the hexagon split ???
i mean, it would be nice to have a nice formulation of this for the hexagon as well, right now i do not see it easily :hurt: the rule seems to only rely on the star shape, - start with a hexagon - cutout the big star shape in the middle - repeat with the six remaining hexagons .... but i thing it is missing the "triangle sections ... :( there must be a 2 way rule... :( Title: Re: Distance Estimated Menger Sponge Normal Calculation Post by: kram1032 on April 18, 2013, 11:54:08 AM Well, you essentially fill a hexagon with smaller hexagons that touch each other and are alligned with the starting hexagon's corners. However, alongside each edge, there will be a missing triangle that you need to fill in too. Repeat as before for the hexagons but note that the edge-triangles also has a new hexagon inside them, that you need to repeat the process with too, however you again need to fill the new holes around the triangles in that iteration. It's a bit more complicated than your typical Sierpinsky-type fractal because it needs some extra filling. I wonder if that's actually necessary though. Equivalently you could probably also start from a triangle of which you cut away the corners to form a hexagon. In either case, it seems to be a two-step iteration loop, rather than a single-step one. In that sense, it's more complicated than a typical 2D sierpinsky-type fractal... Unless there is some way (other than going 3D and just cutting out the final result from an arbitrarily iterated menger sponge) to merge the two steps into one. (Even cutting the final form out of an iterated 3D object seems like an additional step) If you don't fill the missing triangles, you'll instead end up with something that looks like a Koch-flake- with Kock-flake-holes inside each Koch-flake-part: (http://i.imgur.com/2Ro4myY.png) On a different note: Would anything change if you tried this with a menger-hypercube? Are there other interesting special cut-planes in that case? What about interesting cut 3-planes, e.g. 3D cut-outs from 4D-structures? Notably, that problem would be related to Quasicrystal-structures: If you cut a 3D space from an n-D periodic structure (n>3), you'll get all possible crystal structures if the 3D space is rotated with rational angles. quasi-crystals happen if the angle is irrational (for instance the golden angle, which corresponds to a Penrose-tiling) In case of a high-dimensional menger-cube it would obviously be a regular n-cube-lattice, cut in arbitrary angles. But other regular 4D structures might be tried just as well. |