GitHub
7 年前
当前提交
9d3b9c14
共有 45 个文件被更改,包括 1822 次插入 和 2635 次删除
-
1001ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Common.hlsl
-
80ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/CommonLighting.hlsl
-
498ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Debug.hlsl
-
14ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Shadow/Shadow.hlsl
-
44ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Shadow/ShadowAlgorithms.hlsl
-
4ScriptableRenderPipeline/HDRenderPipeline/HDRP/Camera/HDCamera.cs
-
618ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/MaterialDebug.cs
-
3ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs
-
7ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Deferred.shader
-
76ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightEvaluation.hlsl
-
25ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/Deferred.compute
-
4ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.cs
-
4ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoopDef.hlsl
-
12ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/Shadow.hlsl
-
20ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/Resources/VolumetricLighting.compute
-
1001ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/LayeredLit/LayeredLitData.hlsl
-
290ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/LitBuiltinData.hlsl
-
528ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/LitProperties.hlsl
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/LitReference.hlsl
-
19ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/SubsurfaceScattering/SubsurfaceScattering.compute
-
72ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Unlit/UnlitProperties.hlsl
-
1ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderPass/ShaderPass.cs
-
17ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderPass/ShaderPass.cs.hlsl
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderPass/ShaderPassForward.hlsl
-
6ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderVariables.hlsl
-
1Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/CornelBox/Cornell Box.fbx.meta
-
1Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/3DObjects/Sphere/Sphere.fbx.meta
-
1Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Assets/CommonAssets/Cornell Box.fbx.meta
-
1Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/040_UpgradeScene/Models/Environment/Floor.fbx.meta
-
11Tests/Scripts/Editor.meta
-
8Tests/Editor.meta
-
8Tests/GraphicsTests/Framework.meta
-
8Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/Scripts.meta
-
8Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/040_UpgradeScene/Scripts.meta
-
11Tests/Scripts/Editor/GraphicTests/HDRenderPipeline/DebugViewController_Editor.cs.meta
-
8Tests/ShaderGeneratorTests.meta
-
8Tests/GraphicsTests/Framework/Editor.meta
-
8Tests/GraphicsTests/RenderPipeline/HDRenderPipeline/CommonAssets/Scripts/Editor.meta
-
8Tests/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/040_UpgradeScene/Scripts/Editor.meta
-
8Tests/ShaderGeneratorTests/Editor.meta
1001
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Common.hlsl
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
#ifndef UNITY_DEBUG_INCLUDED |
|||
#define UNITY_DEBUG_INCLUDED |
|||
|
|||
// Given an enum (represented by an int here), return a color. |
|||
// Use for DebugView of enum |
|||
real3 GetIndexColor(int index) |
|||
{ |
|||
real3 outColor = real3(1.0, 0.0, 0.0); |
|||
|
|||
if (index == 0) |
|||
outColor = real3(1.0, 0.5, 0.5); |
|||
else if (index == 1) |
|||
outColor = real3(0.5, 1.0, 0.5); |
|||
else if (index == 2) |
|||
outColor = real3(0.5, 0.5, 1.0); |
|||
else if (index == 3) |
|||
outColor = real3(1.0, 1.0, 0.5); |
|||
else if (index == 4) |
|||
outColor = real3(1.0, 0.5, 1.0); |
|||
else if (index == 5) |
|||
outColor = real3(0.5, 1.0, 1.0); |
|||
else if (index == 6) |
|||
outColor = real3(0.25, 0.75, 1.0); |
|||
else if (index == 7) |
|||
outColor = real3(1.0, 0.75, 0.25); |
|||
else if (index == 8) |
|||
outColor = real3(0.75, 1.0, 0.25); |
|||
else if (index == 9) |
|||
outColor = real3(0.75, 0.25, 1.0); |
|||
|
|||
return outColor; |
|||
} |
|||
|
|||
bool SampleDebugFont(int2 pixCoord, uint digit) |
|||
{ |
|||
if (pixCoord.x < 0 || pixCoord.y < 0 || pixCoord.x >= 5 || pixCoord.y >= 9 || digit > 9) |
|||
return false; |
|||
|
|||
#define PACK_BITS25(_x0,_x1,_x2,_x3,_x4,_x5,_x6,_x7,_x8,_x9,_x10,_x11,_x12,_x13,_x14,_x15,_x16,_x17,_x18,_x19,_x20,_x21,_x22,_x23,_x24) (_x0|(_x1<<1)|(_x2<<2)|(_x3<<3)|(_x4<<4)|(_x5<<5)|(_x6<<6)|(_x7<<7)|(_x8<<8)|(_x9<<9)|(_x10<<10)|(_x11<<11)|(_x12<<12)|(_x13<<13)|(_x14<<14)|(_x15<<15)|(_x16<<16)|(_x17<<17)|(_x18<<18)|(_x19<<19)|(_x20<<20)|(_x21<<21)|(_x22<<22)|(_x23<<23)|(_x24<<24)) |
|||
#define _ 0 |
|||
#define x 1 |
|||
uint fontData[9][2] = { |
|||
{ PACK_BITS25(_,_,x,_,_, _,_,x,_,_, _,x,x,x,_, x,x,x,x,x, _,_,_,x,_), PACK_BITS25(x,x,x,x,x, _,x,x,x,_, x,x,x,x,x, _,x,x,x,_, _,x,x,x,_) }, |
|||
{ PACK_BITS25(_,x,_,x,_, _,x,x,_,_, x,_,_,_,x, _,_,_,_,x, _,_,_,x,_), PACK_BITS25(x,_,_,_,_, x,_,_,_,x, _,_,_,_,x, x,_,_,_,x, x,_,_,_,x) }, |
|||
{ PACK_BITS25(x,_,_,_,x, x,_,x,_,_, x,_,_,_,x, _,_,_,x,_, _,_,x,x,_), PACK_BITS25(x,_,_,_,_, x,_,_,_,_, _,_,_,x,_, x,_,_,_,x, x,_,_,_,x) }, |
|||
{ PACK_BITS25(x,_,_,_,x, _,_,x,_,_, _,_,_,_,x, _,_,x,_,_, _,x,_,x,_), PACK_BITS25(x,_,x,x,_, x,_,_,_,_, _,_,_,x,_, x,_,_,_,x, x,_,_,_,x) }, |
|||
{ PACK_BITS25(x,_,_,_,x, _,_,x,_,_, _,_,_,x,_, _,x,x,x,_, _,x,_,x,_), PACK_BITS25(x,x,_,_,x, x,x,x,x,_, _,_,x,_,_, _,x,x,x,_, _,x,x,x,x) }, |
|||
{ PACK_BITS25(x,_,_,_,x, _,_,x,_,_, _,_,x,_,_, _,_,_,_,x, x,_,_,x,_), PACK_BITS25(_,_,_,_,x, x,_,_,_,x, _,_,x,_,_, x,_,_,_,x, _,_,_,_,x) }, |
|||
{ PACK_BITS25(x,_,_,_,x, _,_,x,_,_, _,x,_,_,_, _,_,_,_,x, x,x,x,x,x), PACK_BITS25(_,_,_,_,x, x,_,_,_,x, _,x,_,_,_, x,_,_,_,x, _,_,_,_,x) }, |
|||
{ PACK_BITS25(_,x,_,x,_, _,_,x,_,_, x,_,_,_,_, x,_,_,_,x, _,_,_,x,_), PACK_BITS25(x,_,_,_,x, x,_,_,_,x, _,x,_,_,_, x,_,_,_,x, x,_,_,_,x) }, |
|||
{ PACK_BITS25(_,_,x,_,_, x,x,x,x,x, x,x,x,x,x, _,x,x,x,_, _,_,_,x,_), PACK_BITS25(_,x,x,x,_, _,x,x,x,_, _,x,_,_,_, _,x,x,x,_, _,x,x,x,_) } |
|||
}; |
|||
#undef _ |
|||
#undef x |
|||
#undef PACK_BITS25 |
|||
return (fontData[8 - pixCoord.y][digit >= 5] >> ((digit % 5) * 5 + pixCoord.x)) & 1; |
|||
} |
|||
|
|||
bool SampleDebugFontNumber(int2 pixCoord, uint number) |
|||
{ |
|||
pixCoord.y -= 4; |
|||
if (number <= 9) |
|||
{ |
|||
return SampleDebugFont(pixCoord - int2(6, 0), number); |
|||
} |
|||
else |
|||
{ |
|||
return (SampleDebugFont(pixCoord, number / 10) | SampleDebugFont(pixCoord - int2(6, 0), number % 10)); |
|||
} |
|||
} |
|||
|
|||
float4 GetStreamingMipColor(uint mipCount, float4 mipInfo) |
|||
{ |
|||
// alpha is amount to blend with source color (0.0 = use original, 1.0 = use new color) |
|||
|
|||
// mipInfo : |
|||
// x = quality setings minStreamingMipLevel |
|||
// y = original mip count for texture |
|||
// z = desired on screen mip level |
|||
// w = 0 |
|||
uint originalTextureMipCount = uint(mipInfo.y); |
|||
|
|||
// If material/shader mip info (original mip level) has not been set its not a streamed texture |
|||
if (originalTextureMipCount == 0) |
|||
return float4(1.0, 1.0, 1.0, 0.0); |
|||
|
|||
uint desiredMipLevel = uint(mipInfo.z); |
|||
uint mipCountDesired = uint(originalTextureMipCount)-uint(desiredMipLevel); |
|||
if (mipCount == 0) |
|||
{ |
|||
// Magenta if mip count invalid |
|||
return float4(1.0, 0.0, 1.0, 1.0); |
|||
} |
|||
else if (mipCount < mipCountDesired) |
|||
{ |
|||
// red tones when not at the desired mip level (reduction due to budget). Brighter is further from original, alpha 0 when at desired |
|||
float ratioToDesired = float(mipCount) / float(mipCountDesired); |
|||
return float4(1.0, 0.0, 0.0, 1.0 - ratioToDesired); |
|||
} |
|||
else if (mipCount >= originalTextureMipCount) |
|||
{ |
|||
// original color when at (or beyond) original mip count |
|||
return float4(1.0, 1.0, 1.0, 0.0); |
|||
} |
|||
else |
|||
{ |
|||
// green tones when not at the original mip level. Brighter is closer to original, alpha 0 when at original |
|||
float ratioToOriginal = float(mipCount) / float(originalTextureMipCount); |
|||
return float4(0.0, 1.0, 0.0, 1.0 - ratioToOriginal); |
|||
} |
|||
} |
|||
|
|||
float4 GetSimpleMipCountColor(uint mipCount) |
|||
{ |
|||
// Grey scale for mip counts where mip count of 12 = white |
|||
float mipCountColor = float(mipCount) / 12.0; |
|||
float4 color = float4(mipCountColor, mipCountColor, mipCountColor, 1.0f); |
|||
|
|||
// alpha is amount to blend with source color (0.0 = use original, 1.0 = use new color) |
|||
// Magenta is no valid mip count |
|||
// Original colour if greater than 12 |
|||
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 uv, float4 texelSize) |
|||
{ |
|||
// Push down into colors list to "optimal level" in following table. |
|||
// .zw is texture width,height so *2 is down one mip, *4 is down two mips |
|||
texelSize.zw *= 4.0; |
|||
|
|||
float mipLevel = ComputeTextureLOD(uv, texelSize.wz); |
|||
mipLevel = clamp(mipLevel, 0.0, 5.0 - 0.0001); |
|||
|
|||
float4 colors[6] = { |
|||
float4(0.0, 0.0, 1.0, 0.8), // 0 BLUE = too little texture detail |
|||
float4(0.0, 0.5, 1.0, 0.4), // 1 |
|||
float4(1.0, 1.0, 1.0, 0.0), // 2 = optimal level |
|||
float4(1.0, 0.7, 0.0, 0.2), // 3 (YELLOW tint) |
|||
float4(1.0, 0.3, 0.0, 0.6), // 4 (clamped mipLevel 4.9999) |
|||
float4(1.0, 0.0, 0.0, 0.8) // 5 RED = too much texture detail (max blended value) |
|||
}; |
|||
|
|||
int mipLevelInt = floor(mipLevel); |
|||
float t = frac(mipLevel); |
|||
float4 a = colors[mipLevelInt]; |
|||
float4 b = colors[mipLevelInt + 1]; |
|||
float4 color = lerp(a, b, t); |
|||
|
|||
return color; |
|||
} |
|||
|
|||
float3 GetDebugMipColor(float3 originalColor, Texture2D tex, float4 texelSize, float2 uv) |
|||
{ |
|||
// https://aras-p.info/blog/2011/05/03/a-way-to-visualize-mip-levels/ |
|||
float4 mipColor= GetMipLevelColor(uv, texelSize); |
|||
return lerp(originalColor, mipColor.rgb, mipColor.a); |
|||
} |
|||
|
|||
float3 GetDebugMipCountColor(float3 originalColor, Texture2D tex) |
|||
{ |
|||
uint mipCount = GetMipCount(tex); |
|||
|
|||
float4 mipColor = GetSimpleMipCountColor(mipCount); |
|||
return lerp(originalColor, mipColor.rgb, mipColor.a); |
|||
} |
|||
|
|||
float3 GetDebugStreamingMipColor(Texture2D tex, float4 mipInfo) |
|||
{ |
|||
uint mipCount = GetMipCount(tex); |
|||
return GetStreamingMipColor(mipCount, mipInfo).xyz; |
|||
} |
|||
|
|||
float3 GetDebugStreamingMipColorBlended(float3 originalColor, Texture2D tex, float4 mipInfo) |
|||
{ |
|||
uint mipCount = GetMipCount(tex); |
|||
float4 mipColor = GetStreamingMipColor(mipCount, mipInfo); |
|||
return lerp(originalColor, mipColor.rgb, mipColor.a); |
|||
} |
|||
|
|||
float3 GetDebugMipColorIncludingMipReduction(float3 originalColor, Texture2D tex, float4 texelSize, float2 uv, float4 mipInfo) |
|||
{ |
|||
uint originalTextureMipCount = uint(mipInfo.y); |
|||
if (originalTextureMipCount != 0) |
|||
{ |
|||
// mipInfo : |
|||
// x = quality setings minStreamingMipLevel |
|||
// y = original mip count for texture |
|||
// z = desired on screen mip level |
|||
// w = 0 |
|||
|
|||
// Mip count has been reduced but the texelSize was not updated to take that into account |
|||
uint mipCount = GetMipCount(tex); |
|||
uint mipReductionLevel = originalTextureMipCount - mipCount; |
|||
uint mipReductionFactor = 1 << mipReductionLevel; |
|||
if (mipReductionFactor) |
|||
{ |
|||
float oneOverMipReductionFactor = 1.0 / mipReductionFactor; |
|||
// texelSize.xy *= mipReductionRatio; // Unused in GetDebugMipColor so lets not re-calculate it |
|||
texelSize.zw *= oneOverMipReductionFactor; |
|||
} |
|||
} |
|||
return GetDebugMipColor(originalColor, tex, texelSize, uv); |
|||
} |
|||
|
|||
float3 GetDebugMipReductionColor(Texture2D tex, float4 mipInfo) |
|||
{ |
|||
uint originalTextureMipCount = uint(mipInfo.y); |
|||
if (originalTextureMipCount != 0) |
|||
{ |
|||
// mipInfo : |
|||
// x = quality setings minStreamingMipLevel |
|||
// y = original mip count for texture |
|||
// z = desired on screen mip level |
|||
// w = 0 |
|||
|
|||
// Mip count has been reduced but the texelSize was not updated to take that into account |
|||
uint mipCount = GetMipCount(tex); |
|||
uint mipReductionLevel = originalTextureMipCount - mipCount; |
|||
|
|||
float mipCol = float(mipReductionLevel) / 12.0; |
|||
return float3(0, mipCol, 0); |
|||
} |
|||
|
|||
// Can't calculate without original mip count - return magenta |
|||
return float3(1.0, 0.0, 1.0); |
|||
} |
|||
|
|||
#ifdef DEBUG_DISPLAY |
|||
float3 GetTextureDataDebug(uint paramId, float2 uv, Texture2D tex, float4 texelSize, float4 mipInfo, float3 originalColor) |
|||
{ |
|||
switch (paramId) |
|||
{ |
|||
case DEBUGMIPMAPMODE_MIP_RATIO: |
|||
return GetDebugMipColorIncludingMipReduction(originalColor, tex, texelSize, uv, mipInfo); |
|||
case DEBUGMIPMAPMODE_MIP_COUNT: |
|||
return GetDebugMipCountColor(originalColor, tex); |
|||
case DEBUGMIPMAPMODE_MIP_COUNT_REDUCTION: |
|||
return GetDebugMipReductionColor(tex, mipInfo); |
|||
case DEBUGMIPMAPMODE_STREAMING_MIP_BUDGET: |
|||
return GetDebugStreamingMipColor(tex, mipInfo); |
|||
case DEBUGMIPMAPMODE_STREAMING_MIP: |
|||
return GetDebugStreamingMipColorBlended(originalColor, tex, mipInfo); |
|||
} |
|||
|
|||
return originalColor; |
|||
} |
|||
#endif // DEBUG_DISPLAY |
|||
|
|||
#endif // UNITY_DEBUG_INCLUDED |
|||
#ifndef UNITY_DEBUG_INCLUDED |
|||
#define UNITY_DEBUG_INCLUDED |
|||
|
|||
// Given an enum (represented by an int here), return a color. |
|||
// Use for DebugView of enum |
|||
real3 GetIndexColor(int index) |
|||
{ |
|||
real3 outColor = real3(1.0, 0.0, 0.0); |
|||
|
|||
if (index == 0) |
|||
outColor = real3(1.0, 0.5, 0.5); |
|||
else if (index == 1) |
|||
outColor = real3(0.5, 1.0, 0.5); |
|||
else if (index == 2) |
|||
outColor = real3(0.5, 0.5, 1.0); |
|||
else if (index == 3) |
|||
outColor = real3(1.0, 1.0, 0.5); |
|||
else if (index == 4) |
|||
outColor = real3(1.0, 0.5, 1.0); |
|||
else if (index == 5) |
|||
outColor = real3(0.5, 1.0, 1.0); |
|||
else if (index == 6) |
|||
outColor = real3(0.25, 0.75, 1.0); |
|||
else if (index == 7) |
|||
outColor = real3(1.0, 0.75, 0.25); |
|||
else if (index == 8) |
|||
outColor = real3(0.75, 1.0, 0.25); |
|||
else if (index == 9) |
|||
outColor = real3(0.75, 0.25, 1.0); |
|||
|
|||
return outColor; |
|||
} |
|||
|
|||
bool SampleDebugFont(int2 pixCoord, uint digit) |
|||
{ |
|||
if (pixCoord.x < 0 || pixCoord.y < 0 || pixCoord.x >= 5 || pixCoord.y >= 9 || digit > 9) |
|||
return false; |
|||
|
|||
#define PACK_BITS25(_x0,_x1,_x2,_x3,_x4,_x5,_x6,_x7,_x8,_x9,_x10,_x11,_x12,_x13,_x14,_x15,_x16,_x17,_x18,_x19,_x20,_x21,_x22,_x23,_x24) (_x0|(_x1<<1)|(_x2<<2)|(_x3<<3)|(_x4<<4)|(_x5<<5)|(_x6<<6)|(_x7<<7)|(_x8<<8)|(_x9<<9)|(_x10<<10)|(_x11<<11)|(_x12<<12)|(_x13<<13)|(_x14<<14)|(_x15<<15)|(_x16<<16)|(_x17<<17)|(_x18<<18)|(_x19<<19)|(_x20<<20)|(_x21<<21)|(_x22<<22)|(_x23<<23)|(_x24<<24)) |
|||
#define _ 0 |
|||
#define x 1 |
|||
uint fontData[9][2] = { |
|||
{ PACK_BITS25(_,_,x,_,_, _,_,x,_,_, _,x,x,x,_, x,x,x,x,x, _,_,_,x,_), PACK_BITS25(x,x,x,x,x, _,x,x,x,_, x,x,x,x,x, _,x,x,x,_, _,x,x,x,_) }, |
|||
{ PACK_BITS25(_,x,_,x,_, _,x,x,_,_, x,_,_,_,x, _,_,_,_,x, _,_,_,x,_), PACK_BITS25(x,_,_,_,_, x,_,_,_,x, _,_,_,_,x, x,_,_,_,x, x,_,_,_,x) }, |
|||
{ PACK_BITS25(x,_,_,_,x, x,_,x,_,_, x,_,_,_,x, _,_,_,x,_, _,_,x,x,_), PACK_BITS25(x,_,_,_,_, x,_,_,_,_, _,_,_,x,_, x,_,_,_,x, x,_,_,_,x) }, |
|||
{ PACK_BITS25(x,_,_,_,x, _,_,x,_,_, _,_,_,_,x, _,_,x,_,_, _,x,_,x,_), PACK_BITS25(x,_,x,x,_, x,_,_,_,_, _,_,_,x,_, x,_,_,_,x, x,_,_,_,x) }, |
|||
{ PACK_BITS25(x,_,_,_,x, _,_,x,_,_, _,_,_,x,_, _,x,x,x,_, _,x,_,x,_), PACK_BITS25(x,x,_,_,x, x,x,x,x,_, _,_,x,_,_, _,x,x,x,_, _,x,x,x,x) }, |
|||
{ PACK_BITS25(x,_,_,_,x, _,_,x,_,_, _,_,x,_,_, _,_,_,_,x, x,_,_,x,_), PACK_BITS25(_,_,_,_,x, x,_,_,_,x, _,_,x,_,_, x,_,_,_,x, _,_,_,_,x) }, |
|||
{ PACK_BITS25(x,_,_,_,x, _,_,x,_,_, _,x,_,_,_, _,_,_,_,x, x,x,x,x,x), PACK_BITS25(_,_,_,_,x, x,_,_,_,x, _,x,_,_,_, x,_,_,_,x, _,_,_,_,x) }, |
|||
{ PACK_BITS25(_,x,_,x,_, _,_,x,_,_, x,_,_,_,_, x,_,_,_,x, _,_,_,x,_), PACK_BITS25(x,_,_,_,x, x,_,_,_,x, _,x,_,_,_, x,_,_,_,x, x,_,_,_,x) }, |
|||
{ PACK_BITS25(_,_,x,_,_, x,x,x,x,x, x,x,x,x,x, _,x,x,x,_, _,_,_,x,_), PACK_BITS25(_,x,x,x,_, _,x,x,x,_, _,x,_,_,_, _,x,x,x,_, _,x,x,x,_) } |
|||
}; |
|||
#undef _ |
|||
#undef x |
|||
#undef PACK_BITS25 |
|||
return (fontData[8 - pixCoord.y][digit >= 5] >> ((digit % 5) * 5 + pixCoord.x)) & 1; |
|||
} |
|||
|
|||
bool SampleDebugFontNumber(int2 pixCoord, uint number) |
|||
{ |
|||
pixCoord.y -= 4; |
|||
if (number <= 9) |
|||
{ |
|||
return SampleDebugFont(pixCoord - int2(6, 0), number); |
|||
} |
|||
else |
|||
{ |
|||
return (SampleDebugFont(pixCoord, number / 10) | SampleDebugFont(pixCoord - int2(6, 0), number % 10)); |
|||
} |
|||
} |
|||
|
|||
float4 GetStreamingMipColor(uint mipCount, float4 mipInfo) |
|||
{ |
|||
// alpha is amount to blend with source color (0.0 = use original, 1.0 = use new color) |
|||
|
|||
// mipInfo : |
|||
// x = quality setings minStreamingMipLevel |
|||
// y = original mip count for texture |
|||
// z = desired on screen mip level |
|||
// w = 0 |
|||
uint originalTextureMipCount = uint(mipInfo.y); |
|||
|
|||
// If material/shader mip info (original mip level) has not been set its not a streamed texture |
|||
if (originalTextureMipCount == 0) |
|||
return float4(1.0, 1.0, 1.0, 0.0); |
|||
|
|||
uint desiredMipLevel = uint(mipInfo.z); |
|||
uint mipCountDesired = uint(originalTextureMipCount)-uint(desiredMipLevel); |
|||
if (mipCount == 0) |
|||
{ |
|||
// Magenta if mip count invalid |
|||
return float4(1.0, 0.0, 1.0, 1.0); |
|||
} |
|||
else if (mipCount < mipCountDesired) |
|||
{ |
|||
// red tones when not at the desired mip level (reduction due to budget). Brighter is further from original, alpha 0 when at desired |
|||
float ratioToDesired = float(mipCount) / float(mipCountDesired); |
|||
return float4(1.0, 0.0, 0.0, 1.0 - ratioToDesired); |
|||
} |
|||
else if (mipCount >= originalTextureMipCount) |
|||
{ |
|||
// original color when at (or beyond) original mip count |
|||
return float4(1.0, 1.0, 1.0, 0.0); |
|||
} |
|||
else |
|||
{ |
|||
// green tones when not at the original mip level. Brighter is closer to original, alpha 0 when at original |
|||
float ratioToOriginal = float(mipCount) / float(originalTextureMipCount); |
|||
return float4(0.0, 1.0, 0.0, 1.0 - ratioToOriginal); |
|||
} |
|||
} |
|||
|
|||
float4 GetSimpleMipCountColor(uint mipCount) |
|||
{ |
|||
// Grey scale for mip counts where mip count of 12 = white |
|||
float mipCountColor = float(mipCount) / 12.0; |
|||
float4 color = float4(mipCountColor, mipCountColor, mipCountColor, 1.0f); |
|||
|
|||
// alpha is amount to blend with source color (0.0 = use original, 1.0 = use new color) |
|||
// Magenta is no valid mip count |
|||
// Original colour if greater than 12 |
|||
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 uv, float4 texelSize) |
|||
{ |
|||
// Push down into colors list to "optimal level" in following table. |
|||
// .zw is texture width,height so *2 is down one mip, *4 is down two mips |
|||
texelSize.zw *= 4.0; |
|||
|
|||
float mipLevel = ComputeTextureLOD(uv, texelSize.wz); |
|||
mipLevel = clamp(mipLevel, 0.0, 5.0 - 0.0001); |
|||
|
|||
float4 colors[6] = { |
|||
float4(0.0, 0.0, 1.0, 0.8), // 0 BLUE = too little texture detail |
|||
float4(0.0, 0.5, 1.0, 0.4), // 1 |
|||
float4(1.0, 1.0, 1.0, 0.0), // 2 = optimal level |
|||
float4(1.0, 0.7, 0.0, 0.2), // 3 (YELLOW tint) |
|||
float4(1.0, 0.3, 0.0, 0.6), // 4 (clamped mipLevel 4.9999) |
|||
float4(1.0, 0.0, 0.0, 0.8) // 5 RED = too much texture detail (max blended value) |
|||
}; |
|||
|
|||
int mipLevelInt = floor(mipLevel); |
|||
float t = frac(mipLevel); |
|||
float4 a = colors[mipLevelInt]; |
|||
float4 b = colors[mipLevelInt + 1]; |
|||
float4 color = lerp(a, b, t); |
|||
|
|||
return color; |
|||
} |
|||
|
|||
float3 GetDebugMipColor(float3 originalColor, Texture2D tex, float4 texelSize, float2 uv) |
|||
{ |
|||
// https://aras-p.info/blog/2011/05/03/a-way-to-visualize-mip-levels/ |
|||
float4 mipColor= GetMipLevelColor(uv, texelSize); |
|||
return lerp(originalColor, mipColor.rgb, mipColor.a); |
|||
} |
|||
|
|||
float3 GetDebugMipCountColor(float3 originalColor, Texture2D tex) |
|||
{ |
|||
uint mipCount = GetMipCount(tex); |
|||
|
|||
float4 mipColor = GetSimpleMipCountColor(mipCount); |
|||
return lerp(originalColor, mipColor.rgb, mipColor.a); |
|||
} |
|||
|
|||
float3 GetDebugStreamingMipColor(Texture2D tex, float4 mipInfo) |
|||
{ |
|||
uint mipCount = GetMipCount(tex); |
|||
return GetStreamingMipColor(mipCount, mipInfo).xyz; |
|||
} |
|||
|
|||
float3 GetDebugStreamingMipColorBlended(float3 originalColor, Texture2D tex, float4 mipInfo) |
|||
{ |
|||
uint mipCount = GetMipCount(tex); |
|||
float4 mipColor = GetStreamingMipColor(mipCount, mipInfo); |
|||
return lerp(originalColor, mipColor.rgb, mipColor.a); |
|||
} |
|||
|
|||
float3 GetDebugMipColorIncludingMipReduction(float3 originalColor, Texture2D tex, float4 texelSize, float2 uv, float4 mipInfo) |
|||
{ |
|||
uint originalTextureMipCount = uint(mipInfo.y); |
|||
if (originalTextureMipCount != 0) |
|||
{ |
|||
// mipInfo : |
|||
// x = quality setings minStreamingMipLevel |
|||
// y = original mip count for texture |
|||
// z = desired on screen mip level |
|||
// w = 0 |
|||
|
|||
// Mip count has been reduced but the texelSize was not updated to take that into account |
|||
uint mipCount = GetMipCount(tex); |
|||
uint mipReductionLevel = originalTextureMipCount - mipCount; |
|||
uint mipReductionFactor = 1 << mipReductionLevel; |
|||
if (mipReductionFactor) |
|||
{ |
|||
float oneOverMipReductionFactor = 1.0 / mipReductionFactor; |
|||
// texelSize.xy *= mipReductionRatio; // Unused in GetDebugMipColor so lets not re-calculate it |
|||
texelSize.zw *= oneOverMipReductionFactor; |
|||
} |
|||
} |
|||
return GetDebugMipColor(originalColor, tex, texelSize, uv); |
|||
} |
|||
|
|||
float3 GetDebugMipReductionColor(Texture2D tex, float4 mipInfo) |
|||
{ |
|||
uint originalTextureMipCount = uint(mipInfo.y); |
|||
if (originalTextureMipCount != 0) |
|||
{ |
|||
// mipInfo : |
|||
// x = quality setings minStreamingMipLevel |
|||
// y = original mip count for texture |
|||
// z = desired on screen mip level |
|||
// w = 0 |
|||
|
|||
// Mip count has been reduced but the texelSize was not updated to take that into account |
|||
uint mipCount = GetMipCount(tex); |
|||
uint mipReductionLevel = originalTextureMipCount - mipCount; |
|||
|
|||
float mipCol = float(mipReductionLevel) / 12.0; |
|||
return float3(0, mipCol, 0); |
|||
} |
|||
|
|||
// Can't calculate without original mip count - return magenta |
|||
return float3(1.0, 0.0, 1.0); |
|||
} |
|||
|
|||
#ifdef DEBUG_DISPLAY |
|||
float3 GetTextureDataDebug(uint paramId, float2 uv, Texture2D tex, float4 texelSize, float4 mipInfo, float3 originalColor) |
|||
{ |
|||
switch (paramId) |
|||
{ |
|||
case DEBUGMIPMAPMODE_MIP_RATIO: |
|||
return GetDebugMipColorIncludingMipReduction(originalColor, tex, texelSize, uv, mipInfo); |
|||
case DEBUGMIPMAPMODE_MIP_COUNT: |
|||
return GetDebugMipCountColor(originalColor, tex); |
|||
case DEBUGMIPMAPMODE_MIP_COUNT_REDUCTION: |
|||
return GetDebugMipReductionColor(tex, mipInfo); |
|||
case DEBUGMIPMAPMODE_STREAMING_MIP_BUDGET: |
|||
return GetDebugStreamingMipColor(tex, mipInfo); |
|||
case DEBUGMIPMAPMODE_STREAMING_MIP: |
|||
return GetDebugStreamingMipColorBlended(originalColor, tex, mipInfo); |
|||
} |
|||
|
|||
return originalColor; |
|||
} |
|||
#endif // DEBUG_DISPLAY |
|||
|
|||
#endif // UNITY_DEBUG_INCLUDED |
|
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using System; |
|||
|
|||
namespace UnityEngine.Experimental.Rendering.HDPipeline |
|||
{ |
|||
namespace Attributes |
|||
{ |
|||
// 0 is reserved!
|
|||
[GenerateHLSL] |
|||
public enum DebugViewVarying |
|||
{ |
|||
None = 0, |
|||
Texcoord0 = 1, |
|||
Texcoord1, |
|||
Texcoord2, |
|||
Texcoord3, |
|||
VertexTangentWS, |
|||
VertexBitangentWS, |
|||
VertexNormalWS, |
|||
VertexColor, |
|||
VertexColorAlpha, |
|||
Last, |
|||
}; |
|||
|
|||
// Number must be contiguous
|
|||
[GenerateHLSL] |
|||
public enum DebugViewGbuffer |
|||
{ |
|||
None = 0, |
|||
Depth = DebugViewVarying.Last, |
|||
BakeDiffuseLightingWithAlbedoPlusEmissive, |
|||
BakeShadowMask0, |
|||
BakeShadowMask1, |
|||
BakeShadowMask2, |
|||
BakeShadowMask3, |
|||
Last, |
|||
} |
|||
|
|||
// Number must be contiguous
|
|||
[GenerateHLSL] |
|||
public enum DebugViewProperties |
|||
{ |
|||
None = 0, |
|||
Tessellation = DebugViewGbuffer.Last, |
|||
PixelDisplacement, |
|||
VertexDisplacement, |
|||
TessellationDisplacement, |
|||
DepthOffset, |
|||
Lightmap, |
|||
Last, |
|||
} |
|||
} |
|||
|
|||
[Serializable] |
|||
public class MaterialDebugSettings |
|||
{ |
|||
private static bool isDebugViewMaterialInit = false; |
|||
|
|||
public static GUIContent[] debugViewMaterialStrings = null; |
|||
public static int[] debugViewMaterialValues = null; |
|||
public static GUIContent[] debugViewEngineStrings = null; |
|||
public static int[] debugViewEngineValues = null; |
|||
public static GUIContent[] debugViewMaterialVaryingStrings = null; |
|||
public static int[] debugViewMaterialVaryingValues = null; |
|||
public static GUIContent[] debugViewMaterialPropertiesStrings = null; |
|||
public static int[] debugViewMaterialPropertiesValues = null; |
|||
public static GUIContent[] debugViewMaterialTextureStrings = null; |
|||
public static int[] debugViewMaterialTextureValues = null; |
|||
public static GUIContent[] debugViewMaterialGBufferStrings = null; |
|||
public static int[] debugViewMaterialGBufferValues = null; |
|||
|
|||
public MaterialDebugSettings() |
|||
{ |
|||
BuildDebugRepresentation(); |
|||
} |
|||
|
|||
// className include the additional "/"
|
|||
void FillWithProperties(Type type, GUIContent[] debugViewMaterialStrings, int[] debugViewMaterialValues, string className, ref int index) |
|||
{ |
|||
var attributes = type.GetCustomAttributes(true); |
|||
// Get attribute to get the start number of the value for the enum
|
|||
var attr = attributes[0] as GenerateHLSL; |
|||
|
|||
if (!attr.needParamDebug) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
var fields = type.GetFields(); |
|||
|
|||
var localIndex = 0; |
|||
foreach (var field in fields) |
|||
{ |
|||
var fieldName = field.Name; |
|||
|
|||
// Check if the display name have been override by the users
|
|||
if (Attribute.IsDefined(field, typeof(SurfaceDataAttributes))) |
|||
{ |
|||
var propertyAttr = (SurfaceDataAttributes[])field.GetCustomAttributes(typeof(SurfaceDataAttributes), false); |
|||
if (propertyAttr[0].displayName != "") |
|||
{ |
|||
fieldName = propertyAttr[0].displayName; |
|||
} |
|||
} |
|||
|
|||
fieldName = className + fieldName; |
|||
|
|||
debugViewMaterialStrings[index] = new GUIContent(fieldName); |
|||
debugViewMaterialValues[index] = attr.paramDefinesStart + (int)localIndex; |
|||
index++; |
|||
localIndex++; |
|||
} |
|||
} |
|||
|
|||
void FillWithPropertiesEnum(Type type, GUIContent[] debugViewMaterialStrings, int[] debugViewMaterialValues, string prefix, ref int index) |
|||
{ |
|||
var names = Enum.GetNames(type); |
|||
|
|||
var localIndex = 0; |
|||
foreach (var value in Enum.GetValues(type)) |
|||
{ |
|||
var valueName = prefix + names[localIndex]; |
|||
|
|||
debugViewMaterialStrings[index] = new GUIContent(valueName); |
|||
debugViewMaterialValues[index] = (int)value; |
|||
index++; |
|||
localIndex++; |
|||
} |
|||
} |
|||
|
|||
public class MaterialItem |
|||
{ |
|||
public String className; |
|||
public Type surfaceDataType; |
|||
public Type bsdfDataType; |
|||
}; |
|||
|
|||
void BuildDebugRepresentation() |
|||
{ |
|||
if (!isDebugViewMaterialInit) |
|||
{ |
|||
List<RenderPipelineMaterial> materialList = HDUtils.GetRenderPipelineMaterialList(); |
|||
|
|||
// TODO: Share this code to retrieve deferred material with HDRenderPipeline
|
|||
// Find first material that have non 0 Gbuffer count and assign it as deferredMaterial
|
|||
Type bsdfDataDeferredType = null; |
|||
foreach (RenderPipelineMaterial material in materialList) |
|||
{ |
|||
if (material.GetMaterialGBufferCount() > 0) |
|||
{ |
|||
bsdfDataDeferredType = material.GetType().GetNestedType("BSDFData"); |
|||
} |
|||
} |
|||
|
|||
// TODO: Handle the case of no Gbuffer material
|
|||
Debug.Assert(bsdfDataDeferredType != null); |
|||
|
|||
List<MaterialItem> materialItems = new List<MaterialItem>(); |
|||
|
|||
int numSurfaceDataFields = 0; |
|||
int numBSDFDataFields = 0; |
|||
foreach (RenderPipelineMaterial material in materialList) |
|||
{ |
|||
MaterialItem item = new MaterialItem(); |
|||
|
|||
item.className = material.GetType().Name + "/"; |
|||
|
|||
item.surfaceDataType = material.GetType().GetNestedType("SurfaceData"); |
|||
numSurfaceDataFields += item.surfaceDataType.GetFields().Length; |
|||
|
|||
item.bsdfDataType = material.GetType().GetNestedType("BSDFData"); |
|||
numBSDFDataFields += item.bsdfDataType.GetFields().Length; |
|||
|
|||
materialItems.Add(item); |
|||
} |
|||
|
|||
// Material properties debug
|
|||
var num = typeof(Builtin.BuiltinData).GetFields().Length * materialList.Count // BuildtinData are duplicated for each material
|
|||
+ numSurfaceDataFields + 1; // +1 for None case
|
|||
|
|||
debugViewMaterialStrings = new GUIContent[num]; |
|||
debugViewMaterialValues = new int[num]; |
|||
// Special case for None since it cannot be inferred from SurfaceData/BuiltinData
|
|||
debugViewMaterialStrings[0] = new GUIContent("None"); |
|||
debugViewMaterialValues[0] = 0; |
|||
var index = 1; |
|||
// 0 is a reserved number and should not be used (allow to track error)
|
|||
foreach (MaterialItem item in materialItems) |
|||
{ |
|||
// BuiltinData are duplicated for each material
|
|||
FillWithProperties(typeof(Builtin.BuiltinData), debugViewMaterialStrings, debugViewMaterialValues, item.className, ref index); |
|||
FillWithProperties(item.surfaceDataType, debugViewMaterialStrings, debugViewMaterialValues, item.className, ref index); |
|||
} |
|||
|
|||
// Engine properties debug
|
|||
num = numBSDFDataFields + 1; // +1 for None case
|
|||
debugViewEngineStrings = new GUIContent[num]; |
|||
debugViewEngineValues = new int[num]; |
|||
// 0 is a reserved number and should not be used (allow to track error)
|
|||
debugViewEngineStrings[0] = new GUIContent("None"); |
|||
debugViewEngineValues[0] = 0; |
|||
index = 1; |
|||
foreach (MaterialItem item in materialItems) |
|||
{ |
|||
FillWithProperties(item.bsdfDataType, debugViewEngineStrings, debugViewEngineValues, item.className, ref index); |
|||
} |
|||
|
|||
// Attributes debug
|
|||
var varyingNames = Enum.GetNames(typeof(Attributes.DebugViewVarying)); |
|||
debugViewMaterialVaryingStrings = new GUIContent[varyingNames.Length]; |
|||
debugViewMaterialVaryingValues = new int[varyingNames.Length]; |
|||
index = 0; |
|||
FillWithPropertiesEnum(typeof(Attributes.DebugViewVarying), debugViewMaterialVaryingStrings, debugViewMaterialVaryingValues, "", ref index); |
|||
|
|||
// Properties debug
|
|||
var propertiesNames = Enum.GetNames(typeof(Attributes.DebugViewProperties)); |
|||
debugViewMaterialPropertiesStrings = new GUIContent[propertiesNames.Length]; |
|||
debugViewMaterialPropertiesValues = new int[propertiesNames.Length]; |
|||
index = 0; |
|||
FillWithPropertiesEnum(typeof(Attributes.DebugViewProperties), debugViewMaterialPropertiesStrings, debugViewMaterialPropertiesValues, "", ref index); |
|||
|
|||
// Gbuffer debug
|
|||
var gbufferNames = Enum.GetNames(typeof(Attributes.DebugViewGbuffer)); |
|||
debugViewMaterialGBufferStrings = new GUIContent[gbufferNames.Length + bsdfDataDeferredType.GetFields().Length]; |
|||
debugViewMaterialGBufferValues = new int[gbufferNames.Length + bsdfDataDeferredType.GetFields().Length]; |
|||
index = 0; |
|||
FillWithPropertiesEnum(typeof(Attributes.DebugViewGbuffer), debugViewMaterialGBufferStrings, debugViewMaterialGBufferValues, "", ref index); |
|||
FillWithProperties(typeof(Lit.BSDFData), debugViewMaterialGBufferStrings, debugViewMaterialGBufferValues, "", ref index); |
|||
|
|||
isDebugViewMaterialInit = true; |
|||
} |
|||
} |
|||
|
|||
public int debugViewMaterial { get { return m_DebugViewMaterial; } } |
|||
public int debugViewEngine { get { return m_DebugViewEngine; } } |
|||
public Attributes.DebugViewVarying debugViewVarying { get { return m_DebugViewVarying; } } |
|||
public Attributes.DebugViewProperties debugViewProperties { get { return m_DebugViewProperties; } } |
|||
public int debugViewGBuffer { get { return m_DebugViewGBuffer; } } |
|||
|
|||
int m_DebugViewMaterial = 0; // No enum there because everything is generated from materials.
|
|||
int m_DebugViewEngine = 0; // No enum there because everything is generated from BSDFData
|
|||
Attributes.DebugViewVarying m_DebugViewVarying = Attributes.DebugViewVarying.None; |
|||
Attributes.DebugViewProperties m_DebugViewProperties = Attributes.DebugViewProperties.None; |
|||
int m_DebugViewGBuffer = 0; // Can't use GBuffer enum here because the values are actually split between this enum and values from Lit.BSDFData
|
|||
|
|||
public int GetDebugMaterialIndex() |
|||
{ |
|||
// This value is used in the shader for the actual debug display.
|
|||
// There is only one uniform parameter for that so we just add all of them
|
|||
// They are all mutually exclusive so return the sum will return the right index.
|
|||
return m_DebugViewGBuffer + m_DebugViewMaterial + m_DebugViewEngine + (int)m_DebugViewVarying + (int)m_DebugViewProperties; |
|||
} |
|||
|
|||
public void DisableMaterialDebug() |
|||
{ |
|||
m_DebugViewMaterial = 0; |
|||
m_DebugViewEngine = 0; |
|||
m_DebugViewVarying = Attributes.DebugViewVarying.None; |
|||
m_DebugViewProperties = Attributes.DebugViewProperties.None; |
|||
m_DebugViewGBuffer = 0; |
|||
} |
|||
|
|||
public void SetDebugViewMaterial(int value) |
|||
{ |
|||
if (value != 0) |
|||
DisableMaterialDebug(); |
|||
m_DebugViewMaterial = value; |
|||
} |
|||
|
|||
public void SetDebugViewEngine(int value) |
|||
{ |
|||
if (value != 0) |
|||
DisableMaterialDebug(); |
|||
m_DebugViewEngine = value; |
|||
} |
|||
|
|||
public void SetDebugViewVarying(Attributes.DebugViewVarying value) |
|||
{ |
|||
if (value != 0) |
|||
DisableMaterialDebug(); |
|||
m_DebugViewVarying = value; |
|||
} |
|||
public void SetDebugViewProperties(Attributes.DebugViewProperties value) |
|||
{ |
|||
if (value != 0) |
|||
DisableMaterialDebug(); |
|||
m_DebugViewProperties = value; |
|||
} |
|||
|
|||
public void SetDebugViewGBuffer(int value) |
|||
{ |
|||
if (value != 0) |
|||
DisableMaterialDebug(); |
|||
m_DebugViewGBuffer = value; |
|||
} |
|||
|
|||
|
|||
public bool IsDebugGBufferEnabled() |
|||
{ |
|||
return m_DebugViewGBuffer != 0; |
|||
} |
|||
|
|||
public bool IsDebugDisplayEnabled() |
|||
{ |
|||
return (m_DebugViewEngine != 0 || m_DebugViewMaterial != 0 || m_DebugViewVarying != Attributes.DebugViewVarying.None || m_DebugViewProperties != Attributes.DebugViewProperties.None || m_DebugViewGBuffer != 0); |
|||
} |
|||
} |
|||
} |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using System; |
|||
|
|||
namespace UnityEngine.Experimental.Rendering.HDPipeline |
|||
{ |
|||
namespace Attributes |
|||
{ |
|||
// 0 is reserved!
|
|||
[GenerateHLSL] |
|||
public enum DebugViewVarying |
|||
{ |
|||
None = 0, |
|||
Texcoord0 = 1, |
|||
Texcoord1, |
|||
Texcoord2, |
|||
Texcoord3, |
|||
VertexTangentWS, |
|||
VertexBitangentWS, |
|||
VertexNormalWS, |
|||
VertexColor, |
|||
VertexColorAlpha, |
|||
Last, |
|||
}; |
|||
|
|||
// Number must be contiguous
|
|||
[GenerateHLSL] |
|||
public enum DebugViewGbuffer |
|||
{ |
|||
None = 0, |
|||
Depth = DebugViewVarying.Last, |
|||
BakeDiffuseLightingWithAlbedoPlusEmissive, |
|||
BakeShadowMask0, |
|||
BakeShadowMask1, |
|||
BakeShadowMask2, |
|||
BakeShadowMask3, |
|||
Last, |
|||
} |
|||
|
|||
// Number must be contiguous
|
|||
[GenerateHLSL] |
|||
public enum DebugViewProperties |
|||
{ |
|||
None = 0, |
|||
Tessellation = DebugViewGbuffer.Last, |
|||
PixelDisplacement, |
|||
VertexDisplacement, |
|||
TessellationDisplacement, |
|||
DepthOffset, |
|||
Lightmap, |
|||
Last, |
|||
} |
|||
} |
|||
|
|||
[Serializable] |
|||
public class MaterialDebugSettings |
|||
{ |
|||
private static bool isDebugViewMaterialInit = false; |
|||
|
|||
public static GUIContent[] debugViewMaterialStrings = null; |
|||
public static int[] debugViewMaterialValues = null; |
|||
public static GUIContent[] debugViewEngineStrings = null; |
|||
public static int[] debugViewEngineValues = null; |
|||
public static GUIContent[] debugViewMaterialVaryingStrings = null; |
|||
public static int[] debugViewMaterialVaryingValues = null; |
|||
public static GUIContent[] debugViewMaterialPropertiesStrings = null; |
|||
public static int[] debugViewMaterialPropertiesValues = null; |
|||
public static GUIContent[] debugViewMaterialTextureStrings = null; |
|||
public static int[] debugViewMaterialTextureValues = null; |
|||
public static GUIContent[] debugViewMaterialGBufferStrings = null; |
|||
public static int[] debugViewMaterialGBufferValues = null; |
|||
|
|||
public MaterialDebugSettings() |
|||
{ |
|||
BuildDebugRepresentation(); |
|||
} |
|||
|
|||
// className include the additional "/"
|
|||
void FillWithProperties(Type type, GUIContent[] debugViewMaterialStrings, int[] debugViewMaterialValues, string className, ref int index) |
|||
{ |
|||
var attributes = type.GetCustomAttributes(true); |
|||
// Get attribute to get the start number of the value for the enum
|
|||
var attr = attributes[0] as GenerateHLSL; |
|||
|
|||
if (!attr.needParamDebug) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
var fields = type.GetFields(); |
|||
|
|||
var localIndex = 0; |
|||
foreach (var field in fields) |
|||
{ |
|||
var fieldName = field.Name; |
|||
|
|||
// Check if the display name have been override by the users
|
|||
if (Attribute.IsDefined(field, typeof(SurfaceDataAttributes))) |
|||
{ |
|||
var propertyAttr = (SurfaceDataAttributes[])field.GetCustomAttributes(typeof(SurfaceDataAttributes), false); |
|||
if (propertyAttr[0].displayName != "") |
|||
{ |
|||
fieldName = propertyAttr[0].displayName; |
|||
} |
|||
} |
|||
|
|||
fieldName = className + fieldName; |
|||
|
|||
debugViewMaterialStrings[index] = new GUIContent(fieldName); |
|||
debugViewMaterialValues[index] = attr.paramDefinesStart + (int)localIndex; |
|||
index++; |
|||
localIndex++; |
|||
} |
|||
} |
|||
|
|||
void FillWithPropertiesEnum(Type type, GUIContent[] debugViewMaterialStrings, int[] debugViewMaterialValues, string prefix, ref int index) |
|||
{ |
|||
var names = Enum.GetNames(type); |
|||
|
|||
var localIndex = 0; |
|||
foreach (var value in Enum.GetValues(type)) |
|||
{ |
|||
var valueName = prefix + names[localIndex]; |
|||
|
|||
debugViewMaterialStrings[index] = new GUIContent(valueName); |
|||
debugViewMaterialValues[index] = (int)value; |
|||
index++; |
|||
localIndex++; |
|||
} |
|||
} |
|||
|
|||
public class MaterialItem |
|||
{ |
|||
public String className; |
|||
public Type surfaceDataType; |
|||
public Type bsdfDataType; |
|||
}; |
|||
|
|||
void BuildDebugRepresentation() |
|||
{ |
|||
if (!isDebugViewMaterialInit) |
|||
{ |
|||
List<RenderPipelineMaterial> materialList = HDUtils.GetRenderPipelineMaterialList(); |
|||
|
|||
// TODO: Share this code to retrieve deferred material with HDRenderPipeline
|
|||
// Find first material that have non 0 Gbuffer count and assign it as deferredMaterial
|
|||
Type bsdfDataDeferredType = null; |
|||
foreach (RenderPipelineMaterial material in materialList) |
|||
{ |
|||
if (material.GetMaterialGBufferCount() > 0) |
|||
{ |
|||
bsdfDataDeferredType = material.GetType().GetNestedType("BSDFData"); |
|||
} |
|||
} |
|||
|
|||
// TODO: Handle the case of no Gbuffer material
|
|||
Debug.Assert(bsdfDataDeferredType != null); |
|||
|
|||
List<MaterialItem> materialItems = new List<MaterialItem>(); |
|||
|
|||
int numSurfaceDataFields = 0; |
|||
int numBSDFDataFields = 0; |
|||
foreach (RenderPipelineMaterial material in materialList) |
|||
{ |
|||
MaterialItem item = new MaterialItem(); |
|||
|
|||
item.className = material.GetType().Name + "/"; |
|||
|
|||
item.surfaceDataType = material.GetType().GetNestedType("SurfaceData"); |
|||
numSurfaceDataFields += item.surfaceDataType.GetFields().Length; |
|||
|
|||
item.bsdfDataType = material.GetType().GetNestedType("BSDFData"); |
|||
numBSDFDataFields += item.bsdfDataType.GetFields().Length; |
|||
|
|||
materialItems.Add(item); |
|||
} |
|||
|
|||
// Material properties debug
|
|||
var num = typeof(Builtin.BuiltinData).GetFields().Length * materialList.Count // BuildtinData are duplicated for each material
|
|||
+ numSurfaceDataFields + 1; // +1 for None case
|
|||
|
|||
debugViewMaterialStrings = new GUIContent[num]; |
|||
debugViewMaterialValues = new int[num]; |
|||
// Special case for None since it cannot be inferred from SurfaceData/BuiltinData
|
|||
debugViewMaterialStrings[0] = new GUIContent("None"); |
|||
debugViewMaterialValues[0] = 0; |
|||
var index = 1; |
|||
// 0 is a reserved number and should not be used (allow to track error)
|
|||
foreach (MaterialItem item in materialItems) |
|||
{ |
|||
// BuiltinData are duplicated for each material
|
|||
FillWithProperties(typeof(Builtin.BuiltinData), debugViewMaterialStrings, debugViewMaterialValues, item.className, ref index); |
|||
FillWithProperties(item.surfaceDataType, debugViewMaterialStrings, debugViewMaterialValues, item.className, ref index); |
|||
} |
|||
|
|||
// Engine properties debug
|
|||
num = numBSDFDataFields + 1; // +1 for None case
|
|||
debugViewEngineStrings = new GUIContent[num]; |
|||
debugViewEngineValues = new int[num]; |
|||
// 0 is a reserved number and should not be used (allow to track error)
|
|||
debugViewEngineStrings[0] = new GUIContent("None"); |
|||
debugViewEngineValues[0] = 0; |
|||
index = 1; |
|||
foreach (MaterialItem item in materialItems) |
|||
{ |
|||
FillWithProperties(item.bsdfDataType, debugViewEngineStrings, debugViewEngineValues, item.className, ref index); |
|||
} |
|||
|
|||
// Attributes debug
|
|||
var varyingNames = Enum.GetNames(typeof(Attributes.DebugViewVarying)); |
|||
debugViewMaterialVaryingStrings = new GUIContent[varyingNames.Length]; |
|||
debugViewMaterialVaryingValues = new int[varyingNames.Length]; |
|||
index = 0; |
|||
FillWithPropertiesEnum(typeof(Attributes.DebugViewVarying), debugViewMaterialVaryingStrings, debugViewMaterialVaryingValues, "", ref index); |
|||
|
|||
// Properties debug
|
|||
var propertiesNames = Enum.GetNames(typeof(Attributes.DebugViewProperties)); |
|||
debugViewMaterialPropertiesStrings = new GUIContent[propertiesNames.Length]; |
|||
debugViewMaterialPropertiesValues = new int[propertiesNames.Length]; |
|||
index = 0; |
|||
FillWithPropertiesEnum(typeof(Attributes.DebugViewProperties), debugViewMaterialPropertiesStrings, debugViewMaterialPropertiesValues, "", ref index); |
|||
|
|||
// Gbuffer debug
|
|||
var gbufferNames = Enum.GetNames(typeof(Attributes.DebugViewGbuffer)); |
|||
debugViewMaterialGBufferStrings = new GUIContent[gbufferNames.Length + bsdfDataDeferredType.GetFields().Length]; |
|||
debugViewMaterialGBufferValues = new int[gbufferNames.Length + bsdfDataDeferredType.GetFields().Length]; |
|||
index = 0; |
|||
FillWithPropertiesEnum(typeof(Attributes.DebugViewGbuffer), debugViewMaterialGBufferStrings, debugViewMaterialGBufferValues, "", ref index); |
|||
FillWithProperties(typeof(Lit.BSDFData), debugViewMaterialGBufferStrings, debugViewMaterialGBufferValues, "", ref index); |
|||
|
|||
isDebugViewMaterialInit = true; |
|||
} |
|||
} |
|||
|
|||
public int debugViewMaterial { get { return m_DebugViewMaterial; } } |
|||
public int debugViewEngine { get { return m_DebugViewEngine; } } |
|||
public Attributes.DebugViewVarying debugViewVarying { get { return m_DebugViewVarying; } } |
|||
public Attributes.DebugViewProperties debugViewProperties { get { return m_DebugViewProperties; } } |
|||
public int debugViewGBuffer { get { return m_DebugViewGBuffer; } } |
|||
|
|||
int m_DebugViewMaterial = 0; // No enum there because everything is generated from materials.
|
|||
int m_DebugViewEngine = 0; // No enum there because everything is generated from BSDFData
|
|||
Attributes.DebugViewVarying m_DebugViewVarying = Attributes.DebugViewVarying.None; |
|||
Attributes.DebugViewProperties m_DebugViewProperties = Attributes.DebugViewProperties.None; |
|||
int m_DebugViewGBuffer = 0; // Can't use GBuffer enum here because the values are actually split between this enum and values from Lit.BSDFData
|
|||
|
|||
public int GetDebugMaterialIndex() |
|||
{ |
|||
// This value is used in the shader for the actual debug display.
|
|||
// There is only one uniform parameter for that so we just add all of them
|
|||
// They are all mutually exclusive so return the sum will return the right index.
|
|||
return m_DebugViewGBuffer + m_DebugViewMaterial + m_DebugViewEngine + (int)m_DebugViewVarying + (int)m_DebugViewProperties; |
|||
} |
|||
|
|||
public void DisableMaterialDebug() |
|||
{ |
|||
m_DebugViewMaterial = 0; |
|||
m_DebugViewEngine = 0; |
|||
m_DebugViewVarying = Attributes.DebugViewVarying.None; |
|||
m_DebugViewProperties = Attributes.DebugViewProperties.None; |
|||
m_DebugViewGBuffer = 0; |
|||
} |
|||
|
|||
public void SetDebugViewMaterial(int value) |
|||
{ |
|||
if (value != 0) |
|||
DisableMaterialDebug(); |
|||
m_DebugViewMaterial = value; |
|||
} |
|||
|
|||
public void SetDebugViewEngine(int value) |
|||
{ |
|||
if (value != 0) |
|||
DisableMaterialDebug(); |
|||
m_DebugViewEngine = value; |
|||
} |
|||
|
|||
public void SetDebugViewVarying(Attributes.DebugViewVarying value) |
|||
{ |
|||
if (value != 0) |
|||
DisableMaterialDebug(); |
|||
m_DebugViewVarying = value; |
|||
} |
|||
public void SetDebugViewProperties(Attributes.DebugViewProperties value) |
|||
{ |
|||
if (value != 0) |
|||
DisableMaterialDebug(); |
|||
m_DebugViewProperties = value; |
|||
} |
|||
|
|||
public void SetDebugViewGBuffer(int value) |
|||
{ |
|||
if (value != 0) |
|||
DisableMaterialDebug(); |
|||
m_DebugViewGBuffer = value; |
|||
} |
|||
|
|||
|
|||
public bool IsDebugGBufferEnabled() |
|||
{ |
|||
return m_DebugViewGBuffer != 0; |
|||
} |
|||
|
|||
public bool IsDebugDisplayEnabled() |
|||
{ |
|||
return (m_DebugViewEngine != 0 || m_DebugViewMaterial != 0 || m_DebugViewVarying != Attributes.DebugViewVarying.None || m_DebugViewProperties != Attributes.DebugViewProperties.None || m_DebugViewGBuffer != 0); |
|||
} |
|||
} |
|||
} |
1001
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/LayeredLit/LayeredLitData.hlsl
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
// =========================================================================== |
|||
// WARNING: |
|||
// On PS4, texture/sampler declarations need to be outside of CBuffers |
|||
// Otherwise those parameters are not bound correctly at runtime. |
|||
// =========================================================================== |
|||
|
|||
TEXTURE2D(_DistortionVectorMap); |
|||
SAMPLER(sampler_DistortionVectorMap); |
|||
|
|||
TEXTURE2D(_EmissiveColorMap); |
|||
SAMPLER(sampler_EmissiveColorMap); |
|||
|
|||
#ifndef LAYERED_LIT_SHADER |
|||
|
|||
TEXTURE2D(_DiffuseLightingMap); |
|||
SAMPLER(sampler_DiffuseLightingMap); |
|||
|
|||
TEXTURE2D(_BaseColorMap); |
|||
SAMPLER(sampler_BaseColorMap); |
|||
|
|||
TEXTURE2D(_MaskMap); |
|||
SAMPLER(sampler_MaskMap); |
|||
TEXTURE2D(_BentNormalMap); // Reuse sampler from normal map |
|||
SAMPLER(sampler_BentNormalMap); |
|||
|
|||
TEXTURE2D(_NormalMap); |
|||
SAMPLER(sampler_NormalMap); |
|||
TEXTURE2D(_NormalMapOS); |
|||
SAMPLER(sampler_NormalMapOS); |
|||
|
|||
TEXTURE2D(_DetailMap); |
|||
SAMPLER(sampler_DetailMap); |
|||
|
|||
TEXTURE2D(_HeightMap); |
|||
SAMPLER(sampler_HeightMap); |
|||
|
|||
TEXTURE2D(_TangentMap); |
|||
SAMPLER(sampler_TangentMap); |
|||
TEXTURE2D(_TangentMapOS); |
|||
SAMPLER(sampler_TangentMapOS); |
|||
|
|||
TEXTURE2D(_AnisotropyMap); |
|||
SAMPLER(sampler_AnisotropyMap); |
|||
|
|||
TEXTURE2D(_SubsurfaceMaskMap); |
|||
SAMPLER(sampler_SubsurfaceMaskMap); |
|||
TEXTURE2D(_ThicknessMap); |
|||
SAMPLER(sampler_ThicknessMap); |
|||
|
|||
TEXTURE2D(_SpecularColorMap); |
|||
SAMPLER(sampler_SpecularColorMap); |
|||
|
|||
TEXTURE2D(_TransmittanceColorMap); |
|||
SAMPLER(sampler_TransmittanceColorMap); |
|||
|
|||
#else |
|||
|
|||
// Set of users variables |
|||
#define PROP_DECL(type, name) type name##0, name##1, name##2, name##3 |
|||
// sampler are share by texture type inside a layered material but we need to support that a particualr layer have no texture, so we take the first sampler of available texture as the share one |
|||
// mean we must declare all sampler |
|||
#define PROP_DECL_TEX2D(name)\ |
|||
TEXTURE2D(MERGE_NAME(name, 0)); \ |
|||
SAMPLER(MERGE_NAME(MERGE_NAME(sampler, name), 0)); \ |
|||
TEXTURE2D(MERGE_NAME(name, 1)); \ |
|||
SAMPLER(MERGE_NAME(MERGE_NAME(sampler, name), 1)); \ |
|||
TEXTURE2D(MERGE_NAME(name, 2)); \ |
|||
SAMPLER(MERGE_NAME(MERGE_NAME(sampler, name), 2)); \ |
|||
TEXTURE2D(MERGE_NAME(name, 3)); \ |
|||
SAMPLER(MERGE_NAME(MERGE_NAME(sampler, name), 3)) |
|||
|
|||
|
|||
PROP_DECL_TEX2D(_BaseColorMap); |
|||
PROP_DECL_TEX2D(_MaskMap); |
|||
PROP_DECL_TEX2D(_BentNormalMap); |
|||
PROP_DECL_TEX2D(_NormalMap); |
|||
PROP_DECL_TEX2D(_NormalMapOS); |
|||
PROP_DECL_TEX2D(_DetailMap); |
|||
PROP_DECL_TEX2D(_HeightMap); |
|||
|
|||
PROP_DECL_TEX2D(_SubsurfaceMaskMap); |
|||
PROP_DECL_TEX2D(_ThicknessMap); |
|||
|
|||
TEXTURE2D(_LayerMaskMap); |
|||
SAMPLER(sampler_LayerMaskMap); |
|||
TEXTURE2D(_LayerInfluenceMaskMap); |
|||
SAMPLER(sampler_LayerInfluenceMaskMap); |
|||
|
|||
#endif |
|||
|
|||
CBUFFER_START(UnityPerMaterial) |
|||
|
|||
// shared constant between lit and layered lit |
|||
float _AlphaCutoff; |
|||
float _AlphaCutoffPrepass; |
|||
float _AlphaCutoffPostpass; |
|||
float4 _DoubleSidedConstants; |
|||
float _DistortionScale; |
|||
float _DistortionVectorScale; |
|||
float _DistortionVectorBias; |
|||
float _DistortionBlurScale; |
|||
float _DistortionBlurRemapMin; |
|||
float _DistortionBlurRemapMax; |
|||
|
|||
float _PPDMaxSamples; |
|||
float _PPDMinSamples; |
|||
float _PPDLodThreshold; |
|||
|
|||
float3 _EmissiveColor; |
|||
float _EmissiveIntensity; |
|||
float _AlbedoAffectEmissive; |
|||
|
|||
float _EnableSpecularOcclusion; |
|||
|
|||
// Transparency |
|||
float3 _TransmittanceColor; |
|||
float _IOR; |
|||
float _ATDistance; |
|||
float _ThicknessMultiplier; |
|||
|
|||
// Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor" |
|||
// value that exist to identify if the GI emission need to be enabled. |
|||
// In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it. |
|||
// TODO: Fix the code in legacy unity so we can customize the beahvior for GI |
|||
float3 _EmissionColor; |
|||
float4 _EmissiveColorMap_ST; |
|||
float _TexWorldScaleEmissive; |
|||
float4 _UVMappingMaskEmissive; |
|||
|
|||
float4 _InvPrimScale; // Only XY are used |
|||
|
|||
// Wind |
|||
float _InitialBend; |
|||
float _Stiffness; |
|||
float _Drag; |
|||
float _ShiverDrag; |
|||
float _ShiverDirectionality; |
|||
|
|||
#ifndef LAYERED_LIT_SHADER |
|||
|
|||
// Set of users variables |
|||
float4 _BaseColor; |
|||
float4 _BaseColorMap_ST; |
|||
float4 _BaseColorMap_TexelSize; |
|||
float4 _BaseColorMap_MipInfo; |
|||
|
|||
float _Metallic; |
|||
float _Smoothness; |
|||
float _SmoothnessRemapMin; |
|||
float _SmoothnessRemapMax; |
|||
float _AORemapMin; |
|||
float _AORemapMax; |
|||
|
|||
float _NormalScale; |
|||
|
|||
float4 _DetailMap_ST; |
|||
float _DetailAlbedoScale; |
|||
float _DetailNormalScale; |
|||
float _DetailSmoothnessScale; |
|||
|
|||
float4 _HeightMap_TexelSize; // Unity facility. This will provide the size of the heightmap to the shader |
|||
|
|||
float _HeightAmplitude; |
|||
float _HeightCenter; |
|||
|
|||
float _Anisotropy; |
|||
|
|||
int _DiffusionProfile; |
|||
float _SubsurfaceMask; |
|||
float _Thickness; |
|||
float4 _ThicknessRemap; |
|||
|
|||
float _CoatMask; |
|||
|
|||
float4 _SpecularColor; |
|||
|
|||
float _TexWorldScale; |
|||
float _InvTilingScale; |
|||
float4 _UVMappingMask; |
|||
float4 _UVDetailsMappingMask; |
|||
float _LinkDetailsWithBase; |
|||
|
|||
#else // LAYERED_LIT_SHADER |
|||
|
|||
// Set of users variables |
|||
PROP_DECL(float4, _BaseColor); |
|||
float4 _BaseColorMap0_ST; |
|||
float4 _BaseColorMap1_ST; |
|||
float4 _BaseColorMap2_ST; |
|||
float4 _BaseColorMap3_ST; |
|||
|
|||
float4 _BaseColorMap0_TexelSize; |
|||
float4 _BaseColorMap0_MipInfo; |
|||
|
|||
PROP_DECL(float, _Metallic); |
|||
PROP_DECL(float, _Smoothness); |
|||
PROP_DECL(float, _SmoothnessRemapMin); |
|||
PROP_DECL(float, _SmoothnessRemapMax); |
|||
PROP_DECL(float, _AORemapMin); |
|||
PROP_DECL(float, _AORemapMax); |
|||
|
|||
PROP_DECL(float, _NormalScale); |
|||
float4 _NormalMap0_TexelSize; // Unity facility. This will provide the size of the base normal to the shader |
|||
|
|||
float4 _HeightMap0_TexelSize; |
|||
float4 _HeightMap1_TexelSize; |
|||
float4 _HeightMap2_TexelSize; |
|||
float4 _HeightMap3_TexelSize; |
|||
|
|||
float4 _DetailMap0_ST; |
|||
float4 _DetailMap1_ST; |
|||
float4 _DetailMap2_ST; |
|||
float4 _DetailMap3_ST; |
|||
PROP_DECL(float, _UVDetail); |
|||
PROP_DECL(float, _DetailAlbedoScale); |
|||
PROP_DECL(float, _DetailNormalScale); |
|||
PROP_DECL(float, _DetailSmoothnessScale); |
|||
|
|||
PROP_DECL(float, _HeightAmplitude); |
|||
PROP_DECL(float, _HeightCenter); |
|||
|
|||
PROP_DECL(int, _DiffusionProfile); |
|||
PROP_DECL(float, _SubsurfaceMask); |
|||
PROP_DECL(float, _Thickness); |
|||
PROP_DECL(float4, _ThicknessRemap); |
|||
|
|||
PROP_DECL(float, _OpacityAsDensity); |
|||
float _InheritBaseNormal1; |
|||
float _InheritBaseNormal2; |
|||
float _InheritBaseNormal3; |
|||
float _InheritBaseHeight1; |
|||
float _InheritBaseHeight2; |
|||
float _InheritBaseHeight3; |
|||
float _InheritBaseColor1; |
|||
float _InheritBaseColor2; |
|||
float _InheritBaseColor3; |
|||
PROP_DECL(float, _HeightOffset); |
|||
float _HeightTransition; |
|||
|
|||
float4 _LayerMaskMap_ST; |
|||
float _TexWorldScaleBlendMask; |
|||
PROP_DECL(float, _TexWorldScale); |
|||
PROP_DECL(float, _InvTilingScale); |
|||
float4 _UVMappingMaskBlendMask; |
|||
PROP_DECL(float4, _UVMappingMask); |
|||
PROP_DECL(float4, _UVDetailsMappingMask); |
|||
PROP_DECL(float, _LinkDetailsWithBase); |
|||
|
|||
#endif // LAYERED_LIT_SHADER |
|||
|
|||
// Tessellation specific |
|||
|
|||
#ifdef TESSELLATION_ON |
|||
float _TessellationFactor; |
|||
float _TessellationFactorMinDistance; |
|||
float _TessellationFactorMaxDistance; |
|||
float _TessellationFactorTriangleSize; |
|||
float _TessellationShapeFactor; |
|||
float _TessellationBackFaceCullEpsilon; |
|||
float _TessellationObjectScale; |
|||
float _TessellationTilingScale; |
|||
#endif |
|||
|
|||
CBUFFER_END |
|||
// =========================================================================== |
|||
// WARNING: |
|||
// On PS4, texture/sampler declarations need to be outside of CBuffers |
|||
// Otherwise those parameters are not bound correctly at runtime. |
|||
// =========================================================================== |
|||
|
|||
TEXTURE2D(_DistortionVectorMap); |
|||
SAMPLER(sampler_DistortionVectorMap); |
|||
|
|||
TEXTURE2D(_EmissiveColorMap); |
|||
SAMPLER(sampler_EmissiveColorMap); |
|||
|
|||
#ifndef LAYERED_LIT_SHADER |
|||
|
|||
TEXTURE2D(_DiffuseLightingMap); |
|||
SAMPLER(sampler_DiffuseLightingMap); |
|||
|
|||
TEXTURE2D(_BaseColorMap); |
|||
SAMPLER(sampler_BaseColorMap); |
|||
|
|||
TEXTURE2D(_MaskMap); |
|||
SAMPLER(sampler_MaskMap); |
|||
TEXTURE2D(_BentNormalMap); // Reuse sampler from normal map |
|||
SAMPLER(sampler_BentNormalMap); |
|||
|
|||
TEXTURE2D(_NormalMap); |
|||
SAMPLER(sampler_NormalMap); |
|||
TEXTURE2D(_NormalMapOS); |
|||
SAMPLER(sampler_NormalMapOS); |
|||
|
|||
TEXTURE2D(_DetailMap); |
|||
SAMPLER(sampler_DetailMap); |
|||
|
|||
TEXTURE2D(_HeightMap); |
|||
SAMPLER(sampler_HeightMap); |
|||
|
|||
TEXTURE2D(_TangentMap); |
|||
SAMPLER(sampler_TangentMap); |
|||
TEXTURE2D(_TangentMapOS); |
|||
SAMPLER(sampler_TangentMapOS); |
|||
|
|||
TEXTURE2D(_AnisotropyMap); |
|||
SAMPLER(sampler_AnisotropyMap); |
|||
|
|||
TEXTURE2D(_SubsurfaceMaskMap); |
|||
SAMPLER(sampler_SubsurfaceMaskMap); |
|||
TEXTURE2D(_ThicknessMap); |
|||
SAMPLER(sampler_ThicknessMap); |
|||
|
|||
TEXTURE2D(_SpecularColorMap); |
|||
SAMPLER(sampler_SpecularColorMap); |
|||
|
|||
TEXTURE2D(_TransmittanceColorMap); |
|||
SAMPLER(sampler_TransmittanceColorMap); |
|||
|
|||
#else |
|||
|
|||
// Set of users variables |
|||
#define PROP_DECL(type, name) type name##0, name##1, name##2, name##3 |
|||
// sampler are share by texture type inside a layered material but we need to support that a particualr layer have no texture, so we take the first sampler of available texture as the share one |
|||
// mean we must declare all sampler |
|||
#define PROP_DECL_TEX2D(name)\ |
|||
TEXTURE2D(MERGE_NAME(name, 0)); \ |
|||
SAMPLER(MERGE_NAME(MERGE_NAME(sampler, name), 0)); \ |
|||
TEXTURE2D(MERGE_NAME(name, 1)); \ |
|||
SAMPLER(MERGE_NAME(MERGE_NAME(sampler, name), 1)); \ |
|||
TEXTURE2D(MERGE_NAME(name, 2)); \ |
|||
SAMPLER(MERGE_NAME(MERGE_NAME(sampler, name), 2)); \ |
|||
TEXTURE2D(MERGE_NAME(name, 3)); \ |
|||
SAMPLER(MERGE_NAME(MERGE_NAME(sampler, name), 3)) |
|||
|
|||
|
|||
PROP_DECL_TEX2D(_BaseColorMap); |
|||
PROP_DECL_TEX2D(_MaskMap); |
|||
PROP_DECL_TEX2D(_BentNormalMap); |
|||
PROP_DECL_TEX2D(_NormalMap); |
|||
PROP_DECL_TEX2D(_NormalMapOS); |
|||
PROP_DECL_TEX2D(_DetailMap); |
|||
PROP_DECL_TEX2D(_HeightMap); |
|||
|
|||
PROP_DECL_TEX2D(_SubsurfaceMaskMap); |
|||
PROP_DECL_TEX2D(_ThicknessMap); |
|||
|
|||
TEXTURE2D(_LayerMaskMap); |
|||
SAMPLER(sampler_LayerMaskMap); |
|||
TEXTURE2D(_LayerInfluenceMaskMap); |
|||
SAMPLER(sampler_LayerInfluenceMaskMap); |
|||
|
|||
#endif |
|||
|
|||
CBUFFER_START(UnityPerMaterial) |
|||
|
|||
// shared constant between lit and layered lit |
|||
float _AlphaCutoff; |
|||
float _AlphaCutoffPrepass; |
|||
float _AlphaCutoffPostpass; |
|||
float4 _DoubleSidedConstants; |
|||
float _DistortionScale; |
|||
float _DistortionVectorScale; |
|||
float _DistortionVectorBias; |
|||
float _DistortionBlurScale; |
|||
float _DistortionBlurRemapMin; |
|||
float _DistortionBlurRemapMax; |
|||
|
|||
float _PPDMaxSamples; |
|||
float _PPDMinSamples; |
|||
float _PPDLodThreshold; |
|||
|
|||
float3 _EmissiveColor; |
|||
float _EmissiveIntensity; |
|||
float _AlbedoAffectEmissive; |
|||
|
|||
float _EnableSpecularOcclusion; |
|||
|
|||
// Transparency |
|||
float3 _TransmittanceColor; |
|||
float _IOR; |
|||
float _ATDistance; |
|||
float _ThicknessMultiplier; |
|||
|
|||
// Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor" |
|||
// value that exist to identify if the GI emission need to be enabled. |
|||
// In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it. |
|||
// TODO: Fix the code in legacy unity so we can customize the beahvior for GI |
|||
float3 _EmissionColor; |
|||
float4 _EmissiveColorMap_ST; |
|||
float _TexWorldScaleEmissive; |
|||
float4 _UVMappingMaskEmissive; |
|||
|
|||
float4 _InvPrimScale; // Only XY are used |
|||
|
|||
// Wind |
|||
float _InitialBend; |
|||
float _Stiffness; |
|||
float _Drag; |
|||
float _ShiverDrag; |
|||
float _ShiverDirectionality; |
|||
|
|||
#ifndef LAYERED_LIT_SHADER |
|||
|
|||
// Set of users variables |
|||
float4 _BaseColor; |
|||
float4 _BaseColorMap_ST; |
|||
float4 _BaseColorMap_TexelSize; |
|||
float4 _BaseColorMap_MipInfo; |
|||
|
|||
float _Metallic; |
|||
float _Smoothness; |
|||
float _SmoothnessRemapMin; |
|||
float _SmoothnessRemapMax; |
|||
float _AORemapMin; |
|||
float _AORemapMax; |
|||
|
|||
float _NormalScale; |
|||
|
|||
float4 _DetailMap_ST; |
|||
float _DetailAlbedoScale; |
|||
float _DetailNormalScale; |
|||
float _DetailSmoothnessScale; |
|||
|
|||
float4 _HeightMap_TexelSize; // Unity facility. This will provide the size of the heightmap to the shader |
|||
|
|||
float _HeightAmplitude; |
|||
float _HeightCenter; |
|||
|
|||
float _Anisotropy; |
|||
|
|||
int _DiffusionProfile; |
|||
float _SubsurfaceMask; |
|||
float _Thickness; |
|||
float4 _ThicknessRemap; |
|||
|
|||
float _CoatMask; |
|||
|
|||
float4 _SpecularColor; |
|||
|
|||
float _TexWorldScale; |
|||
float _InvTilingScale; |
|||
float4 _UVMappingMask; |
|||
float4 _UVDetailsMappingMask; |
|||
float _LinkDetailsWithBase; |
|||
|
|||
#else // LAYERED_LIT_SHADER |
|||
|
|||
// Set of users variables |
|||
PROP_DECL(float4, _BaseColor); |
|||
float4 _BaseColorMap0_ST; |
|||
float4 _BaseColorMap1_ST; |
|||
float4 _BaseColorMap2_ST; |
|||
float4 _BaseColorMap3_ST; |
|||
|
|||
float4 _BaseColorMap0_TexelSize; |
|||
float4 _BaseColorMap0_MipInfo; |
|||
|
|||
PROP_DECL(float, _Metallic); |
|||
PROP_DECL(float, _Smoothness); |
|||
PROP_DECL(float, _SmoothnessRemapMin); |
|||
PROP_DECL(float, _SmoothnessRemapMax); |
|||
PROP_DECL(float, _AORemapMin); |
|||
PROP_DECL(float, _AORemapMax); |
|||
|
|||
PROP_DECL(float, _NormalScale); |
|||
float4 _NormalMap0_TexelSize; // Unity facility. This will provide the size of the base normal to the shader |
|||
|
|||
float4 _HeightMap0_TexelSize; |
|||
float4 _HeightMap1_TexelSize; |
|||
float4 _HeightMap2_TexelSize; |
|||
float4 _HeightMap3_TexelSize; |
|||
|
|||
float4 _DetailMap0_ST; |
|||
float4 _DetailMap1_ST; |
|||
float4 _DetailMap2_ST; |
|||
float4 _DetailMap3_ST; |
|||
PROP_DECL(float, _UVDetail); |
|||
PROP_DECL(float, _DetailAlbedoScale); |
|||
PROP_DECL(float, _DetailNormalScale); |
|||
PROP_DECL(float, _DetailSmoothnessScale); |
|||
|
|||
PROP_DECL(float, _HeightAmplitude); |
|||
PROP_DECL(float, _HeightCenter); |
|||
|
|||
PROP_DECL(int, _DiffusionProfile); |
|||
PROP_DECL(float, _SubsurfaceMask); |
|||
PROP_DECL(float, _Thickness); |
|||
PROP_DECL(float4, _ThicknessRemap); |
|||
|
|||
PROP_DECL(float, _OpacityAsDensity); |
|||
float _InheritBaseNormal1; |
|||
float _InheritBaseNormal2; |
|||
float _InheritBaseNormal3; |
|||
float _InheritBaseHeight1; |
|||
float _InheritBaseHeight2; |
|||
float _InheritBaseHeight3; |
|||
float _InheritBaseColor1; |
|||
float _InheritBaseColor2; |
|||
float _InheritBaseColor3; |
|||
PROP_DECL(float, _HeightOffset); |
|||
float _HeightTransition; |
|||
|
|||
float4 _LayerMaskMap_ST; |
|||
float _TexWorldScaleBlendMask; |
|||
PROP_DECL(float, _TexWorldScale); |
|||
PROP_DECL(float, _InvTilingScale); |
|||
float4 _UVMappingMaskBlendMask; |
|||
PROP_DECL(float4, _UVMappingMask); |
|||
PROP_DECL(float4, _UVDetailsMappingMask); |
|||
PROP_DECL(float, _LinkDetailsWithBase); |
|||
|
|||
#endif // LAYERED_LIT_SHADER |
|||
|
|||
// Tessellation specific |
|||
|
|||
#ifdef TESSELLATION_ON |
|||
float _TessellationFactor; |
|||
float _TessellationFactorMinDistance; |
|||
float _TessellationFactorMaxDistance; |
|||
float _TessellationFactorTriangleSize; |
|||
float _TessellationShapeFactor; |
|||
float _TessellationBackFaceCullEpsilon; |
|||
float _TessellationObjectScale; |
|||
float _TessellationTilingScale; |
|||
#endif |
|||
|
|||
CBUFFER_END |
|
|||
TEXTURE2D(_DistortionVectorMap); |
|||
SAMPLER(sampler_DistortionVectorMap); |
|||
|
|||
TEXTURE2D(_UnlitColorMap); |
|||
SAMPLER(sampler_UnlitColorMap); |
|||
|
|||
TEXTURE2D(_EmissiveColorMap); |
|||
SAMPLER(sampler_EmissiveColorMap); |
|||
|
|||
CBUFFER_START(UnityPerMaterial) |
|||
|
|||
float4 _UnlitColor; |
|||
float4 _UnlitColorMap_ST; |
|||
float4 _UnlitColorMap_TexelSize; |
|||
float4 _UnlitColorMap_MipInfo; |
|||
|
|||
float3 _EmissiveColor; |
|||
float4 _EmissiveColorMap_ST; |
|||
|
|||
float _EmissiveIntensity; |
|||
|
|||
float _AlphaCutoff; |
|||
float _DistortionScale; |
|||
float _DistortionVectorScale; |
|||
float _DistortionVectorBias; |
|||
float _DistortionBlurScale; |
|||
float _DistortionBlurRemapMin; |
|||
float _DistortionBlurRemapMax; |
|||
|
|||
// Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor" |
|||
// value that exist to identify if the GI emission need to be enabled. |
|||
// In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it. |
|||
// TODO: Fix the code in legacy unity so we can customize the behavior for GI |
|||
float3 _EmissionColor; |
|||
|
|||
CBUFFER_END |
|||
TEXTURE2D(_DistortionVectorMap); |
|||
SAMPLER(sampler_DistortionVectorMap); |
|||
|
|||
TEXTURE2D(_UnlitColorMap); |
|||
SAMPLER(sampler_UnlitColorMap); |
|||
|
|||
TEXTURE2D(_EmissiveColorMap); |
|||
SAMPLER(sampler_EmissiveColorMap); |
|||
|
|||
CBUFFER_START(UnityPerMaterial) |
|||
|
|||
float4 _UnlitColor; |
|||
float4 _UnlitColorMap_ST; |
|||
float4 _UnlitColorMap_TexelSize; |
|||
float4 _UnlitColorMap_MipInfo; |
|||
|
|||
float3 _EmissiveColor; |
|||
float4 _EmissiveColorMap_ST; |
|||
|
|||
float _EmissiveIntensity; |
|||
|
|||
float _AlphaCutoff; |
|||
float _DistortionScale; |
|||
float _DistortionVectorScale; |
|||
float _DistortionVectorBias; |
|||
float _DistortionBlurScale; |
|||
float _DistortionBlurRemapMin; |
|||
float _DistortionBlurRemapMax; |
|||
|
|||
// Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor" |
|||
// value that exist to identify if the GI emission need to be enabled. |
|||
// In our case we don't use such a mechanism but need to keep the code quiet. We declare the value and always enable it. |
|||
// TODO: Fix the code in legacy unity so we can customize the behavior for GI |
|||
float3 _EmissionColor; |
|||
|
|||
CBUFFER_END |
|
|||
fileFormatVersion: 2 |
|||
guid: 0f6887a1ff514ed690ada3786867d216 |
|||
timeCreated: 1512986333 |
|||
fileFormatVersion: 2 |
|||
guid: 2ea8802fb7f2fa641a567a661fb6a58e |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 0f6887a1ff514ed690ada3786867d216 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 8305d4811b3aa624ea663e2d7841e470 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: c1f6eaf19a5d40045818530f57b09da5 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 2c9ce194a1bfc4733b75593a1f4ced22 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: da59c0df09fb17e4f99a667936fce895 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 552442937a683d2479830866e050b035 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: ac919a67e7c764f70a75900c12043d9b |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 129562301394edd45a199c538cda6f8f |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 8a8e7dc88956341568162060a68f1e7e |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 76dedef1a7bcc354e900c23b8135d94c |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue