pouët.net

Go to bottom

Raymarching Beginners' Thread

category: code [glöplog]
Just one really simple question... I definitly need some more sleep...
The normal in an SDF flips when moving from the inside to the outside (or vice versa) - right?
added on the 2011-07-22 17:34:27 by las las
If you construct your normal using central differences (by sampling your SDF), then yes. Also depends on what you mean by flips… When the boundary of the object defining the SDF crossed the normal faces the exact opposite direction it faces when it is on the surface of the object boundary.
added on the 2011-07-22 19:08:48 by decipher decipher
BB Image
Ignore the noise.
added on the 2011-07-22 19:33:42 by las las
Finally some caustics! :) Or are they?
added on the 2011-07-22 19:50:23 by decipher decipher
I say increase the noise. Plug in ambient drones. Edge detect.

Profit :)
added on the 2011-07-22 19:57:18 by ferris ferris
las: thanks, I'll give that tool a go. In the end I made a quick custom tool to inspect the LUT I made before - and found that it was quite badly screwed up, making it even harder to see! (That was the whole point of having a viewer to see what's going on :) So yeah, a decent viewer that can handle strange cases like this = essential.

Nice caustics btw. That's starting to look pretty good :)
added on the 2011-07-22 21:38:19 by psonice psonice
I have to mention that "realistic" materials SUCK.
Something like AIR|WATER WATER|AIR kinda sucks. AIR|WATER AIR|WATER is completely unrealistic but looks so much better (the screenshot above is the unrealistic one - it's 512 sppx and the way we compute the caustics sucks and introduces a lot of noise - 2048 sppx finished some minutes ago and looks awesome :D)...
That's why our glass material supports:
Code: bsdfs->setEtaBehavior(GlassMaterialFlags::ETA_UNREALISTIC);

\o/


Reality sucks. Demoscene solutions \o/ :D
added on the 2011-07-22 23:39:55 by las las
are you doing reflection as well as refraction there? For decent looking glass, you need both. (And I've totally forgotten what the function is called, where you have transparency when the normal faces the camera, and reflection when the normal is at a tangent to the camera. Wtf is that called?)
added on the 2011-07-23 01:49:20 by psonice psonice
buzzword bingo: fresnel, schlicks approximation.
added on the 2011-07-23 01:52:04 by las las
And if you are not blind you can see the reflections. ;)
added on the 2011-07-23 01:58:50 by las las
Yes, but no reflection caustics, and the reflections look quite weak compared to the refractions. Reflection should be near 100% at the edges if I remember me fresnels right.
added on the 2011-07-23 10:34:22 by psonice psonice
But that's a pretty small area where you have those 100% reflections on the edges.
We use Schlick's approximation:
Code: reflectance = R_0 + (1-R_0)*(1 - cos(theta))^5

And in that screenshot R_0 = 0 - so there is not that much reflection at all.
added on the 2011-07-23 11:25:54 by las las
Schlick's approximation is for specularity on metals, not fresnel on liquids/glasses etc. Your highlights do look kind of metallic :) (Which is cool, but maybe not right for glass/water... but totally add a chrome ball :D )

From a very quick refresh of how fresnel effects work, for air->glass, the only time there's 100% refraction is at about 56º. At a tangent to the surface you get about 10% reflection, and parallel to the surface you get 100%. There's also internal reflection, and beyond the critical angle (just 41º for glass->air!) you get 100% reflection.

added on the 2011-07-23 18:03:57 by psonice psonice
BB Image
added on the 2011-07-23 18:31:33 by w00t! w00t!
My turn: Raymarching of rounded cubes with refraction & reflection in a raytraced scene. (I dont handle specular and transparency correctly.)

BB Image
BB Image
added on the 2011-07-23 21:27:07 by T21 T21
nice cubes :D
added on the 2011-07-24 01:33:47 by las las
yo nice. still missing sharp light distribution in the cast shadows. that would break a shot.

btw... can I have a screen in 1366x768 next? would be a nice motivational on my desktop.

I really need to get into that shit... now that I atleast have the hardware for that. mmh.
added on the 2011-07-24 01:49:25 by yumeji yumeji
Yep, lots of tasty cubes :)

wsw: any chance of a video of that one? It looks good, but unrounded glass cubes are confusing as fuck to look at somehow :) Some motion really helps.
added on the 2011-07-24 02:45:08 by psonice psonice
psonice: http://wiki.blender.org/uploads/f/ff/With-total-internal-reflection-2.jpg
you might have better chances asking the guy who did this, not the one posting only to residue threads
added on the 2011-07-24 03:52:54 by vectory vectory
Vectory: I see. Lame.
added on the 2011-07-24 11:54:29 by psonice psonice
@T21 : Impressive screenshots. One question : how to handle refraction + transparency using raymarching ?

For reflection its very easy, just raymarche until you hit something, then once you hit, reflect ray direction (using surface normal), move a little bit from surface (increase t) and raymarche again...

For refaction :
Lets say we hit something transparent : we refract (indice of glass?) the direction vector.

How to move the ray to be sure we are outside the object ?
Then once we get our two colors/distance how to combine them to handle transparency?
added on the 2011-07-24 14:52:37 by Tigrou Tigrou
tigrou: glsl has a refract() function. If you're doing transparency + reflection, you have to split the ray and march twice. When you do the refraction, get the new ray direction with refract() and move forward by say 2.5x epsilon (1 moves you to the surface, 2 moves you to surface+e inside, then you want to move slightly more so it's a safe distance).

To handle mixing back together, you need to get the mixing factors at the time when the ray hits the surface, because it depends on the fresnel effect (which depends on the normal/ray direction angle). Guess you could store the fresnel curves in a LUT.
added on the 2011-07-24 15:28:21 by psonice psonice
[img]
http://research.mercury-labs.org/RT/SPIKEBALL_GLASS_4k.png
[/img]
It's not perfect - but one of the pictures of our final presentation we had today.
added on the 2011-07-29 20:52:42 by las las
BB Image
added on the 2011-07-29 20:53:26 by las las
(And marching inside objects is a really nasty thing... But you can.)
added on the 2011-07-29 20:56:02 by las las

login

Go to top