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.
GPU accelerated volumetric shadowbuffer
GPU accelerated volumetric shadowbuffer
- Attachments
-
- volumetric_paint.love
- (2.1 MiB) Downloaded 452 times
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: GPU accelerated volumetric shadowbuffer
Holy crap that's heavy. I only get 2 FPS out of it on my trusty laptop.
Help us help you: attach a .love.
Re: GPU accelerated volumetric shadowbuffer
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
Btw, forgot to write that you can move the light source with the arrow keys and change the brush size with the mouse wheel.
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
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
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 .
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
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
Here's an updated version. I changed the absorption so that it multiplies by the absorption factor rather than subtracting it. Also added background
- Attachments
-
- volumetric_paint_v0.1.love
- (1.99 MiB) Downloaded 339 times
- xXxMoNkEyMaNxXx
- Party member
- Posts: 206
- Joined: Thu Jan 10, 2013 6:16 am
- Location: Canada
Re: GPU accelerated volumetric shadowbuffer
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?
Re: GPU accelerated volumetric shadowbuffer
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 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.
Also, I guess you're right, except area-metric isn't really a word 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.
- AntonioModer
- Party member
- Posts: 202
- Joined: Fri Jun 15, 2012 5:31 pm
- Location: Belarus
- Contact:
Re: GPU accelerated volumetric shadowbuffer
I run this demo ( volumetric_paint_v0.1) in LOVE 0.9.2, and have bug:
Help to fix this bug, please.
I try fix this, but not successful.
Help to fix this bug, please.
Re: GPU accelerated volumetric shadowbuffer
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)
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
- AntonioModer
- Party member
- Posts: 202
- Joined: Fri Jun 15, 2012 5:31 pm
- Location: Belarus
- Contact:
Re: GPU accelerated volumetric shadowbuffer
Change in conf.lua variable "screen" to "window".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)
Help: https://www.love2d.org/wiki/Config_Files
Who is online
Users browsing this forum: No registered users and 7 guests