🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

"in game" lightmap creation

Started by
25 comments, last by Programmer71 1 year, 6 months ago

JoeJ said:

Aressera said:
Monte Carlo ray tracing is pretty much the only way to calculate accurate GI.

Wait and see… >:D

It's not the only way, but the easiest one. Mostly because it needs no parametrization, probes for a radiance cache, etc.

Ed Welch said:
This would be useful for procedurally generated scenes, which can't use offline creation.

How do those scenes look like, how large? How do you plan to get lightmap UVs? What's your requirement on quality? (just diffuse or some directional for specular too reflections? One, N, or infinite bounces? How large can a single lightmap texel be?)

Scenes are small (this is what the game looks like: https://ed-welch.itch.io/merc-tactics)

I haven't really done any investigation on lightmap UV generation yet (and that GI stuff is really over my head to tell the truth)

I guess quality would have to take a hit, to be rendered in a reasonable time. specular not needed, one, or two bounces

Advertisement

Looks nice.
But it's pretty flat, so the effect of GI would be subtle. Not worth to sink much time into that damn GI problem, i would say first ; )

Have you tried some screenspace GI post effects using Reshade or such tool? Afaik, good filters often have some cost and you could get them from Patreon. But i guess this would give you already most of the benefit with acceptable error for this game. And then you could peek a bit at the shader code as well.

Here's an example of such method, working even pretty well for complex interiors:

Afaik, the dev is gfx lead for the Path Of Exile game, which does all lighting in screenspace. Nice soft shadows. So this game also would be a good example on how good this works for top down perspective.

Another simple (baking) solution would be to render a volume probe grid. You would render a cube map per probe, then down sample it to Valves Ambient Cube or SH2 basis. Lookup at runtime is trivial.
This would give less detail than screenspace GI, but also less artifacts.
Edit: Adding bounces is pretty simple:
1. Render the scene as you do now to the cube maps.
2. Convert cubemaps to probes, and add their contribution to your rendering. (It's a trivial lookup like with a volume texture, if you use a regular grid for probe placement.) You could keep higher res cubemaps too to support specular, in theory.
3. Continue with step 1 but this time using your new and improved rendering including the GI contribution from the old probes.

That's basically how the Radiosity Method i've talked above works. If you repeat the process 5 times, you have 5 bounces. The scene becomes brighter with each step. For outdoor scenes, adding one more bounce likely would show no more difference, so the solve has converged.

Ed Welch said:

Does anyone of a game engine where the lightmaps are created automatically in the game? (i.e. during scene loading, not in the editor)

https://youtu.be/0wd-cy-lP7g

The lighting in that game is all run-time baked lightmaps, on PS3/360. First a low quality bake is done quickly on the loading screen, and then 1ms per frame of GPU time is budgeted per frame to perform higher quality bakes over the course of a match.

@JoeJ

Thanks very much for the advice. I had a quick look at ambient occulusion shader and Glamarye Fast Effects in Reshade and it seems to give reasonable results for little effort. I will check the other stuff you mentioned out.

Ed Welch said:
Monte Carlo ray tracing is pretty much the only way to calculate accurate GI.

Path tracing (and dozens of its subvariants - unidirectional, bidirectional, next event estimation, etc. etc.) were the only way to calculate unbiased accurate GI. Yet… Progressive photon mapping is the other one (unlike standard photon mapping, as this is progressive - it is unbiased - given “enough time” you will get accurate results).

As far as I recall, Tower22 did dynamic calculation of light maps, back them - when they were still active. You'd have to look in older posts - http://tower22.blogspot.com/​ - at this point I don't think project is actively developed anymore.

For small scenes - if dynamic lighting is a must - I'd go for VCT approach. It tends to have problems mainly with larger scenes or finer details. Even a single bounce can be enough for very good results. But there are MANY other approaches that will work.

Of course, path tracing and filtering is possible - but somewhat extremely heavy on resources. Not to mention dynamic geometry, particles, etc. Support on older hardware. Some things are a bit of pain with that.

My current blog on programming, linux and stuff - http://gameprogrammerdiary.blogspot.com

Ed Welch said:
Does anyone of a game engine where the lightmaps are created automatically in the game? (i.e. during scene loading, not in the editor)

In one of my oldest engines ~15 years ago, i have tried to auto generate a common lightmap texture for every model. Instead of generating a texture one by one, i used a common big texture to do it. It worked, but the results were very disappointing. I scrapped it and switched to vertex coloring instead.

I assume that using prebaked lightmaps is not an option for you, probably because the scenes are partially or wholly procedurally generated. The options are therefore “dynamically generated lightmap” and “no lightmap”.

Have you considered not using lightmaps at all?

Godot could be another option. It's open source, and the editor and the engine are the same program (with the editor parts optionally removed for distribution), so if it can bake lightmaps at all, it should be able to do so at runtime.

a light breeze said:
Godot could be another option. It's open source, and the editor and the engine are the same program (with the editor parts optionally removed for distribution), so if it can bake lightmaps at all, it should be able to do so at runtime.

I asked in the Godot forums and they said it's only possible in editor. Anyways I'm investigating screen space ambient occlusion as an alternative.

Forget lightmaps in realtime.

If you're looking for generating runtime lighting for low end HW then volumetric probes is the way to go. This has a good overview of what I mean, even if their realtime version is very much WIP. Lightmaps have always been a nightmare of errors even offline.

This topic is closed to new replies.

Advertisement