Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Light Implementation #19

Closed
siddhartpai opened this issue Feb 14, 2018 · 4 comments
Closed

Light Implementation #19

siddhartpai opened this issue Feb 14, 2018 · 4 comments

Comments

@siddhartpai
Copy link

Hi @bwasty

It seems like currently point lights are applied somehow on the object so that it is shown on the screen and lit up .
Is there someway i can change the point light implementation to an ambient light ?

@bwasty
Copy link
Owner

bwasty commented Feb 14, 2018

It's actually a single directional light at the moment. For better lighting we could either add an ambient lighting term to the shader or use IBL. Here's the reference shader demo where you can play a bit with the lighting: http://github.khronos.org/glTF-WebGL-PBR/
The current lighting should be equivalent to a lightScale of 5 (-> see here) and IBL contribution of 0.

For IBL we'd only need to add support for loading diffuse and specular environment maps, the shader already supports it (-> see here).

Adding a constant ambient term should also be pretty easy, but I'm not sure where exactly in the shader to add it - my previous attempts didn't look good enough. Perhaps this might help. Essentially it should look somewhat like this:

uniform float u_AmbientIntensity;
...
color += u_AmbientIntensity * baseColor * ao;

@alteous
Copy link

alteous commented Feb 14, 2018

FYI, a lights extension is being discussed: KhronosGroup/glTF#945

@bwasty
Copy link
Owner

bwasty commented Feb 15, 2018

@alteous Thanks, I'm aware of it. Was also thinking of adding it.

@bwasty
Copy link
Owner

bwasty commented Feb 17, 2018

@siddhartpai
I've added simple ambient lighting: dbdd01c.
Here are some before and after screenshots of the official sample models:
https://bwasty.github.io/gltf-viewer/no_ambient/
https://bwasty.github.io/gltf-viewer/ambient_0.2/

The ambient light color and intensity can be adjusted in shader.rs (uniforms u_AmbientLightColor , u_AmbientLightIntensity).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants