-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
base: master
Are you sure you want to change the base?
Initial implementation for Area Lights #16078
Conversation
…into sergio/area-light
…of Specular power
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't review the shaders or the inspector. Some smallish comments on the rest.
Co-authored-by: Gary Hsu <[email protected]>
Co-authored-by: Gary Hsu <[email protected]>
Co-authored-by: Gary Hsu <[email protected]>
Co-authored-by: Gary Hsu <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
packages/dev/core/src/Shaders/ShadersInclude/lightsFragmentFunctions.fx
Outdated
Show resolved
Hide resolved
packages/dev/core/src/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.fx
Show resolved
Hide resolved
packages/dev/inspector/src/components/actionTabs/tabs/propertyGridTabComponent.tsx
Outdated
Show resolved
Hide resolved
…GridTabComponent.tsx Co-authored-by: Popov72 <[email protected]>
Co-authored-by: Popov72 <[email protected]>
Co-authored-by: Gary Hsu <[email protected]>
Visualization tests for WebGPU (Experimental) |
WebGL2 visualization test reporter: |
ltc1Texture: BaseTexture; | ||
|
||
/** | ||
* Linearly trasnformed cossine texture Fresnel Approximation. | ||
* Linearly transformed cosine texture Fresnel Approximation. | ||
*/ | ||
ltc2Texture: BaseTexture; | ||
|
||
/** | ||
* Promise to wait for Area Lights are ready. | ||
*/ | ||
whenAreaLightsReady: Promise<void>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a great pattern. It's possible for someone to get an undefined ltc texture with the contract. Consider returning the ltc textures in the Promise result and rename function to getTexturesAsync
.
There was a problem hiding this 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); |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Next PR @SergioRZMasson ?
uniform sampler2D areaLightsLTC2Sampler; | ||
|
||
lightingInfo computeAreaLighting(sampler2D ltc1, sampler2D ltc2, vec3 viewDirectionW, vec3 vNormal, vec3 vPosition, vec4 lightData, vec3 halfWidth, vec3 halfHeight, vec3 diffuseColor, vec3 specularColor, float roughness ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add the reference to the paper we used just before the function ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it also looks really similar to computeAreaPreLightingInfo ? nothing we should factorize ? the rest is splitted cause pbr and standard do not do the same.
// http://blog.selfshadow.com/publications/s2016-advances/s2016_ltc_fresnel.pdf | ||
vec3 fresnel = ( specularColor * t2.x + ( vec3( 1.0 ) - specularColor ) * t2.y ); | ||
result.areaLightSpecular = specularColor * fresnel * LTCEvaluate( normal, viewDir, position, mInv, rectCoords ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we should not do the mul by specularColor to be consistent with the diffuse part
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.
By default shaders will use LTC data stored in the Babylon.js CDN. However, users can assign their own
IAreaLightLTCProvider
toscene.areaLightLTCProvider
and use their own LTC textures.