Live data from Hacker News

Ray Marching Soft Shadows in 2D

rykap.com

31–37 of 37 posts

Re: Ray Marching Soft Shadows in 2D

#31
I can’t seem to find the PDF of Brent’s siggraph sketch in 2006 (Shadow map bias cones), but our follow up work [1] hopefully makes the connection between distance and r^2 clear: these techniques are all computing some sort of solid angle and filter width from that.

As Raph is mentioning in a side thread, there are lots of assumptions! (Some of them similar to the randomized assumptions behind alpha, generally).

[1] http://graphics.stanford.edu/~boulos/papers/prefilter_rt08.p...

Re: Ray Marching Soft Shadows in 2D

#32
This shows how broken webgl is on mobile...

On my Mediatek device, each demo worked great... Until I scrolled up the screen and then suddenly I saw a "Chrome error icon" in the demo... I refreshed the page and the demos were replaced with white boxes. I killed and restarted chrome and now the demos appeared to work till you interacted with them and they became black boxes.

Had to restart the phone to regain full functionality.

Re: Ray Marching Soft Shadows in 2D

#33

Earlier quoted context omitted.

The parent is saying that you can simply do the hard shadow algorithm but n times, starting from n random points uniformly sampled from a disk around the original point light source, then averaging the result. The bigger the disk the softer the shadow. This is how soft shadows are often achieved in ray tracing.

Ah, thanks for clarifying! I think someone already called this out above, but the benefit of the approach I describe is that you only need one sample per pixel. Four samples per pixel starts to feel pretty slow on my machine, and I suspect you'd need more than that to make the averaging approach look good.

One option might be to render, say, two samples per frame, and keep the previous samples when the light source doesn’t move. The shadows would be noisy while the light is moving, but quickly look smoother when it stops.

Re: Ray Marching Soft Shadows in 2D

#34
post #2

This reminded me of a shadow casting engine for the Pico-8 ( https://medium.com/hackernoon/pico-8-lighting-part-1-thin-da... ). Despite the limitations of the "console" the result is quite impressive: https://miro.medium.com/max/384/1*xgIPZgLgcJGBnRhFeJIJLQ.gif

oh yes, I was soo amazed (and still I am!) when I've first learned about this! Really clever work!

Re: Ray Marching Soft Shadows in 2D

#35

Uncaught Error: Failed to get uniform location for name O get graphics.ts:822 value graphics.ts:950 value graphics.ts:1234 value graphics.ts:493 value renderer.ts:355 value renderer.ts:471 onFrame app.ts:631 t app.ts:501 QCba index.ts:4 QCba index.ts:3 f src.515687e2.js:1 parcelRequire src.515687e2.js:1 src.515687e2.js:1 graphics.ts:822:14 firefox, ubuntu 20.04

Thanks! I just pushed a fix. Does it work now?

no its still broken, different errors now. you should look into adding metrics so you dont have users doing this for you

Uncaught Exception { name: "NS_ERROR_FAILURE", message: "", result: 2147500037, filename: "https://ray-marching-talk.netlify.app/src.c9ac1cf4.js", lineNumber: 20, columnNumber: 0, data: null, stack: "k@https://ray-marching-talk.netlify.app/src.c9ac1cf4.js:20:425... } canvas-scene.ts:1

Uncaught Exception { name: "NS_ERROR_FAILURE", message: "", result: 2147500037, filename: "https://ray-marching-talk.netlify.app/src.c9ac1cf4.js", lineNumber: 20, columnNumber: 0, data: null, stack: "k@https://ray-marching-talk.netlify.app/src.c9ac1cf4.js:20:425... } canvas-scene.ts:1

Uncaught Exception { name: "NS_ERROR_FAILURE", message: "", result: 2147500037, filename: "https://ray-marching-talk.netlify.app/src.c9ac1cf4.js", lineNumber: 20, columnNumber: 0, data: null, stack: "k@https://ray-marching-talk.netlify.app/src.c9ac1cf4.js:20:425... } canvas-scene.ts:1

Uncaught Exception { name: "NS_ERROR_FAILURE", message: "", result: 2147500037, filename: "https://ray-marching-talk.netlify.app/src.c9ac1cf4.js", lineNumber: 20, columnNumber: 0, data: null, stack: "k@https://ray-marching-talk.netlify.app/src.c9ac1cf4.js:20:425... } canvas-scene.ts:1

Uncaught Exception { name: "NS_ERROR_FAILURE", message: "", result: 2147500037, filename: "https://ray-marching-talk.netlify.app/src.c9ac1cf4.js", lineNumber: 28, columnNumber: 0, data: null, stack: "t@https://ray-marching-talk.netlify.app/src.c9ac1cf4.js:28:748... } app.ts:269

Re: Ray Marching Soft Shadows in 2D

#37

The algorithm discussed here reminds me very much of the "Line of Sight" problem. Line of Sight is calculated on a 2-d topographical map, where each 2d point is a height-map. The question is: does location "X" have a line-of-sight to location "Y" ?? You solve this question by marching rays from X towards Y, and seeing if any intermediate 2d point has a height that would block the sight. I bring this up because line-o…

You can use Jump Flood Assignment to compute the distance field in parallel. See: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.101...
Post reply on HN