From 1e5338d4c653e925da83455043bef861d7550204 Mon Sep 17 00:00:00 2001 From: Arttu Peltonen Date: Fri, 15 Oct 2021 11:18:18 +0300 Subject: [PATCH 1/2] Remove ifdef that disabled debug shader functionality due to HLSLcc bug. - This was fixed in https://ono.unity3d.com/unity/unity/pull-request/132203/_/graphics/shadersystem/minor_fixes_0003 --- .../ShaderLibrary/Debug/Debugging3D.hlsl | 88 +++++++++---------- 1 file changed, 41 insertions(+), 47 deletions(-) diff --git a/com.unity.render-pipelines.universal/ShaderLibrary/Debug/Debugging3D.hlsl b/com.unity.render-pipelines.universal/ShaderLibrary/Debug/Debugging3D.hlsl index a9df611b011..51da566f018 100644 --- a/com.unity.render-pipelines.universal/ShaderLibrary/Debug/Debugging3D.hlsl +++ b/com.unity.render-pipelines.universal/ShaderLibrary/Debug/Debugging3D.hlsl @@ -31,61 +31,55 @@ void SetupDebugDataBrdf(inout InputData inputData, half3 brdfDiffuse, half3 brdf bool UpdateSurfaceAndInputDataForDebug(inout SurfaceData surfaceData, inout InputData inputData) { - #if SHADER_API_VULKAN || SHADER_API_GLES || SHADER_API_GLES3 || SHADER_API_GLCORE - // Something about this function is problematic for HLSLcc (generates forbidden 'uintBitsToFloat' intrinsics). - // Re-enable when this is fixed. - return false; - #else - bool changed = false; + bool changed = false; - if (_DebugLightingMode == DEBUGLIGHTINGMODE_LIGHTING_WITHOUT_NORMAL_MAPS || _DebugLightingMode == DEBUGLIGHTINGMODE_LIGHTING_WITH_NORMAL_MAPS) + if (_DebugLightingMode == DEBUGLIGHTINGMODE_LIGHTING_WITHOUT_NORMAL_MAPS || _DebugLightingMode == DEBUGLIGHTINGMODE_LIGHTING_WITH_NORMAL_MAPS) + { + surfaceData.albedo = 1; + surfaceData.emission = 0; + surfaceData.specular = 0; + surfaceData.occlusion = 1; + surfaceData.clearCoatMask = 0; + surfaceData.clearCoatSmoothness = 1; + surfaceData.metallic = 0; + surfaceData.smoothness = 0; + changed = true; + } + else if (_DebugLightingMode == DEBUGLIGHTINGMODE_REFLECTIONS || _DebugLightingMode == DEBUGLIGHTINGMODE_REFLECTIONS_WITH_SMOOTHNESS) + { + surfaceData.albedo = 0; + surfaceData.emission = 0; + surfaceData.occlusion = 1; + surfaceData.clearCoatMask = 0; + surfaceData.clearCoatSmoothness = 1; + if (_DebugLightingMode == DEBUGLIGHTINGMODE_REFLECTIONS) { - surfaceData.albedo = 1; - surfaceData.emission = 0; - surfaceData.specular = 0; - surfaceData.occlusion = 1; - surfaceData.clearCoatMask = 0; - surfaceData.clearCoatSmoothness = 1; + surfaceData.specular = 1; surfaceData.metallic = 0; - surfaceData.smoothness = 0; - changed = true; + surfaceData.smoothness = 1; } - else if (_DebugLightingMode == DEBUGLIGHTINGMODE_REFLECTIONS || _DebugLightingMode == DEBUGLIGHTINGMODE_REFLECTIONS_WITH_SMOOTHNESS) + else if (_DebugLightingMode == DEBUGLIGHTINGMODE_REFLECTIONS_WITH_SMOOTHNESS) { - surfaceData.albedo = 0; - surfaceData.emission = 0; - surfaceData.occlusion = 1; - surfaceData.clearCoatMask = 0; - surfaceData.clearCoatSmoothness = 1; - if (_DebugLightingMode == DEBUGLIGHTINGMODE_REFLECTIONS) - { - surfaceData.specular = 1; - surfaceData.metallic = 0; - surfaceData.smoothness = 1; - } - else if (_DebugLightingMode == DEBUGLIGHTINGMODE_REFLECTIONS_WITH_SMOOTHNESS) - { - surfaceData.specular = 0; - surfaceData.metallic = 1; - surfaceData.smoothness = 0; - } - changed = true; + surfaceData.specular = 0; + surfaceData.metallic = 1; + surfaceData.smoothness = 0; } + changed = true; + } - if (_DebugLightingMode == DEBUGLIGHTINGMODE_LIGHTING_WITHOUT_NORMAL_MAPS || _DebugLightingMode == DEBUGLIGHTINGMODE_REFLECTIONS) - { - const half3 normalTS = half3(0, 0, 1); - #if defined(_NORMALMAP) - inputData.normalWS = TransformTangentToWorld(normalTS, inputData.tangentToWorld); - #else - inputData.normalWS = inputData.normalWS; - #endif - surfaceData.normalTS = normalTS; - changed = true; - } + if (_DebugLightingMode == DEBUGLIGHTINGMODE_LIGHTING_WITHOUT_NORMAL_MAPS || _DebugLightingMode == DEBUGLIGHTINGMODE_REFLECTIONS) + { + const half3 normalTS = half3(0, 0, 1); + #if defined(_NORMALMAP) + inputData.normalWS = TransformTangentToWorld(normalTS, inputData.tangentToWorld); + #else + inputData.normalWS = inputData.normalWS; + #endif + surfaceData.normalTS = normalTS; + changed = true; + } - return changed; - #endif + return changed; } bool CalculateValidationMetallic(half3 albedo, half metallic, inout half4 debugColor) From caf9d3efcf363cc828894a21c30d5cae44cae47b Mon Sep 17 00:00:00 2001 From: Arttu Peltonen Date: Mon, 25 Oct 2021 10:44:04 +0300 Subject: [PATCH 2/2] Changelog --- com.unity.render-pipelines.universal/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/com.unity.render-pipelines.universal/CHANGELOG.md b/com.unity.render-pipelines.universal/CHANGELOG.md index 70b7aaf8fe3..10b3014e30c 100644 --- a/com.unity.render-pipelines.universal/CHANGELOG.md +++ b/com.unity.render-pipelines.universal/CHANGELOG.md @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fix for rendering thumbnails. [case 1348209](https://issuetracker.unity3d.com/issues/preview-of-assets-do-not-show-in-the-project-window) - Fixed a regression bug where XR camera postion can not be modified in beginCameraRendering [case 1365000] - Fixed an issue in where installing the Adaptive Performance package caused errors to the inspector UI [1368161](https://issuetracker.unity3d.com/issues/urp-package-throws-compilation-error-cs1525-when-imported-together-with-adaptive-performance-package) +- Fixed disabled debug lighting modes on Vulkan and OpenGL following a shader compiler fix. [case 1334240] ## [13.1.0] - 2021-09-24 ### Added