From 8b08a7b86f78bccb2b6d635a09bd80fced75a108 Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Mon, 8 Jun 2020 02:07:51 +0200 Subject: [PATCH 1/4] Add concept of LightLoop Output --- .../Runtime/Lighting/Deferred.shader | 9 +++-- .../Lighting/LightLoop/Deferred.compute | 9 +++-- .../Lighting/LightLoop/DeferredTile.shader | 18 ++++++---- .../Runtime/Lighting/LightLoop/LightLoop.hlsl | 29 +++++++-------- .../Lighting/LightLoop/LightLoopDef.hlsl | 8 +++++ .../Runtime/Material/AxF/AxF.hlsl | 10 +++--- .../Runtime/Material/Eye/Eye.hlsl | 8 ++--- .../Runtime/Material/Fabric/Fabric.hlsl | 8 ++--- .../Runtime/Material/Hair/Hair.hlsl | 8 ++--- .../Runtime/Material/Lit/Lit.hlsl | 12 +++---- .../Runtime/Material/Lit/SimpleLit.hlsl | 10 +++--- .../Runtime/Material/MaterialEvaluation.hlsl | 36 +++++++++---------- .../Runtime/Material/StackLit/StackLit.hlsl | 8 ++--- .../Deferred/RaytracingDeferred.compute | 19 ++++++---- .../Shaders/RaytracingLightLoop.hlsl | 10 +++--- .../ShaderPass/ShaderPassForward.hlsl | 8 +++-- .../ShaderPassRaytracingForward.hlsl | 9 +++-- .../ShaderPassRaytracingIndirect.hlsl | 9 +++-- .../VFXGraph/Shaders/VFXLitPixelOutput.hlsl | 8 ++++- 19 files changed, 140 insertions(+), 96 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Deferred.shader b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Deferred.shader index f8ef1337638..10af7eb0f8a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Deferred.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Deferred.shader @@ -136,10 +136,13 @@ Shader "Hidden/HDRP/Deferred" PreLightData preLightData = GetPreLightData(V, posInput, bsdfData); - float3 diffuseLighting; - float3 specularLighting; - LightLoop(V, posInput, preLightData, bsdfData, builtinData, LIGHT_FEATURE_MASK_FLAGS_OPAQUE, diffuseLighting, specularLighting); + LightLoopOutput lightLoopOutput; + LightLoop(V, posInput, preLightData, bsdfData, builtinData, LIGHT_FEATURE_MASK_FLAGS_OPAQUE, lightLoopOutput); + // Alias + float3 diffuseLighting = lightLoopOutput.diffuseLighting; + float3 specularLighting = lightLoopOutput.specularLighting; + diffuseLighting *= GetCurrentExposureMultiplier(); specularLighting *= GetCurrentExposureMultiplier(); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/Deferred.compute b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/Deferred.compute index d97be9b9e81..b78b9dee4b6 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/Deferred.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/Deferred.compute @@ -165,9 +165,12 @@ void SHADE_OPAQUE_ENTRY(uint3 dispatchThreadId : SV_DispatchThreadID, uint2 grou PreLightData preLightData = GetPreLightData(V, posInput, bsdfData); - float3 diffuseLighting; - float3 specularLighting; - LightLoop(V, posInput, preLightData, bsdfData, builtinData, featureFlags, diffuseLighting, specularLighting); + LightLoopOutput lightLoopOutput; + LightLoop(V, posInput, preLightData, bsdfData, builtinData, featureFlags, lightLoopOutput); + + // Alias + float3 diffuseLighting = lightLoopOutput.diffuseLighting; + float3 specularLighting = lightLoopOutput.specularLighting; diffuseLighting *= GetCurrentExposureMultiplier(); specularLighting *= GetCurrentExposureMultiplier(); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/DeferredTile.shader b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/DeferredTile.shader index e0754fde912..d29856a198b 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/DeferredTile.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/DeferredTile.shader @@ -243,9 +243,12 @@ Shader "Hidden/HDRP/DeferredTile" PreLightData preLightData = GetPreLightData(V, posInput, bsdfData); - float3 diffuseLighting; - float3 specularLighting; - LightLoop(V, posInput, preLightData, bsdfData, builtinData, featureFlags, diffuseLighting, specularLighting); + LightLoopOutput lightLoopOutput; + LightLoop(V, posInput, preLightData, bsdfData, builtinData, featureFlags, lightLoopOutput); + + // Alias + float3 diffuseLighting = lightLoopOutput.diffuseLighting; + float3 specularLighting = lightLoopOutput.specularLighting; diffuseLighting *= GetCurrentExposureMultiplier(); specularLighting *= GetCurrentExposureMultiplier(); @@ -405,9 +408,12 @@ Shader "Hidden/HDRP/DeferredTile" PreLightData preLightData = GetPreLightData(V, posInput, bsdfData); - float3 diffuseLighting; - float3 specularLighting; - LightLoop(V, posInput, preLightData, bsdfData, builtinData, LIGHT_FEATURE_MASK_FLAGS_OPAQUE, diffuseLighting, specularLighting); + LightLoopOutput lightLoopOutput; + LightLoop(V, posInput, preLightData, bsdfData, builtinData, LIGHT_FEATURE_MASK_FLAGS_OPAQUE, lightLoopOutput); + + // Alias + float3 diffuseLighting = lightLoopOutput.diffuseLighting; + float3 specularLighting = lightLoopOutput.specularLighting; diffuseLighting *= GetCurrentExposureMultiplier(); specularLighting *= GetCurrentExposureMultiplier(); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl index 242a44f0fa4..7a90477f77a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl @@ -75,23 +75,23 @@ void ApplyDebugToLighting(LightLoopContext context, inout BuiltinData builtinDat #endif } -void ApplyDebug(LightLoopContext context, PositionInputs posInput, BSDFData bsdfData, inout float3 diffuseLighting, inout float3 specularLighting) +void ApplyDebug(LightLoopContext context, PositionInputs posInput, BSDFData bsdfData, inout LightLoopOutput lightLoopOutput) { #ifdef DEBUG_DISPLAY if (_DebugLightingMode == DEBUGLIGHTINGMODE_PROBE_VOLUME) { // Debug info is written to diffuseColor inside of light loop. - specularLighting = float3(0.0, 0.0, 0.0); + lightLoopOutput.specularLighting = float3(0.0, 0.0, 0.0); } else if (_DebugLightingMode == DEBUGLIGHTINGMODE_LUX_METER) { - specularLighting = float3(0.0, 0.0, 0.0); // Disable specular lighting + lightLoopOutput.specularLighting = float3(0.0, 0.0, 0.0); // Disable specular lighting // Take the luminance - diffuseLighting = Luminance(diffuseLighting).xxx; + lightLoopOutput.diffuseLighting = Luminance(lightLoopOutput.diffuseLighting).xxx; } else if (_DebugLightingMode == DEBUGLIGHTINGMODE_VISUALIZE_CASCADE) { - specularLighting = float3(0.0, 0.0, 0.0); + lightLoopOutput.specularLighting = float3(0.0, 0.0, 0.0); const float3 s_CascadeColors[] = { float3(0.5, 0.5, 0.7), @@ -101,7 +101,7 @@ void ApplyDebug(LightLoopContext context, PositionInputs posInput, BSDFData bsdf float3(1.0, 1.0, 1.0) }; - diffuseLighting = Luminance(diffuseLighting); + lightLoopOutput.diffuseLighting = Luminance(lightLoopOutput.diffuseLighting); if (_DirectionalShadowIndex >= 0) { real alpha; @@ -133,14 +133,14 @@ void ApplyDebug(LightLoopContext context, PositionInputs posInput, BSDFData bsdf float3 cascadeShadowColor = lerp(s_CascadeColors[shadowSplitIndex], s_CascadeColors[shadowSplitIndex + 1], alpha); // We can't mix with the lighting as it can be HDR and it is hard to find a good lerp operation for this case that is still compliant with // exposure. So disable exposure instead and replace color. - diffuseLighting = cascadeShadowColor * Luminance(diffuseLighting) * shadow; + lightLoopOutput.diffuseLighting = cascadeShadowColor * Luminance(lightLoopOutput.diffuseLighting) * shadow; } } } else if (_DebugLightingMode == DEBUGLIGHTINGMODE_MATCAP_VIEW) { - specularLighting = float3(0.0, 0.0, 0.0); + lightLoopOutput.specularLighting = float3(0.0, 0.0, 0.0); float3 normalVS = mul((float3x3)UNITY_MATRIX_V, bsdfData.normalWS).xyz; float3 V = GetWorldSpaceNormalizeViewDir(posInput.positionWS); @@ -155,15 +155,17 @@ void ApplyDebug(LightLoopContext context, PositionInputs posInput, BSDFData bsdf UV = saturate(R.xy * 0.5f + 0.5f); } - diffuseLighting = SAMPLE_TEXTURE2D_LOD(_DebugMatCapTexture, s_linear_repeat_sampler, UV, 0).rgb * (_MatcapMixAlbedo > 0 ? defaultColor.rgb * _MatcapViewScale : 1.0f); + lightLoopOutput.diffuseLighting = SAMPLE_TEXTURE2D_LOD(_DebugMatCapTexture, s_linear_repeat_sampler, UV, 0).rgb * (_MatcapMixAlbedo > 0 ? defaultColor.rgb * _MatcapViewScale : 1.0f); } #endif } void LightLoop( float3 V, PositionInputs posInput, PreLightData preLightData, BSDFData bsdfData, BuiltinData builtinData, uint featureFlags, - out float3 diffuseLighting, - out float3 specularLighting) + out LightLoopOutput lightLoopOutput) { + // Init LightLoop output structure + ZERO_INITIALIZE(LightLoopOutput, lightLoopOutput); + LightLoopContext context; context.shadowContext = InitShadowContext(); @@ -541,8 +543,7 @@ void LightLoop( float3 V, PositionInputs posInput, PreLightData preLightData, BS // Also Apply indiret diffuse (GI) // PostEvaluateBSDF will perform any operation wanted by the material and sum everything into diffuseLighting and specularLighting - PostEvaluateBSDF( context, V, posInput, preLightData, bsdfData, builtinData, aggregateLighting, - diffuseLighting, specularLighting); + PostEvaluateBSDF( context, V, posInput, preLightData, bsdfData, builtinData, aggregateLighting, lightLoopOutput); - ApplyDebug(context, posInput, bsdfData, diffuseLighting, specularLighting); + ApplyDebug(context, posInput, bsdfData, lightLoopOutput); } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl index ea8354f75c9..bb43e4b44f7 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl @@ -28,6 +28,14 @@ struct LightLoopContext DirectionalShadowType shadowValue; // Stores the value of the cascade shadow map }; +// LightLoopOutput is the output of the LightLoop fuction call. +// It allow to retrieve the data output by the LightLoop +struct LightLoopOutput +{ + float3 diffuseLighting; + float3 specularLighting; +}; + //----------------------------------------------------------------------------- // Reflection probe / Sky sampling function // ---------------------------------------------------------------------------- diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.hlsl index 1a42ba904eb..6163a043f09 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.hlsl @@ -2584,7 +2584,7 @@ IndirectLighting EvaluateBSDF_Env( LightLoopContext lightLoopContext, void PostEvaluateBSDF( LightLoopContext lightLoopContext, float3 V, PositionInputs posInput, PreLightData preLightData, BSDFData bsdfData, BuiltinData builtinData, AggregateLighting lighting, - out float3 diffuseLighting, out float3 specularLighting) + out LightLoopOutput lightLoopOutput) { // There is no AmbientOcclusion from data with AxF, but let's apply our SSAO AmbientOcclusionFactor aoFactor; @@ -2595,16 +2595,16 @@ void PostEvaluateBSDF( LightLoopContext lightLoopContext, ApplyAmbientOcclusionFactor(aoFactor, builtinData, lighting); - diffuseLighting = bsdfData.diffuseColor * lighting.direct.diffuse + builtinData.bakeDiffuseLighting; - specularLighting = lighting.direct.specular + lighting.indirect.specularReflected; + lightLoopOutput.diffuseLighting = bsdfData.diffuseColor * lighting.direct.diffuse + builtinData.bakeDiffuseLighting; + lightLoopOutput.specularLighting = lighting.direct.specular + lighting.indirect.specularReflected; #if !defined(_AXF_BRDF_TYPE_SVBRDF) && !defined(_AXF_BRDF_TYPE_CAR_PAINT) // Not supported: Display a flashy color instead - diffuseLighting = 10 * float3(1, 0.3, 0.01); + lightLoopOutput.diffuseLighting = 10 * float3(1, 0.3, 0.01); #endif #ifdef DEBUG_DISPLAY - PostEvaluateBSDFDebugDisplay(aoFactor, builtinData, lighting, bsdfData.diffuseColor, diffuseLighting, specularLighting); + PostEvaluateBSDFDebugDisplay(aoFactor, builtinData, lighting, bsdfData.diffuseColor, lightLoopOutput); #endif } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Eye/Eye.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/Eye/Eye.hlsl index a34ad165590..cb7a88e04a3 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Eye/Eye.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Eye/Eye.hlsl @@ -820,7 +820,7 @@ IndirectLighting EvaluateBSDF_Env( LightLoopContext lightLoopContext, void PostEvaluateBSDF( LightLoopContext lightLoopContext, float3 V, PositionInputs posInput, PreLightData preLightData, BSDFData bsdfData, BuiltinData builtinData, AggregateLighting lighting, - out float3 diffuseLighting, out float3 specularLighting) + out LightLoopOutput lightLoopOutput) { AmbientOcclusionFactor aoFactor; GetScreenSpaceAmbientOcclusionMultibounce(posInput.positionSS, preLightData.NdotV, bsdfData.perceptualRoughness, bsdfData.ambientOcclusion, bsdfData.specularOcclusion, bsdfData.diffuseColor, bsdfData.fresnel0, aoFactor); @@ -831,11 +831,11 @@ void PostEvaluateBSDF( LightLoopContext lightLoopContext, // Apply the albedo to the direct diffuse lighting (only once). The indirect (baked) // diffuse lighting has already multiply the albedo in ModifyBakedDiffuseLighting(). - diffuseLighting = modifiedDiffuseColor * lighting.direct.diffuse + builtinData.bakeDiffuseLighting + builtinData.emissiveColor; - specularLighting = lighting.direct.specular + lighting.indirect.specularReflected; + lightLoopOutput.diffuseLighting = modifiedDiffuseColor * lighting.direct.diffuse + builtinData.bakeDiffuseLighting + builtinData.emissiveColor; + lightLoopOutput.specularLighting = lighting.direct.specular + lighting.indirect.specularReflected; #ifdef DEBUG_DISPLAY - PostEvaluateBSDFDebugDisplay(aoFactor, builtinData, lighting, bsdfData.diffuseColor, diffuseLighting, specularLighting); + PostEvaluateBSDFDebugDisplay(aoFactor, builtinData, lighting, bsdfData.diffuseColor, lightLoopOutput); #endif } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Fabric/Fabric.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/Fabric/Fabric.hlsl index 010c1a2f3db..71810177be5 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Fabric/Fabric.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Fabric/Fabric.hlsl @@ -651,7 +651,7 @@ IndirectLighting EvaluateBSDF_Env( LightLoopContext lightLoopContext, void PostEvaluateBSDF( LightLoopContext lightLoopContext, float3 V, PositionInputs posInput, PreLightData preLightData, BSDFData bsdfData, BuiltinData builtinData, AggregateLighting lighting, - out float3 diffuseLighting, out float3 specularLighting) + out LightLoopOutput lightLoopOutput) { AmbientOcclusionFactor aoFactor; GetScreenSpaceAmbientOcclusionMultibounce(posInput.positionSS, preLightData.NdotV, bsdfData.perceptualRoughness, bsdfData.ambientOcclusion, bsdfData.specularOcclusion, bsdfData.diffuseColor, bsdfData.fresnel0, aoFactor); @@ -662,13 +662,13 @@ void PostEvaluateBSDF( LightLoopContext lightLoopContext, // Apply the albedo to the direct diffuse lighting (only once). The indirect (baked) // diffuse lighting has already multiply the albedo in ModifyBakedDiffuseLighting(). - diffuseLighting = modifiedDiffuseColor * lighting.direct.diffuse + builtinData.bakeDiffuseLighting + builtinData.emissiveColor; - specularLighting = lighting.direct.specular + lighting.indirect.specularReflected; + lightLoopOutput.diffuseLighting = modifiedDiffuseColor * lighting.direct.diffuse + builtinData.bakeDiffuseLighting + builtinData.emissiveColor; + lightLoopOutput.specularLighting = lighting.direct.specular + lighting.indirect.specularReflected; // TODO: Multiscattering for cloth? #ifdef DEBUG_DISPLAY - PostEvaluateBSDFDebugDisplay(aoFactor, builtinData, lighting, bsdfData.diffuseColor, diffuseLighting, specularLighting); + PostEvaluateBSDFDebugDisplay(aoFactor, builtinData, lighting, bsdfData.diffuseColor, lightLoopOutput); #endif } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Hair/Hair.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/Hair/Hair.hlsl index ec96e98ab8c..a37f6b78955 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Hair/Hair.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Hair/Hair.hlsl @@ -593,7 +593,7 @@ IndirectLighting EvaluateBSDF_Env( LightLoopContext lightLoopContext, void PostEvaluateBSDF( LightLoopContext lightLoopContext, float3 V, PositionInputs posInput, PreLightData preLightData, BSDFData bsdfData, BuiltinData builtinData, AggregateLighting lighting, - out float3 diffuseLighting, out float3 specularLighting) + out LightLoopOutput lightLoopOutput)) { AmbientOcclusionFactor aoFactor; GetScreenSpaceAmbientOcclusionMultibounce(posInput.positionSS, preLightData.NdotV, bsdfData.perceptualRoughness, bsdfData.ambientOcclusion, bsdfData.specularOcclusion, bsdfData.diffuseColor, bsdfData.fresnel0, aoFactor); @@ -601,11 +601,11 @@ void PostEvaluateBSDF( LightLoopContext lightLoopContext, // Apply the albedo to the direct diffuse lighting (only once). The indirect (baked) // diffuse lighting has already multiply the albedo in ModifyBakedDiffuseLighting(). - diffuseLighting = bsdfData.diffuseColor * lighting.direct.diffuse + builtinData.bakeDiffuseLighting + builtinData.emissiveColor; - specularLighting = lighting.direct.specular + lighting.indirect.specularReflected; + lightLoopOutput.diffuseLighting = bsdfData.diffuseColor * lighting.direct.diffuse + builtinData.bakeDiffuseLighting + builtinData.emissiveColor; + lightLoopOutput.specularLighting = lighting.direct.specular + lighting.indirect.specularReflected; #ifdef DEBUG_DISPLAY - PostEvaluateBSDFDebugDisplay(aoFactor, builtinData, lighting, bsdfData.diffuseColor, diffuseLighting, specularLighting); + PostEvaluateBSDFDebugDisplay(aoFactor, builtinData, lighting, bsdfData.diffuseColor, lightLoopOutput); #endif } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl index 7a6b59ef56f..629a99a22b7 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl @@ -1992,7 +1992,7 @@ IndirectLighting EvaluateBSDF_Env( LightLoopContext lightLoopContext, void PostEvaluateBSDF( LightLoopContext lightLoopContext, float3 V, PositionInputs posInput, PreLightData preLightData, BSDFData bsdfData, BuiltinData builtinData, AggregateLighting lighting, - out float3 diffuseLighting, out float3 specularLighting) + out LightLoopOutput lightLoopOutput) { AmbientOcclusionFactor aoFactor; // Use GTAOMultiBounce approximation for ambient occlusion (allow to get a tint from the baseColor) @@ -2010,7 +2010,7 @@ void PostEvaluateBSDF( LightLoopContext lightLoopContext, // Apply the albedo to the direct diffuse lighting (only once). The indirect (baked) // diffuse lighting has already multiply the albedo in ModifyBakedDiffuseLighting(). // Note: In deferred bakeDiffuseLighting also contain emissive and in this case emissiveColor is 0 - diffuseLighting = modifiedDiffuseColor * lighting.direct.diffuse + builtinData.bakeDiffuseLighting + builtinData.emissiveColor; + lightLoopOutput.diffuseLighting = modifiedDiffuseColor * lighting.direct.diffuse + builtinData.bakeDiffuseLighting + builtinData.emissiveColor; // If refraction is enable we use the transmittanceMask to lerp between current diffuse lighting and refraction value // Physically speaking, transmittanceMask should be 1, but for artistic reasons, we let the value vary @@ -2019,15 +2019,15 @@ void PostEvaluateBSDF( LightLoopContext lightLoopContext, // since we know it won't be further processed: it is called at the end of the LightLoop(), but doing this // enables opacity to affect it (in ApplyBlendMode()) while the rest of specularLighting escapes it. #if HAS_REFRACTION - diffuseLighting = lerp(diffuseLighting, lighting.indirect.specularTransmitted, bsdfData.transmittanceMask * _EnableSSRefraction); + lightLoopOutput.diffuseLighting = lerp(lightLoopOutput.diffuseLighting, lighting.indirect.specularTransmitted, bsdfData.transmittanceMask * _EnableSSRefraction); #endif - specularLighting = lighting.direct.specular + lighting.indirect.specularReflected; + lightLoopOutput.specularLighting = lighting.direct.specular + lighting.indirect.specularReflected; // Rescale the GGX to account for the multiple scattering. - specularLighting *= 1.0 + bsdfData.fresnel0 * preLightData.energyCompensation; + lightLoopOutput.specularLighting *= 1.0 + bsdfData.fresnel0 * preLightData.energyCompensation; #ifdef DEBUG_DISPLAY - PostEvaluateBSDFDebugDisplay(aoFactor, builtinData, lighting, bsdfData.diffuseColor, diffuseLighting, specularLighting); + PostEvaluateBSDFDebugDisplay(aoFactor, builtinData, lighting, bsdfData.diffuseColor, lightLoopOutput); #endif } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/SimpleLit.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/SimpleLit.hlsl index 93ee8bb6450..555893a975e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/SimpleLit.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/SimpleLit.hlsl @@ -446,7 +446,7 @@ IndirectLighting EvaluateBSDF_Env( LightLoopContext lightLoopContext, void PostEvaluateBSDF( LightLoopContext lightLoopContext, float3 V, PositionInputs posInput, PreLightData preLightData, BSDFData bsdfData, BuiltinData builtinData, AggregateLighting lighting, - out float3 diffuseLighting, out float3 specularLighting) + out LightLoopOutput lightLoopOutput) { AmbientOcclusionFactor aoFactor; // Use GTAOMultiBounce approximation for ambient occlusion (allow to get a tint from the baseColor) @@ -458,18 +458,18 @@ void PostEvaluateBSDF( LightLoopContext lightLoopContext, // Note: Unlike Lit material, the SimpleLit material don't have ModifyBakedDiffuseLighting() function // So we need to multiply by the diffuse albedo here. - diffuseLighting = modifiedDiffuseColor * lighting.direct.diffuse + builtinData.emissiveColor; + lightLoopOutput.diffuseLighting = modifiedDiffuseColor * lighting.direct.diffuse + builtinData.emissiveColor; #ifdef HDRP_ENABLE_ENV_LIGHT // TODO: check what this is suppose to do? // Note: When baking reflection probes, we approximate the diffuse with the fresnel0 bsdfData.diffuseColor = modifiedDiffuseColor; // Note: This affect the debug mode of mipmap streaming for simple Lit in PostEvaluateBSDFDebugDisplay. But we are ok with that. - diffuseLighting += builtinData.bakeDiffuseLighting * GetDiffuseOrDefaultColor(bsdfData, _ReplaceDiffuseForIndirect).rgb; + lightLoopOutput.diffuseLighting += builtinData.bakeDiffuseLighting * GetDiffuseOrDefaultColor(bsdfData, _ReplaceDiffuseForIndirect).rgb; #endif - specularLighting = lighting.direct.specular + lighting.indirect.specularReflected; + lightLoopOutput.specularLighting = lighting.direct.specular + lighting.indirect.specularReflected; #ifdef DEBUG_DISPLAY - PostEvaluateBSDFDebugDisplay(aoFactor, builtinData, lighting, bsdfData.diffuseColor, diffuseLighting, specularLighting); + PostEvaluateBSDFDebugDisplay(aoFactor, builtinData, lighting, bsdfData.diffuseColor, lightLoopOutput); #endif } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialEvaluation.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialEvaluation.hlsl index 9bdbc03f0c8..65f6a37080d 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialEvaluation.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialEvaluation.hlsl @@ -119,15 +119,15 @@ void ApplyAmbientOcclusionFactor(AmbientOcclusionFactor aoFactor, inout BuiltinD #ifdef DEBUG_DISPLAY // mipmapColor is color use to store texture streaming information in XXXData.hlsl (look for DEBUGMIPMAPMODE_NONE) void PostEvaluateBSDFDebugDisplay( AmbientOcclusionFactor aoFactor, BuiltinData builtinData, AggregateLighting lighting, float3 mipmapColor, - inout float3 diffuseLighting, inout float3 specularLighting) + inout LightLoopOutput lightLoopOutput) { if (_DebugShadowMapMode != SHADOWMAPDEBUGMODE_NONE) { switch (_DebugShadowMapMode) { case SHADOWMAPDEBUGMODE_SINGLE_SHADOW: - diffuseLighting = g_DebugShadowAttenuation.xxx; - specularLighting = float3(0, 0, 0); + lightLoopOutput.diffuseLighting = g_DebugShadowAttenuation.xxx; + lightLoopOutput.specularLighting = float3(0, 0, 0); break ; } } @@ -139,46 +139,46 @@ void PostEvaluateBSDFDebugDisplay( AmbientOcclusionFactor aoFactor, BuiltinData { case DEBUGLIGHTINGMODE_LUX_METER: // Note: We don't include emissive here (and in deferred it is correct as lux calculation of bakeDiffuseLighting don't consider emissive) - diffuseLighting = lighting.direct.diffuse + builtinData.bakeDiffuseLighting; + lightLoopOutput.diffuseLighting = lighting.direct.diffuse + builtinData.bakeDiffuseLighting; //Compress lighting values for color picker if enabled if (_ColorPickerMode != COLORPICKERDEBUGMODE_NONE) - diffuseLighting = diffuseLighting / LUXMETER_COMPRESSION_RATIO; + lightLoopOutput.diffuseLighting = lightLoopOutput.diffuseLighting / LUXMETER_COMPRESSION_RATIO; - specularLighting = float3(0.0, 0.0, 0.0); // Disable specular lighting + lightLoopOutput.specularLighting = float3(0.0, 0.0, 0.0); // Disable specular lighting break; case DEBUGLIGHTINGMODE_INDIRECT_DIFFUSE_OCCLUSION: - diffuseLighting = aoFactor.indirectAmbientOcclusion; - specularLighting = float3(0.0, 0.0, 0.0); // Disable specular lighting + lightLoopOutput.diffuseLighting = aoFactor.indirectAmbientOcclusion; + lightLoopOutput.specularLighting = float3(0.0, 0.0, 0.0); // Disable specular lighting break; case DEBUGLIGHTINGMODE_INDIRECT_SPECULAR_OCCLUSION: - diffuseLighting = aoFactor.indirectSpecularOcclusion; - specularLighting = float3(0.0, 0.0, 0.0); // Disable specular lighting + lightLoopOutput.diffuseLighting = aoFactor.indirectSpecularOcclusion; + lightLoopOutput.specularLighting = float3(0.0, 0.0, 0.0); // Disable specular lighting break; case DEBUGLIGHTINGMODE_VISUALIZE_SHADOW_MASKS: #ifdef SHADOWS_SHADOWMASK - diffuseLighting = float3( + lightLoopOutput.diffuseLighting = float3( builtinData.shadowMask0 / 2 + builtinData.shadowMask1 / 2, builtinData.shadowMask1 / 2 + builtinData.shadowMask2 / 2, builtinData.shadowMask2 / 2 + builtinData.shadowMask3 / 2 ); - specularLighting = float3(0, 0, 0); + lightLoopOutput.specularLighting = float3(0, 0, 0); #endif break ; case DEBUGLIGHTINGMODE_PROBE_VOLUME: - diffuseLighting = builtinData.bakeDiffuseLighting; - specularLighting = float3(0, 0, 0); + lightLoopOutput.diffuseLighting = builtinData.bakeDiffuseLighting; + lightLoopOutput.specularLighting = float3(0, 0, 0); break; } } else if (_DebugMipMapMode != DEBUGMIPMAPMODE_NONE) { - diffuseLighting = mipmapColor; - specularLighting = float3(0.0, 0.0, 0.0); // Disable specular lighting + lightLoopOutput.diffuseLighting = mipmapColor; + lightLoopOutput.specularLighting = float3(0.0, 0.0, 0.0); // Disable specular lighting } else if (_DebugProbeVolumeMode != PROBEVOLUMEDEBUGMODE_NONE) { @@ -186,8 +186,8 @@ void PostEvaluateBSDFDebugDisplay( AmbientOcclusionFactor aoFactor, BuiltinData { case PROBEVOLUMEDEBUGMODE_VISUALIZE_DEBUG_COLORS: case PROBEVOLUMEDEBUGMODE_VISUALIZE_VALIDITY: - diffuseLighting = builtinData.bakeDiffuseLighting; - specularLighting = float3(0.0, 0.0, 0.0); + lightLoopOutput.diffuseLighting = builtinData.bakeDiffuseLighting; + lightLoopOutput.specularLighting = float3(0.0, 0.0, 0.0); break; } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/StackLit/StackLit.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/StackLit/StackLit.hlsl index e588302833e..6421ead5411 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/StackLit/StackLit.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/StackLit/StackLit.hlsl @@ -4431,7 +4431,7 @@ IndirectLighting EvaluateBSDF_Env( LightLoopContext lightLoopContext, void PostEvaluateBSDF( LightLoopContext lightLoopContext, float3 V, PositionInputs posInput, PreLightData preLightData, BSDFData bsdfData, BuiltinData builtinData, AggregateLighting lighting, - out float3 diffuseLighting, out float3 specularLighting) + out LightLoopOutput lightLoopOutput) { // Specular occlusion has been pre-computed in GetPreLightData() and applied on indirect specular light // while screenSpaceAmbientOcclusion has also been cached in preLightData. @@ -4459,9 +4459,9 @@ void PostEvaluateBSDF( LightLoopContext lightLoopContext, // on it. Specular occlusion has been applied per lobe during specular lighting evaluations before. // We also add emissive since it is not merged with bakeDiffuseLighting in ModifyBakedDiffuseLighting. // (also cf lit deferred EncodeToGBuffer function). - diffuseLighting = (modifiedDiffuseColor * lighting.direct.diffuse) + (builtinData.bakeDiffuseLighting * diffuseOcclusion) + builtinData.emissiveColor; + lightLoopOutput.diffuseLighting = (modifiedDiffuseColor * lighting.direct.diffuse) + (builtinData.bakeDiffuseLighting * diffuseOcclusion) + builtinData.emissiveColor; - specularLighting = lighting.direct.specular + lighting.indirect.specularReflected; + lightLoopOutput.specularLighting = lighting.direct.specular + lighting.indirect.specularReflected; #ifdef DEBUG_DISPLAY // For specularOcclusion we display red to indicate there's not one value possible here. @@ -4478,7 +4478,7 @@ void PostEvaluateBSDF( LightLoopContext lightLoopContext, GetAmbientOcclusionFactor(diffuseOcclusion, specularOcclusion, directAmbientOcclusion /* not used for now in PostEvaluateBSDFDebugDisplay */ , aoFactor); - PostEvaluateBSDFDebugDisplay(aoFactor, builtinData, lighting, bsdfData.diffuseColor, diffuseLighting, specularLighting); + PostEvaluateBSDFDebugDisplay(aoFactor, builtinData, lighting, bsdfData.diffuseColor, lightLoopOutput); #endif } diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Deferred/RaytracingDeferred.compute b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Deferred/RaytracingDeferred.compute index 431969d69bb..9e77ffee38b 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Deferred/RaytracingDeferred.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Deferred/RaytracingDeferred.compute @@ -92,9 +92,13 @@ void RAYTRACING_DEFERRED(uint3 dispatchThreadId : SV_DispatchThreadID, uint2 gro PreLightData preLightData = GetPreLightData(V, posInput, bsdfData); // Evaluate the complete lighting - float3 diffuseLighting; - float3 specularLighting; - LightLoop(V, posInput, preLightData, bsdfData, builtinData, 0.0, 0.0, float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), diffuseLighting, specularLighting); + LightLoopOutput lightLoopOutput; + LightLoop(V, posInput, preLightData, bsdfData, builtinData, 0.0, 0.0, float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), lightLoopOutput); + + // Alias + float3 diffuseLighting = lightLoopOutput.diffuseLighting; + float3 specularLighting = lightLoopOutput.specularLighting; + float3 finalColor = (diffuseLighting + specularLighting); // Apply fog attenuation ApplyFogAttenuation(positionWS, rayDirection, rayDistance, finalColor, true); @@ -178,9 +182,12 @@ void RaytracingDiffuseDeferred(uint3 dispatchThreadId : SV_DispatchThreadID, uin PreLightData preLightData = GetPreLightData(viewWS, posInput, bsdfData); // Evaluate lighting - float3 diffuseLighting; - float3 specularLighting; - LightLoop(viewWS, posInput, preLightData, bsdfData, builtinData, 0.0, 0.0, float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), diffuseLighting, specularLighting); + LightLoopOutput lightLoopOutput; + LightLoop(viewWS, posInput, preLightData, bsdfData, builtinData, 0.0, 0.0, float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), lightLoopOutput); + + // Alias + float3 diffuseLighting = lightLoopOutput.diffuseLighting; + float3 specularLighting = lightLoopOutput.specularLighting; // Read the previous value and combine with the current lighting float3 previousValue = _RaytracingLitBufferRW[COORD_TEXTURE2D_X(currentCoord)].xyz; diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingLightLoop.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingLightLoop.hlsl index 7226f739ced..ee4571c145f 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingLightLoop.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingLightLoop.hlsl @@ -3,10 +3,12 @@ #define USE_LIGHT_CLUSTER void LightLoop( float3 V, PositionInputs posInput, PreLightData preLightData, BSDFData bsdfData, BuiltinData builtinData, - float reflectionHierarchyWeight, float refractionHierarchyWeight, float3 reflection, float3 transmission, - out float3 diffuseLighting, - out float3 specularLighting) + float reflectionHierarchyWeight, float refractionHierarchyWeight, float3 reflection, float3 transmission, + out LightLoopOutput lightLoopOutput) { + // Init LightLoop output structure + ZERO_INITIALIZE(LightLoopOutput, lightLoopOutput); + LightLoopContext context; context.contactShadow = 1.0; context.shadowContext = InitShadowContext(); @@ -217,5 +219,5 @@ void LightLoop( float3 V, PositionInputs posInput, PreLightData preLightData, BS } } - PostEvaluateBSDF(context, V, posInput, preLightData, bsdfData, builtinData, aggregateLighting, diffuseLighting, specularLighting); + PostEvaluateBSDF(context, V, posInput, preLightData, bsdfData, builtinData, aggregateLighting, lightLoopOutput); } diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForward.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForward.hlsl index 92648e0a2ba..b9d548d1443 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForward.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForward.hlsl @@ -199,10 +199,12 @@ void Frag(PackedVaryingsToPS packedInput, #else uint featureFlags = LIGHT_FEATURE_MASK_FLAGS_OPAQUE; #endif - float3 diffuseLighting; - float3 specularLighting; + LightLoopOutput lightLoopOutput; + LightLoop(V, posInput, preLightData, bsdfData, builtinData, featureFlags, lightLoopOutput); - LightLoop(V, posInput, preLightData, bsdfData, builtinData, featureFlags, diffuseLighting, specularLighting); + // Alias + float3 diffuseLighting = lightLoopOutput.diffuseLighting; + float3 specularLighting = lightLoopOutput.specularLighting; diffuseLighting *= GetCurrentExposureMultiplier(); specularLighting *= GetCurrentExposureMultiplier(); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingForward.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingForward.hlsl index 454afff584c..fa3a2198791 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingForward.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingForward.hlsl @@ -181,9 +181,12 @@ void ClosestHitForward(inout RayIntersection rayIntersection : SV_RayPayload, At } // Run the lightloop - float3 diffuseLighting; - float3 specularLighting; - LightLoop(viewWS, posInput, preLightData, bsdfData, builtinData, reflectedWeight, refractedWeight, reflected, transmitted, diffuseLighting, specularLighting); + LightLoopOutput lightLoopOutput; + LightLoop(viewWS, posInput, preLightData, bsdfData, builtinData, reflectedWeight, refractedWeight, reflected, transmitted, lightLoopOutput); + + // Alias + float3 diffuseLighting = lightLoopOutput.diffuseLighting; + float3 specularLighting = lightLoopOutput.specularLighting; // Color display for the moment rayIntersection.color = diffuseLighting + specularLighting; diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingIndirect.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingIndirect.hlsl index 50b5082dd07..0f215a1cdec 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingIndirect.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingIndirect.hlsl @@ -115,9 +115,12 @@ void ClosestHitMain(inout RayIntersection rayIntersection : SV_RayPayload, Attri #endif // Run the lightloop - float3 diffuseLighting; - float3 specularLighting; - LightLoop(viewWS, posInput, preLightData, bsdfData, builtinData, reflectedWeight, 0.0, reflected, float3(0.0, 0.0, 0.0), diffuseLighting, specularLighting); + LightLoopOutput lightLoopOutput; + LightLoop(viewWS, posInput, preLightData, bsdfData, builtinData, reflectedWeight, 0.0, reflected, float3(0.0, 0.0, 0.0), lightLoopOutput); + + // Alias + float3 diffuseLighting = lightLoopOutput.diffuseLighting; + float3 specularLighting = lightLoopOutput.specularLighting; // Color display for the moment rayIntersection.color = diffuseLighting + specularLighting; diff --git a/com.unity.render-pipelines.high-definition/Runtime/VFXGraph/Shaders/VFXLitPixelOutput.hlsl b/com.unity.render-pipelines.high-definition/Runtime/VFXGraph/Shaders/VFXLitPixelOutput.hlsl index fe43e6555a6..5231eadabdb 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/VFXGraph/Shaders/VFXLitPixelOutput.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/VFXGraph/Shaders/VFXLitPixelOutput.hlsl @@ -25,7 +25,13 @@ float4 VFXCalcPixelOutputForward(const SurfaceData surfaceData, const BuiltinDat #endif #endif - LightLoop(GetWorldSpaceNormalizeViewDir(posRWS), posInput, preLightData, bsdfData, builtinData, featureFlags, diffuseLighting, specularLighting); + + LightLoopOutput lightLoopOutput; + LightLoop(GetWorldSpaceNormalizeViewDir(posRWS), posInput, preLightData, bsdfData, builtinData, featureFlags, lightLoopOutput); + + // Alias + float3 diffuseLighting = lightLoopOutput.diffuseLighting; + float3 specularLighting = lightLoopOutput.specularLighting; diffuseLighting *= GetCurrentExposureMultiplier(); specularLighting *= GetCurrentExposureMultiplier(); From 67ab660415198bf32ad0ecc2308b38f3b84c7aed Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Mon, 8 Jun 2020 02:25:32 +0200 Subject: [PATCH 2/4] update upgrade guide --- .../Documentation~/Upgrading-from-2020.1-to-2020.2.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md b/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md index 191aa4edc17..f08d0bed5ea 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md @@ -8,4 +8,10 @@ From Unity 2020.2, it is not necessary to change the [HDRP Config package](HDRP- Starting from 2020.2, HDRP now stores OnEnable and OnDemand shadows in a separate atlas and more API is available to handle them. For more information, see [Shadows in HDRP](Shadows-in-HDRP.md). -From Unity 2020.2, the shader function `SampleShadow_PCSS` now requires you to pass in an additional float2 parameter which contains the shadow atlas resolution in x and the inverse of the atlas resolution in y. \ No newline at end of file +From Unity 2020.2, the shader function `SampleShadow_PCSS` now requires you to pass in an additional float2 parameter which contains the shadow atlas resolution in x and the inverse of the atlas resolution in y. + +## Shader code + +A new structure is use to output the information of the LightLoop. LightLoop struct is use instead of the pair (float3 diffuseLighting, float3 specularLighting). This is to allow to export more information from the LightLoop in the future without breaking the API. The function LightLoop() - For rasterization and raytracing - PostEvaluateBSDF(), ApplyDebug() and PostEvaluateBSDFDebugDisplay now pass this structure instead of the Pair. The function LightLoop() will initialize this structure to zero. To upgrade existing shader, replace the declaration "float3 diffuseLighting; float3 specularLighting;" by "LightLoopOutput lightLoopOutput;" before call of LightLoop and repalce the argument pair "out float3 diffuseLighting, out float3 specularLighting" by "out LightLoopOutput lightLoopOutput" in all the function mention. + +The prototype of the function ModifyBakedDiffuseLighting() in the various material have change from "void ModifyBakedDiffuseLighting(float3 V, PositionInputs posInput, SurfaceData surfaceData, inout BuiltinData builtinData)" to "void ModifyBakedDiffuseLighting(float3 V, PositionInputs posInput, PreLightData preLightData, BSDFData bsdfData, inout BuiltinData builtinData)". There is a new ModifyBakedDiffuseLighting using the former prototype added in the file BuiltinUtilities.hlsl which will call the new function prototype with the correct arguments. The purpose of this change it to prepare for future lighting features. To update code, in addition of the prototype update it is required to remove those line "BSDFData bsdfData = ConvertSurfaceDataToBSDFData(posInput.positionSS, surfaceData); PreLightData preLightData = GetPreLightData(V, posInput, bsdfData);" as it is now perform by the common code from BuiltinUtilities.hlsl. From 88f14b53ef8520ce44732ec7299dd270d79ba552 Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Mon, 8 Jun 2020 02:35:18 +0200 Subject: [PATCH 3/4] Update Upgrading-from-2020.1-to-2020.2.md --- .../Documentation~/Upgrading-from-2020.1-to-2020.2.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md b/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md index f08d0bed5ea..39d6965f461 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md @@ -2,6 +2,10 @@ In the High Definition Render Pipeline (HDRP), some features work differently between major versions of Unity. This document helps you upgrade HDRP from Unity 2020.1 to 2020.2. +## Lighting + +From Unity 2020.2, when the Sky component affected to the volume profile used for Static Lighting Sky in Environment settings of the Lighting panel is disabled. It now don't affect the bake lighting. Previously the Sky was still affecting the bake lighting even if disabled. + ## Shadows From Unity 2020.2, it is not necessary to change the [HDRP Config package](HDRP-Config-Package.html) in order to set the [Shadows filtering quality](HDRP-Asset.html#FilteringQualities) for Deferred rendering. Instead the filtering quality can be simply set on the [HDRP Asset](HDRP-Asset.html#FilteringQualities) similarly to what was previously setting only the quality for Forward. Note that if previously the Shadow filtering quality wasn't setup on medium on the HDRP Asset you will experience a change of shadow quality as now it will be taken into account. From da40621f3fb973ce3a49fdb2b61cbf1431a6d760 Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Mon, 8 Jun 2020 02:42:12 +0200 Subject: [PATCH 4/4] update upgrade guide --- .../Documentation~/Upgrading-from-2019.3-to-2020.1.md | 2 +- .../Documentation~/Upgrading-from-2020.1-to-2020.2.md | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2019.3-to-2020.1.md b/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2019.3-to-2020.1.md index aaf04d2c617..624f51a07a5 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2019.3-to-2020.1.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2019.3-to-2020.1.md @@ -12,4 +12,4 @@ From Unity 2020.1, Cookie on light are not taken into account for the lightmaps ## Default Volume Profile -From Unity 2020.1, the Default Volume Profile asset has changed so that the Exposure component sets the default Compensation to 0. \ No newline at end of file +From Unity 2020.1, the Default Volume Profile asset has changed so that the Exposure component sets the default Compensation to 0. This may cause a decrease of brightness of 1EV on scene that haven't change the default settings and aren't overriding it. diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md b/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md index 39d6965f461..491a29aa72e 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md @@ -2,6 +2,14 @@ In the High Definition Render Pipeline (HDRP), some features work differently between major versions of Unity. This document helps you upgrade HDRP from Unity 2020.1 to 2020.2. +## Constant Buffer API + +From Unity 2020.2, HDRP is using a new constant buffer API that allow to setup uniform used during the Frame and sent to the shader in a single transfer instead of multiple one. The consequence is that it is no longer possible to setup any of the values declare in ShaderVariablesGlobal.cs individualy with cmd.SetVectorXXX() or related function. It is now required to update the value of ShaderVariablesGlobal to be able to update the values use in the shaders. + +## FrameSettings + +From Unity 2020.2, "MSAA Within Forward" Camera Frame Setting is enabled by default when new Render Pipeline asset is created. + ## Lighting From Unity 2020.2, when the Sky component affected to the volume profile used for Static Lighting Sky in Environment settings of the Lighting panel is disabled. It now don't affect the bake lighting. Previously the Sky was still affecting the bake lighting even if disabled.