godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.13k stars 69 forks source link

Add a cheap specular occlusion for LightmapGI #8637

Open guerro323 opened 9 months ago

guerro323 commented 9 months ago

Describe the project you are working on

I'm working on a procedural and UGC game where users can create their own maps from blocks and custom models.

Describe the problem or limitation you are having in your project

Some surfaces can have metallic or reflective materials that still receive reflections (from environment sky or reflection probes) even though they should be darkened/occluded from lightmaps.

I can't use directional lightmaps as they take more size and takes longer to compute (they're also buggy at the moment).

Describe the feature / enhancement and how it helps to overcome the problem or limitation

The goal would be to add specular occlusion to lightmapped meshes.
To make it as cheap as possible, its value would be taken from the brightness of the current targeted LM pixel and then decrease its specular intensity.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

It should work out of the box without the user needing to do anything.
There should be an option (in the project settings or material) to disable (or enable) specular occlusion as it can be intended for some games.

I made a proof of concept by editing the existing code, and complementing it with my other PR (https://github.com/godotengine/godot/pull/86039) : No Lightmap Lightmap on 4.2 With specular occlusion Specular Occlusion + PR (LM+SDFGI)
no lightmaps godot 4.2 lightmap & specular occlusion lightmap & specular occlusion + sdfgi

If this enhancement will not be used often, can it be worked around with a few lines of script?

I don't think it's possible unless you're able to get the lightmap data from shader.

Is there a reason why this should be core and not an add-on in the asset library?

LightmapGI is core

Calinou commented 9 months ago

I think this is a great idea, even if it's not physically accurate.