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

Initial implementation for Area Lights #16078

Open
wants to merge 87 commits into
base: master
Choose a base branch
from

Conversation

SergioRZMasson
Copy link
Contributor

Overview

This PR provides a first implementation for rectangular area lights. The implementation is based on reference repo https://github.com/selfshadow/ltc_code/ and uses the Linearly Transformed Cosines technique described by Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt`s paper in 2016 . This PR only supports single color rectangular area lights with texture support been introduced in a latter PR. This PR also does not support shadows for the RectAreaLight.

API

Besides the usual diffuse and specular colors the area light is defined by a position, a width and a height. Setting a rotation is possible by assigning a transform node as a parent for the light.

var light = new BABYLON.RectAreaLight("areaLight", position, width, height, scene);

By default shaders will use LTC data stored in the Babylon.js CDN. However, users can assign their own IAreaLightLTCProvider to scene.areaLightLTCProvider and use their own LTC textures.

@bjsplat
Copy link
Collaborator

bjsplat commented Jan 17, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Jan 17, 2025

Copy link
Member

@sebavan sebavan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job !! Besides the comments, I am wondering what makes standard and PBR not look alike in the tests knowing they use the same maths ?

const _ltc1 = new Uint16Array(64 * 64 * 4);
const _ltc2 = new Uint16Array(64 * 64 * 4);

const ltcPath = Tools.GetBabylonScriptURL("https://assets.babylonjs.com/areaLights/areaLightsLTC.bin", true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should still support something through the script base url if we can ? this is the centralized way for our users to prevent external call.

}

public transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string) {
// TO DO: Implement this to add support for NME.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Next PR @SergioRZMasson ?

@SergioRZMasson
Copy link
Contributor Author

Great job !! Besides the comments, I am wondering what makes standard and PBR not look alike in the tests knowing they use the same maths ?

I think this is related to the metallic calculations performed down in the shader. By changing the metallic values we can make them more or less simular.

@Popov72
Copy link
Contributor

Popov72 commented Jan 20, 2025

Great job !! Besides the comments, I am wondering what makes standard and PBR not look alike in the tests knowing they use the same maths ?

I think this is related to the metallic calculations performed down in the shader. By changing the metallic values we can make them more or less simular.

Also, we perform the calculation in linear space in the PBR and apply the gamma correction at the end, whereas we perform the calculation directly in gamma space in the standard material. This could explain some of the differences.

this.position = position;

if (!this._scene._ltcTextures) {
this._scene.areaLightLTCProvider ||= new DefaultAreaLightLTCProvider(this._scene, "https://assets.babylonjs.com/areaLights/areaLightsLTC.bin");
Copy link
Member

@RaananW RaananW Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this PR #16089 is merged and available in master you can use the same paradigm to allow overriding this URL (i.e. use the Tools.GetAssetsUrl function). You will also need to move the asset to the /core/ directory in the Assets repository to stay consistent and make the asset override procedure work correctly.

@bjsplat
Copy link
Collaborator

bjsplat commented Jan 20, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Jan 20, 2025

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

Successfully merging this pull request may close these issues.

7 participants