pouët.net

Raymarching Toolbox Thread

category: code [glöplog]
Quote:
The Menger is an excellent base to create buildings, towers and the like.


oh really
added on the 2011-08-25 12:39:43 by smash smash
Quote:
The Menger is an excellent base to create buildings, towers and the like.


oh really

:)
added on the 2011-08-25 12:45:03 by gopher gopher
added on the 2011-08-25 12:58:25 by Gargaj Gargaj
Code:The Menger is an excellent base to create buildings, towers and the like.


oh really
added on the 2011-08-25 19:11:43 by iq iq
STOP IT NOW. Behave. ;)
added on the 2011-08-25 22:43:17 by las las
*puts away manger joke and walks away*
added on the 2011-08-25 22:45:05 by ferris ferris
Really!
Sorry, couldn't resist. :))
added on the 2011-08-26 02:08:29 by knighty knighty
Fold and cut polyhedra:
Code:float DE(vec3 z) { // Fold: //This is a folding set with dodecahedral symmetry z = abs(z); z-=2.0 * max(0.0, dot(z, n1)) * n1;//Thanks AndyAlias for the optimization z-=2.0 * max(0.0, dot(z, n2)) * n2; z = abs(z); z-=2.0 * max(0.0, dot(z, n1)) * n1; z-=2.0 * max(0.0, dot(z, n2)) * n2; z = abs(z); z-=2.0 * max(0.0, dot(z, n1)) * n1; z-=2.0 * max(0.0, dot(z, n2)) * n2; //Cut: //Distance to the plane going through vec3(Size,0.,0.) and which normal is plnormal (must be normalized) //You can also use curved and/or multiple cuts return dot(z-vec3(Size,0.,0.),plnormal); }
added on the 2011-08-26 02:35:48 by knighty knighty
any screenshot ?
added on the 2011-08-26 09:25:43 by Tigrou Tigrou
Thanks a lot for all your DE work knighty, i don't know how we could visualize all these fractals without you. (: And the first one in your link reminds surprisingly of a recent 4k intro too. ;)
added on the 2011-08-26 11:39:21 by nystep nystep
I like the last examples , especially the subblue link.
Sorry for emphasize obvious facts.
added on the 2011-08-26 12:52:46 by rotwang rotwang
nystep: ;o)

iq: About "cantor fracals", there is also this thread where I've given the method to get the distance estimate. I'm not surprised that it was already used in demoscene but it's a pitty such techniques are keps secret for so long time. That said I'm still wondering how the menger sponge was rendered in stargazer.

tigrou: It's cool you found the same technique as KIFS to render the Menger sponge. :)
BB Image
You can of course experiment with other folding planes.

Maybe this is a little bit out of subject but It's related to it and I thought you may find this of some interrest: using foldings to generate triangle group tilings.
here is what I did so far:
evaldraw script
fragmentarium scripts

here is where that idea came from:
"kleinian drops" boxplorer scripts. There is an hyperbolic tesselation hiding in one of the examples. ;)
video by marius.
added on the 2011-08-28 03:39:45 by knighty knighty
geometry:
Code: Octahedron: float octahedron(float3 p, float size) { p=abs(p); return (p.x+p.y+p.z-size)/3; } Rounded Cubes: float rcube(float3 p,float3 box,float rad ) { return length(max(abs(p)-box+rad,0.0))-rad; } Hexagon: float hexagonX(float3 p, float x,float y ) { p=abs(p); return max(p.x-y,max(p.y+p.z*.5,p.z)-x); } Rings: float ring(float3 p,float r,float r2,float c) { return max(abs(length(p.xz)-r)-r2,abs(p.y)-c); }
the hexagon is just on x-plane, also the dividing is not correct, but smaller! (for 4k-usage) ;)
Does anyone have a copy of zeno.pdf that they can upload? I can't seem to find it anywhere and the links posted earlier are both dead.
added on the 2012-08-23 18:12:36 by Hofstee Hofstee
I also want to mention that the "Hexagonal Prism - unsigned" isn't really symmetric.
IQ's dist functions

Code: q.x+q.y*0.57735


should maybe be (coeffs are sin/cos of 60°)

Code: q.x*0.866025 + q.y*0.5
added on the 2012-08-23 19:25:22 by las las
I did some RM stuff a while back and stumbled onto the scale repeater thing, I'm sure u guys have done it but just in case:

rad=4*floor(mod(length(p),128)-64)*(mod(normalize(p),0.1));
dist=Box(rad,0.5);

I'm not sure how it works - since it was a pure accident for me - I was trying to do something else.

this was the start of the math fumbling

http://www.youtube.com/watch?v=JuVtAwqRWL0


and ended up with this

http://www.youtube.com/watch?v=f7ATokNn3RM

never had so much fun before :P
added on the 2012-08-23 20:50:33 by Shabby Shabby
las:

cos(60) / sin(60) = 0.57735
added on the 2012-08-24 01:49:06 by iq iq
ooops, you are right, i missed one multiplication!!!!
added on the 2012-08-24 02:10:20 by iq iq
correct code:

Code: float udHexPrism( vec3 p, vec2 h ) { float q = abs(p); return max(q.z-h.y,max(q.x+q.y*0.57735,q.y*1.154700538)-h.x); }


added on the 2012-08-24 02:15:04 by iq iq
(q is a vec3, of course)
added on the 2012-08-24 02:15:38 by iq iq
0.57735 = 1/sqrt(3), 1.1547=2/sqrt(3)

BB Image

Code: #ifdef GL_ES precision highp float; #endif uniform vec2 resolution; float udHexPrism( vec2 p, float h ) { vec2 q = abs(p); return max(q.x+q.y*0.57735,q.y*1.1547)-h; } void main(void) { vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy; p.x *= 1.3333; float d1 = udHexPrism( p, 1.0 ); float d2 = length(p) - 1.0; float f = 0.0; if( d1<0.0 ) f=1.0; float g = 0.0; if( d2<0.0 ) g=1.0; vec3 col = vec3(f,g,0.0); gl_FragColor = vec4(col,1.0); }


i'll fix my website
added on the 2012-08-24 02:26:16 by iq iq
Here is a comparison of both versions:

"inner" hexagon (yours)
"outer" hexagon (what I proposed)

There are good reasons for both versions - I really prefer the "outer" version for e.g. you have a "circle packing" and use the outer version on it -> it will be space filling.

And the "outer" version has another plus - you can easily express it as dot product (well depends whether it's really a plus - but I like dot products):
Code: float udHexPrism( vec2 p, float h ) { vec2 q = abs(p); //return max(q.x*0.866025 + q.y*0.5, q.y)-h; // can also be expressed as dot prod. return max(dot(q, vec2(0.866025, 0.5)), q.y)-h; }


btw. there are still some people expecting an e-mail ;D
added on the 2012-08-24 03:35:00 by las las
i like inners in general (hex, tris, quads, ...) cause then the meaning of the "radious" sort of makes sense, which comes helpful for me when i have to pack or combine geometry, as i know exactly the bounds of my objects and therefore i know when things will touch, etc. but i suppose is a matter or taste and depends no the application. also, i noticed that in fact this gives negative distances in the inside, although i didn't check if they give the correct distance (the images look promising). can anybody check???

as for the email, i stopped the project i wanted to work on. perhaps i'll resume it in 2013...!
added on the 2012-08-24 04:06:14 by iq iq

login