gdx-gltf icon indicating copy to clipboard operation
gdx-gltf copied to clipboard

[Feature Request] Add Spherical Harmonics to PBR light shader

Open fgnm opened this issue 2 years ago • 2 comments

Again, this could be another minor feature, however could be nice to have :) A brief explain of Spherical Harmonics can be found in the ARCore documentation, with also some examples: https://developers.google.com/ar/develop/lighting-estimation#ambient_spherical_harmonics

I also noticed that in the default libGDX shader spherical harmonics are implemented but there's nothing that sets the sphericalHarmonicsFlag in the Java side.. https://github.com/mgsx-dev/gdx-gltf/blob/c8047c23a269179c985664b5869a25e056d8c84a/gltf/src/net/mgsx/gltf/shaders/default.vs.glsl#L279-L289 Weird, btw this could be an improvement to this library, a lot of PBR rendering implements this feature.

Thanks!

fgnm avatar Nov 22 '22 14:11 fgnm

@mgsx-dev I did a POC implementation of SH in your library.. Doesn't looks like so bad, I'm not sure if the shader and calculations are right, basically I copied from official google ar example (https://github.com/google-ar/arcore-android-sdk/tree/master/samples/hello_ar_java) which include a PBR shader. I'd like to know what do you think, if and how could be improved, etc. https://github.com/fgnm/ARPlayground/commit/e9c75b2ecd899e1f38908ec06cd502bc6f045782 a part from extended Java classes the only glsl I've modified is the pbr.fs.glsl adding spherical harmonics.

Light on the model looks much more realistic :)

Without Spherical Harmonics With Spherical Harmonics
photo_2022-11-26_13-25-47 photo_2022-11-26_13-25-47 (2)

fgnm avatar Nov 26 '22 13:11 fgnm

it looks realy nice IMHO

MikOfClassX avatar Jan 12 '23 08:01 MikOfClassX