Skip to content

Commit

Permalink
[APV] Scenario blending improvements (#7198)
Browse files Browse the repository at this point in the history
* Separate memory budget enum

* Give control over blending factor

* Allow SRP with no compute support

* Added debug mode for scenario blending

* Blending runtime test

* reviews

* Fix test

* fix formatting

* Fix renaming, hide active scenario from debug, fix test
  • Loading branch information
adrien-de-tocqueville authored Feb 21, 2022
1 parent 8092fd3 commit 71a6010
Show file tree
Hide file tree
Showing 30 changed files with 601 additions and 151 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,6 @@ MonoBehaviour:
searchMultiplier: 0.2
profile: {fileID: 11400000, guid: c70ba2f8270ecc54fa63963d2f32413d, type: 2}
lightingScenarios:
- Default
- Scenario 1
- Scenario 2
m_Version: 3
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
240 changes: 239 additions & 1 deletion TestProjects/HDRP_RuntimeTests/Assets/Scenes/007-BasicAPV.unity
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,238 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1381588290
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1381588293}
- component: {fileID: 1381588292}
- component: {fileID: 1381588291}
- component: {fileID: 1381588294}
m_Layer: 0
m_Name: ScenarioTest
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1381588291
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1381588290}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7a68c43fe1f2a47cfa234b5eeaa98012, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Intensity: 60000
m_EnableSpotReflector: 1
m_LuxAtDistance: 1
m_InnerSpotPercent: 0
m_SpotIESCutoffPercent: 100
m_LightDimmer: 1
m_VolumetricDimmer: 1
m_LightUnit: 0
m_FadeDistance: 10000
m_VolumetricFadeDistance: 10000
m_AffectDiffuse: 1
m_AffectSpecular: 1
m_NonLightmappedOnly: 0
m_ShapeWidth: 0.5
m_ShapeHeight: 0.5
m_AspectRatio: 1
m_ShapeRadius: 0.025
m_SoftnessScale: 1
m_UseCustomSpotLightShadowCone: 0
m_CustomSpotLightShadowCone: 30
m_MaxSmoothness: 0.99
m_ApplyRangeAttenuation: 1
m_DisplayAreaLightEmissiveMesh: 0
m_AreaLightCookie: {fileID: 0}
m_IESPoint: {fileID: 0}
m_IESSpot: {fileID: 0}
m_IncludeForRayTracing: 1
m_AreaLightShadowCone: 120
m_UseScreenSpaceShadows: 0
m_InteractsWithSky: 1
m_AngularDiameter: 0.5
m_FlareSize: 2
m_FlareTint: {r: 1, g: 1, b: 1, a: 1}
m_FlareFalloff: 4
m_SurfaceTexture: {fileID: 0}
m_SurfaceTint: {r: 1, g: 1, b: 1, a: 1}
m_Distance: 1.5e+11
m_UseRayTracedShadows: 0
m_NumRayTracingSamples: 4
m_FilterTracedShadow: 1
m_FilterSizeTraced: 16
m_SunLightConeAngle: 0.5
m_LightShadowRadius: 0.5
m_SemiTransparentShadow: 0
m_ColorShadow: 1
m_DistanceBasedFiltering: 0
m_EvsmExponent: 15
m_EvsmLightLeakBias: 0
m_EvsmVarianceBias: 0.00001
m_EvsmBlurPasses: 0
m_LightlayersMask: 1
m_LinkShadowLayers: 1
m_ShadowNearPlane: 0.1
m_BlockerSampleCount: 24
m_FilterSampleCount: 16
m_MinFilterSize: 0.1
m_KernelSize: 5
m_LightAngle: 1
m_MaxDepthBias: 0.001
m_ShadowResolution:
m_Override: 512
m_UseOverride: 1
m_Level: 0
m_ShadowDimmer: 1
m_VolumetricShadowDimmer: 1
m_ShadowFadeDistance: 10000
m_UseContactShadow:
m_Override: 0
m_UseOverride: 1
m_Level: 0
m_RayTracedContactShadow: 0
m_ShadowTint: {r: 0, g: 0, b: 0, a: 1}
m_PenumbraTint: 0
m_NormalBias: 0.75
m_SlopeBias: 0.5
m_ShadowUpdateMode: 0
m_AlwaysDrawDynamicShadows: 0
m_UpdateShadowOnLightMovement: 0
m_CachedShadowTranslationThreshold: 0.01
m_CachedShadowAngularThreshold: 0.5
m_BarnDoorAngle: 90
m_BarnDoorLength: 0.05
m_preserveCachedShadow: 0
m_OnDemandShadowRenderOnPlacement: 1
m_ShadowCascadeRatios:
- 0.05
- 0.2
- 0.3
m_ShadowCascadeBorders:
- 0.2
- 0.2
- 0.2
- 0.2
m_ShadowAlgorithm: 0
m_ShadowVariant: 0
m_ShadowPrecision: 0
useOldInspector: 0
useVolumetric: 1
featuresFoldout: 1
m_AreaLightEmissiveMeshShadowCastingMode: 0
m_AreaLightEmissiveMeshMotionVectorGenerationMode: 0
m_AreaLightEmissiveMeshLayer: -1
m_Version: 11
m_ObsoleteShadowResolutionTier: 1
m_ObsoleteUseShadowQualitySettings: 0
m_ObsoleteCustomShadowResolution: 512
m_ObsoleteContactShadows: 0
m_PointlightHDType: 0
m_SpotLightShape: 0
m_AreaLightShape: 0
--- !u!108 &1381588292
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1381588290}
m_Enabled: 1
serializedVersion: 10
m_Type: 2
m_Shape: 0
m_Color: {r: 0, g: 1, b: 0, a: 1}
m_Intensity: 4774.648
m_Range: 1.9943948
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize: 10
m_Shadows:
m_Type: 0
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 2
m_LightShadowCasterMode: 2
m_AreaSize: {x: 0.5, y: 0.5}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 1
m_BoundingSphereOverride: {x: 0, y: 39, z: 0, w: 47}
m_UseBoundingSphereOverride: 0
m_UseViewFrustumForShadowCasterCull: 1
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &1381588293
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1381588290}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -5.48, y: 6.42, z: -4.388}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 11
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1381588294
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1381588290}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c148302b36d2e59449372067143bc5e2, type: 3}
m_Name:
m_EditorClassIdentifier:
scenario1Color: {r: 1, g: 0, b: 0, a: 1}
scenario2Color: {r: 0, g: 1, b: 0, a: 1}
--- !u!1 &1438838908
GameObject:
m_ObjectHideFlags: 1
Expand Down Expand Up @@ -2109,12 +2341,18 @@ MonoBehaviour:
cellSupportDataAsset: {fileID: 4900000, guid: acb4ae6ad947b73478110ec6f398e997,
type: 3}
serializedScenarios:
- scenario: Default
- scenario: Scenario 1
data:
sceneHash: 1784705805
cellDataAsset: {fileID: 4900000, guid: 33ad5211599350941aaefb40a027a52f, type: 3}
cellOptionalDataAsset: {fileID: 4900000, guid: 777185668354240419006bd3f247492e,
type: 3}
- scenario: Scenario 2
data:
sceneHash: 1784705805
cellDataAsset: {fileID: 4900000, guid: 0a543b607d2590343a782f224798513d, type: 3}
cellOptionalDataAsset: {fileID: 4900000, guid: 640e074dc3b3bcf4ca37e51301964f7b,
type: 3}
--- !u!4 &1943135966
Transform:
m_ObjectHideFlags: 0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using UnityEngine;
using UnityEngine.Rendering;

#if UNITY_EDITOR
using UnityEditor;
#endif

[ExecuteAlways]
public class LightScenario : MonoBehaviour
{
const string scenario1 = "Scenario 1";
const string scenario2 = "Scenario 2";

public Color scenario1Color = Color.red;
public Color scenario2Color = Color.green;

void OnEnable()
{
#if UNITY_EDITOR
Lightmapping.bakeStarted += SetupLight;
#else
// Ensure Light is baked and not coming from realtime
if (Application.isPlaying)
GetComponent<Light>().enabled = false;
#endif
}

private void Update()
{
if (Application.isPlaying && ProbeReferenceVolume.instance.isInitialized)
{
ProbeReferenceVolume.instance.SetNumberOfCellsLoadedPerFrame(100);
ProbeReferenceVolume.instance.lightingScenario = scenario1;
ProbeReferenceVolume.instance.BlendLightingScenario(scenario2, 0.5f);
}
}

#if UNITY_EDITOR
void OnDisable()
{
Lightmapping.bakeStarted -= SetupLight;
}

void SetupLight()
{
var color = ProbeReferenceVolume.instance.lightingScenario == scenario1 ? scenario1Color : scenario2Color;
GetComponent<Light>().color = color;
}
#endif
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions com.unity.render-pipelines.core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added error on ResourceReloader when attempting to use [ReloadGroup] on ScriptableObject.
- Added Screen Coordinates Override shader utilities.
- Added API to blend between baking states for Probe Volumes.
- Aded explicit control over scenario blending factor and a debug mode for visualization.

### Changed
- Volume Component editor are now specified by `CustomEditorAttribute` instead of `VolumeComponentEditorAttribute`.
Expand Down
Loading

0 comments on commit 71a6010

Please sign in to comment.