News for hackers. Stuff that matters.
Re:Depth of Field by dahart on Tuesday May 28, 2019 @04:06PM (#20033842)
Since the theory isn't really described here, anyone who wants a tad more might look at the Ray Tracing In One Weekend booklet for a touch of the optics math behind depth of field. Chapter 11 derives a defocus blur. http://www.realtimerendering.com/raytracing/Ray%20Tracing%20...

> find the new position, w = v + rndSphere(r).

For anyone wanting control over the look of the defocus blur, also known as the "bokeh", random sphere gives you more samples toward the center than the edges. For a circular aperture, it is slightly better & more correct to sample a disk than to sample a sphere, and slightly faster to converge as well. You can optionally use a hexagon or octagon on the disk if you want to get the look of a film-camera type aperture.

Re:Depth of Field by inconvergent on Tuesday May 28, 2019 @04:29PM (#20034070)
i would say that what is correct depends on the intention
Re:Depth of Field by dahart on Tuesday May 28, 2019 @04:45PM (#20034202)
I'm talking about correctness in the physical optics/lens sense. With lenses, light always passes uniformly through the aperture, where sphere sampling is non-uniform.

Intention is totally fine. This is reasonable if you actually intended to do something different than what a camera does, or if the intention is not physical correctness. This blog post seems to be intending to do something easy for picking samples, as opposed to something optically correct. I'm all for easy, but I also think it never hurts to understand the tradeoff you're choosing, nor to present the harder alternatives.

It's also worth considering disk sampling rather than sphere sampling, because it's barely any harder, and it will make the code converge to the same quality something like 2x faster. Sphere sampling spends too much time in the middle and not enough at the edges. Disk sampling only takes a teeny tiny bit more arithmetic. Jittering & QMC methods will also help a lot with efficiency.

Re:Depth of Field by inconvergent on Wednesday May 29, 2019 @02:00AM (#20037204)
yeah, i'm going for easy. and also, easily explainable. i like to leave some of the details up to whoever tries it. which is also why i generally don't include code anymore. i guess i could have had more references though.

sphere sampling has the appearance i want. but sampling inside discs with a probability over the disc radius would also work, probably. i didn't try it here.

Re:Depth of Field by tylermw on Tuesday May 28, 2019 @12:38PM (#20031775)
Nice. I created a package to generate similar depth of field images in R, using a depth map/image pair. Also offers customizable bokeh shape and some other nice features.

Github: https://github.com/tylermorganwall/rayfocus Blogpost: https://www.tylermw.com/portrait-mode-data/

Re:Depth of Field by jv22222 on Tuesday May 28, 2019 @02:32PM (#20032946)
From his generative collection these ones really stand out:

https://img.inconvergent.net/img/gen/20170523-193637-305712-...

https://img.inconvergent.net/img/gen/20170520-230701-136920-...

It's almost hard to believe they are computer generated. They just seem so organic.

Re:Depth of Field by sq_ on Tuesday May 28, 2019 @02:48PM (#20033096)
It looks like the links you posted are broken because the site owner doesn’t allow hotlinking to those images.

Could you post the link to the blog post with those images? I’d absolutely love to see them!

Re:Depth of Field by sq_ on Tuesday May 28, 2019 @04:15PM (#20033910)
Thanks for linking those, Anders. jv22222 is right, they really do look amazingly organic. Love your work!
Re:Depth of Field by inconvergent on Wednesday May 29, 2019 @02:10AM (#20037248)
thank you. btw, the green one is rather similar to floraform by Nervous System. https://n-e-r-v-o-u-s.com/projects/sets/floraform/
Re:Depth of Field by sq_ on Wednesday May 29, 2019 @11:33PM (#20048134)
If you don't mind me asking, can you recommend any good resources for getting into generative art?

I've been interested for a while and played around a bit, but I'd like to dive in a bit more since I have a bit more spare time now than I've had in while.

Re:Depth of Field by inconvergent on Thursday May 30, 2019 @06:13AM (#20049766)
there are some references on my website. see the faq and the generative section. there are many ways to start. depends on your previous knowledge and how you prefer to work. the nature of code is a book that might be of interest. Nervous System have written up several of their projects. then there is the work by early generative artists. Vera Molnar, Frieder Nake, Manfred Mohr, Lillian Schwartz, among others. also, see https://github.com/terkelg/awesome-creative-coding/blob/mast...
Re:Depth of Field by sq_ on Thursday May 30, 2019 @03:13PM (#20054891)
Thank you for the recommendations! I’ll check them out.
Re:Depth of Field by Kuraj on Tuesday May 28, 2019 @06:16PM (#20034962)
Hitting enter in the address bar allows you to access them
Re:Depth of Field by londons_explore on Thursday May 30, 2019 @05:26AM (#20049592)
On Chrome mobile you need to put a '?' in the URL so it thinks it's a new site and doesn't send the referrer.
Re:Depth of Field by sq_ on Tuesday May 28, 2019 @07:06PM (#20035303)
I was accessing them on mobile earlier, so maybe that was the difference? I'm almost certain I did that.

Either way, the author posted the links, so I saw what jv22222 was talking about.

Re:Depth of Field by tomxor on Tuesday May 28, 2019 @12:45PM (#20031853)
So pretty! I'm going to assimilate this purely for the aesthetic pleasure :D
Re:Depth of Field by ratsimihah on Tuesday May 28, 2019 @01:22PM (#20032203)
I know this is so hot! And written in Lisp, I'm having a nerdgasm!
Re:Depth of Field by londons_explore on Thursday May 30, 2019 @05:24AM (#20049582)
This could be made a lot clearer with an animated version either changing the focus depth or rotating the view...
Re:Depth of Field by tenaciousDaniel on Tuesday May 28, 2019 @12:25PM (#20031647)
Why is the randomization necessary?
Re:Depth of Field by dahart on Tuesday May 28, 2019 @04:00PM (#20033779)
It's not necessary, but it's convenient. What's actually happening here is Monte Carlo integration. Randomness guarantees you get the right answer. It prevents correlation artifacts. It also gives you a nice film grain look when you don't have the time to take samples until complete convergence.
Re:Depth of Field by inconvergent on Tuesday May 28, 2019 @12:28PM (#20031672)
you get unwanted artefacts in the results if you don't use some randomness. having said that, there might ways of reducing the need for it (which would be more efficient).