On 7/22/2017 at 0:09 AM, Solid_Spy said:
I would love to learn how to use spherical gaussians, but unfortunately I can't find much info or any tutorials on the subject. The only info I could find were calc and theory based dissertations sadly. Do you know where I can find any practical information on the subject?
MJP made a real nice post about this and also wrote a sample demo for people to try. Should be enough to get you going.
On 7/22/2017 at 0:09 AM, Solid_Spy said:
Do you mean using only 9 SH textures for one texture atlas, then another 9 for another, and then combine both textures using deferred rendering? That I can do.
Each of your 3D textures likely has a world bounds, so you can render this bounds as a deferred volume (box, whatever) and apply it to the screen using deferred shading, adding up all the results of your 3D volumes (or using blending so that they overwrite what's below). This way none of your geometry shaders need to know about which volumes affect them, you don't need to scan for volumes that the object needs to be lit by, and you don't have to worry about excessive overdraw (where a light might relight the same pixel many times).
If you don't have a deferred shading pipeline in your engine or aren't sure how to add one, then you can also do an old-school forward shading pipeline where you render the geometry several times with additive blending over a base (which has ambient + sunlight/global lighting) using a new set of volume textures in each pass. Heavier on geometry load if you have heavy scenes but simple to implement (just iterate over your geometry draw for every N lights/volumes and set the appropriate data and blend state).
However if you can keep your texture count within whatever limit you set (either from hardware or a decision on your part) you can just use the single pass. I assume each object likely won't have more than 1-3 volumes affecting it, so if that assumption is correct and you've got a 32-texture limit, you should be able to handle several volumes. Even with 9 textures per volume that's 3 volumes per object + 5 textures for other stuff (diffuse, spec/gloss/roughness, normals, emissive - all of which can be combined in certain ways to reduce the number of samples and textures you actually need, the above can be combined down to 2 textures if you know what you're doing). I think in this case you should be just fine.
Cutting down to 5-gaussian SG lighting gives you more volumes and textures.