pouët.net

Raymarching idea: Invertible Surfaces

category: code [glöplog]
Another question for the raymarching community :]

I wonder whether this is a novel idea - or a known technique.

The idea is to define the distance function also for the inside of each object. On the outside, it will return the distance to the surface as usual. On the inside, it will also designate the distance to the closest surface point - but with a negative sign.

(In the distance functions I have seen, it seemed that on the inside of objects, the distance function was 0 or a random negative value.)

This way, you gain multiple advantages:

-Every object, even complicated ones, can now be inverted (space becoming solid and solid becoming space), simply by negating the distance function. Could be useful for CSG. And (admittedly a minor advantage) you can do with fewer primitives.

-You can also travel through the inside of objects (until you reach the surface). This would allow for transparent objects. And even refraction.

-In addition to spherically growing objects (by subtracting a fixed value from the distance function), you can also spherically shrink them (by adding a fixed value). (This is not possible without invertible surfaces as distances very close to the object would not be defined properly.)

As an example of an invertible surface (for some reason I always want to spell it 'invertable'), here's an invertible cube:

Code: public static double invertibleCube(V v, double size) { double x = size-Math.abs(v.x), y = size-Math.abs(v.y), z = size-Math.abs(v.z); if (x <= 0 || y <= 0 || z <= 0) // outside return new V(Math.max(-x, 0), Math.max(-y, 0), Math.max(-z, 0)).len(); else // inside return -Math.min(Math.min(x, y), z); }
added on the 2011-02-06 19:31:29 by vibrator vibrator
BB Image
added on the 2011-02-06 19:55:04 by w00t! w00t!
Make a demo or be quiet
I'm not sure but I think that usually happens with most distance functions.
added on the 2011-02-06 20:58:07 by xernobyl xernobyl
done here, where the sphere shits the cube upwards. But this shows both surfaces always, as there's a hole on top of the sphere.
added on the 2011-02-06 21:57:10 by ferris ferris
..and yeah, make a demo already :) You'll figure all this out from experimentation.
added on the 2011-02-06 22:07:31 by ferris ferris
Quote:
Make a demo or be quiet

So you can't handle talking? You better stay out of the BBS.
Quote:
..and yeah, make a demo already :)

Making a demo requires a dedication I think I don't want to invest at this point. What's wrong with talking about technique? I like to discuss things and lay ground work. Maybe another place would be better for this anyway - to get away from the pointless crap responses one gets on pouet.
added on the 2011-02-06 23:31:21 by vibrator vibrator
You know what?

You guys need to fuck more.

I might consider bothering with you again when you've grown up.
added on the 2011-02-07 01:15:57 by vibrator vibrator
Well, I didn't realize showing you an example of your idea was a crap response :) . And can we be blamed for trying to bolster some productivity and bring in some new releases?
added on the 2011-02-07 01:39:10 by ferris ferris
Ferris: no, he's right - because nothing is more grown-up than insinuating that someone else does not get laid.
added on the 2011-02-07 14:28:41 by gloom gloom
literal lol
added on the 2011-02-07 14:37:29 by ferris ferris
haha what a monkey
Quote:
Making a demo requires a dedication I think I don't want to invest at this point. What's wrong with talking about technique? I like to discuss things and lay ground work. Maybe another place would be better for this anyway - to get away from the pointless crap responses one gets on pouet.


there's nothing wrong with discussion. i can't answer your post because i dont know squat about distance functions. though, instead try be patient, some smart guy will eventually answer your question(s).
added on the 2011-02-07 15:55:08 by rudi rudi
vibrator has a point. this is a bbs and it's the right place to talk/ask/discuss. "make a demo or be quiet" is not logical just like "you guys need to fuck more" isn't.

vibrator, your nick is killing me. "vibrator has a point" hahahahaha
added on the 2011-02-07 16:14:53 by Skate Skate
Quote:
The oldskool pouët BBS is not the demoscene, please visit a demoparty. This is merely a forum for sceners, with obviously too much free time, to release their frustrations and request salted communitary feedback, as opposed to polluting the prod comments section.

New users: please take your vaccines before entering, don't expect instant praise, and try not to feel easily insulted.
Old users: please don't feed the trolls. Reoccuring annoying behavior will result in a heavily subjective ban. Just try not to piss off 90% of our active users with childish and/or idiotic behaviour and you should be safe.

You have been warned.
added on the 2011-02-07 16:51:07 by raer raer
Skate: if you have read the whole thread you can clearly see that Ferris did in fact answer him, but vibrator just chose to be a dick anyway. That's the life of the BBS.
added on the 2011-02-07 17:14:23 by gloom gloom
BB Image
Ugly as fuck - but just a proof of concept.
3 RM-Steps:
Code: RM to surface refract (e.g. AIR -> GLASS) RM through surface refract (e.g. GLASS -> AIR) RM to next surface

But walking through the surface is somewhat pretty ugly - the distance is negative and in the beginning very small - so you start with a very (too) small step size inside the object - and I had some trouble with the epsilons...
+ You do not want refraction rays only.
added on the 2011-02-07 18:35:56 by las las
vibrator, i would say most raymarchers out there are using signed distance fields (negative inside of objects). it helps getting better normals.

as for your "invertible" cube, this is how you would usually do it in an optimized way:

Code: float signedDistToBox( in vec3 p, in vec3 b ) { const vec3 di = abs(p) - b; return min( maxcomp(di), length(max(di,0.0)) ); }


this was posted long ago in some of the other raymarching threads here at pouet, but it's true that the info is all scattered all over these threads and makes it difficult to find the info. So, answering your question, no, it's not a new thing, this idea is currently used in demos/intros already.
added on the 2011-02-07 18:36:48 by iq iq
Uhmmm, what about cutting out stuff from the distance function that is behind the viewer that looks from the first hit point in direction of the refracted ray...
added on the 2011-02-07 18:38:51 by las las
Here we go... Some more testing with refractions...

Two spheres
BB Image
BB Image

Cube & Sphere
BB Image
BB Image

Damn those artifacts... Maybe sth like total internal reflection? Epsilon screwd up?
added on the 2011-02-07 19:45:43 by las las
las: Perhaps you need to need to step back/forth a small amount along the normal for the reflection/refraction to make sure the ray doesn't immediately intersect with the object it hit?
added on the 2011-02-07 20:26:46 by kusma kusma
I thought I already did that... I rechecked the code and I obviously failed... ;)
BB Image
added on the 2011-02-07 21:38:19 by las las
Quote:
las: Perhaps you need to need to step back/forth a small amount

Vibrator already said
Quote:
You guys need to fuck more.
added on the 2011-02-07 23:57:18 by xernobyl xernobyl
That's what she said!
added on the 2011-02-08 09:26:02 by las las
Quote:
Making a demo requires a dedication I think I don't want to invest at this point.


pfft. so, you'd rather spent time updating pouet on your latest ideas of raymaching?!

if you shut down pouet and enter your thoughts into your editor and compile them - et voila - demo on the way!

login