Go to bottom

Raymarching Beginners' Thread

category: code [glöplog]
(hmmm that modelling tool looks really cool :))
added on the 2011-03-19 03:33:17 by las las
I know it's obvious stuff and an old approach, but I hadn't actually seen it done in a proper tool before. There's a difference between "Hey, that's easy to do," and then actually doing it. A lot of great ideas have been shattered by shitty implementations.
iq: long-belated reply; yes, that's how Himalaya was done :)
added on the 2011-03-19 03:49:31 by ferris ferris
Okay. I'm currently working on that nice simplex noise :)
It's really cool all - but I suggest some optimizations:
1. "step" is faster than lessThanEqual (vec3(lessThanEqual(A,B)) == step(A,B)) and greaterThan (== 1. - step(A,B))
2. the permutation can be done faster by moving the floor out of the permutation and some inlining
3. working on it.

=> it's already a bit faster than the original one and i'm still getting the same noise.
added on the 2011-03-19 22:15:14 by las las
las - why are you telling us? Go make some noise on the ogl.org
added on the 2011-03-20 01:00:36 by hornet hornet
las ...contact info is in the paper :) Also, the guy who started the thread is the one who wrote the paper.
added on the 2011-03-20 01:10:15 by hornet hornet
hornet: too late - btw. that's not the same guy who did the implementation - already posted a link to changed the code - I didn't care to read the license file - so I hope it will be ok :D
added on the 2011-03-20 01:30:19 by las las
I was reading through Smash's smashing blog http://directtovideo.wordpress.com/ and came across this "All the hype about distance fields made me get around to writing a proper mesh to signed distance field conversion routine for some effect or other" :O It says he'll may be writing an article about it soon. Can't wait!
added on the 2011-03-22 08:43:47 by Mewler Mewler
The guys who are tutoring me on my bachelor project also did a paper on the subject.
Yeah, that WOULD be interesting. I'm really struggling to think how that could work. Using the actual mesh within the fragment shader is probably out of the question.

Pre-computing it? Storing the signed distance field as a 3d texture? That could work, although accuracy would depend on resolution and I'm not sure if animation would be workable. Actually, he's talking about collisions with particles, and he's talking about a fixed scene. It might be accurate enough for that, but you probably wouldn't want to use it for lighting for a really complex object.
added on the 2011-03-22 11:28:32 by psonice psonice
once youve got the distance fields you find all manner of uses for them. :)
graga: i actually used something like the weighted normal method for signs they describe.
added on the 2011-03-22 11:39:42 by smash smash
For the "voxelized"-spikeball in Regus Ademordna I computed the signed distance field by rasterizing the object to a 3d grid on the GPU with the stencil buffer (similar to stencil shadows), and performing an O(n) exact distance transform (based on some parabola intersections, don't remember the exact paper) on it. Worked out well, since it was an offline process.
added on the 2011-03-22 13:06:09 by kusma kusma
added on the 2011-03-22 13:54:47 by raer raer
las, being anal retentive, I did read the license a while back. I remember as long as you provide changes back as open source you are free to redistribute - in other words what you are doing ...
added on the 2011-03-22 14:19:41 by auld auld
added on the 2011-03-22 21:54:17 by las las
I has been making the rays bounce.

BB Image

Reflections are fun :)
added on the 2011-03-25 02:31:27 by psonice psonice
psonice: back to the topic... and nice. :)
added on the 2011-03-25 02:53:04 by yumeji yumeji
I'm quite happy with that. The way it moves is pretty funky: http://www.youtube.com/watch?v=jU2M4HEOYyQ

Things are starting to come together for an intro i think :)
added on the 2011-03-25 08:48:58 by psonice psonice
nice! :)
added on the 2011-03-25 09:46:35 by las las
psonice: I want that for my EP cover. :)
added on the 2011-03-25 09:51:55 by 4mat 4mat
that would rule :D Want a really high quality version?
added on the 2011-03-25 10:03:46 by psonice psonice
psonice: yes please :) thankyou.
added on the 2011-03-25 10:04:41 by 4mat 4mat
4mat: drop me an email. Just did a quick test render :) psonice@gmail.com
added on the 2011-03-25 10:50:06 by psonice psonice
My first raymarcher:

Inverted Malevich Black Square using orthogonal raymarcher

Code: // orthogonal raymarcher using GLSL 1.0, WebGL and ShaderToy #ifdef GL_ES precision highp float; #endif uniform float time; uniform vec2 resolution; uniform vec4 mouse; // SDF cube float cube(float x,float y,float z,float size) { return max(max(abs(x)-size,abs(y)-size),abs(z)-size); } float f(vec3 p) { float sdf; // only one object in the scene currently sdf = cube(p.x, p.y, p.z, 0.5); return sdf; } void main(void) { vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy; vec3 color = vec3(0.0,0.0,0.0); // orthogonal ray cast vec3 Ro = vec3(p.x,p.y,-1.0); // ray origin vec3 Rd = vec3(0.0,0.0,1.0); // ray direction float t = 0.0; // WebGL uses OpenGL ES which GLSL 1.0 have no support // neither for "while" loop, neither for "for" loop with float counter // only integer counter loops allowed const int maxsteps = 75; for(int steps = 0; steps < maxsteps; steps++) { float d = f(Ro+t*Rd); const float eps = 0.001; if(d < eps) // are we too close to some object's surface { // WE HIT SOMETHING!!! color = vec3(1.0,1.0,1.0); break; } t = t + d; } gl_FragColor = vec4(color,1.0); }

BB Image
added on the 2011-03-27 08:56:39 by SLeo SLeo
oh my god, I just understood that max() functions of that cube's SDF is non-uniform along spherical coordinates, which can bring serious artefacts, everything must be expressed through geometrical distance i.e. GLSL length() function

is it better to use?
Code:float unsigned_sdf_cube( in vec3 p, in float size ) { vec3 di = max(abs(p)-size,0.0); return sqrt(dot(di,di)); }

it uniform outside, but non-uniform inside = 0

maybe this is best cube SDF? author is iq as I remember
Code:float cube( in vec3 p, in float b ) { const vec3 di = abs(p) - b; return min( maxcomp(di), length(max(di,0.0)) ); }
added on the 2011-03-27 10:09:26 by SLeo SLeo


Go to top