浏览代码

Tidied up mip map debugging in shaders based on PR feedback

/feature-ReflectionProbeFit
lyndon homewood 7 年前
当前提交
9b9d85af
共有 5 个文件被更改,包括 22 次插入21 次删除
  1. 10
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Debug.hlsl
  2. 8
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/LayeredLit/LayeredLitData.hlsl
  3. 22
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/LitData.hlsl
  4. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Unlit/UnlitData.hlsl
  5. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderPass/FragInputs.hlsl

10
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Debug.hlsl


return mipCount==0 ? float4(1.0, 0.0, 1.0, 1.0) : (mipCount > 12 ? float4(1.0, 1.0, 1.0, 0.0) : color );
}
float4 GetMipLevelColor(float2 iUV, float4 texelSize)
float4 GetMipLevelColor(float2 uv, float4 texelSize)
float mipLevel = ComputeTextureLOD(iUV, texelSize);
float mipLevel = ComputeTextureLOD(uv, texelSize);
mipLevel = clamp(mipLevel, 0.0, 5.0 - 0.0001);
float4 colors[6] = {

}
#ifdef DEBUG_DISPLAY
#ifdef FRAG_INPUTS_DEFINED
float3 GetTextureDataDebug(uint paramId, FragInputs input, Texture2D tex, float4 texelSize, float4 mipInfo, float3 originalColor)
float3 GetTextureDataDebug(uint paramId, float2 uv, Texture2D tex, float4 texelSize, float4 mipInfo, float3 originalColor)
return GetDebugMipColorIncludingMipReduction(originalColor, tex, texelSize, input.texCoord0.xy, mipInfo);
return GetDebugMipColorIncludingMipReduction(originalColor, tex, texelSize, uv, mipInfo);
case DEBUGMIPMAPMODE_MIP_COUNT:
return GetDebugMipCountColor(originalColor, tex);
case DEBUGMIPMAPMODE_MIP_COUNT_REDUCTION:

return originalColor;
}
#endif // FRAG_INPUTS_DEFINED
#endif // DEBUG_DISPLAY
#endif // UNITY_DEBUG_INCLUDED

8
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/LayeredLit/LayeredLitData.hlsl


AddDecalContribution(posInput.positionSS, surfaceData);
#if defined(DEBUG_DISPLAY)
if (_DebugMipMapMode != DEBUGMIPMAPMODE_NONE)
{
surfaceData.baseColor = GetTextureDataDebug(_DebugMipMapMode, layerTexCoord.base0.uv, _BaseColorMap0, _BaseColorMap0_TexelSize, _BaseColorMap0_MipInfo, surfaceData.baseColor);
surfaceData.metallic = 0;
}
#endif
GetBuiltinData(input, surfaceData, alpha, bentNormalWS, depthOffset, builtinData);
}

22
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/LitData.hlsl


return SphericalCapIntersectionSolidArea(cosAv, cosAs, cosB) / (TWO_PI * (1.0 - cosAs));
}
void GetBuiltinData(FragInputs input, inout SurfaceData surfaceData, float alpha, float3 bentNormalWS, float depthOffset, out BuiltinData builtinData)
void GetBuiltinData(FragInputs input, in SurfaceData surfaceData, float alpha, float3 bentNormalWS, float depthOffset, out BuiltinData builtinData)
{
// Builtin Data
builtinData.opacity = alpha;

#endif
builtinData.depthOffset = depthOffset;
#if defined(DEBUG_DISPLAY)
if (_DebugMipMapMode != DEBUGMIPMAPMODE_NONE)
{
#ifdef LAYERED_LIT_SHADER
surfaceData.baseColor = GetTextureDataDebug(_DebugMipMapMode, input, _BaseColorMap0, _BaseColorMap0_TexelSize, _BaseColorMap0_MipInfo, surfaceData.baseColor);
#else
surfaceData.baseColor = GetTextureDataDebug(_DebugMipMapMode, input, _BaseColorMap, _BaseColorMap_TexelSize, _BaseColorMap_MipInfo, surfaceData.baseColor);
#endif
surfaceData.metallic = 0;
}
#endif
}
// Struct that gather UVMapping info of all layers + common calculation

surfaceData.tangentWS = Orthonormalize(surfaceData.tangentWS, surfaceData.normalWS);
AddDecalContribution(posInput.positionSS, surfaceData);
#if defined(DEBUG_DISPLAY)
if (_DebugMipMapMode != DEBUGMIPMAPMODE_NONE)
{
surfaceData.baseColor = GetTextureDataDebug(_DebugMipMapMode, layerTexCoord.base.uv, _BaseColorMap, _BaseColorMap_TexelSize, _BaseColorMap_MipInfo, surfaceData.baseColor);
surfaceData.metallic = 0;
}
#endif
// Caution: surfaceData must be fully initialize before calling GetBuiltinData
GetBuiltinData(input, surfaceData, alpha, bentNormalWS, depthOffset, builtinData);

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Unlit/UnlitData.hlsl


#if defined(DEBUG_DISPLAY)
if (_DebugMipMapMode != DEBUGMIPMAPMODE_NONE)
{
surfaceData.color = GetTextureDataDebug(_DebugMipMapMode, input, _UnlitColorMap, _UnlitColorMap_TexelSize, _UnlitColorMap_MipInfo, surfaceData.color);
surfaceData.color = GetTextureDataDebug(_DebugMipMapMode, unlitColorMapUv, _UnlitColorMap, _UnlitColorMap_TexelSize, _UnlitColorMap_MipInfo, surfaceData.color);
}
#endif
}

1
ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderPass/FragInputs.hlsl


#include "../Debug/MaterialDebug.cs.hlsl"
#define FRAG_INPUTS_DEFINED
struct FragInputs
{
// Contain value return by SV_POSITION (That is name positionCS in PackedVarying).

正在加载...
取消
保存