Distance field attempts

A picture is worth a thousand words.

Distance field attempts

Postby beason » 11 May 2009, 03:36

portal.jpg
portal.jpg (368.2 KiB) Viewed 4136 times


Bug in distance field intersector opened a portal. Oops. This was encountered in my feeble attempt to emulate the scene in Inigo Quilez's slisesix http://www.pouet.net/prod.php?which=51074
Sadly I gave up. But I did get these out of it also:

http://beason.deviantart.com/art/Field- ... -121992555 (attached)
http://beason.deviantart.com/art/Another-Bug-122037670
http://beason.deviantart.com/art/Monster-121991033 (attached)
http://beason.deviantart.com/art/Monster-121991033
Attachments
monster.jpg
monster.jpg (269.49 KiB) Viewed 4076 times
field_of_holes.jpg
field_of_holes.jpg (145.37 KiB) Viewed 4040 times
quad core abuser
User avatar
beason
SNR police
 
Posts: 434
Location: Los Angeles, CA

Re: Distance field attempts

Postby BlindSideAsGuest » 11 May 2009, 07:03

Interesting. I managed to get a metaball or two showing in a pixel shader and that's about as far as I got with distance fields. I've been thinking about having another go and tracing a full scene similar to your attempts. I can vaguely see that camera lens warping effect Inigo had in his screenshot in yours, despite the bug it's not a bad attempt. The slithery thingy would have been my first goal though.

Any comments on performance? Did you try any particular optimization for this method?
BlindSideAsGuest
 

Re: Distance field attempts

Postby beason » 11 May 2009, 08:47

One ray per pixel is about 5-6 seconds for these simple fields on a quad core 2.4ghz intel q6600.
I didn't do any optimization. Just step the field distance each time (with a minimum step size) and a few iterations of bisection method to refine.

I didn't do any camera ray warping.

I was stumped by the slithery thing. How would you model that field? The long tentacles in particular. I can do a regular ball. :)
quad core abuser
User avatar
beason
SNR police
 
Posts: 434
Location: Los Angeles, CA

Re: Distance field attempts

Postby BlindSideGuest » 11 May 2009, 09:02

I don't want to talk like I know it before I attempt it myself, but according to Inigo you start by taking the distance to an arbitary axis, or line. Say f is our distance function:

[...]

For instance that would give you the distance to the axis at a position 10 units above the y plane, right? You end up with a simple cylinder. Now here's where the trickery comes in, you do something like this:

[...]

and that's more or less all there is to it, just offset the sampling position using perlin noise based on the position along that axis. Because we are not taking the X value into account in our calculation anyway, it should produce fairly consistent results as our seed. (But I am yet to try this so don't take my word for it!) :P

More info in this very informative (And increasingly hard to find because half of Inigo's links lead to a 404) presentation: http://iquilezles.org/www/material/nvscene2008/nvscene2008.htm

EDIT by toxie: see below
BlindSideGuest
 

Re: Distance field attempts

Postby BlindSideGuest » 11 May 2009, 09:05

I should stop posting as guest, can't edit my posts now :(

Anyway the code should have been:

Code: Select all
f(vec3 pos)
{
  vec3 offsetPos = pos;
  offsetPos.y += 10.0;
  return length(offsetPos.yz)[b] - 10.0[/b];
}


And that would give us a cylinder of radius 10 along the X axis. I know it's obvious to see but I hate saying incorrect things. :P Also for the sake of correction the second code snippet should be:

Code: Select all
f(vec3 pos)
{
  vec3 offsetPos = pos;
  offsetPos.y += 10.0;
  offsetPos.y += perlinNoise(pos.x);
  offsetPos.z += perlinNoise(pox.x);
  return length(offsetPos.yz) - 10.0;
}
BlindSideGuest
 

Re: Distance field attempts

Postby davepermen » 11 May 2009, 09:36

the tentacle code is actually all documented and shown in a presentation you'll find on the original developers page. don't know the link right now.. but got it working myself more or less thanks to it.
User avatar
davepermen
 
Posts: 272
Location: Switzerland

Re: Distance field attempts

Postby tbp » 14 May 2009, 06:39

Said link appeared 2 posts ago and makes for a truly fascinating read; i think it's only fair to hide such knowledge deep down a mighty 404 forest.
Press any key to continue: _
radius | ompf | stuff | tokaspt
User avatar
tbp
Overlord
 
Posts: 1445
Location: France

Re: Distance field attempts

Postby beason » 14 May 2009, 19:12

Yes, thank you for the link! I will definitely give it a read soon.
quad core abuser
User avatar
beason
SNR police
 
Posts: 434
Location: Los Angeles, CA

Re: Distance field attempts

Postby BlindSide » 24 Oct 2009, 01:04

Bit of an old post but I finally decided to have a crack at this. I didn't use any root finding or minimum step size, this took about 8 seconds on my laptop:

Image

The AO/fake shadows was surprisingly easy to achieve thanks to Inigo's paper, I didn't even have to tweak any of the params or sample amount after the first render.
User avatar
BlindSide
 
Posts: 50
Location: Auckland, New Zealand

Re: Distance field attempts

Postby beason » 24 Oct 2009, 02:01

Cool! Nice application of the basic approach to three shapes. So are those soft shadows only using one ray then?
quad core abuser
User avatar
beason
SNR police
 
Posts: 434
Location: Los Angeles, CA

Re: Distance field attempts

Postby BlindSide » 24 Oct 2009, 04:01

I sampled 5 points along the normal and used the difference between the closest distance and the distance to the shading point as a factor for the AO, very similar to what's shown in slide 52 of the pdf. That's actually purely AO but the samples are quite spread out so it could pass for a soft shadow.
User avatar
BlindSide
 
Posts: 50
Location: Auckland, New Zealand

Re: Distance field attempts

Postby Reinder » 24 Feb 2010, 09:26

Two weeks ago I spend 7 hours to implement a very simple distance field renderer using de Go language (as an experiment and just for fun).

You can find my results here:

http://www.infi.nl/blog/view/id/47/Rendering_distance_fields_using_the_Go_language
Reinder
 

Re: Distance field attempts

Postby beason » 09 Mar 2010, 02:55

Reinder wrote:Two weeks ago I spend 7 hours to implement a very simple distance field renderer using de Go language (as an experiment and just for fun).

You can find my results here:

http://www.infi.nl/blog/view/id/47/Rendering_distance_fields_using_the_Go_language


That's pretty cool. Nice choice of language and fast dev time! Also I like the complexity achieved. Thank you for sharing.
quad core abuser
User avatar
beason
SNR police
 
Posts: 434
Location: Los Angeles, CA


Return to Visuals

Who is online

Users browsing this forum: No registered users and 1 guest