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

Merged
merged 96 commits into from
Jan 23, 2025

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 20, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Jan 20, 2025

@sebavan
Copy link
Member

sebavan commented Jan 22, 2025

@SergioRZMasson I think the latest question is about testing all the other materials using BindLights/PrepareDefinesForLight as most of them are currently working like standard material and supporting them all I guess.

All of those would work the same I believe:
image

@SergioRZMasson
Copy link
Contributor Author

@SergioRZMasson I think the latest question is about testing all the other materials using BindLights/PrepareDefinesForLight as most of them are currently working like standard material and supporting them all I guess.

All of those would work the same I believe: image

Added a #defien AREALIGHT_ROUGHNESS to use 1.0 instead of vReflectionInfos.y for shaders that don't have that uniform data available. This makes all materials in the list completely ignore the Area Lights, but we have no shader crashes and they work normally with other lights. The only materials that will be affected by Area Lights are Standard and PBR.

@sebavan
Copy link
Member

sebavan commented Jan 23, 2025

Next PRS will be:
-NME
-Other Supported Babylon Materials :-)
-Once done lets remove/document the last commit to help our users adapt to it as well

@SergioRZMasson SergioRZMasson merged commit 5484832 into BabylonJS:master Jan 23, 2025
14 checks passed
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