浏览代码

Handle emissiveColor separate of bakeDiffuseLighting in forward

/main
Sebastien Lagarde 6 年前
当前提交
f0619d1d
共有 5 个文件被更改,包括 11 次插入7 次删除
  1. 1
      com.unity.render-pipelines.high-definition/CHANGELOG.md
  2. 1
      com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoop.hlsl
  3. 9
      com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.hlsl
  4. 3
      com.unity.render-pipelines.high-definition/HDRP/Material/MaterialEvaluation.hlsl
  5. 4
      com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.hlsl

1
com.unity.render-pipelines.high-definition/CHANGELOG.md


- Added the possibility to add an override transform on the camera for volume interpolation
- Added desired lux intensity and auto multiplier for HDRI sky
- Added gradient sky
- Split EmissiveColor and bakeDiffuseLighting in forward avoiding the emissiveColor to be affect by SSAO
### Fixed
- Fixed an issue with PreIntegratedFGD texture being sometimes destroyed and not regenerated causing rendering to break

1
com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoop.hlsl


return (lightLayers & renderingLayers) != 0;
}
// bakeDiffuseLighting is part of the prototype so a user is able to implement a "base pass" with GI and multipass direct light (aka old unity rendering path)
void LightLoop( float3 V, PositionInputs posInput, PreLightData preLightData, BSDFData bsdfData, BuiltinData builtinData, uint featureFlags,
out float3 diffuseLighting,
out float3 specularLighting)

9
com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.hlsl


outGBuffer2.a = PackFloatInt8bit(coatMask, materialFeatureId, 8);
// RT3 - 11f:11f:10f
outGBuffer3 = float4(builtinData.bakeDiffuseLighting, 0.0);
// In deferred we encode emissive color with bakeDiffuseLighting. We don't have the room to store emissiveColor.
// It mean that any futher process that affect bakeDiffuseLighting will also affect emissiveColor, like SSAO for example.
outGBuffer3 = float4(builtinData.bakeDiffuseLighting + builtinData.emissiveColor, 0.0);
#ifdef LIGHT_LAYERS
// If we have light layers, take the opportunity to save AO and avoid double occlusion with SSAO

}
// Premultiply bake diffuse lighting information with DisneyDiffuse pre-integration
return builtinData.bakeDiffuseLighting * preLightData.diffuseFGD * surfaceData.ambientOcclusion * bsdfData.diffuseColor + builtinData.emissiveColor;
return builtinData.bakeDiffuseLighting * preLightData.diffuseFGD * surfaceData.ambientOcclusion * bsdfData.diffuseColor;
}
//-----------------------------------------------------------------------------

// Apply the albedo to the direct diffuse lighting (only once). The indirect (baked)
// diffuse lighting has already had the albedo applied in GetBakedDiffuseLighting().
diffuseLighting = modifiedDiffuseColor * lighting.direct.diffuse + builtinData.bakeDiffuseLighting;
// Note: In deferred bakeDiffuseLighting also contain emissive and in this case emissiveColor is 0
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

3
com.unity.render-pipelines.high-definition/HDRP/Material/MaterialEvaluation.hlsl


void ApplyAmbientOcclusionFactor(AmbientOcclusionFactor aoFactor, inout BuiltinData builtinData, inout AggregateLighting lighting)
{
// Note: in case of deferred Lit, builtinData.bakeDiffuseLighting contain indirect diffuse + emissive,
// so Ambient occlusion is multiply by emissive which is wrong but not a big deal
// so Ambient occlusion is multiply by emissive which is incorrect but we accept the tradeoff
builtinData.bakeDiffuseLighting *= aoFactor.indirectAmbientOcclusion;
lighting.indirect.specularReflected *= aoFactor.indirectSpecularOcclusion;
lighting.direct.diffuse *= aoFactor.directAmbientOcclusion;

switch (_DebugLightingMode)
{
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;
//Compress lighting values for color picker if enabled

4
com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.hlsl


// Premultiply bake diffuse lighting information
// preLightData.diffuseEnergy will be 1,1,1 if no vlayering or no VLAYERED_DIFFUSE_ENERGY_HACKED_TERM
return builtinData.bakeDiffuseLighting * preLightData.diffuseFGD * preLightData.diffuseEnergy * surfaceData.ambientOcclusion * bsdfData.diffuseColor + builtinData.emissiveColor;
return builtinData.bakeDiffuseLighting * preLightData.diffuseFGD * preLightData.diffuseEnergy * surfaceData.ambientOcclusion * bsdfData.diffuseColor;
}

// Apply the albedo to the direct diffuse lighting (only once). The indirect (baked)
// diffuse lighting has already had the albedo applied in GetBakedDiffuseLighting().
diffuseLighting = modifiedDiffuseColor * lighting.direct.diffuse + builtinData.bakeDiffuseLighting;
diffuseLighting = modifiedDiffuseColor * lighting.direct.diffuse + builtinData.bakeDiffuseLighting + builtinData.emissiveColor;
specularLighting = lighting.direct.specular + lighting.indirect.specularReflected;

正在加载...
取消
保存