[WIP] Custom Realtime 2D GI in Unity3D
Posted May 30, 2018, 8:20 PM UTC
Posted May 30, 2018, 8:20 PM UTC
This is insanely cool. So will you be able to make something like a Diablo 2 looking 2d thing that has this kind of lighting?
Yeah, although i would use 3D models and just sample the lighting in 2D.
If i offset the sample point based on the normal, It should look pretty good on a 3D model.
I look forward to seeing how that will look. Good luck man.
Oh baby that looks amazing
You might want to take a look at these articles: https://habr.com/post/313776/
It's in Russian, but you should be able to get the general idea using google translate:)
This article breaks down the general concept. although its a baked version of it and its only for the skylight. Doesnt look like any of the point/spot/emissive light stuff contributes.
"Speed ​​of work. About two seconds to calculate the lighting when the level is loaded" - Ouch, and that's only at 25 directions, I think the above clip was done at 256 directional samples and is all done in realtime. I still have a lot of optimizations to go as well.
In the last article he has attached following video: https://www.youtube.com/watch?v=12ibOr3G2Sg
Which is realtime and really cool:)
Your work is wonderful, no doubts. It's amazing how the yet-to-come 3d tech is already there in 2d.
None of the GI in that video is dynamic. The only lighting in these articles that has bounce lighting is the skybox and it is baked when the level loads (2 seconds).
All the dynamic lighting in this scene only contains direct lighting. It looks like they just modulate the brightness of the baked texture with the time of day.
Edit: Looks like it works well for there use, it just means none of the world can really be dynamic (terraria)
Ok, I see. Thanks:)
So can you move the camera around too, or is the SDF baked?
SDF gets generated every frame, so everything is dynamic.
I haven't added the ability for the volume to move yet, but its possible.
That's really cool. Thanks for sharing
May I ask how you are generating the Voronoi Diagram and SDF? Is that with a computer shader?
Has to be either compute or jobs or a combination of both. With the performance he is reporting I have to guess it is purely compute shaders
Yes its a compute shader. Voronoi Diagram is generated using a Jump fill algorithm. Then the SDF just calculates its distance to the Voronoi cell.
It could be done in a pixel shader as well though.
Very impressive, any chance that you would sell this?
It's hard for me to support assets as my time is spread pretty thin. If the system isn't close to automatic then I have to spend too much time helping people.
My team wants to make a jam game using this, So ill get it production ready over the next week. If I'm happy with the results and how easy it is to use, ill consider releasing it.
You can also sell it just to me, as is, once its production ready of course 🙃
Alright, this is straight up amazing. I couldn't even think of something like that, let alone make it.
I had a dream about a isometric game that used 2D lighting so I put this together as a proof of concept.
All the emissive surfaces in this scene are white. the colors come from the light bouncing off all the surfaces.
It uses a world G_buffer to store the material properties of all the light blocking and emitting surfaces.
I generate a Voronoi Diagram from all surfaces.
I use this data to calculate a Signed Distance Field of the world.
Each pixel then pathtraces the world and uses the SDF to accelerate the trace.
This gives me the direct lighting data from all emissive surfaces. This buffer is then feed into the next frame and added to the emission of every surface, Giving me infinite bounces.
I'm working on a few methods to speed up the lighting calculation, but its already fast enough for realtime use on current hardware.
It's mostly a set cost, Adding more lights doesn't effect the speed of the effect.
This is a super cool algorithm. Do you think it could scale to SDF-defined scenes in three dimensions?
I have a version that I'm working on that is going to be similar to this but in 3D. It wont be as responsive though, I've done a lot of work trying to get 3D GI working in realtime + runtime. I have a few different solutions that work pretty well.
Biggest issue is making it scalable to large scenes. Memory really becomes an issue when you expand this to three dimensions.
that's awesome. thanks so much for sharing your process!