Page 1 of 2

GPU accelerated volumetric shadowbuffer

Posted: Wed Mar 19, 2014 9:28 am
by Jorzi
After getting inspired by PriorBlue's Light vs Shadow engine, I decided to tackle the problem of semitransparent shadows in arbitrary shapes of varying optical density. Since this requires some serious computing I implemented all the heavy calculations as fragment shaders.

The demo starts with a black screen but you can paint in stuff with lmb and rmb.

Re: GPU accelerated volumetric shadowbuffer

Posted: Wed Mar 19, 2014 12:05 pm
by Robin
Holy crap that's heavy. I only get 2 FPS out of it on my trusty laptop.

Re: GPU accelerated volumetric shadowbuffer

Posted: Wed Mar 19, 2014 2:03 pm
by Jorzi
Hi, what's your GPU?
What the algorithm does is it starts by converting the map into polar coordinates, then it integrates (cumulative sum) over the radius, i.e. downwards on the texture. The integration is currently very unoptimized and could theoretically be reduced from O(N^2) to O(N), but I have to figure out how to do that on the GPU.

Meanwhile, if you want to hack the code, try lowering the range (the third component) of the light source for a smaller shadow buffer.
I personally get 60FPS on my gtx 560 but I guess that's a little hardcore for a 2d game :P

Btw, forgot to write that you can move the light source with the arrow keys and change the brush size with the mouse wheel.

Re: GPU accelerated volumetric shadowbuffer

Posted: Wed Mar 19, 2014 9:05 pm
by PriorBlue
Wow the shadow quality is amazing, i have made a ray tracing pixel shadow engine by my self (http://www.love2d.org/forums/viewtopic. ... er#p163757) with additional glass effect, but it was very slow so i skipped it. I hope you can make it better :).

Oh and please give the floor a color or texture, so we can see the nice shadow effect more easily :).

Re: GPU accelerated volumetric shadowbuffer

Posted: Fri Mar 21, 2014 7:09 am
by Jorzi
Yeah I looked at that one :) I think yours could be pretty fast if done with shaders.

Here's an updated version. I changed the absorption so that it multiplies by the absorption factor rather than subtracting it. Also added background

Re: GPU accelerated volumetric shadowbuffer

Posted: Sat Mar 22, 2014 8:51 am
by xXxMoNkEyMaNxXx
This looks great! To make it as complicated as possible, I would be trying to use a solved integral, but you would probably end up with erf or Ei, so you'd have to implement them if they come up... I like solved integrals. Also, since this is in 2D, wouldn't it be an area-metric shadow buffer? :rofl:

Re: GPU accelerated volumetric shadowbuffer

Posted: Sat Mar 22, 2014 1:39 pm
by Jorzi
What is a solved integral and can you apply it to numerical computations?
Also, I guess you're right, except area-metric isn't really a word :P You could think of it as volumetric for an infinitesimal slice dz.

Anyway I have tried to calculate the integral(/cumulative product) over the radius more efficiently but I really need to do it purely on the gpu, otherwise it'll be too slow...
The current algorithm recalculates the product of all previous elements for each pixel, but it's still faster than calculating anything in lua.

Re: GPU accelerated volumetric shadowbuffer

Posted: Wed Aug 12, 2015 7:06 pm
by AntonioModer
I run this demo ( volumetric_paint_v0.1) in LOVE 0.9.2, and have bug:
bug in 0.9.2.jpg
bug in 0.9.2.jpg (71.26 KiB) Viewed 7518 times
I try fix this, but not successful.
Help to fix this bug, please.

Re: GPU accelerated volumetric shadowbuffer

Posted: Thu Aug 13, 2015 1:34 pm
by T-Bone
When I try to run it on Löve 0.9.2 on Windows 8.1, I get

Code: Select all

boot.lua:339: conf.lua:9 attempt to index field 'screen' (a nil value)

Re: GPU accelerated volumetric shadowbuffer

Posted: Thu Aug 13, 2015 8:34 pm
by AntonioModer
T-Bone wrote:When I try to run it on Löve 0.9.2 on Windows 8.1, I get

Code: Select all

boot.lua:339: conf.lua:9 attempt to index field 'screen' (a nil value)
Change in conf.lua variable "screen" to "window".
Help: https://www.love2d.org/wiki/Config_Files