Skip to content

Commit ec1d314

Browse files
alelievrsebastienlagarde
authored andcommitted
Fix Light overlap #444
1 parent 187be6d commit ec1d314

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
@@ -1106,6 +1106,32 @@ public static bool IsSceneLightingDisabled(Camera camera)
11061106
return disabled;
11071107
}
11081108

1109+
/// <summary>
1110+
/// Returns true if the "Light Overlap" scene view draw mode is enabled.
1111+
/// </summary>
1112+
/// <param name="camera">Input camera.</param>
1113+
/// <returns>True if "Light Overlap" is enabled in the scene view associated with the input camera.</returns>
1114+
public static bool IsLightOverlapDebugEnabled(Camera camera)
1115+
{
1116+
bool enabled = false;
1117+
#if UNITY_EDITOR
1118+
if (camera.cameraType == CameraType.SceneView)
1119+
{
1120+
// Determine whether the "LightOverlap" mode is enabled for the current view.
1121+
for (int i = 0; i < UnityEditor.SceneView.sceneViews.Count; i++)
1122+
{
1123+
var sv = UnityEditor.SceneView.sceneViews[i] as UnityEditor.SceneView;
1124+
if (sv.camera == camera && sv.cameraMode.drawMode == UnityEditor.DrawCameraMode.LightOverlap)
1125+
{
1126+
enabled = true;
1127+
break;
1128+
}
1129+
}
1130+
}
1131+
#endif
1132+
return enabled;
1133+
}
1134+
11091135
#if UNITY_EDITOR
11101136
static Func<List<UnityEditor.MaterialEditor>> materialEditors;
11111137

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
124124
- Fix spelling and grammatical errors in material samples
125125
- Fixed issue with sceneview camera settings not being saved after Editor restart.
126126
- Fixed issue that caused not all baked reflection to be deleted upon clicking "Clear Baked Data" in the lighting menu (case 1136080)
127+
- Fixed the light overlap scene view draw mode (wasn't working at all).
127128

128129
### Changed
129130
- Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history.

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)