Skip to content

Commit 1cbecd5

Browse files
Fix Light overlap (#444)
* Added the light overlap volume code * Updated changelog * Made outline thinner and removed the semi-transparent color of the light shape in light overlap debug mode * Fixed documentation Co-authored-by: sebastienlagarde <sebastien@unity3d.com>
1 parent 3b4eec6 commit 1cbecd5

File tree

6 files changed

+178
-93
lines changed

6 files changed

+178
-93
lines changed

com.unity.render-pipelines.core/Runtime/Utilities/CoreUtils.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,6 +1124,32 @@ public static bool IsSceneLightingDisabled(Camera camera)
11241124
return disabled;
11251125
}
11261126

1127+
/// <summary>
1128+
/// Returns true if the "Light Overlap" scene view draw mode is enabled.
1129+
/// </summary>
1130+
/// <param name="camera">Input camera.</param>
1131+
/// <returns>True if "Light Overlap" is enabled in the scene view associated with the input camera.</returns>
1132+
public static bool IsLightOverlapDebugEnabled(Camera camera)
1133+
{
1134+
bool enabled = false;
1135+
#if UNITY_EDITOR
1136+
if (camera.cameraType == CameraType.SceneView)
1137+
{
1138+
// Determine whether the "LightOverlap" mode is enabled for the current view.
1139+
for (int i = 0; i < UnityEditor.SceneView.sceneViews.Count; i++)
1140+
{
1141+
var sv = UnityEditor.SceneView.sceneViews[i] as UnityEditor.SceneView;
1142+
if (sv.camera == camera && sv.cameraMode.drawMode == UnityEditor.DrawCameraMode.LightOverlap)
1143+
{
1144+
enabled = true;
1145+
break;
1146+
}
1147+
}
1148+
}
1149+
#endif
1150+
return enabled;
1151+
}
1152+
11271153
#if UNITY_EDITOR
11281154
static Func<List<UnityEditor.MaterialEditor>> materialEditors;
11291155

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
610610
- Fixed various multi-editing issues when changing Emission parameters.
611611
- Fixed error when undo a Reflection Probe removal in a prefab instance. (case 1244047)
612612
- Tentative fix for missing include in depth of field shaders.
613+
- Fixed the light overlap scene view draw mode (wasn't working at all).
613614

614615
### Changed
615616
- Improve MIP selection for decals on Transparents

com.unity.render-pipelines.high-definition/Runtime/Debug/DebugLightVolumes.compute

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@
77
// Tile size of this compute
88
#define DEBUG_LIGHT_VOLUME_TILE_SIZE 8
99

10-
// The pixel radius to switch on the edge color
11-
#define RADIUS_PIXEL_BORDER 1
12-
1310
// Input Runtime textures
1411
TEXTURE2D_X_FLOAT(_DebugLightCountBuffer);
1512
TEXTURE2D_X(_DebugColorAccumulationBuffer);
1613

1714
// Data used for the computation
1815
Texture2D<float4> _ColorGradientTexture;
1916
int _MaxDebugLightCount;
17+
// The pixel radius to switch on the edge color
18+
float _BorderRadius;
2019

2120
// output texture
2221
RW_TEXTURE2D_X(float4, _DebugLightVolumesTexture);
@@ -58,9 +57,9 @@ void LightVolumeColors(uint3 dispatchThreadId : SV_DispatchThreadID, uint2 group
5857
// Look around this pixel to check if this should be displayed as a border
5958
float maxLightCount = lightCount;
6059
bool isBorder = false;
61-
for (int radiusX = -RADIUS_PIXEL_BORDER; radiusX <= RADIUS_PIXEL_BORDER; ++radiusX)
60+
for (float radiusX = -_BorderRadius; radiusX <= _BorderRadius; ++radiusX)
6261
{
63-
for (int radiusY = -RADIUS_PIXEL_BORDER; radiusY <= RADIUS_PIXEL_BORDER; ++radiusY)
62+
for (float radiusY = -_BorderRadius; radiusY <= _BorderRadius; ++radiusY)
6463
{
6564
// Compute the target pixel
6665
int2 targetpixel = int2((uint)currentPixelCoordinate.x + radiusX, (uint)currentPixelCoordinate.y + radiusY);

0 commit comments

Comments
 (0)