TimelineImprovements

This commit is contained in:
ThomasCharester committed 2026-11-20 14:28:56 +03:00
1 parent e312131725
commit f927552adc
2211 files changed
+115416 -540944

No files matched your search

+61 -20
View File
@@ -91,7 +91,11 @@
//near OR far has to be > 0.0
float rawDepth = SampleDepth(uvScreen.xy);
float sceneDepth = (unity_OrthoParams.w == 0) ? ComputeLinearDepth(rawDepth) : ComputeLinearDepthToEyeDepth(rawDepth);
float depth = ComputeLinearDepth(ndc.z);
#if defined(MK_URP) && UNITY_VERSION >= 60070000
float depth = (unity_OrthoParams.w == 0) ? ComputeLinearDepth(ndc.z) : ComputeLinearDepthToEyeDepth(ndc.z);
#else
float depth = ComputeLinearDepth(ndc.z);
#endif
return saturate(far * ((sceneDepth - near) - depth));
}
@@ -114,7 +118,7 @@
return saturate((depth - near) * far);
}
inline void MixAlbedoDetail(inout half3 albedo, in half4 detail, in int mode)
inline void MixAlbedoDetail(inout MK_LIGHT_ACCUM3 albedo, in half4 detail, in int mode)
{
if(mode < 1)
albedo = lerp(albedo, detail.rgb, _DetailMix * detail.a);
@@ -278,13 +282,13 @@
}
//Rampcolor when dissolving
inline half3 DissolveRamp(half dissolveValue, DECLARE_TEXTURE_2D_ARGS(dissolveBorderRampTex, samplerTex), half4 dissolveBorderColor, half dissolveBorderSize, half dissolveAmount, half2 uv, half3 baseCol)
inline MK_LIGHT_ACCUM3 DissolveRamp(half dissolveValue, DECLARE_TEXTURE_2D_ARGS(dissolveBorderRampTex, samplerTex), half4 dissolveBorderColor, half dissolveBorderSize, half dissolveAmount, half2 uv, MK_LIGHT_ACCUM3 baseCol)
{
half sv = dissolveBorderSize * dissolveAmount;
return lerp(baseCol, dissolveBorderColor.rgb * SampleTex2D(PASS_TEXTURE_2D(dissolveBorderRampTex, samplerTex), half2(dissolveValue * Rcp(sv), T_V)).rgb, dissolveBorderColor.a * step(dissolveValue, sv));
}
//Color when dissolving
inline half3 DissolveColor(half dissolveValue, half4 dissolveBorderColor, half dissolveBorderSize, half dissolveAmount, half3 baseCol)
inline MK_LIGHT_ACCUM3 DissolveColor(half dissolveValue, half4 dissolveBorderColor, half dissolveBorderSize, half dissolveAmount, MK_LIGHT_ACCUM3 baseCol)
{
return lerp(baseCol, dissolveBorderColor.rgb, dissolveBorderColor.a * step(dissolveValue, dissolveBorderSize * dissolveAmount));
}
@@ -312,18 +316,22 @@
}
//Contrast - Saturation - Brightness
inline half3 ColorGrading(half3 color, half brightness, half saturation, half contrast)
inline MK_LIGHT_ACCUM3 ColorGrading(MK_LIGHT_ACCUM3 color, half brightness, half saturation, half contrast)
{
half3 hueColor;
MK_LIGHT_ACCUM3 hueColor;
UnitySGHue(color, _Hue, hueColor);
color = hueColor;
//
half3 bc = color * brightness;
half i = dot(bc, REL_LUMA);
#ifdef MK_FORWARD_ADD_PASS
color = lerp(half3(0.0, 0.0, 0.0), lerp(half3(i, i, i), bc, saturation), contrast);
MK_LIGHT_ACCUM3 bc = color * brightness;
#if defined(MK_URP) && UNITY_VERSION >= 60070000 && defined(_EXPOSURE)
float i = dot(bc, REL_LUMA);
#else
color = lerp(half3(0.5, 0.5, 0.5), lerp(half3(i, i, i), bc, saturation), contrast);
half i = dot(bc, REL_LUMA);
#endif
#ifdef MK_FORWARD_ADD_PASS
color = lerp(half3(0.0, 0.0, 0.0), lerp(MK_LIGHT_ACCUM3(i, i, i), bc, saturation), contrast);
#else
color = lerp(half3(0.5, 0.5, 0.5), lerp(MK_LIGHT_ACCUM3(i, i, i), bc, saturation), contrast);
#endif
return color;
}
@@ -425,20 +433,20 @@
return c.z * lerp(K.xxx, saturate(p - K.xxx), c.y);
}
inline float3 VertexAnimationSine(float3 positionObject, half intensity, half3 frequency)
inline float3 VertexAnimationSine(float3 positionObject, half intensity, half3 frequency, float animationTime)
{
half3 f = abs(frequency.zyx);
half3 eps = half3(HALF_MIN, HALF_MIN, HALF_MIN);
half3 nz = step(eps, f);
half3 fSafe = max(f, eps);
half st = step(HALF_MIN, _VertexAnimationStutter);
half3 phase = lerp(_Time.yyy, Stutter(_Time.y, fSafe), st.xxx);
half3 phase = lerp(animationTime.xxx, Stutter(animationTime, fSafe), st.xxx);
float3 addV = (sin((positionObject.zxx + phase) * f) * intensity * 0.5 + 0.5 * intensity) * nz;
positionObject += addV;
return positionObject;
}
inline float3 VertexAnimationPulse(float3 positionObject, half3 normalObject, half intensity, half3 frequency)
inline float3 VertexAnimationPulse(float3 positionObject, half3 normalObject, half intensity, half3 frequency, float animationTime)
{
const half3 eps = half3(HALF_MIN, HALF_MIN, HALF_MIN);
@@ -448,7 +456,7 @@
half3 fSafe = max(absF, eps);
half stutterOn = step(HALF_MIN, _VertexAnimationStutter);
half3 phase = lerp(_Time.yyy, Stutter(_Time.y, fSafe), stutterOn.xxx);
half3 phase = lerp(animationTime.xxx, Stutter(animationTime, fSafe), stutterOn.xxx);
half3 intensity3 = intensity * nzMask;
@@ -459,20 +467,33 @@
return positionObject;
}
inline float3 VertexAnimationNoise(float3 positionObject, float2 uv, half3 normalObject, half intensity, half3 frequency)
inline float3 VertexAnimationNoise(float3 positionObject, float2 uv, half3 normalObject, half intensity, half3 frequency, float animationTime)
{
half3 f = abs(frequency);
half3 eps = half3(HALF_MIN, HALF_MIN, HALF_MIN);
half3 nz = step(eps, f);
half3 fSafe = max(f, eps);
half st = step(HALF_MIN, _VertexAnimationStutter);
half van = NoiseSimple(positionObject, normalObject.xz) * _Time.y;
half van = NoiseSimple(positionObject, normalObject.xz) * animationTime;
half3 phase = lerp(van.xxx, Stutter(van, fSafe), st.xxx);
half3 a = (sin(phase * f) * intensity * 0.5 + 0.5 * intensity) * nz;
positionObject += normalObject * a;
return positionObject;
}
inline float3 VertexAnimationSine(float3 positionObject, half intensity, half3 frequency)
{
return VertexAnimationSine(positionObject, intensity, frequency, _Time.y);
}
inline float3 VertexAnimationPulse(float3 positionObject, half3 normalObject, half intensity, half3 frequency)
{
return VertexAnimationPulse(positionObject, normalObject, intensity, frequency, _Time.y);
}
inline float3 VertexAnimationNoise(float3 positionObject, float2 uv, half3 normalObject, half intensity, half3 frequency)
{
return VertexAnimationNoise(positionObject, uv, normalObject, intensity, frequency, _Time.y);
}
#if !defined(MK_VERTEX_ANIMATION_SINE)
#define PASS_VERTEX_ANIMATION_ARG(vertexAnimationMap, uv, intensity, frequency, positionObject, normalObject) vertexAnimationMap, uv, intensity, frequency, positionObject, normalObject
#else
@@ -486,6 +507,7 @@
, half intensity
, float3 frequency
, float3 positionObject
, float animationTime
#ifndef MK_VERTEX_ANIMATION_SINE
, half3 normalObject
#endif
@@ -495,11 +517,30 @@
intensity *= tex2Dlod(vertexAnimationMap, float4(uv, 0, 0)).r;
#endif
#if defined(MK_VERTEX_ANIMATION_PULSE)
return VertexAnimationPulse(positionObject, normalObject, intensity, frequency);
return VertexAnimationPulse(positionObject, normalObject, intensity, frequency, animationTime);
#elif defined(MK_VERTEX_ANIMATION_NOISE)
return VertexAnimationNoise(positionObject, uv, normalObject, intensity, frequency);
return VertexAnimationNoise(positionObject, uv, normalObject, intensity, frequency, animationTime);
#else
return VertexAnimationSine(positionObject, intensity, frequency);
return VertexAnimationSine(positionObject, intensity, frequency, animationTime);
#endif
}
inline float3 VertexAnimation
(
sampler2D vertexAnimationMap
, float2 uv
, half intensity
, float3 frequency
, float3 positionObject
#ifndef MK_VERTEX_ANIMATION_SINE
, half3 normalObject
#endif
)
{
return VertexAnimation(vertexAnimationMap, uv, intensity, frequency, positionObject, _Time.y
#ifndef MK_VERTEX_ANIMATION_SINE
, normalObject
#endif
);
}
#endif
+2 -2
View File
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/Common.hlsl
uploadId: 1012352
uploadId: 1023756
+28 -2
View File
@@ -19,7 +19,10 @@
{
#ifdef MK_LIT
#ifdef MK_VERTEX_LIGHTING
surface.direct.rgb += surfaceData.vertexLighting * pbsData.diffuseRadiance;
#if defined(MK_URP) && UNITY_VERSION >= 60070000 && defined(DEBUG_DISPLAY)
if (IsLightingFeatureEnabled(DEBUGLIGHTINGFEATUREFLAGS_VERTEX_LIGHTING))
#endif
surface.direct.rgb += surfaceData.vertexLighting * pbsData.diffuseRadiance;
#endif
#if defined(MK_SCREEN_SPACE_OCCLUSION) && defined(MK_URP_2020_2_Or_Newer)
@@ -100,7 +103,30 @@
surface.final.rgb = ColorGrading(surface.final.rgb, _Brightness, _Saturation, _Contrast);
#endif
#ifdef MK_FOG
#if defined(MK_URP) && UNITY_VERSION >= 60070000 && !defined(MK_UNIVERSAL2D_PASS)
#ifdef MK_LIT
#ifdef MK_FOG
surface.final.rgb = BlendDistanceFog(surface.final.rgb, surfaceData.svPositionClip);
#endif
surface.final.rgb = ClampExposed(surface.final.rgb * GetPreExposureMultiplier());
#else
#ifdef MK_FOG
surface.final.rgb = BlendDistanceFogColor(surface.final.rgb, surfaceData.svPositionClip, unity_FogColor.rgb * GetPreExposureMultiplier());
#endif
surface.final.rgb = ClampExposed(surface.final.rgb);
#endif
#if defined(MK_SURFACE_TYPE_TRANSPARENT) && !defined(_MK_TRANSPARENT_RECEIVE_FOG_OFF)
#if defined(MK_BLEND_ADDITIVE)
surface.final.rgb = MixVolumetricFog(surface.final.rgb, surface.final.a, 2, false, surfaceData.svPositionClip);
#elif defined(MK_BLEND_MULTIPLY)
surface.final.rgb = MixVolumetricFog(surface.final.rgb, surface.final.a, 3, false, surfaceData.svPositionClip);
#elif defined(MK_BLEND_PREMULTIPLY)
surface.final.rgb = MixVolumetricFog(surface.final.rgb, surface.final.a, 1, true, surfaceData.svPositionClip);
#else
surface.final.rgb = MixVolumetricFog(surface.final.rgb, surface.final.a, 0, false, surfaceData.svPositionClip);
#endif
#endif
#elif defined(MK_FOG)
ApplyFog(surface.final.rgb, surfaceData.fogFactor);
#endif
}
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/Composite.hlsl
uploadId: 1012352
uploadId: 1023756
+10 -1
View File
@@ -18,6 +18,15 @@
/////////////////////////////////////////////////////////////////////////////////////////////
#include "GlobalShaderFeatures.hlsl"
#if defined(MK_URP) && UNITY_VERSION >= 60070000 && defined(APPLICATION_SPACE_WARP_MOTION_TRANSPARENT)
#define MK_ALPHA_LOOKUP
#endif
#if defined(MK_URP) && UNITY_VERSION >= 60070000 && defined(DEBUG_DISPLAY)
#define MK_TCM
#define MK_POS_WORLD
#endif
//CurvedWorldSupport
//CurvedWorldVertexData
//Uncomment Below
@@ -124,7 +133,7 @@
#endif
//Just a safety thing, not supported on every device
#if defined(UNITY_COMPILER_HLSL) || defined(SHADER_API_PSSL) || defined(UNITY_COMPILER_HLSLCC)
#if defined(UNITY_COMPILER_HLSL) || defined(SHADER_API_PSSL) || defined(UNITY_COMPILER_HLSLCC) || (defined(MK_URP) && UNITY_VERSION >= 60070000)
#define INITIALIZE_STRUCT(type, name) name = (type)0;
#else
#define INITIALIZE_STRUCT(type, name)
+2 -2
View File
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/Config.hlsl
uploadId: 1012352
uploadId: 1023756
+10
View File
@@ -40,6 +40,16 @@
#endif
//
#if defined(MK_URP) && UNITY_VERSION >= 60070000
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareExposureTexture.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/VolumetricFog.hlsl"
#define MK_LIGHT_ACCUM3 URP_LIGHT_ACCUM3
#define MK_LIGHT_ACCUM4 URP_LIGHT_ACCUM4
#else
#define MK_LIGHT_ACCUM3 half3
#define MK_LIGHT_ACCUM4 half4
#endif
struct MKInputDataWrapper
{
float2 normalizedScreenSpaceUV;
+2 -2
View File
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/Core.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/DepthNormals/Data.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -85,7 +85,9 @@
LODFadeCrossFade(vertexOutput.svPositionClip);
#endif
#if _SCREENSPACEREFLECTIONSCONTRIBUTETRANSPARENT_OFF_KEYWORD_DECLARED
#if UNITY_VERSION >= 60070000 && defined(_MK_SURFACE_TYPE_TRANSPARENT) && defined(_SCREENSPACEREFLECTIONSCONTRIBUTETRANSPARENT_OFF)
discard;
#elif UNITY_VERSION < 60070000 && _SCREENSPACEREFLECTIONSCONTRIBUTETRANSPARENT_OFF_KEYWORD_DECLARED
if (_SCREENSPACEREFLECTIONSCONTRIBUTETRANSPARENT_OFF)
discard;
#endif
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/DepthNormals/ProgramDepthNormals.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/DepthNormals/Setup.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/DepthOnly/Data.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/DepthOnly/ProgramDepthOnly.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/DepthOnly/Setup.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/DotsInstancingSetup.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/Forward/AddSetup.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/Forward/BaseSetup.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/Forward/Data.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -188,6 +188,10 @@
Surface surface = InitSurface(surfaceData, PASS_SAMPLER_2D(_AlbedoMap), _AlbedoColor, vertexOutputLight.SV_CLIP_POS);
MKPBSData pbsData = ComputePBSData(surface, surfaceData);
#if defined(MK_URP) && UNITY_VERSION >= 60070000 && defined(MK_LIT)
ComputeBakedGI(surfaceData);
#endif
#ifdef MK_LIT
//Init per mainLight
MKLight mainLight = ComputeMainLight(surfaceData, vertexOutputLight);
@@ -209,10 +213,10 @@
}
#if defined(_ADDITIONAL_LIGHTS)
half4 gD = surface.goochDark;
MK_LIGHT_ACCUM4 gD = surface.goochDark;
surface.goochDark = 0;
uint additionalLightCount = GetAdditionalLightsCount();
half4 additionalDirect = 0;
MK_LIGHT_ACCUM4 additionalDirect = 0;
MKLight additionalLight;
MKLightData additionalLightData;
@@ -261,10 +265,10 @@
}
#ifdef _ADDITIONAL_LIGHTS
half4 gD = surface.goochDark;
MK_LIGHT_ACCUM4 gD = surface.goochDark;
surface.goochDark = 0;
uint additionalLightCount = GetAdditionalLightsCount();
half4 additionalDirect = 0;
MK_LIGHT_ACCUM4 additionalDirect = 0;
MKLight additionalLight;
MKLightData additionalLightData;
@@ -300,10 +304,10 @@
#else
LightingDirect(surface, surfaceData, pbsData, mainLight, lightData, surface.direct);
#ifdef _ADDITIONAL_LIGHTS
half4 gD = surface.goochDark;
MK_LIGHT_ACCUM4 gD = surface.goochDark;
surface.goochDark = 0;
uint additionalLightCount = GetAdditionalLightsCount();
half4 additionalDirect = 0;
MK_LIGHT_ACCUM4 additionalDirect = 0;
for (uint lightIndex = 0u; lightIndex < additionalLightCount; ++lightIndex)
{
@@ -323,6 +327,61 @@
//Finalize the output
Composite(surface, surfaceData, pbsData);
#if defined(MK_URP) && UNITY_VERSION >= 60070000 && defined(DEBUG_DISPLAY)
InputData debugInput;
INITIALIZE_STRUCT(InputData, debugInput);
SurfaceData debugSurface;
INITIALIZE_STRUCT(SurfaceData, debugSurface);
debugInput.positionWS = surfaceData.positionWorld;
debugInput.positionCS = surfaceData.svPositionClip;
debugInput.normalWS = surfaceData.vertexNormalWorld;
debugInput.viewDirectionWS = GetWorldSpaceNormalizeViewDir(surfaceData.positionWorld);
debugInput.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(surfaceData.svPositionClip);
debugInput.preExposureMultiplier = GetPreExposureMultiplier();
debugSurface.albedo = surface.albedo;
debugSurface.alpha = surface.alpha;
debugSurface.metallic = pbsData.metallic;
debugSurface.specular = pbsData.specular;
debugSurface.smoothness = pbsData.smoothness;
debugSurface.normalTS = half3(0, 0, 1);
debugSurface.occlusion = 1;
#ifdef MK_LIT
debugInput.normalWS = surfaceData.normalWorld;
debugInput.bakedGI = surfaceData.bakedGI;
debugSurface.occlusion = surface.occlusion.r;
#ifdef MK_TBN
debugSurface.normalTS = mul(half3x3(surfaceData.tangentWorld, surfaceData.bitangentWorld, surfaceData.vertexNormalWorld), surfaceData.normalWorld);
#endif
#ifdef MK_EMISSION
debugSurface.emission = surface.emission;
#endif
#endif
SETUP_DEBUG_TEXTURE_DATA(debugInput, surfaceData.rawUV);
debugInput.originalColor = surface.albedo;
SetupDebugDataBrdf(debugInput, pbsData.diffuseRadiance, pbsData.specularRadiance);
half4 debugColor = 0;
bool debugOverride = CalculateColorForDebug(debugInput, debugSurface, debugColor);
if (_DebugMaterialMode == DEBUGMATERIALMODE_LIGHTING_COMPLEXITY)
{
debugColor = CalculateDebugLightingComplexityColor(debugInput, debugSurface);
debugOverride = true;
}
else if (_DebugLightingMode == DEBUGLIGHTINGMODE_GLOBAL_ILLUMINATION)
{
debugColor = half4(ClampExposed(debugInput.bakedGI * debugInput.preExposureMultiplier), surface.alpha);
debugOverride = true;
}
#ifdef MK_LIT
if (IsOnlyAOLightingFeatureEnabled())
{
debugColor = half4(surface.occlusion.rrr, surface.alpha);
debugOverride = true;
}
#endif
if (debugOverride)
surface.final = debugColor;
#endif
mkFragmentOutput.svTarget0 = surface.final;
#ifdef MK_WRITE_RENDERING_LAYERS
#if UNITY_VERSION >= 60020000
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/Forward/ProgramForward.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/GlobalShaderFeatures.hlsl
uploadId: 1012352
uploadId: 1023756
+102 -20
View File
@@ -84,8 +84,8 @@
struct MKLight
{
half3 color;
half3 radiometricColor;
MK_LIGHT_ACCUM3 color;
MK_LIGHT_ACCUM3 radiometricColor;
half3 dirWorld;
half attenuation;
half distanceAttenuation;
@@ -103,8 +103,8 @@
struct MKGI
{
half3 diffuse;
half3 specular;
MK_LIGHT_ACCUM3 diffuse;
MK_LIGHT_ACCUM3 specular;
};
struct MKGlossyEnvironmentData
@@ -212,7 +212,7 @@
#ifdef MK_LIT
#ifdef MK_VERTEX_LIGHTING
//should be automatically clamped (0 - 1) at a 8bit precision, still enough for a simple vertex lighting
half3 vertexLighting : COLOR1;
MK_LIGHT_ACCUM3 vertexLighting : COLOR1;
#endif
#ifdef MK_LIGHTMAP_UV
DECLARE_LIGHTMAP_UV(5);
@@ -351,6 +351,35 @@
}
//GI functions should match input
#if defined(MK_URP) && UNITY_VERSION >= 60070000 && defined(MK_LIT)
inline void ComputeBakedGI(inout MKSurfaceData surfaceData)
{
GIParams giParams;
INITIALIZE_STRUCT(GIParams, giParams);
#ifdef MK_LIGHTMAP_UV
#if defined(LIGHTMAP_ON)
giParams.staticLightmapUV = surfaceData.lightmapUV.xy;
#else
giParams.vertexSH = surfaceData.lightmapUV.rgb;
#endif
#if defined(DYNAMICLIGHTMAP_ON)
giParams.dynamicLightmapUV = surfaceData.lightmapUV.zw;
#endif
#endif
giParams.positionWS = surfaceData.positionWorld;
giParams.normalWS = surfaceData.normalWorld;
giParams.viewDirWS = GetWorldSpaceNormalizeViewDir(surfaceData.positionWorld);
giParams.positionSS = surfaceData.svPositionClip.xy;
#ifdef USE_APV_PROBE_OCCLUSION
giParams.vertexProbeOcclusion = surfaceData.probeOcclusion;
#endif
#ifdef MK_SURFACE_TYPE_TRANSPARENT
giParams.isSurfaceTypeTransparent = true;
#endif
InitializeBakedGI(giParams, surfaceData.bakedGI, surfaceData.shadowMask);
}
#endif
inline MKGI MKGlobalIllumination(in MKGlossyEnvironmentData glossyED, half occlusion, MKLight mkLight, in MKSurfaceData surfaceData)
{
MKGI gi;
@@ -359,7 +388,9 @@
gi.specular = half3(0,0,0);
#ifdef MK_INDIRECT
#if defined(MK_URP) || defined(MK_LWRP)
#if UNITY_VERSION >= 60000009
#if defined(MK_URP) && UNITY_VERSION >= 60070000
gi.diffuse = surfaceData.bakedGI;
#elif UNITY_VERSION >= 60000009
#if defined(_SCREEN_SPACE_IRRADIANCE)
gi.diffuse = SAMPLE_GI(_ScreenSpaceIrradiance, surfaceData.svPositionClip.xy);
#elif defined(DYNAMICLIGHTMAP_ON)
@@ -475,7 +506,7 @@
return gi;
}
inline half3 ComputeVertexLighting(float3 positionWorld, half3 normalWorld)
inline MK_LIGHT_ACCUM3 ComputeVertexLighting(float3 positionWorld, half3 normalWorld)
{
#if defined(MK_URP) || defined(MK_LWRP)
return VertexLighting(positionWorld, normalWorld);
@@ -609,7 +640,11 @@
float lightRangeSqr = Rcp(distanceAndSpotAttenuation.x);
#if(META_QUEST_NO_SPOTLIGHTS_LIGHT_LOOP)
light.distanceAttenuation = DistanceAttenuation(distanceSqr, distanceAndSpotAttenuation.xy);
#if defined(MK_URP) && UNITY_VERSION >= 60070000 && defined(UNITY_PLATFORM_META_QUEST)
light.distanceAttenuation = DistanceAttenuation(distanceSqr, distanceAndSpotAttenuation.xy, rsqrt(distanceSqr));
#else
light.distanceAttenuation = DistanceAttenuation(distanceSqr, distanceAndSpotAttenuation.xy);
#endif
#else
light.distanceAttenuation = saturate(saturate((1 - (distanceSqr / lightRangeSqr)) * 5.0) * Rcp(1.0 + 25.0 * distanceSqr / lightRangeSqr)) * AngleAttenuation(spotDirection.xyz, LightDir, distanceAndSpotAttenuation.zw);
#endif
@@ -623,7 +658,13 @@
INITIALIZE_STRUCT(MKLight, mkLight);
#if defined(MK_URP) || defined(MK_LWRP)
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
#if defined(MK_URP) && UNITY_VERSION >= 70000000
#ifdef MK_SURFACE_TYPE_TRANSPARENT
vertexOutputLight._ShadowCoord = TransformWorldToShadowCoord(surfaceData.positionWorld, true, surfaceData.vertexNormalWorld);
#else
vertexOutputLight._ShadowCoord = TransformWorldToShadowCoord(surfaceData.positionWorld, false, surfaceData.vertexNormalWorld);
#endif
#elif defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
//skip interpolator...
#elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
vertexOutputLight._ShadowCoord = TransformWorldToShadowCoord(surfaceData.positionWorld);
@@ -636,7 +677,19 @@
Light light;
INITIALIZE_STRUCT(Light, light);
#if defined(MK_URP_2020_2_Or_Newer)
#if defined(MK_URP) && UNITY_VERSION >= 70000000
bool receiveShadows = false;
bool isTransparent = false;
#ifdef _MK_RECEIVE_SHADOWS
receiveShadows = true;
#endif
#ifdef MK_SURFACE_TYPE_TRANSPARENT
isTransparent = true;
#endif
light = GetMainLight();
light.shadowAttenuation = MainLightShadow(vertexOutputLight._ShadowCoord, surfaceData.positionWorld, surfaceData.shadowMask, _MainLightOcclusionProbes, receiveShadows, isTransparent, surfaceData.svPositionClip.xy);
ApplyMainLightCookieAndFog(light, surfaceData.positionWorld);
#elif defined(MK_URP_2020_2_Or_Newer)
light = GetMainLight(vertexOutputLight._ShadowCoord, surfaceData.positionWorld, surfaceData.shadowMask);
#else
light = GetMainLight(vertexOutputLight._ShadowCoord);
@@ -686,6 +739,13 @@
mkLight.radiometricColor = mkLight.color * PI;
#endif
#if defined(MK_URP) && UNITY_VERSION >= 60070000 && defined(DEBUG_DISPLAY)
if (!IsLightingFeatureEnabled(DEBUGLIGHTINGFEATUREFLAGS_MAIN_LIGHT))
{
mkLight.color = 0;
mkLight.radiometricColor = 0;
}
#endif
return mkLight;
}
@@ -696,7 +756,13 @@
INITIALIZE_STRUCT(MKLight, mkLight);
Light light;
INITIALIZE_STRUCT(Light, light);
#if defined(MK_URP_2020_2_Or_Newer)
#if defined(MK_URP) && UNITY_VERSION >= 70000000
bool receiveShadows = false;
#ifdef _MK_RECEIVE_SHADOWS
receiveShadows = true;
#endif
light = GetAdditionalLight(index, surfaceData.positionWorld, surfaceData.shadowMask, receiveShadows, surfaceData.vertexNormalWorld, surfaceData.svPositionClip.xy, true);
#elif defined(MK_URP_2020_2_Or_Newer)
light = GetAdditionalLight(index, surfaceData.positionWorld, surfaceData.shadowMask);
#else
light = GetAdditionalLight(index, surfaceData.positionWorld);
@@ -725,6 +791,13 @@
mkLight.layerMask = light.layerMask;
#endif
#if defined(MK_URP) && UNITY_VERSION >= 60070000 && defined(DEBUG_DISPLAY)
if (!IsLightingFeatureEnabled(DEBUGLIGHTINGFEATUREFLAGS_ADDITIONAL_LIGHTS))
{
mkLight.color = 0;
mkLight.radiometricColor = 0;
}
#endif
return mkLight;
#else
//On Legacy RP additional lights are computed per pass
@@ -935,8 +1008,8 @@
surface.indirect = pbsData.specularRadiance * pbsData.reflectivity;
#endif
half3 iL;
half3 indirectReflectRadiance;
MK_LIGHT_ACCUM3 iL;
MK_LIGHT_ACCUM3 indirectReflectRadiance;
#if defined(MK_PBS)
indirectReflectRadiance = pbsData.specularRadiance;
#else //Simple
@@ -962,7 +1035,16 @@
surface.indirectFade = lerp(surface.indirectFade, pbsData.reflectivity, pbsData.reflectivity);
#endif
#if defined(MK_URP) && UNITY_VERSION >= 60070000 && defined(DEBUG_DISPLAY)
if (!IsLightingFeatureEnabled(DEBUGLIGHTINGFEATUREFLAGS_GLOBAL_ILLUMINATION))
surface.indirect = 0;
#endif
#ifdef MK_EMISSION
#if defined(MK_URP) && UNITY_VERSION >= 60070000 && defined(DEBUG_DISPLAY)
if (!IsLightingFeatureEnabled(DEBUGLIGHTINGFEATUREFLAGS_EMISSION))
surface.emission = 0;
#endif
//Emission handled as indirect
surface.indirect += surface.emission;
#endif
@@ -1069,7 +1151,7 @@
#endif
}
inline void MKLightingSFX(inout Surface surface, in MKSurfaceData surfaceData, in MKPBSData pbsData, in MKLight light, in MKLightData lightData, in half4 diffuse, inout half4 finalLightColor)
inline void MKLightingSFX(inout Surface surface, in MKSurfaceData surfaceData, in MKPBSData pbsData, in MKLight light, in MKLightData lightData, in MK_LIGHT_ACCUM4 diffuse, inout MK_LIGHT_ACCUM4 finalLightColor)
{
#ifdef MK_LIT
half3 goochRamp;
@@ -1090,7 +1172,7 @@
//Surface Direct + Gooch
#ifdef MK_SPECULAR
half4 specular;
MK_LIGHT_ACCUM4 specular;
#if defined(MK_PBS)
//Distribution - Geometric - Fresnel
half distribution, geometric;
@@ -1135,7 +1217,7 @@
#endif
#ifdef MK_LightTransmission
half4 lightTransmission;
MK_LIGHT_ACCUM4 lightTransmission;
//A scaling could be implemented here: dot(vohld, scale) then saturate
lightTransmission.a = FastPow4(lightData.VoLND);
//Based on Colin Barre-Brisebois - GDC 2011 - Approximating Translucency for a Fast, Cheap and Convincing Subsurface-Scattering
@@ -1180,11 +1262,11 @@
#endif
}
inline void LightingDirectAdditional(inout Surface surface, in MKSurfaceData surfaceData, in MKPBSData pbsData, inout MKLight light, in MKLightData lightData, out half4 finalLightColor)
inline void LightingDirectAdditional(inout Surface surface, in MKSurfaceData surfaceData, in MKPBSData pbsData, inout MKLight light, in MKLightData lightData, out MK_LIGHT_ACCUM4 finalLightColor)
{
#ifdef MK_LIT
half diffuseRaw = MKLightingDiffuseAdditional(surface, surfaceData, pbsData, light, lightData, _AdditionalLightsThreshold);
half4 diffuse = half4(0, 0, 0, diffuseRaw);
MK_LIGHT_ACCUM4 diffuse = half4(0, 0, 0, diffuseRaw);
#ifndef MK_STYLIZE_SYSTEM_SHADOWS
ARTISTIC_RAW_MASKED(diffuse.a, 0, light.distanceAttenuation);
#else
@@ -1197,7 +1279,7 @@
#endif
}
inline void LightingDirect(inout Surface surface, in MKSurfaceData surfaceData, in MKPBSData pbsData, in MKLight light, inout MKLightData lightData, out half4 finalLightColor)
inline void LightingDirect(inout Surface surface, in MKSurfaceData surfaceData, in MKPBSData pbsData, in MKLight light, inout MKLightData lightData, out MK_LIGHT_ACCUM4 finalLightColor)
{
#ifdef MK_LIT
#ifdef MK_LEGACY_RP
@@ -1210,7 +1292,7 @@
half diffuseRaw = MKLightingDiffuse(surface, surfaceData, pbsData, light, lightData, _LightThreshold);
#endif
half4 diffuse = half4(0, 0, 0, diffuseRaw);
MK_LIGHT_ACCUM4 diffuse = half4(0, 0, 0, diffuseRaw);
#ifndef MK_STYLIZE_SYSTEM_SHADOWS
ARTISTIC_RAW_MASKED(diffuse.a, 0, light.distanceAttenuation);
#else
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/Lighting.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/Meta/Common.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/Meta/Data.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/Meta/ProgramMeta.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/Meta/Setup.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/MotionVectors/Data.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -23,6 +23,20 @@
UNITY_TRANSFER_INSTANCE_ID(vertexInput, vertexOutput);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(vertexOutput);
#if defined(MK_URP) && UNITY_VERSION >= 60070000
float4 previousVertex = unity_MotionVectorsParams.x == 1 ? float4(vertexInput.positionOld, 1) : vertexInput.vertex;
#if _ADD_PRECOMPUTED_VELOCITY
previousVertex.xyz -= vertexInput.alembicMotionVector;
#endif
#ifdef MK_VERTEX_ANIMATION
previousVertex.xyz = VertexAnimation(_VertexAnimationMap, PASS_VERTEX_ANIMATION_UV(vertexInput.texcoord0.xy), _VertexAnimationIntensity, _VertexAnimationFrequency.xyz, previousVertex.xyz, _LastTimeParameters.x
#ifndef MK_VERTEX_ANIMATION_SINE
, vertexInput.normal
#endif
);
#endif
#endif
#ifdef MK_VERTEX_ANIMATION
vertexInput.vertex.xyz = VertexAnimation(PASS_VERTEX_ANIMATION_ARG(_VertexAnimationMap, PASS_VERTEX_ANIMATION_UV(vertexInput.texcoord0.xy), _VertexAnimationIntensity, _VertexAnimationFrequency.xyz, vertexInput.vertex.xyz, vertexInput.normal));
#endif
@@ -67,9 +81,13 @@
vertexOutput.positionCSNoJitter = mul(_NonJitteredViewProjMatrix, mul(MATRIX_M, vertexInput.vertex));
#endif
float4 prevPos = (unity_MotionVectorsParams.x == 1) ? float4(vertexInput.positionOld, 1) : vertexInput.vertex;
#if _ADD_PRECOMPUTED_VELOCITY
prevPos = prevPos - float4(vertexInput.alembicMotionVector, 0);
#if defined(MK_URP) && UNITY_VERSION >= 60070000
float4 prevPos = previousVertex;
#else
float4 prevPos = (unity_MotionVectorsParams.x == 1) ? float4(vertexInput.positionOld, 1) : vertexInput.vertex;
#if _ADD_PRECOMPUTED_VELOCITY
prevPos = prevPos - float4(vertexInput.alembicMotionVector, 0);
#endif
#endif
vertexOutput.previousPositionCSNoJitter = mul(_PrevViewProjMatrix, mul(UNITY_PREV_MATRIX_M, prevPos));
#ifndef MK_URP_6000_1_0_OR_NEWER
@@ -113,6 +131,9 @@
#endif
#if defined(APPLICATION_SPACE_WARP_MOTION)
#if UNITY_VERSION >= 60070000 && defined(APPLICATION_SPACE_WARP_MOTION_TRANSPARENT)
clip(surface.alpha - 0.001);
#endif
return float4(CalcAswNdcMotionVectorFromCsPositions(vertexOutput.positionCSNoJitter, vertexOutput.previousPositionCSNoJitter), 1);
#else
return float4(CalcNdcMotionVectorFromCsPositions(vertexOutput.positionCSNoJitter, vertexOutput.previousPositionCSNoJitter), 0, 0);
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/MotionVectors/ProgramMotionVectors.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/MotionVectors/Setup.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/Outline/Data.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/Outline/ProgramOutline.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/Outline/Setup.hlsl
uploadId: 1012352
uploadId: 1023756
+25 -5
View File
@@ -636,15 +636,23 @@
/////////////////////////////////////////////////////////////////////////////////////////////
// Refraction
/////////////////////////////////////////////////////////////////////////////////////////////
#if defined(MK_URP) || defined(MK_LWRP)
#if defined(MK_URP) && UNITY_VERSION >= 60070000
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareOpaqueTexture.hlsl"
#elif defined(MK_URP) || defined(MK_LWRP)
UNIFORM_TEXTURE_2D_AUTO(_CameraOpaqueTexture)
#else
UNIFORM_TEXTURE_2D_AUTO(_MKToonRefraction)
#endif
inline half3 SampleRefraction(float2 uv)
inline MK_LIGHT_ACCUM3 SampleRefraction(float2 uv)
{
#if defined(MK_URP) || defined(MK_LWRP)
#if defined(MK_URP) && UNITY_VERSION >= 60070000
#ifdef MK_LIT
return MK_LIGHT_ACCUM3(SampleSceneColor(uv)) * GetInvPreExposureMultiplier();
#else
return SampleSceneColor(uv);
#endif
#elif defined(MK_URP) || defined(MK_LWRP)
return SampleTex2DAuto(PASS_TEXTURE_2D(_CameraOpaqueTexture, SAMPLER_CLAMPED_MAIN), uv).rgb;
#else
return SampleTex2DAuto(PASS_TEXTURE_2D(_MKToonRefraction, SAMPLER_CLAMPED_MAIN), uv).rgb;
@@ -654,11 +662,23 @@
/////////////////////////////////////////////////////////////////////////////////////////////
// Depth
/////////////////////////////////////////////////////////////////////////////////////////////
UNIFORM_SAMPLER_AND_TEXTURE_2D_AUTO_HP(_CameraDepthTexture)
#if defined(MK_URP) && UNITY_VERSION >= 60070000
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"
#else
UNIFORM_SAMPLER_AND_TEXTURE_2D_AUTO_HP(_CameraDepthTexture)
#endif
inline float SampleDepth(float2 uv)
{
return SampleTex2DAutoHP(PASS_TEXTURE_2D(_CameraDepthTexture, SAMPLER_CLAMPED_MAIN), uv).r;
#if defined(MK_URP) && UNITY_VERSION >= 70000000 && defined(_DEPTH_AS_INPUT_ATTACHMENT)
return FetchSceneDepth(uv * _ScreenSize.xy);
#elif defined(MK_URP) && UNITY_VERSION >= 70000000 && defined(_DEPTH_AS_INPUT_ATTACHMENT_MSAA)
return FetchSceneDepth(uv * _ScreenSize.xy, 0);
#elif defined(MK_URP) && UNITY_VERSION >= 60070000
return SampleSceneDepth(uv);
#else
return SampleTex2DAutoHP(PASS_TEXTURE_2D(_CameraDepthTexture, SAMPLER_CLAMPED_MAIN), uv).r;
#endif
}
/////////////////////////////////////////////////////////////////////////////////////////////
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/Pipeline.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/RenderersSetup.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/ShadowCaster/Data.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/ShadowCaster/ProgramShadowCaster.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/ShadowCaster/Setup.hlsl
uploadId: 1012352
uploadId: 1023756
+89 -20
View File
@@ -25,16 +25,19 @@
#if defined(MK_DEPTH_NORMALS_PASS) || defined(MK_LIT)
half3 normalWorld;
#endif
#ifdef MK_TBN
half3 tangentWorld;
half3 bitangentWorld;
#endif
#ifdef MK_LIT
#if defined(MK_URP) && UNITY_VERSION >= 60070000
MK_LIGHT_ACCUM3 bakedGI;
#endif
#ifdef MK_LIGHTMAP_UV
float4 lightmapUV;
#endif
#ifdef MK_VERTEX_LIGHTING
half3 vertexLighting;
#endif
#ifdef MK_TBN
half3 tangentWorld;
half3 bitangentWorld;
MK_LIGHT_ACCUM3 vertexLighting;
#endif
#ifdef MK_PARALLAX
half height;
@@ -124,8 +127,8 @@
half smoothness;
half metallic;
half3 specular;
half3 diffuseRadiance;
half3 specularRadiance;
MK_LIGHT_ACCUM3 diffuseRadiance;
MK_LIGHT_ACCUM3 specularRadiance;
#ifdef MK_FRESNEL_HIGHLIGHTS
half3 fresnel;
#endif
@@ -134,14 +137,14 @@
//dynamic surface struct
struct Surface
{
half4 final;
half3 albedo;
MK_LIGHT_ACCUM4 final;
MK_LIGHT_ACCUM3 albedo;
#ifdef MK_DETAIL_MAP
half4 detail;
#endif
half alpha;
#ifdef MK_REFRACTION
half3 refraction;
MK_LIGHT_ACCUM3 refraction;
#endif
// RGB - RAW
@@ -150,15 +153,15 @@
#ifdef MK_THRESHOLD_MAP
half thresholdOffset;
#endif
half4 goochBright;
half4 goochDark;
MK_LIGHT_ACCUM4 goochBright;
MK_LIGHT_ACCUM4 goochDark;
half2 occlusion;
#ifdef MK_EMISSION
half3 emission;
MK_LIGHT_ACCUM3 emission;
#endif
half3 indirect;
half4 direct;
MK_LIGHT_ACCUM3 indirect;
MK_LIGHT_ACCUM4 direct;
#ifdef MK_ARTISTIC
#if defined(MK_ARTISTIC_DRAWN) || defined(MK_ARTISTIC_SKETCH)
@@ -286,7 +289,7 @@
}
//Texture color
inline void SurfaceColor(out half3 albedo, out half alpha, DECLARE_SAMPLER_2D_ARGS(albedoMap), float2 uv, float3 blendUV, half4 color)
inline void SurfaceColor(out MK_LIGHT_ACCUM3 albedo, out half alpha, DECLARE_SAMPLER_2D_ARGS(albedoMap), float2 uv, float3 blendUV, half4 color)
{
half4 c;
#ifdef MK_OUTLINE_PASS
@@ -303,7 +306,7 @@
#endif
}
inline void SurfaceColor(out half3 albedo, out half alpha, DECLARE_SAMPLER_2D_ARGS(albedoMap), DECLARE_SAMPLER_2D_ARGS(albedoMap1), DECLARE_SAMPLER_2D_ARGS(albedoMap2), DECLARE_SAMPLER_2D_ARGS(albedoMap3), float2 uv, half4 blendColor, float3 blendUV, half4 color)
inline void SurfaceColor(out MK_LIGHT_ACCUM3 albedo, out half alpha, DECLARE_SAMPLER_2D_ARGS(albedoMap), DECLARE_SAMPLER_2D_ARGS(albedoMap1), DECLARE_SAMPLER_2D_ARGS(albedoMap2), DECLARE_SAMPLER_2D_ARGS(albedoMap3), float2 uv, half4 blendColor, float3 blendUV, half4 color)
{
half4 c0, c1, c2, c3;
#ifdef MK_OUTLINE_PASS
@@ -329,7 +332,7 @@
}
//Non texture color
inline void SurfaceColor(out half3 albedo, out half alpha, half4 vertexColor, half4 color)
inline void SurfaceColor(out MK_LIGHT_ACCUM3 albedo, out half alpha, half4 vertexColor, half4 color)
{
half4 c = vertexColor * color;
albedo = c.rgb;
@@ -365,7 +368,7 @@
, in half3 normalWorld
#endif
#ifdef MK_VERTEX_LIGHTING
, in half3 vertexLighting
, in MK_LIGHT_ACCUM3 vertexLighting
#endif
#if defined(MK_TBN)
, in half3 tangentWorld
@@ -496,6 +499,13 @@
#if defined(MK_SCREEN_SPACE_OCCLUSION) && defined(MK_URP_2020_2_Or_Newer)
surfaceData.ambientOcclusion = GetScreenSpaceAmbientOcclusion(surfaceData.screenUV.xy);
#if defined(MK_URP) && UNITY_VERSION >= 60070000 && defined(DEBUG_DISPLAY)
if (!IsLightingFeatureEnabled(DEBUGLIGHTINGFEATUREFLAGS_AMBIENT_OCCLUSION))
{
surfaceData.ambientOcclusion.directAmbientOcclusion = 1;
surfaceData.ambientOcclusion.indirectAmbientOcclusion = 1;
}
#endif
#endif
#if defined(MK_ARTISTIC)
@@ -689,7 +699,9 @@
half4 pbsInput;
#if defined(MK_WORKFLOW_METALLIC)
#if defined(MK_URP) && UNITY_VERSION >= 60070000 && !defined(MK_LIT)
pbsInput = half4(0, 0, 0, 1);
#elif defined(MK_WORKFLOW_METALLIC)
#ifdef MK_PBS_MAP_0
pbsInput = SAMPLE_TEX2D_FLIPBOOK(_MetallicMap, SAMPLER_REPEAT_MAIN, surfaceData.baseUV.xy, SURFACE_FLIPBOOK_UV).rrra;
pbsInput.a *= _Smoothness;
@@ -776,6 +788,53 @@
#endif
#endif
#if defined(MK_URP) && UNITY_VERSION >= 60070000 && defined(DEBUG_DISPLAY)
InputData debugInput;
INITIALIZE_STRUCT(InputData, debugInput);
SurfaceData debugSurface;
INITIALIZE_STRUCT(SurfaceData, debugSurface);
debugInput.positionWS = surfaceData.positionWorld;
debugInput.normalWS = surfaceData.vertexNormalWorld;
#ifdef MK_LIT
debugInput.normalWS = surfaceData.normalWorld;
debugSurface.occlusion = surface.occlusion.r;
#ifdef MK_EMISSION
debugSurface.emission = surface.emission;
#endif
#endif
#ifdef MK_TBN
debugInput.tangentToWorld = half3x3(surfaceData.tangentWorld, surfaceData.bitangentWorld, surfaceData.vertexNormalWorld);
#endif
debugSurface.albedo = surface.albedo;
debugSurface.alpha = surface.alpha;
debugSurface.metallic = pbsData.metallic;
debugSurface.specular = pbsData.specular;
debugSurface.smoothness = pbsData.smoothness;
UpdateSurfaceAndInputDataForDebug(debugSurface, debugInput);
if (!IsLightingFeatureEnabled(DEBUGLIGHTINGFEATUREFLAGS_AMBIENT_OCCLUSION))
debugSurface.occlusion = 1;
if (_DebugLightingMode == DEBUGLIGHTINGMODE_SHADOW_CASCADES)
debugSurface.albedo = CalculateDebugShadowCascadeColor(debugInput);
surface.albedo = debugSurface.albedo;
pbsData.metallic = debugSurface.metallic;
pbsData.specular = debugSurface.specular;
pbsData.smoothness = debugSurface.smoothness;
#ifdef MK_LIT
surfaceData.normalWorld = debugInput.normalWS;
surface.occlusion.r = debugSurface.occlusion;
#ifdef MK_EMISSION
surface.emission = debugSurface.emission;
#endif
#ifdef MK_V_DOT_N
surfaceData.VoN = saturate(dot(surfaceData.viewWorld, surfaceData.normalWorld));
surfaceData.OneMinusVoN = 1.0 - surfaceData.VoN;
#endif
#ifdef MK_MV_REF_N
surfaceData.MVrN = reflect(-surfaceData.viewWorld, surfaceData.normalWorld);
#endif
#endif
#endif
#if defined(MK_WORKFLOW_METALLIC)
pbsData.oneMinusReflectivity = K_SPEC_DIELECTRIC_MAX - pbsData.metallic * K_SPEC_DIELECTRIC_MAX;
pbsData.reflectivity = 1.0 - pbsData.oneMinusReflectivity;
@@ -798,6 +857,16 @@
pbsData.specularRadiance = pbsData.specular.rgb;
#endif
#if defined(MK_URP) && UNITY_VERSION >= 60070000 && defined(DEBUG_DISPLAY)
if (_DebugLightingMode == DEBUGLIGHTINGMODE_REFLECTIONS || _DebugLightingMode == DEBUGLIGHTINGMODE_REFLECTIONS_WITH_SMOOTHNESS)
{
pbsData.diffuseRadiance = 0;
pbsData.specularRadiance = 1;
pbsData.reflectivity = 1;
pbsData.oneMinusReflectivity = 0;
}
#endif
pbsData.roughness = 1.0 - pbsData.smoothness;
#if defined(MK_ENVIRONMENT_REFLECTIONS) || defined(MK_SPECULAR) || defined(MK_DIFFUSE_OREN_NAYAR) || defined(MK_DIFFUSE_MINNAERT)
pbsData.roughnessPow2 = FastPow2(pbsData.roughness);
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/Surface.hlsl
uploadId: 1012352
uploadId: 1023756
+6
View File
@@ -10,6 +10,9 @@
#define MK_TOON_UNIFORM
#include "Pipeline.hlsl"
#if defined(MK_URP) && UNITY_VERSION >= 60070000
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl"
#endif
/////////////////////////////////////////////////////////////////////////////////////////////
// UNIFORM VARIABLES
@@ -27,6 +30,9 @@
// Sampler2D | Sampler3D
CBUFFER_START(UnityPerMaterial)
#if defined(MK_URP) && UNITY_VERSION >= 60070000
UNITY_TEXTURE_STREAMING_DEBUG_VARS
#endif
uniform float4 _AlbedoMap_ST;
uniform float4 _MainTex_ST;
uniform float4 _DetailMap_ST;
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/Uniform.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/Universal2D/Data.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/Universal2D/ProgramUniversal2D.hlsl
uploadId: 1012352
uploadId: 1023756
@@ -11,6 +11,6 @@ AssetOrigin:
serializedVersion: 1
productId: 178415
packageName: MK Toon - Stylized Shader
packageVersion: 3.5.0C
packageVersion: 3.5.0D
assetPath: Assets/MK/MKToon/Shader/Lib/Universal2D/Setup.hlsl
uploadId: 1012352
uploadId: 1023756