浏览代码

Merge pull request #1515 from Unity-Technologies/FixColorPickerPrecisionLimit

Increased debug color picker lux limit
/main
GitHub 6 年前
当前提交
1e1467c4
共有 6 个文件被更改,包括 39 次插入17 次删除
  1. 1
      com.unity.render-pipelines.high-definition/CHANGELOG.md
  2. 40
      com.unity.render-pipelines.high-definition/HDRP/Debug/DebugColorPicker.shader
  3. 5
      com.unity.render-pipelines.high-definition/HDRP/Debug/DebugDisplay.cs
  4. 3
      com.unity.render-pipelines.high-definition/HDRP/Debug/DebugDisplay.hlsl
  5. 5
      com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.hlsl
  6. 2
      com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs

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


- Add color swatch to decal material
### Improvements
- Increased debug color picker limit up to 260k lux
### Changed, Removals and deprecations
- Change Render -> Planar Reflection creation to 3D Object -> Mirror

40
com.unity.render-pipelines.high-definition/HDRP/Debug/DebugColorPicker.shader


SAMPLER(sampler_DebugColorPickerTexture);
float4 _ColorPickerParam; // 4 increasing threshold
int _ColorPickerMode;
float3 _ColorPickerFontColor;
float _ApplyLinearToSRGB;
float _RequireToFlipInputTexture;

float4 result = SAMPLE_TEXTURE2D(_DebugColorPickerTexture, sampler_DebugColorPickerTexture, input.texcoord);
float4 mousePixelCoord = _MousePixelCoord;
if (_RequireToFlipInputTexture > 0.0)
{
mousePixelCoord.y = _ScreenSize.y - mousePixelCoord.y;
// Note: We must not flip the mousePixelCoord.w coordinate
}
float4 mouseResult = SAMPLE_TEXTURE2D(_DebugColorPickerTexture, sampler_DebugColorPickerTexture, mousePixelCoord.zw);
// Reverse debug exposure in order to display the real values.
// _DebugExposure will be set to zero if the debug view does not need it so we don't need to make a special case here. It's handled in only one place in C#
mouseResult = mouseResult / exp2(_DebugExposure);
//Decompress value if luxMeter is active
if (_DebugLightingMode == DEBUGLIGHTINGMODE_LUX_METER && _ColorPickerMode != COLORPICKERDEBUGMODE_NONE)
result.rgb = result.rgb * LUXMETER_COMPRESSION_RATIO;
float4 finalResult = result;
finalResult = DisplayPixelInformationAtMousePosition(input, result, mouseResult, mousePixelCoord);
{
float4 mousePixelCoord = _MousePixelCoord;
if (_RequireToFlipInputTexture > 0.0)
{
mousePixelCoord.y = _ScreenSize.y - mousePixelCoord.y;
// Note: We must not flip the mousePixelCoord.w coordinate
}
float4 mouseResult = SAMPLE_TEXTURE2D(_DebugColorPickerTexture, sampler_DebugColorPickerTexture, mousePixelCoord.zw);
//Decompress value if luxMeter is active
if (_DebugLightingMode == DEBUGLIGHTINGMODE_LUX_METER)
mouseResult = mouseResult * LUXMETER_COMPRESSION_RATIO;
// Reverse debug exposure in order to display the real values.
// _DebugExposure will be set to zero if the debug view does not need it so we don't need to make a special case here. It's handled in only one place in C#
mouseResult = mouseResult / exp2(_DebugExposure);
result = DisplayPixelInformationAtMousePosition(input, result, mouseResult, mousePixelCoord);
}
return finalResult;
return result;
}
ENDHLSL

5
com.unity.render-pipelines.high-definition/HDRP/Debug/DebugDisplay.cs


return mipMapDebugSettings.debugMipMapMode;
}
public ColorPickerDebugMode GetDebugColorPickerMode()
{
return colorPickerDebugSettings.colorPickerMode;
}
public bool IsDebugDisplayEnabled()
{
return materialDebugSettings.IsDebugDisplayEnabled() || lightingDebugSettings.IsDebugDisplayEnabled() || mipMapDebugSettings.IsDebugDisplayEnabled() || IsDebugFullScreenEnabled();

3
com.unity.render-pipelines.high-definition/HDRP/Debug/DebugDisplay.hlsl


int _DebugLightingSubMode;
int _DebugViewMaterial; // Contain the id (define in various materialXXX.cs.hlsl) of the property to display
int _DebugMipMapMode; // Match enum DebugMipMapMode
int _ColorPickerMode; // Match enum ColorPickerDebugMode
int _DebugStep;
float4 _DebugLightingAlbedo; // x == bool override, yzw = albedo for diffuse
float4 _DebugLightingSmoothness; // x == bool override, y == override value

float4 _MouseClickPixelCoord; // xy unorm, zw norm
float _DebugExposure;
CBUFFER_END
#define LUXMETER_COMPRESSION_RATIO 4
TEXTURE2D(_DebugFont); // Debug font to write string in shader
RWStructuredBuffer<ScreenSpaceTracingDebug> _DebugScreenSpaceTracingData : register(u7); // TODO: Change the register number for PS4

5
com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.hlsl


{
case DEBUGLIGHTINGMODE_LUX_METER:
diffuseLighting = lighting.direct.diffuse + bakeLightingData.bakeDiffuseLighting;
//Compress lighting values for color picker if enabled
if (_ColorPickerMode != COLORPICKERDEBUGMODE_NONE)
diffuseLighting = diffuseLighting / LUXMETER_COMPRESSION_RATIO;
specularLighting = float3(0.0, 0.0, 0.0); // Disable specular lighting
break;

2
com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs


cmd.SetGlobalInt(HDShaderIDs._DebugLightingMode, (int)m_CurrentDebugDisplaySettings.GetDebugLightingMode());
cmd.SetGlobalInt(HDShaderIDs._DebugLightingSubMode, (int)m_CurrentDebugDisplaySettings.GetDebugLightingSubMode());
cmd.SetGlobalInt(HDShaderIDs._DebugMipMapMode, (int)m_CurrentDebugDisplaySettings.GetDebugMipMapMode());
cmd.SetGlobalInt(HDShaderIDs._ColorPickerMode, (int)m_CurrentDebugDisplaySettings.GetDebugColorPickerMode());
cmd.SetGlobalVector(HDShaderIDs._DebugLightingAlbedo, debugAlbedo);
cmd.SetGlobalVector(HDShaderIDs._DebugLightingSmoothness, debugSmoothness);

cmd.SetGlobalTexture(HDShaderIDs._DebugColorPickerTexture, m_DebugColorPickerBuffer); // No SetTexture with RenderTarget identifier... so use SetGlobalTexture
// TODO: Replace with command buffer call when available
m_DebugColorPicker.SetColor(HDShaderIDs._ColorPickerFontColor, colorPickerDebugSettings.fontColor);
m_DebugColorPicker.SetInt(HDShaderIDs._ColorPickerMode, (int)colorPickerDebugSettings.colorPickerMode);
m_DebugColorPicker.SetInt(HDShaderIDs._FalseColorEnabled, falseColorDebugSettings.falseColor ? 1 : 0);
m_DebugColorPicker.SetVector(HDShaderIDs._FalseColorThresholds, falseColorThresholds);
// The material display debug perform sRGBToLinear conversion as the final blit currently hardcode a linearToSrgb conversion. As when we read with color picker this is not done,

正在加载...
取消
保存