Skip to content

Commit

Permalink
Show file tree
Hide file tree
Showing 21 changed files with 101 additions and 37 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Expand Up @@ -33,5 +33,13 @@ static void CreatePlanarReflectionGameObject(MenuCommand menuCommand)
var planarProbe = go.AddComponent<PlanarReflectionProbe>();
planarProbe.influenceVolume.boxSize = new Vector3(1, 0.01f, 1);
}

[MenuItem("GameObject/Volume/Reflection Proxy Volume", priority = 12)]
static void CreateReflectionProxyVolumeGameObject(MenuCommand menuCommand)
{
var parent = menuCommand.context as GameObject;
var go = CoreEditorUtils.CreateGameObject("Reflection Proxy Volume", parent);
var proxyVolume = go.AddComponent<ReflectionProxyVolumeComponent>();
}
}
}
Expand Up @@ -217,7 +217,13 @@ static void Drawer_AdvancedBlendDistance(SerializedInfluenceVolume serialized, b
static void Drawer_SectionShapeSphere(SerializedInfluenceVolume serialized, Editor owner, bool drawOffset, bool drawNormal)
{
EditorGUILayout.BeginHorizontal();
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(serialized.sphereRadius, radiusContent);
if (EditorGUI.EndChangeCheck())
{
if (serialized.sphereRadius.floatValue < serialized.sphereBlendDistance.floatValue)
serialized.sphereBlendDistance.floatValue = serialized.sphereRadius.floatValue;
}
HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.InfluenceShape, owner, GUILayout.Width(28f), GUILayout.MinHeight(22f));
EditorGUILayout.EndHorizontal();

Expand Down
Expand Up @@ -525,7 +525,10 @@ void DrawSurfaceInputsGUI()

if ((uvBaseMapping == UVBaseMapping.Planar) || (uvBaseMapping == UVBaseMapping.Triplanar))
{
materialEditor.ShaderProperty(uvMappingSpace, Styles.uvMappingSpace);
// The uv mapping is not always defined in shader (e.g. for layered lit).
if (uvMappingSpace != null)
materialEditor.ShaderProperty(uvMappingSpace, Styles.uvMappingSpace);

materialEditor.ShaderProperty(TexWorldScale[m_LayerIndex], Styles.texWorldScaleText);
}
materialEditor.TextureScaleOffsetProperty(baseColorMap[m_LayerIndex]);
Expand Down
Expand Up @@ -72,6 +72,10 @@ void OnEnable()

public override void OnInspectorGUI()
{
if (HDRenderPipeline.currentAsset == null || !HDRenderPipeline.currentAsset.currentPlatformRenderPipelineSettings.supportCustomPass)
HDEditorUtils.QualitySettingsHelpBox("The current HDRP asset does not support Custom Passes.", MessageType.Error,
HDRenderPipelineUI.Expandable.Rendering, "m_RenderPipelineSettings.supportCustomPass");

DrawSettingsGUI();
DrawCustomPassReorderableList();
DrawMaterialsGUI();
Expand Down Expand Up @@ -103,8 +107,11 @@ void DrawMaterialsGUI()
// Draw the material inspectors:
foreach (var materialEditor in m_MaterialEditors)
{
materialEditor.DrawHeader();
materialEditor.OnInspectorGUI();
using (new EditorGUI.DisabledScope((materialEditor.target.hideFlags & HideFlags.NotEditable) != 0))
{
materialEditor.DrawHeader();
materialEditor.OnInspectorGUI();
}
}

m_CustomPassMaterialsHash = materialsHash;
Expand Down
Expand Up @@ -632,7 +632,7 @@ static void Drawer_SectionDynamicResolutionSettings(SerializedHDRenderPipelineAs
EditorGUI.BeginChangeCheck();
maxPercentage = EditorGUILayout.DelayedFloatField(HDRenderPipelineUI.Styles.maxPercentage, maxPercentage);
if (EditorGUI.EndChangeCheck())
serialized.renderPipelineSettings.dynamicResolutionSettings.maxPercentage.floatValue = Mathf.Clamp(maxPercentage, 0.0f, 100.0f);
serialized.renderPipelineSettings.dynamicResolutionSettings.maxPercentage.floatValue = Mathf.Clamp(maxPercentage, minPercentage, 100.0f);

EditorGUI.showMixedValue = false;
}
Expand Down
Expand Up @@ -150,8 +150,15 @@ static void InitializeEntryList()
{
if (EditorWindow.HasOpenInstances<HDWizard>())
{
HDWizard window = (HDWizard)EditorWindow.GetWindow(typeof(HDWizard));
window.ReBuildEntryList();
EditorApplication.update += DelayedRebuildEntryList;

// Case 1407981: Calling GetWindow in InitializeOnLoadMethod doesn't work and creates a new window instead of getting the existing one.
void DelayedRebuildEntryList()
{
EditorApplication.update -= DelayedRebuildEntryList;
HDWizard window = EditorWindow.GetWindow<HDWizard>(Style.title.text);
window.ReBuildEntryList();
}
}
}

Expand Down
Expand Up @@ -449,7 +449,11 @@ void FinePruneLights(uint threadID, int iNrCoarseLights, uint2 viTilLL, float vL
int idxCoarse;
int uLightVolume;
LoadLightVolumeCache(l, idxCoarse, uLightVolume);
bool lightValid = false;

// WARNING: we use here a uint for lightValid because there is a bug with the unity vulkan compiler.
// If this is a bool, the second dword of uLightsFlags never gets written to, which causes light tile artifacts
// on tiles that have more than 32 lights.
uint lightValid = 0;
if (uLightVolume == LIGHTVOLUMETYPE_CONE)
{
LightVolumeData lightData = _LightVolumeData[idxCoarse];
Expand Down Expand Up @@ -534,7 +538,7 @@ void FinePruneLights(uint threadID, int iNrCoarseLights, uint2 viTilLL, float vL
else
break;

uLightsFlags[l<32 ? 0 : 1] |= ((lightValid ? 1 : 0)<<(l&31));
uLightsFlags[l<32 ? 0 : 1] |= lightValid << (l&31);
}

InterlockedOr(ldsDoesLightIntersect[0], uLightsFlags[0]);
Expand Down
Expand Up @@ -30,7 +30,7 @@ public partial class InfluenceVolume
Vector3 m_BoxSideFadeNegative = Vector3.one;

// Sphere
[SerializeField, FormerlySerializedAs("m_SphereBaseRadius")]
[SerializeField, FormerlySerializedAs("m_SphereBaseRadius"), Min(0)]
float m_SphereRadius = 3f;
[SerializeField, FormerlySerializedAs("m_SphereInfluenceFade")]
float m_SphereBlendDistance;
Expand Down
Expand Up @@ -8,7 +8,8 @@ partial class ProxyVolume : IVersionable<ProxyVolume.Version>, ISerializationCal
enum Version
{
Initial,
InfiniteProjectionInShape
InfiniteProjectionInShape,
ForcePositiveSize,
}

static readonly MigrationDescription<Version, ProxyVolume> k_Migration = MigrationDescription.New(
Expand All @@ -21,6 +22,11 @@ enum Version
{
p.shape = ProxyShape.Infinite;
}
}),
MigrationStep.New(Version.ForcePositiveSize, (ProxyVolume p) =>
{
p.sphereRadius = Mathf.Abs(p.sphereRadius);
p.boxSize = new Vector3(Mathf.Abs(p.boxSize.x), Mathf.Abs(p.boxSize.y), Mathf.Abs(p.boxSize.z));
})
);

Expand Down
Expand Up @@ -13,9 +13,9 @@ public partial class ProxyVolume
{
[SerializeField, FormerlySerializedAs("m_ShapeType")]
ProxyShape m_Shape = ProxyShape.Box;
[SerializeField]
[SerializeField, Min(0)]
Vector3 m_BoxSize = Vector3.one;
[SerializeField]
[SerializeField, Min(0)]
float m_SphereRadius = 1;

/// <summary>The shape of the proxy</summary>
Expand Down
Expand Up @@ -74,7 +74,7 @@ bool CreateMaterialData(PathIntersection pathIntersection, BuiltinData builtinDa
mtlData.bsdfWeight[1] = HasClearcoat() ? Fcoat * Luminance(mtlData.bsdfData.clearcoatColor) : 0.0;
float clearcoatTransmission = HasClearcoat() ? 1.0 - Fcoat : 1.0;
mtlData.bsdfWeight[2] = clearcoatTransmission * lerp(Fspec, 0.5, GetScalarRoughness(mtlData.bsdfData.roughness)) * specularCoeff;
mtlData.bsdfWeight[0] = clearcoatTransmission * Luminance(mtlData.bsdfData.diffuseColor) * mtlData.bsdfData.ambientOcclusion;
mtlData.bsdfWeight[0] = clearcoatTransmission * Luminance(mtlData.bsdfData.diffuseColor) * max(mtlData.bsdfData.ambientOcclusion, 0.001);
}

// Normalize the weights
Expand Down
Expand Up @@ -41,7 +41,7 @@ bool CreateMaterialData(PathIntersection pathIntersection, BuiltinData builtinDa
if (!IsAbove(mtlData))
return false;

mtlData.bsdfWeight[0] = Luminance(mtlData.bsdfData.diffuseColor) * mtlData.bsdfData.ambientOcclusion;
mtlData.bsdfWeight[0] = Luminance(mtlData.bsdfData.diffuseColor) * max(mtlData.bsdfData.ambientOcclusion, 0.001);

// If N.V < 0 (can happen with normal mapping, or smooth normals on coarsely tesselated objects) we want to avoid spec sampling
float NdotV = dot(GetSpecularNormal(mtlData), mtlData.V);
Expand Down
Expand Up @@ -70,7 +70,7 @@ bool CreateMaterialData(PathIntersection pathIntersection, BuiltinData builtinDa
coatingTransmission = 1.0 - mtlData.bsdfWeight[1];
mtlData.bsdfWeight[2] = coatingTransmission * lerp(Fspec, 0.5, 0.5 * (mtlData.bsdfData.roughnessT + mtlData.bsdfData.roughnessB)) * GetSpecularCompensation(mtlData);
mtlData.bsdfWeight[3] = (coatingTransmission - mtlData.bsdfWeight[2]) * mtlData.bsdfData.transmittanceMask;
mtlData.bsdfWeight[0] = coatingTransmission * (1.0 - mtlData.bsdfData.transmittanceMask) * Luminance(mtlData.bsdfData.diffuseColor) * mtlData.bsdfData.ambientOcclusion;
mtlData.bsdfWeight[0] = coatingTransmission * (1.0 - mtlData.bsdfData.transmittanceMask) * Luminance(mtlData.bsdfData.diffuseColor) * max(mtlData.bsdfData.ambientOcclusion, 0.001);
}
#ifdef _SURFACE_TYPE_TRANSPARENT
else // Below
Expand Down
Expand Up @@ -152,6 +152,7 @@ Shader "HDRP/LitTessellation"
[Enum(Auto, 0, On, 1, Off, 2)] _DoubleSidedGIMode("Double sided GI mode", Float) = 0

[Enum(UV0, 0, UV1, 1, UV2, 2, UV3, 3, Planar, 4, Triplanar, 5)] _UVBase("UV Set for base", Float) = 0
[Enum(WorldSpace, 0, ObjectSpace, 1)] _ObjectSpaceUVMapping("Mapping space", Float) = 0.0
_TexWorldScale("Scale to apply on world coordinate", Float) = 1.0
[HideInInspector] _InvTilingScale("Inverse tiling scale = 2 / (abs(_BaseColorMap_ST.x) + abs(_BaseColorMap_ST.y))", Float) = 1
[HideInInspector] _UVMappingMask("_UVMappingMask", Color) = (1, 0, 0, 0)
Expand Down
Expand Up @@ -92,7 +92,7 @@ bool CreateMaterialData(PathIntersection pathIntersection, BuiltinData builtinDa
float coatingTransmissionWeight = Luminance(coatingTransmission);
mtlData.bsdfWeight[2] = coatingTransmissionWeight * (1.0 - mtlData.bsdfData.lobeMix) * lerp(Fspec, 0.5, 0.5 * (mtlData.bsdfData.roughnessAT + mtlData.bsdfData.roughnessAB)) * GetSpecularCompensationA(mtlData);
mtlData.bsdfWeight[3] = coatingTransmissionWeight * mtlData.bsdfData.lobeMix * lerp(Fspec, 0.5, 0.5 * (mtlData.bsdfData.roughnessBT + mtlData.bsdfData.roughnessBB)) * GetSpecularCompensationB(mtlData);
mtlData.bsdfWeight[0] = coatingTransmissionWeight * Luminance(mtlData.bsdfData.diffuseColor) * mtlData.bsdfData.ambientOcclusion;
mtlData.bsdfWeight[0] = coatingTransmissionWeight * Luminance(mtlData.bsdfData.diffuseColor) * max(mtlData.bsdfData.ambientOcclusion, 0.001);
}

// Normalize the weights
Expand Down
Expand Up @@ -31,8 +31,11 @@ void AddConvergenceCue(uint2 pixelCoord, uint sampleCount, inout float3 color)
uint width = _ScreenSize.x;
uint height = _ScreenSize.y;

// Change color only in a region corresponding to a progress bar, on the bottom 1% of the screen
if (pixelCoord.y < 4 && (float)pixelCoord.x / width <= (float)sampleCount / _AccumulationNumSamples)
// Define progress bar height as 0.5% of the resolution (and at least 4 pixels high)
uint barHeight = max(4, ceil(height * 0.005));

// Change color only in a region corresponding to a progress bar, at the bottom of the screen
if (pixelCoord.y < barHeight && (float)pixelCoord.x / width <= (float)sampleCount / _AccumulationNumSamples)
{
float lum = Luminance(color);

Expand Down
Expand Up @@ -847,15 +847,15 @@ internal void Update(FrameSettings currentFrameSettings, HDRenderPipeline hdrp,

// If we have a mismatch with color buffer format we need to reallocate the pyramid
var hdPipeline = (HDRenderPipeline)(RenderPipelineManager.currentPipeline);
bool forceReallocPyramid = false;
bool forceReallocHistorySystem = false;
int colorBufferID = (int)HDCameraFrameHistoryType.ColorBufferMipChain;
int numColorPyramidBuffersAllocated = m_HistoryRTSystem.GetNumFramesAllocated(colorBufferID);
if (numColorPyramidBuffersAllocated > 0)
{
var currPyramid = GetCurrentFrameRT(colorBufferID);
if (currPyramid != null && currPyramid.rt.graphicsFormat != hdPipeline.GetColorBufferFormat())
{
forceReallocPyramid = true;
forceReallocHistorySystem = true;
}
}

Expand All @@ -871,34 +871,41 @@ internal void Update(FrameSettings currentFrameSettings, HDRenderPipeline hdrp,
var aovHistory = GetHistoryRTHandleSystem(aovRequest);
if (aovHistory.GetNumFramesAllocated(colorBufferID) != numColorPyramidBuffersRequired)
{
forceReallocPyramid = true;
forceReallocHistorySystem = true;
break;
}
}

// If we change the upscale schedule, refresh the history buffers. We need to do this, because if postprocess is after upscale, the size of some buffers needs to change.
if (m_PrevUpsamplerSchedule != DynamicResolutionHandler.instance.upsamplerSchedule || previousFrameWasTAAUpsampled != IsTAAUEnabled())
{
forceReallocPyramid = true;
forceReallocHistorySystem = true;
m_PrevUpsamplerSchedule = DynamicResolutionHandler.instance.upsamplerSchedule;
}

// Handle the color buffers
if (numColorPyramidBuffersAllocated != numColorPyramidBuffersRequired || forceReallocPyramid)
if (numColorPyramidBuffersAllocated != numColorPyramidBuffersRequired || forceReallocHistorySystem)
{
// Reinit the system.
colorPyramidHistoryIsValid = false;

// Since we nuke all history we must inform the post process system too.
resetPostProcessingHistory = true;

// The history system only supports the "nuke all" option.
// TODO: Fix this, only the color buffers should be discarded.
m_HistoryRTSystem.Dispose();
m_HistoryRTSystem = new BufferedRTHandleSystem();
if (forceReallocHistorySystem)
{
m_HistoryRTSystem.Dispose();
m_HistoryRTSystem = new BufferedRTHandleSystem();
}
else
{
// We only need to release all the ColorBufferMipChain buffers (and they will potentially be allocated just under if needed).
m_HistoryRTSystem.ReleaseBuffer((int)HDCameraFrameHistoryType.ColorBufferMipChain);
}

m_ExposureTextures.clear();

if (numColorPyramidBuffersRequired != 0 || forceReallocPyramid)
if (numColorPyramidBuffersRequired != 0 || forceReallocHistorySystem)
{
AllocHistoryFrameRT((int)HDCameraFrameHistoryType.ColorBufferMipChain, HistoryBufferAllocatorFunction, numColorPyramidBuffersRequired);

Expand Down
Expand Up @@ -504,9 +504,9 @@ TextureHandle GetPostprocessUpsampledOutputHandle(RenderGraph renderGraph, strin
// Save the post process screen size before any resolution group change
var postProcessScreenSize = hdCamera.postProcessScreenSize;

//default always to downsampled resolution group.
//when DRS is off this resolution group is the same.
SetCurrentResolutionGroup(renderGraph, hdCamera, ResolutionGroup.BeforeDynamicResUpscale);
//The resGroup is always expected to be in BeforeDynamicResUpscale state at the beginning of post processing.
//If this assert fails, it means that some effects prior might be using the wrong resolution.
Assert.IsTrue(resGroup == ResolutionGroup.BeforeDynamicResUpscale, "Resolution group must always be reset before calling RenderPostProcess");

// Note: whether a pass is really executed or not is generally inside the Do* functions.
// with few exceptions.
Expand Down Expand Up @@ -570,7 +570,7 @@ TextureHandle GetPostprocessUpsampledOutputHandle(RenderGraph renderGraph, strin
// HDRP to reduce the amount of resolution lost at the center of the screen
source = PaniniProjectionPass(renderGraph, hdCamera, source);

source = LensFlareDataDrivenPass(renderGraph, hdCamera, source, depthBuffer, sunOcclusionTexture);
source = LensFlareDataDrivenPass(renderGraph, hdCamera, source, depthBufferMipChain, sunOcclusionTexture);

TextureHandle bloomTexture = BloomPass(renderGraph, hdCamera, source);
TextureHandle logLutOutput = ColorGradingPass(renderGraph);
Expand Down Expand Up @@ -3215,7 +3215,7 @@ TextureHandle LensFlareDataDrivenPass(RenderGraph renderGraph, HDCamera hdCamera
data.parameters.usePanini, data.parameters.paniniDistance, data.parameters.paniniCropToFit,
ShaderConfig.s_CameraRelativeRendering != 0,
data.hdCamera.mainViewConstants.worldSpaceCameraPos,
data.hdCamera.mainViewConstants.viewProjMatrix,
data.hdCamera.mainViewConstants.nonJitteredViewProjMatrix,
ctx.cmd, data.source,
// If you pass directly 'GetLensFlareLightAttenuation' that create alloc apparently to cast to System.Func
// And here the lambda setup like that seem to not alloc anything.
Expand Down
Expand Up @@ -40,6 +40,9 @@ public partial class HDRenderPipeline
bool msaa = hdCamera.msaaEnabled;
var target = renderRequest.target;

//Set resolution group for the entire frame
SetCurrentResolutionGroup(m_RenderGraph, hdCamera, ResolutionGroup.BeforeDynamicResUpscale);

// Caution: We require sun light here as some skies use the sun light to render, it means that UpdateSkyEnvironment must be called after PrepareLightsForGPU.
// TODO: Try to arrange code so we can trigger this call earlier and use async compute here to run sky convolution during other passes (once we move convolution shader to compute).
if (!m_CurrentDebugDisplaySettings.IsMatcapViewEnabled(hdCamera))
Expand Down Expand Up @@ -1599,7 +1602,7 @@ void PreRenderSky(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle dept

void RenderSky(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle colorBuffer, TextureHandle volumetricLighting, TextureHandle depthStencilBuffer, TextureHandle depthTexture)
{
if (m_CurrentDebugDisplaySettings.DebugHideSky(hdCamera) || CoreUtils.IsSceneFilteringEnabled())
if (m_CurrentDebugDisplaySettings.DebugHideSky(hdCamera))
return;

m_SkyManager.RenderSky(renderGraph, hdCamera, colorBuffer, depthStencilBuffer, "Render Sky", ProfilingSampler.Get(HDProfileId.RenderSky));
Expand Down

0 comments on commit 8c6a242

Please sign in to comment.