@@ -1096,7 +1096,7 @@ public static void InitializeShaderGlobalKeywords()
10961096 ShaderGlobalKeywords . _ENABLE_ALPHA_OUTPUT = GlobalKeyword . Create ( ShaderKeywordStrings . _ENABLE_ALPHA_OUTPUT ) ;
10971097 ShaderGlobalKeywords . ForwardPlus = GlobalKeyword . Create ( ShaderKeywordStrings . ForwardPlus ) ; // Backward compatibility. Deprecated in 6.1.
10981098#if ( UNITY_META_QUEST )
1099- ShaderGlobalKeywords . META_QUEST_ORTHO_PROJ = GlobalKeyword . Create ( ShaderKeywordStrings . META_QUEST_ORTHO_PROJ ) ;
1099+ ShaderGlobalKeywords . META_QUEST_ORTHO_PROJ = GlobalKeyword . Create ( ShaderKeywordStrings . META_QUEST_ORTHO_PROJ ) ;
11001100 ShaderGlobalKeywords . META_QUEST_LIGHTUNROLL = GlobalKeyword . Create ( ShaderKeywordStrings . META_QUEST_LIGHTUNROLL ) ;
11011101#endif
11021102
@@ -1434,7 +1434,7 @@ public static class ShaderKeywordStrings
14341434
14351435#if ( UNITY_META_QUEST )
14361436 /// <summary> Used to statically branch when checking for projection type on Meta Quest device . </summary>
1437- internal const string META_QUEST_ORTHO_PROJ = "META_QUEST_ORTHO_PROJ" ;
1437+ internal const string META_QUEST_ORTHO_PROJ = "META_QUEST_ORTHO_PROJ" ;
14381438
14391439 /// <summary> Unroll light loop if there is only one additional light on Meta Quest device . </summary>
14401440 internal const string META_QUEST_LIGHTUNROLL = "META_QUEST_LIGHTUNROLL" ;
@@ -1607,6 +1607,12 @@ internal static RenderTextureDescriptor CreateRenderTextureDescriptor(Camera cam
16071607 private static Lightmapping . RequestLightsDelegate lightsDelegate = ( Light [ ] requests , NativeArray < LightDataGI > lightsOutput ) =>
16081608 {
16091609 LightDataGI lightData = new LightDataGI ( ) ;
1610+
1611+ // URP uses a game like lambertian response for punctual lights, they are off by a factor PI.
1612+ // Since LightBaker expects its punctual lights to be expressed in standard radiometric units, the intensity is pre-multiplied by PI here to counteract this.
1613+ // This ensures that the baked punctual light intensity matches realtime intensity. (See GFXLIGHT-1755)
1614+ const float piCorrection = Mathf . PI ;
1615+
16101616#if UNITY_EDITOR
16111617 // Always extract lights in the Editor.
16121618 for ( int i = 0 ; i < requests . Length ; i ++ )
@@ -1621,6 +1627,8 @@ internal static RenderTextureDescriptor CreateRenderTextureDescriptor(Camera cam
16211627 case LightType . Directional :
16221628 DirectionalLight directionalLight = new DirectionalLight ( ) ;
16231629 LightmapperUtils . Extract ( light , ref directionalLight ) ;
1630+ directionalLight . color . intensity *= piCorrection ;
1631+ directionalLight . indirectColor . intensity *= piCorrection ;
16241632
16251633 if ( light . cookie != null )
16261634 {
@@ -1642,11 +1650,15 @@ internal static RenderTextureDescriptor CreateRenderTextureDescriptor(Camera cam
16421650 case LightType . Point :
16431651 PointLight pointLight = new PointLight ( ) ;
16441652 LightmapperUtils . Extract ( light , ref pointLight ) ;
1653+ pointLight . color . intensity *= piCorrection ;
1654+ pointLight . indirectColor . intensity *= piCorrection ;
16451655 lightData . Init ( ref pointLight , ref cookie ) ;
16461656 break ;
16471657 case LightType . Spot :
16481658 SpotLight spotLight = new SpotLight ( ) ;
16491659 LightmapperUtils . Extract ( light , ref spotLight ) ;
1660+ spotLight . color . intensity *= piCorrection ;
1661+ spotLight . indirectColor . intensity *= piCorrection ;
16501662 spotLight . innerConeAngle = light . innerSpotAngle * Mathf . Deg2Rad ;
16511663 spotLight . angularFalloff = AngularFalloffType . AnalyticAndInnerAngle ;
16521664 lightData . Init ( ref spotLight , ref cookie ) ;
@@ -1692,16 +1704,22 @@ internal static RenderTextureDescriptor CreateRenderTextureDescriptor(Camera cam
16921704 case LightType . Directional :
16931705 DirectionalLight directionalLight = new DirectionalLight ( ) ;
16941706 LightmapperUtils . Extract ( light , ref directionalLight ) ;
1707+ directionalLight . color . intensity *= piCorrection ;
1708+ directionalLight . indirectColor . intensity *= piCorrection ;
16951709 lightData . Init ( ref directionalLight ) ;
16961710 break ;
16971711 case LightType . Point :
16981712 PointLight pointLight = new PointLight ( ) ;
16991713 LightmapperUtils . Extract ( light , ref pointLight ) ;
1714+ pointLight . color . intensity *= piCorrection ;
1715+ pointLight . indirectColor . intensity *= piCorrection ;
17001716 lightData . Init ( ref pointLight ) ;
17011717 break ;
17021718 case LightType . Spot :
17031719 SpotLight spotLight = new SpotLight ( ) ;
17041720 LightmapperUtils . Extract ( light , ref spotLight ) ;
1721+ spotLight . color . intensity *= piCorrection ;
1722+ spotLight . indirectColor . intensity *= piCorrection ;
17051723 spotLight . innerConeAngle = light . innerSpotAngle * Mathf . Deg2Rad ;
17061724 spotLight . angularFalloff = AngularFalloffType . AnalyticAndInnerAngle ;
17071725 lightData . Init ( ref spotLight ) ;
0 commit comments