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?
The normal in an SDF flips when moving from the inside to the outside (or vice versa) - right?
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.
Ignore the noise.
Finally some caustics! :) Or are they?
I say increase the noise. Plug in ambient drones. Edge detect.
Profit :)
Profit :)
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 :)
Nice caustics btw. That's starting to look pretty good :)
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:
\o/
Reality sucks. Demoscene solutions \o/ :D
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
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?)
buzzword bingo: fresnel, schlicks approximation.
And if you are not blind you can see the reflections. ;)
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.
But that's a pretty small area where you have those 100% reflections on the edges.
We use Schlick's approximation:
And in that screenshot R_0 = 0 - so there is not that much reflection at all.
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.
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.
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.
My turn: Raymarching of rounded cubes with refraction & reflection in a raytraced scene. (I dont handle specular and transparency correctly.)
nice cubes :D
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.
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.
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.
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.
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
you might have better chances asking the guy who did this, not the one posting only to residue threads
Vectory: I see. Lame.
@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?
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?
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.
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.
[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.
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.
(And marching inside objects is a really nasty thing... But you can.)