- Decal now support per channel selection mask. There is now two mode. One with BaseColor, Normal and Smoothness and another one more expensive with BaseColor, Normal, Smoothness, Metal and AO. Control is on HDRP Asset. This may require to launch an update script for old scene: 'Edit/Render Pipeline/Single step upgrade script/Upgrade all DecalMaterial MaskBlendMode'.
- Decal now supports depth bias for decal mesh, to prevent z-fighting
- Decal material now supports draw order for decal projectors
- Added LightLayers support (Base on mask from renderers name RenderingLayers and mask from light name LightLayers - if they match, the light apply) - cost an extra GBuffer in deferred (more bandwidth)
- When LightLayers is enabled, the AmbientOclusion is store in the GBuffer in deferred path allowing to avoid double occlusion with SSAO. In forward the double occlusion is now always avoided.
### Fixed
- Fixed an issue with PreIntegratedFGD texture being sometimes destroyed and not regenerated causing rendering to break
- Update detail map formula for smoothness and albedo, goal it to bright and dark perceptually and scale factor is use to control gradient speed
- Refactor the Upgrade material system. Now a material can be update from older version at any time. Call Edit/Render Pipeline/Upgrade all Materials to newer version
- Change name EnableDBuffer to EnableDecals at several place (shader, hdrp asset...), this require a call to Edit/Render Pipeline/Upgrade all Materials to newer version to have up to date material.
- Refactor shader code: BakeLightingData structure have been replace by BuiltinData. Lot of shader code have been remove/change.
- Refactor shader code: All GBuffer are now handled by the deferred material. Mean ShadowMask and LightLayers are control by lit material in lit.hlsl and not outside anymore. Lot of shader code have been remove/change.
### Added
- Added support for RendererPriority on Renderer. This allow to control order of transparent rendering manually. HDRP have now two stage of sorting for transparent in addition to bact to front. Material have a priority then Renderer have a priority.
publicreadonlyGUIContentapplyRangeAttenuation=newGUIContent("Apply Range Attenuation","Allows disabling range attenuation. This is useful indoor (like a room) to avoid having to setup a large range for a light to get correct inverse square attenuation that may leak out of the indoor");
publicreadonlyGUIContentdisplayAreaLightEmissiveMesh=newGUIContent("Display Emissive Mesh","Generate an emissive mesh using the size, color and intensity of the area light");
publicreadonlyGUIContentlightLayer=newGUIContent("Light Layer","Specifies the current light layers that the light affect. Corresponding renderer with the same flags will be lit by this light.");
publicreadonlyGUIContentshape=newGUIContent("Type","Specifies the current type of light. Possible types are Directional, Spot, Point, Rectangle and Line lights.");
EditorGUILayout.PropertyField(d.increaseSssSampleCount,_.GetContent("Increase SSS Sample Count|This allows for better SSS quality. Warning: high performance cost, do not enable on consoles."));
EditorGUILayout.PropertyField(d.supportVolumetrics,_.GetContent("Support volumetrics|Enable memory and shader variant for volumetric."));
EditorGUILayout.PropertyField(d.increaseResolutionOfVolumetrics,_.GetContent("Increase resolution of volumetrics|Increase the resolution of volumetric lighting buffers. Warning: high performance cost, do not enable on consoles."));
EditorGUILayout.PropertyField(d.supportLightLayers,_.GetContent("Support LightLayers|Enable light layers. In deferred this imply an extra render target in memory and extra cost."));
EditorGUILayout.PropertyField(d.supportOnlyForward,_.GetContent("Support Only Forward|Remove all the memory and shader variant of GBuffer. The renderer can be switch to deferred anymore."));
EditorGUILayout.PropertyField(d.supportOnlyForward,_.GetContent("Support Only Forward|Remove all the memory and shader variant of GBuffer. The renderer can be switch to deferred anymore."));
EditorGUILayout.PropertyField(d.increaseSssSampleCount,_.GetContent("Increase SSS Sample Count|This allows for better SSS quality. Warning: high performance cost, do not enable on consoles."));
EditorGUILayout.PropertyField(d.supportVolumetrics,_.GetContent("Support volumetrics|Enable memory and shader variant for volumetric."));
EditorGUILayout.PropertyField(d.increaseResolutionOfVolumetrics,_.GetContent("Increase resolution of volumetrics|Increase the resolution of volumetric lighting buffers. Warning: high performance cost, do not enable on consoles."));
EditorGUILayout.PropertyField(d.supportRuntimeDebugDisplay,_.GetContent("Support runtime debug display|Remove all debug display shader variant only in the player. Allow faster build."));
EditorGUILayout.PropertyField(d.supportDitheringCrossFade,_.GetContent("Support dithering cross fade|Remove all dithering cross fade shader variant only in the player. Allow faster build."));
#include "CoreRP/ShaderLibrary/Debug.hlsl" // Require for GetIndexColor auto generated
// common Encode/Decode functions
// helper macro
struct BakeLightingData
{
float3 bakeDiffuseLighting;
#ifdef SHADOWS_SHADOWMASK
float4 bakeShadowMask;
#endif
};
// Guideline for velocity buffer.
// We support various architecture for HDRenderPipeline
// - Forward only rendering
// - Hybrid forward/deferred opaque
// - Regular deferred
// The velocity buffer is potentially fill in several pass.
// - In gbuffer pass with extra RT
// - In forward opaque pass (Can happen even when deferred) with MRT
// - In dedicated velocity pass
// Also the velocity buffer is only fill in case of dynamic or deformable objects, static case can use camera reprojection to retrieve motion vector (<= TODO: this may be false with TAA due to jitter matrix)
// or just previous and current transform
// So here we decide the following rules:
// - A deferred material can't override the velocity buffer format of builtinData, must use appropriate function
// - If velocity buffer is enable in deferred material it is the last one
// - Velocity buffer can be optionally enabled (either in forward or deferred)
// - Velocity data can't be pack with other properties
// - Same velocity buffer is use for all scenario, so if deferred define a velocity buffer, the same is reuse for forward case.
// For these reasons we chose to avoid to pack velocity buffer with anything else in case of PackgbufferInFP16 (and also in case the format change)
// Encode/Decode shadowmask/velocity/distortion in a buffer (either forward of deferred)
// This contain the usage for all allocated buffer
protectedGBufferUsage[]m_GBufferUsage;
// This is the index of the gbuffer use for shadowmask and lightlayers, if any
protectedintm_ShadowMaskIndex=-1;
protectedintm_LightLayers=-1;
protectedHDRenderPipelineAssetm_asset;
// We need to store current set of RT to bind exactly, as we can have dynamic RT (LightLayers, ShadowMask), we allocated an array for each possible size (to avoid gardbage collect pressure)
cmd.SetGlobalTexture(HDShaderIDs._LightLayersTexture,RuntimeUtilities.whiteTexture);// This is never use but need to be bind as the read is inside a if
// nameID can change from one frame to another depending on the msaa flag so so we need to update this array to be sure it's up to date.
// Moreover, if we don't have shadow masks we only need to bind the first GBuffers
// This is important because in the shader the shadowmask buffer gets optimized out so anything bound after (like the DBuffer HTile) has a different bind point.
EvaluateLight_Directional(lightLoopContext, posInput, lightData, bakeLightingData, N, L, color, attenuation);
EvaluateLight_Directional(lightLoopContext, posInput, lightData, builtinData, N, L, color, attenuation);
float intensity = max(0, attenuation * NdotL); // Warning: attenuation can be greater than 1 due to the inverse square attenuation (when position is close to light)
EvaluateLight_Punctual(lightLoopContext, posInput, lightData, bakeLightingData, N, L,
EvaluateLight_Punctual(lightLoopContext, posInput, lightData, builtinData, N, L,
lightToSample, distances, color, attenuation);
float intensity = max(0, attenuation * NdotL); // Warning: attenuation can be greater than 1 due to the inverse square attenuation (when position is close to light)
float intensity = max(0, attenuation); // Warning: attenuation can be greater than 1 due to the inverse square attenuation (when position is close to light)
// We can now bind the normal buffer to be use by any effect
m_NormalBufferManager.BindNormalBuffers(cmd);
// RenderGBuffer do the gbuffer pass. This is solely call with deferred. If we use a depth prepass, then the depth prepass will perform the alpha testing for opaque apha tested and we don't need to do it anymore
// during Gbuffer pass. This is handled in the shader and the depth test (equal and no depth write) is done here.