diff --git a/Assets.meta b/Assets.meta new file mode 100644 index 0000000..a9fe4a0 --- /dev/null +++ b/Assets.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7faec3fe2d94ffc45b3832fa4aa8eb22 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/CHANGELOG.md b/CHANGELOG.md index c7d78f3..42e3fc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +#1.1.12 +- DCL_Toon: declared `_MetallicGlossMapArr` and `_MatCap_SamplerArr` in the Properties block (they existed only in HLSL), so the texture-array path can actually bind the stylized-metallic mask + matcap arrays via `material.SetTexture` (texture-array consumers like unity-explorer) + +#1.1.11 +- DCL_Toon: promoted `_MatCapColor` and `_BlurLevelMatcap` from compile-time constants to runtime per-material properties, so matcap tint and blur can be driven per material (e.g. from `MatcapPresets`) + +#1.1.10 +- DCL_Toon: added `MatcapPresets` ScriptableObject + bundled matcap library as the shared source of truth for stylized-metallic matcaps (consumed by aang-renderer, unity-explorer and future repos) + +#1.1.9 +- DCL_Toon: added normal map support (base/high-color/rim shading + DepthNormals for SSAO) +- DCL_Toon: added stylized metallic via matcap, driven by per-renderer `_IsStylizedMetallic` and an optional `_MetallicGlossMap` mask + #1.1.8 - Reverted gltfast version to 5.0.0 diff --git a/Runtime/Shaders/Avatar/DCL_Toon/DCL_Toon.shader b/Runtime/Shaders/Avatar/DCL_Toon/DCL_Toon.shader index 92a7c2e..10f8311 100644 --- a/Runtime/Shaders/Avatar/DCL_Toon/DCL_Toon.shader +++ b/Runtime/Shaders/Avatar/DCL_Toon/DCL_Toon.shader @@ -11,6 +11,8 @@ Shader "DCL/DCL_Toon" [HideInInspector] [PerRendererData] _MatCap_SamplerArr_ID ("MatCap Array ID", Integer) = -1 [HideInInspector] [PerRendererData] _Emissive_TexArr_ID ("Emissive Array ID", Integer) = -1 [HideInInspector] [PerRendererData] _MetallicGlossMapArr_ID ("MetallicGlossMap Array ID", Integer) = -1 + [HideInInspector] [PerRendererData] _IsStylizedMetallic ("Is Stylized Metallic (matcap)", Integer) = 0 + [HideInInspector] [PerRendererData] _IsIridescent ("Is Iridescent (matcap)", Integer) = 0 [HideInInspector] [PerRendererData] _lastWearableVertCount ("Last wearable Vert Count", Integer) = -1 [HideInInspector] [PerRendererData] _lastAvatarVertCount ("Last avatar vert count", Integer) = -1 @@ -24,6 +26,8 @@ Shader "DCL/DCL_Toon" [HideInInspector] _MainTexArr ("Main Texture Array", 2DArray) = "white" {} [HideInInspector] _NormalMapArr ("Normal Texture Array", 2DArray) = "bump" {} [HideInInspector] _Emissive_TexArr ("Emissive Texture Array", 2DArray) = "black" {} + [HideInInspector] _MetallicGlossMapArr ("MetallicGloss Texture Array", 2DArray) = "black" {} + [HideInInspector] _MatCap_SamplerArr ("MatCap Texture Array", 2DArray) = "black" {} [HideInInspector] _simpleUI ("SimpleUI", Int ) = 0 @@ -133,6 +137,9 @@ Shader "DCL/DCL_Toon" // [Toggle(_)] _MatCap ("MatCap", Float ) = 0 _MatCap_Sampler ("MatCap_Sampler", 2D) = "black" {} + // Stylized-metallic mask (non-array path). glTF metallic-roughness map or a baked metallicFactor; + // the frag reads the metallic (.b) channel. Default black => no metal when no map is bound. + _MetallicGlossMap ("MetallicGlossMap (stylized metal mask)", 2D) = "black" {} //v.2.0.6 _BlurLevelMatcap ("Blur Level of MatCap_Sampler", Range(0, 10)) = 0 _MatCapColor ("MatCapColor", Color) = (1,1,1,1) diff --git a/Runtime/Shaders/Avatar/DCL_Toon/DCL_ToonBodyDoubleShadeWithFeather.hlsl b/Runtime/Shaders/Avatar/DCL_Toon/DCL_ToonBodyDoubleShadeWithFeather.hlsl index ed3025d..af2a7fb 100644 --- a/Runtime/Shaders/Avatar/DCL_Toon/DCL_ToonBodyDoubleShadeWithFeather.hlsl +++ b/Runtime/Shaders/Avatar/DCL_Toon/DCL_ToonBodyDoubleShadeWithFeather.hlsl @@ -8,10 +8,19 @@ float4 fragDoubleShadeFeather(VertexOutput i, half facing : VFACE) : SV_TARGET float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir); int nNormalMapArrID = _NormalMapArr_ID; - float3 _NormalMap_var = UnpackNormalScale(SAMPLE_NORMALMAP(TRANSFORM_TEX(Set_UV0, _NormalMap), nNormalMapArrID), _BumpScale); - - float3 normalLocal = _NormalMap_var.rgb; - float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals + float3 normalDirection; + // Uniform branch (per-material ID): materials without a normal map fall back to the + // geometric normal instead of sampling an invalid (-1) array slice. + if (nNormalMapArrID < 0) + { + normalDirection = i.normalDir; + } + else + { + float3 _NormalMap_var = UnpackNormalScale(SAMPLE_NORMALMAP(TRANSFORM_TEX(Set_UV0, _NormalMap), nNormalMapArrID), _BumpScale); + float3 normalLocal = _NormalMap_var.rgb; + normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals + } // todo. not necessary to calc gi factor in shadowcaster pass. @@ -182,8 +191,11 @@ float4 fragDoubleShadeFeather(VertexOutput i, half facing : VFACE) : SV_TARGET half _Camera_Dir = _Camera_Right.y < 0 ? -1 : 1; float _Rot_MatCapUV_var_ang = (fRotate_MatCapUV*3.141592654) - _Camera_Dir*_Camera_Roll*_CameraRolling_Stabilizer; float2 _Rot_MatCapNmUV_var = RotateUV(Set_UV0, (_Rotate_NormalMapForMatCapUV*3.141592654), float2(0.5, 0.5), 1.0); - // MatCap with camera skew correction - float3 viewNormal = (mul(UNITY_MATRIX_V, float4(i.normalDir,0))).rgb; + // MatCap with camera skew correction. + // Use the normal-mapped world normal (normalDirection) so the matcap sheen catches normal-map + // detail. Falls back to the geometric normal automatically when no normal map is set, because + // normalDirection == i.normalDir in that case (see the _NormalMapArr_ID guard at the top). + float3 viewNormal = (mul(UNITY_MATRIX_V, float4(normalDirection,0))).rgb; //float3 viewNormal = (mul(UNITY_MATRIX_V, float4(lerp( i.normalDir, mul( _NormalMapForMatCap_var.rgb, tangentTransform ).rgb, _Is_NormalMapForMatCap ),0))).rgb; float3 NormalBlend_MatcapUV_Detail = viewNormal.rgb * float3(-1,-1,1); float3 NormalBlend_MatcapUV_Base = (mul( UNITY_MATRIX_V, float4(viewDirection,0) ).rgb*float3(-1,-1,1)) + float3(0,0,1); @@ -201,23 +213,73 @@ float4 fragDoubleShadeFeather(VertexOutput i, half facing : VFACE) : SV_TARGET _Rot_MatCapUV_var = _Rot_MatCapUV_var; } - int nMatCap_SamplerArrID = _MatCap_SamplerArr_ID; - float4 _MatCap_Sampler_var = SAMPLE_MATCAP(TRANSFORM_TEX(_Rot_MatCapUV_var, _MatCap_Sampler), nMatCap_SamplerArrID, _BlurLevelMatcap); - - // MatcapMask - float _Tweak_MatcapMaskLevel_var = 1.0f;//saturate(lerp(_Set_MatcapMask_var.g, (1.0 - _Set_MatcapMask_var.g), _Inverse_MatcapMask) + _Tweak_MatcapMaskLevel); - float3 _Is_LightColor_MatCap_var = lerp( (_MatCap_Sampler_var.rgb*_MatCapColor.rgb), ((_MatCap_Sampler_var.rgb*_MatCapColor.rgb)*Set_LightColor), _Is_LightColor_MatCap ); - // ShadowMask on Matcap in Blend mode : multiply - float3 Set_MatCap = lerp( _Is_LightColor_MatCap_var, (_Is_LightColor_MatCap_var*((1.0 - Set_FinalShadowMask)+(Set_FinalShadowMask*_TweakMatCapOnShadow)) + lerp(Set_HighColor*Set_FinalShadowMask*(1.0-_TweakMatCapOnShadow), float3(0.0, 0.0, 0.0), _Is_BlendAddToMatCap)), _Is_UseTweakMatCapOnShadow ); - - // Composition: RimLight and MatCap as finalColor - // Broke down finalColor composition - float3 matCapColorOnAddMode = _RimLight_var+Set_MatCap*_Tweak_MatcapMaskLevel_var; - float _Tweak_MatcapMaskLevel_var_MultiplyMode = _Tweak_MatcapMaskLevel_var * lerp (1.0, (1.0 - (Set_FinalShadowMask)*(1.0 - _TweakMatCapOnShadow)), _Is_UseTweakMatCapOnShadow); - float3 matCapColorOnMultiplyMode = Set_HighColor*(1-_Tweak_MatcapMaskLevel_var_MultiplyMode) + Set_HighColor*Set_MatCap*_Tweak_MatcapMaskLevel_var_MultiplyMode + lerp(float3(0,0,0),Set_RimLight,_RimLight); - float3 matCapColorFinal = lerp(matCapColorOnMultiplyMode, matCapColorOnAddMode, _Is_BlendAddToMatCap); - float3 finalColor = lerp(_RimLight_var, matCapColorFinal, _MatCap);// Final Composition before Emissive - // Matcap - End + // The general UTS matcap feature is disabled (_MatCap == 0), so the base composition is RimLight. + float3 finalColor = _RimLight_var;// Final Composition before Emissive + + // --- Stylized metallic (matcap-driven) ------------------------------------------------ + // Uniform branch on per-material flags, so non-metallic materials pay no matcap fetch. + // Requires a matcap uploaded into _MatCap_SamplerArr; the optional _MetallicGlossMapArr + // slice acts as a per-pixel mask (r channel). No mask => fully metallic. + if (_IsStylizedMetallic > 0 && _MatCap_SamplerArr_ID >= 0) + { + int nMatCap_SamplerArrID = _MatCap_SamplerArr_ID; + float4 _MatCap_Sampler_var = SAMPLE_MATCAP(TRANSFORM_TEX(_Rot_MatCapUV_var, _MatCap_Sampler), nMatCap_SamplerArrID, _BlurLevelMatcap); + + // Mask = "where do we put the matcap". Sampled from the glTF metallic-roughness map, whose + // metallic channel is B (glTF packs occlusion=R, roughness=G, metallic=B). A uniform + // metallicFactor is baked into a flat mask on the C# side, so it flows through here too. + // _MetallicGlossMapArr_ID < 0 => no mask => fully metallic (metalAmt = 1). + int nMetalMaskID = _MetallicGlossMapArr_ID; + float metalAmt = (nMetalMaskID < 0) ? 1.0 : SAMPLE_METALLICGLOSS(uv_maintex, nMetalMaskID).b; + + // Strength of the metallic effect (0 = none, 1 = full). Tune to taste. + const float _StylizedMetalStrength = 1.0; + + // Matcap reflection, tinted by scene light colour. + float3 matcapRefl = _MatCap_Sampler_var.rgb * _MatCapColor.rgb * Set_LightColor; + + // --- Iridescence (view/fresnel thin-film, non-animated) ------------------------------- + // Off by default; only tints the stylized-metal reflection. Reuses the grazing-angle + // fresnel (_RimArea_var = abs(1 - N·V)) so the hue shifts with camera angle like a real + // thin film. Cosine spectral palette (iq) — no time input, so nothing animates. + if (_IsIridescent > 0) + { + const float _IridescenceStrength = 1.0; // tint amount AT the grazing edge (0..1) + const float _IridescenceFrequency = 3.0; // spectral bands across the fresnel sweep + const float _IridescenceEdge = 1.0; // edge falloff: lower = wider mask, higher = hugs silhouette + float fresnel = saturate(_RimArea_var); // 0 head-on .. 1 grazing + float3 iri = 0.5 + 0.5 * cos(6.2831853 * (_IridescenceFrequency * fresnel + float3(0.0, 0.33, 0.67))); + + // Multiplying by a [0,1] hue removes energy (darkens ~2 of 3 channels). Rescale the tinted + // reflection back to the original luminance so we shift hue WITHOUT losing brightness + // (energy-conserving, like real thin-film interference). + const float3 LUMA = float3(0.2126, 0.7152, 0.0722); + float3 tinted = matcapRefl * iri; + tinted *= dot(matcapRefl, LUMA) / max(dot(tinted, LUMA), 1e-4); + + // Concentrate the effect at the fresnel/grazing edge so the surface stays plain chrome + // face-on and only the silhouette shimmers (real thin-film reads strongest at grazing angles). + float edge = pow(fresnel, _IridescenceEdge); + matcapRefl = lerp(matcapRefl, tinted, _IridescenceStrength * edge); + } + + // REPLACE (active): the matcap reflection BECOMES the surface where metalAmt = 1, so metal + // areas read as bright chrome/silver instead of a darkened base. lerp so the mask/strength + // fade cleanly back to the lit toon colour where there's no metal. + finalColor = lerp(finalColor, matcapRefl, saturate(metalAmt) * _StylizedMetalStrength); + + // --- Alternative looks (swap the line above for ONE of these) -------------------------- + // Colored metal (replace, but tint the reflection by the base colour so hue is kept — gold etc.): + // finalColor = lerp(finalColor, matcapRefl * Set_FinalBaseColor, saturate(metalAmt) * _StylizedMetalStrength); + // Multiply (modulate base by matcap — subtle, can only darken, never full chrome): + // finalColor *= lerp(float3(1.0, 1.0, 1.0), matcapRefl, saturate(metalAmt) * _StylizedMetalStrength); + // Additive sheen (layer the reflection on top instead of replacing): + // finalColor += matcapRefl * saturate(metalAmt) * _StylizedMetalStrength; + // Screen blend (adds highlights with softer clipping than additive): + // float3 sheen = saturate(matcapRefl * saturate(metalAmt) * _StylizedMetalStrength); + // finalColor = 1.0 - (1.0 - finalColor) * (1.0 - sheen); + } + // --- Stylized metallic end ------------------------------------------------------------ // GI_Intensity with Intensity Multiplier Filter float3 envLightColor = envColor.rgb; diff --git a/Runtime/Shaders/Avatar/DCL_Toon/DCL_ToonDepthNormalsPass.hlsl b/Runtime/Shaders/Avatar/DCL_Toon/DCL_ToonDepthNormalsPass.hlsl index d71b7d1..34c7874 100644 --- a/Runtime/Shaders/Avatar/DCL_Toon/DCL_ToonDepthNormalsPass.hlsl +++ b/Runtime/Shaders/Avatar/DCL_Toon/DCL_ToonDepthNormalsPass.hlsl @@ -33,6 +33,9 @@ struct Varyings float4 positionCS : SV_POSITION; float2 uv : TEXCOORD1; float3 normalWS : TEXCOORD2; + // TBN carried so the normals buffer can match the lit surface's normal map (SSAO consistency). + float3 tangentWS : TEXCOORD3; + float3 bitangentWS : TEXCOORD4; UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_OUTPUT_STEREO @@ -54,6 +57,8 @@ Varyings DepthNormalsVertex(Attributes input) #endif output.normalWS = NormalizeNormalPerVertex(normalInput.normalWS); + output.tangentWS = normalInput.tangentWS; + output.bitangentWS = normalInput.bitangentWS; return output; } @@ -76,14 +81,25 @@ void DepthNormalsFragment( LODFadeCrossFade(input.positionCS); #endif + // Perturb the surface normal by the normal map (ID-guarded; same TBN transform as the + // ForwardLit pass) so SSAO / the camera normals buffer match the shaded surface. + float3 surfaceNormalWS = input.normalWS; + int nNormalMapArrID = _NormalMapArr_ID; + if (nNormalMapArrID >= 0) + { + float3x3 tangentToWorld = float3x3(input.tangentWS, input.bitangentWS, input.normalWS); + float3 normalTS = UnpackNormalScale(SAMPLE_NORMALMAP(input.uv, nNormalMapArrID), _BumpScale); + surfaceNormalWS = mul(normalTS, tangentToWorld); + } + #if defined(_GBUFFER_NORMALS_OCT) - float3 normalWS = normalize(input.normalWS); + float3 normalWS = normalize(surfaceNormalWS); float2 octNormalWS = PackNormalOctQuadEncode(normalWS); // values between [-1, +1], must use fp32 on some platforms. float2 remappedOctNormalWS = saturate(octNormalWS * 0.5 + 0.5); // values between [ 0, 1] half3 packedNormalWS = PackFloat2To888(remappedOctNormalWS); // values between [ 0, 1] outNormalWS = half4(packedNormalWS, 0.0); #else - float3 normalWS = NormalizeNormalPerPixel(input.normalWS); + float3 normalWS = NormalizeNormalPerPixel(surfaceNormalWS); outNormalWS = half4(normalWS, 0.0); #endif diff --git a/Runtime/Shaders/Avatar/DCL_Toon/DCL_ToonInput.hlsl b/Runtime/Shaders/Avatar/DCL_Toon/DCL_ToonInput.hlsl index eca0845..b5652fe 100644 --- a/Runtime/Shaders/Avatar/DCL_Toon/DCL_ToonInput.hlsl +++ b/Runtime/Shaders/Avatar/DCL_Toon/DCL_ToonInput.hlsl @@ -16,6 +16,7 @@ float4 _BaseMap_ST; // Per Material half4 _BaseColor; half4 _SpecColor; float4 _Emissive_Color; +float4 _MatCapColor; float _EndFadeDistance; float _StartFadeDistance; float _FadeDistance; @@ -23,11 +24,14 @@ float4 _RevealPosition; float _RevealEnabled; float _Clipping_Level; float _Tweak_transparency; -int _MainTexArr_ID; +float _BlurLevelMatcap; +int _MainTexArr_ID; int _NormalMapArr_ID; int _MatCap_SamplerArr_ID; int _Emissive_TexArr_ID; int _MetallicGlossMapArr_ID; +int _IsStylizedMetallic; +int _IsIridescent; int _lastWearableVertCount; int _lastAvatarVertCount; CBUFFER_END @@ -46,8 +50,10 @@ UNITY_DOTS_INSTANCING_START(MaterialPropertyMetadata) UNITY_DOTS_INSTANCED_PROP(float4, _BaseColor) UNITY_DOTS_INSTANCED_PROP(float4, _SpecColor) UNITY_DOTS_INSTANCED_PROP(float4, _Emissive_Color) + UNITY_DOTS_INSTANCED_PROP(float4, _MatCapColor) UNITY_DOTS_INSTANCED_PROP(float, _Clipping_Level) UNITY_DOTS_INSTANCED_PROP(float, _Tweak_transparency) + UNITY_DOTS_INSTANCED_PROP(float, _BlurLevelMatcap) UNITY_DOTS_INSTANCED_PROP(int, _lastWearableVertCount) UNITY_DOTS_INSTANCED_PROP(int, _lastAvatarVertCount) UNITY_DOTS_INSTANCING_END(MaterialPropertyMetadata) @@ -58,6 +64,8 @@ UNITY_DOTS_INSTANCING_START(UserPropertyMetadata) UNITY_DOTS_INSTANCED_PROP(int, _MatCap_SamplerArr_ID) UNITY_DOTS_INSTANCED_PROP(int, _Emissive_TexArr_ID) UNITY_DOTS_INSTANCED_PROP(int, _MetallicGlossMapArr_ID) + UNITY_DOTS_INSTANCED_PROP(int, _IsStylizedMetallic) + UNITY_DOTS_INSTANCED_PROP(int, _IsIridescent) UNITY_DOTS_INSTANCED_PROP(float, _EndFadeDistance) UNITY_DOTS_INSTANCED_PROP(float, _StartFadeDistance) UNITY_DOTS_INSTANCED_PROP(float, _FadeDistance) @@ -83,6 +91,7 @@ static float4 unity_DOTS_Sampled_BaseMap_ST; static float4 unity_DOTS_Sampled_BaseColor; static float4 unity_DOTS_Sampled_SpecColor; static float4 unity_DOTS_Sampled_Emissive_Color; +static float4 unity_DOTS_Sampled_MatCapColor; static float unity_DOTS_Sampled_EndFadeDistance; static float unity_DOTS_Sampled_StartFadeDistance; static float unity_DOTS_Sampled_FadeDistance; @@ -90,12 +99,15 @@ static float4 unity_DOTS_Sampled_RevealPosition; static float unity_DOTS_Sampled_RevealEnabled; static float unity_DOTS_Sampled_Clipping_Level; static float unity_DOTS_Sampled_Tweak_transparency; +static float unity_DOTS_Sampled_BlurLevelMatcap; static int unity_DOTS_Sampled_MainTexArr_ID; static int unity_DOTS_Sampled_NormalMapArr_ID; static int unity_DOTS_Sampled_MatCap_SamplerArr_ID; static int unity_DOTS_Sampled_Emissive_TexArr_ID; static int unity_DOTS_Sampled_MetallicGlossMapArr_ID; -static int unity_DOTS_Sampled_lastWearableVertCount; +static int unity_DOTS_Sampled_IsStylizedMetallic; +static int unity_DOTS_Sampled_IsIridescent; +static int unity_DOTS_Sampled_lastWearableVertCount; static int unity_DOTS_Sampled_lastAvatarVertCount; @@ -108,20 +120,24 @@ void SetupDOTSToonMaterialPropertyCaches() unity_DOTS_Sampled_BaseMap_ST = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4, _BaseMap_ST); unity_DOTS_Sampled_BaseColor = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4, _BaseColor); unity_DOTS_Sampled_SpecColor = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4, _SpecColor); - unity_DOTS_Sampled_Emissive_Color = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4, _Emissive_Color); + unity_DOTS_Sampled_Emissive_Color = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4, _Emissive_Color); + unity_DOTS_Sampled_MatCapColor = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4, _MatCapColor); unity_DOTS_Sampled_EndFadeDistance = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float, _EndFadeDistance); unity_DOTS_Sampled_StartFadeDistance = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float, _StartFadeDistance); unity_DOTS_Sampled_FadeDistance = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float, _FadeDistance); unity_DOTS_Sampled_RevealPosition = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4, _RevealPosition); unity_DOTS_Sampled_RevealEnabled = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float, _RevealEnabled); unity_DOTS_Sampled_Clipping_Level = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float, _Clipping_Level); - unity_DOTS_Sampled_Tweak_transparency = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float, _Tweak_transparency); + unity_DOTS_Sampled_Tweak_transparency = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float, _Tweak_transparency); + unity_DOTS_Sampled_BlurLevelMatcap = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float, _BlurLevelMatcap); unity_DOTS_Sampled_MainTexArr_ID = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(int, _MainTexArr_ID); unity_DOTS_Sampled_NormalMapArr_ID = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(int, _NormalMapArr_ID); unity_DOTS_Sampled_MatCap_SamplerArr_ID = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(int, _MatCap_SamplerArr_ID); unity_DOTS_Sampled_Emissive_TexArr_ID = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(int, _Emissive_TexArr_ID); - unity_DOTS_Sampled_MetallicGlossMapArr_ID = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(int, _MetallicGlossMapArr_ID); - unity_DOTS_Sampled_lastWearableVertCount = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(int, _lastWearableVertCount); + unity_DOTS_Sampled_MetallicGlossMapArr_ID = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(int, _MetallicGlossMapArr_ID); + unity_DOTS_Sampled_IsStylizedMetallic = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(int, _IsStylizedMetallic); + unity_DOTS_Sampled_IsIridescent = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(int, _IsIridescent); + unity_DOTS_Sampled_lastWearableVertCount = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(int, _lastWearableVertCount); unity_DOTS_Sampled_lastAvatarVertCount = UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(int, _lastAvatarVertCount); } @@ -136,6 +152,7 @@ void SetupDOTSToonMaterialPropertyCaches() #define _BaseColor unity_DOTS_Sampled_BaseColor #define _SpecColor unity_DOTS_Sampled_SpecColor #define _Emissive_Color unity_DOTS_Sampled_Emissive_Color +#define _MatCapColor unity_DOTS_Sampled_MatCapColor #define _EndFadeDistance unity_DOTS_Sampled_EndFadeDistance #define _StartFadeDistance unity_DOTS_Sampled_StartFadeDistance #define _FadeDistance unity_DOTS_Sampled_FadeDistance @@ -143,12 +160,15 @@ void SetupDOTSToonMaterialPropertyCaches() #define _RevealEnabled unity_DOTS_Sampled_RevealEnabled #define _Clipping_Level unity_DOTS_Sampled_Clipping_Level #define _Tweak_transparency unity_DOTS_Sampled_Tweak_transparency +#define _BlurLevelMatcap unity_DOTS_Sampled_BlurLevelMatcap #define _MainTexArr_ID unity_DOTS_Sampled_MainTexArr_ID #define _NormalMapArr_ID unity_DOTS_Sampled_NormalMapArr_ID #define _MatCap_SamplerArr_ID unity_DOTS_Sampled_MatCap_SamplerArr_ID #define _Emissive_TexArr_ID unity_DOTS_Sampled_Emissive_TexArr_ID #define _MetallicGlossMapArr_ID unity_DOTS_Sampled_MetallicGlossMapArr_ID -#define _lastWearableVertCount unity_DOTS_Sampled_lastWearableVertCount +#define _IsStylizedMetallic unity_DOTS_Sampled_IsStylizedMetallic +#define _IsIridescent unity_DOTS_Sampled_IsIridescent +#define _lastWearableVertCount unity_DOTS_Sampled_lastWearableVertCount #define _lastAvatarVertCount unity_DOTS_Sampled_lastAvatarVertCount #endif @@ -174,9 +194,8 @@ void SetupDOTSToonMaterialPropertyCaches() #define SAMPLE_BUMPMAP(uv,texArrayID) DCL_SAMPLE_TEX2DARRAY(_BumpMapArr, float3(uv, texArrayID)) #define SAMPLE_EMISSIONMAP(uv,texArrayID) DCL_SAMPLE_TEX2DARRAY(_EmissionMapArr, float3(uv, texArrayID)) #define SAMPLE_MAINTEX(uv,texArrayID) DCL_SAMPLE_TEX2DARRAY_DEFAULT_SAMPLER(_MainTexArr, float3(uv, texArrayID)) - #define SAMPLE_NORMALMAP(uv,texArrayID) float4(0.5f, 0.5f, 1.0f, 1.0f) - // #define SAMPLE_MATCAP(uv,texArrayID,lod) DCL_SAMPLE_TEX2DARRAY_LOD(_MatCap_SamplerArr, float3(uv, texArrayID), lod) - #define SAMPLE_MATCAP(uv,texArrayID,lod) float4(0.0f, 0.0f, 0.0f, 0.0f) + #define SAMPLE_NORMALMAP(uv,texArrayID) DCL_SAMPLE_TEX2DARRAY_DEFAULT_SAMPLER(_NormalMapArr, float3(uv, texArrayID)) + #define SAMPLE_MATCAP(uv,texArrayID,lod) DCL_SAMPLE_TEX2DARRAY_LOD(_MatCap_SamplerArr, float3(uv, texArrayID), lod) #define SAMPLE_EMISSIVE(uv,texArrayID) DCL_SAMPLE_TEX2DARRAY(_Emissive_TexArr, float3(uv, texArrayID)) #define SAMPLE_OCCLUSIONMAP(uv,texArrayID) DCL_SAMPLE_TEX2DARRAY(_OcclusionMapArr, float3(uv, texArrayID)) #define SAMPLE_METALLICGLOSS(uv,texArrayID) DCL_SAMPLE_TEX2DARRAY(_MetallicGlossMapArr, float3(uv, texArrayID)) @@ -184,7 +203,7 @@ void SetupDOTSToonMaterialPropertyCaches() TEXTURE2D(_BaseMap); SAMPLER(sampler_BaseMap); TEXTURE2D(_BumpMap); SAMPLER(sampler_BumpMap); TEXTURE2D(_MainTex); SAMPLER(sampler_MainTex); - TEXTURE2D(_NormalMap); + TEXTURE2D(_NormalMap); SAMPLER(sampler_NormalMap); TEXTURE2D(_MetallicGlossMap); SAMPLER(sampler_MetallicGlossMap); sampler2D _MatCap_Sampler; @@ -194,7 +213,7 @@ void SetupDOTSToonMaterialPropertyCaches() #define SAMPLE_BUMPMAP(uv,texArrayID) SAMPLE_TEXTURE2D(_BumpMap, sampler_BumpMap, uv) #define SAMPLE_EMISSIONMAP(uv,texArrayID) float4(0.0f, 0.0f, 0.0f, 0.0f) #define SAMPLE_MAINTEX(uv,texArrayID) SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uv) - #define SAMPLE_NORMALMAP(uv,texArrayID) SAMPLE_TEXTURE2D(_NormalMap, sampler_MainTex, uv) + #define SAMPLE_NORMALMAP(uv,texArrayID) SAMPLE_TEXTURE2D(_NormalMap, sampler_NormalMap, uv) #define SAMPLE_OCCLUSIONMAP(uv,texArrayID) float4(0.0f, 0.0f, 0.0f, 0.0f) #define SAMPLE_METALLICGLOSS(uv,texArrayID) SAMPLE_TEXTURE2D(_MetallicGlossMap, sampler_MetallicGlossMap, uv) #define SAMPLE_MATCAP(uv,texArrayID,lod) tex2Dlod(_MatCap_Sampler, float4(uv, 0.0f, lod)) diff --git a/Runtime/Shaders/Avatar/DCL_Toon/DCL_ToonVariables.hlsl b/Runtime/Shaders/Avatar/DCL_Toon/DCL_ToonVariables.hlsl index a226f83..10274e6 100644 --- a/Runtime/Shaders/Avatar/DCL_Toon/DCL_ToonVariables.hlsl +++ b/Runtime/Shaders/Avatar/DCL_Toon/DCL_ToonVariables.hlsl @@ -13,7 +13,7 @@ #define _Ap_RimLight_Power 0.1f #define _BaseColor_Step 0.2f #define _BaseShade_Feather 0.02f -#define _BlurLevelMatcap 0.0f +// _BlurLevelMatcap promoted to a runtime per-material property (see DCL_ToonInput.hlsl) #define _BlurLevelSGM 0.0f #define _BumpScale 1.0f #define _BumpScaleMatcap 1.0f @@ -41,7 +41,7 @@ #define _Is_LightColor_Outline 0.0f #define _Is_LightColor_RimLight 1.0f #define _Is_NormalMapForMatCap 0.0f -#define _Is_NormalMapToBase 0.0f +#define _Is_NormalMapToBase 1.0f #define _Is_NormalMapToHighColor 1.0f #define _Is_NormalMapToRimLight 1.0f #define _Is_Ortho 0.0f @@ -91,7 +91,7 @@ #define _Color float4 (1, 1, 1, 1) #define _EmissionColor float4 (0, 0, 0, 1) #define _HighColor float4 (1, 1, 1, 1) -#define _MatCapColor float4 (1, 1, 1, 1) +// _MatCapColor promoted to a runtime per-material property (see DCL_ToonInput.hlsl) // _Is_BlendBaseColor == 1.0f, so OutlineColor can be removed #define _Outline_Color float4 (0.6320754, 0.6320754, 0.6320754, 1) // _Is_LightColor_RimLight == 1.0f, so RimLightColor can be removed diff --git a/Runtime/Shaders/Avatar/DCL_Toon/Matcaps.meta b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps.meta new file mode 100644 index 0000000..a3a177b --- /dev/null +++ b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e321bf4dd5634cc4a66ba08bb4291836 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/MatcapPresets.asset b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/MatcapPresets.asset new file mode 100644 index 0000000..b960d71 --- /dev/null +++ b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/MatcapPresets.asset @@ -0,0 +1,39 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f8bd9755480e4e43b45ef448fa6e780e, type: 3} + m_Name: MatcapPresets + m_EditorClassIdentifier: + presets: + - name: matcap_01 + texture: {fileID: 2800000, guid: 2f7715e42aa1474191c64539a77b2eb3, type: 3} + tint: {r: 1, g: 1, b: 1, a: 1} + blur: 0 + - name: matcap_02 + texture: {fileID: 2800000, guid: 512caf6744e742feb9d6bd5d4b8461cc, type: 3} + tint: {r: 1, g: 1, b: 1, a: 1} + blur: 0 + - name: matcap_03 + texture: {fileID: 2800000, guid: 4a4e32217cd643909e1c7942c3df6c69, type: 3} + tint: {r: 1, g: 1, b: 1, a: 1} + blur: 0 + - name: matcap_04 + texture: {fileID: 2800000, guid: a13afab06939421496ff7fb742bdc8a9, type: 3} + tint: {r: 1, g: 1, b: 1, a: 1} + blur: 0 + - name: matcap_05 + texture: {fileID: 2800000, guid: 3481c21125e64e9697e66d6751c7383a, type: 3} + tint: {r: 1, g: 1, b: 1, a: 1} + blur: 0 + - name: matcap_06 + texture: {fileID: 2800000, guid: fe3d6696fe6f413e9afef8f25b6a0ca8, type: 3} + tint: {r: 1, g: 1, b: 1, a: 1} + blur: 0 diff --git a/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/MatcapPresets.asset.meta b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/MatcapPresets.asset.meta new file mode 100644 index 0000000..c09ff87 --- /dev/null +++ b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/MatcapPresets.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e77eccfdf49b4ea09a22904b9864a2a3 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_01.png b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_01.png new file mode 100644 index 0000000..51ebff7 Binary files /dev/null and b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_01.png differ diff --git a/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_01.png.meta b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_01.png.meta new file mode 100644 index 0000000..1f9eb15 --- /dev/null +++ b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_01.png.meta @@ -0,0 +1,117 @@ +fileFormatVersion: 2 +guid: 2f7715e42aa1474191c64539a77b2eb3 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 256 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 4 + buildTarget: DefaultTexturePlatform + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Standalone + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + customData: + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spriteCustomMetadata: + entries: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_02.png b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_02.png new file mode 100644 index 0000000..fd62535 Binary files /dev/null and b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_02.png differ diff --git a/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_02.png.meta b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_02.png.meta new file mode 100644 index 0000000..aec7c14 --- /dev/null +++ b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_02.png.meta @@ -0,0 +1,117 @@ +fileFormatVersion: 2 +guid: 512caf6744e742feb9d6bd5d4b8461cc +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 256 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 4 + buildTarget: DefaultTexturePlatform + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Standalone + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + customData: + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spriteCustomMetadata: + entries: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_03.png b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_03.png new file mode 100644 index 0000000..f1c85b5 Binary files /dev/null and b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_03.png differ diff --git a/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_03.png.meta b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_03.png.meta new file mode 100644 index 0000000..afcc023 --- /dev/null +++ b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_03.png.meta @@ -0,0 +1,117 @@ +fileFormatVersion: 2 +guid: 4a4e32217cd643909e1c7942c3df6c69 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 256 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 4 + buildTarget: DefaultTexturePlatform + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Standalone + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + customData: + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spriteCustomMetadata: + entries: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_04.png b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_04.png new file mode 100644 index 0000000..4e6ae85 Binary files /dev/null and b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_04.png differ diff --git a/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_04.png.meta b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_04.png.meta new file mode 100644 index 0000000..7bba8a5 --- /dev/null +++ b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_04.png.meta @@ -0,0 +1,117 @@ +fileFormatVersion: 2 +guid: a13afab06939421496ff7fb742bdc8a9 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 256 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 4 + buildTarget: DefaultTexturePlatform + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Standalone + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + customData: + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spriteCustomMetadata: + entries: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_05.png b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_05.png new file mode 100644 index 0000000..2f3698b Binary files /dev/null and b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_05.png differ diff --git a/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_05.png.meta b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_05.png.meta new file mode 100644 index 0000000..50eb2c1 --- /dev/null +++ b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_05.png.meta @@ -0,0 +1,117 @@ +fileFormatVersion: 2 +guid: 3481c21125e64e9697e66d6751c7383a +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 256 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 4 + buildTarget: DefaultTexturePlatform + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Standalone + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + customData: + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spriteCustomMetadata: + entries: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_06.png b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_06.png new file mode 100644 index 0000000..30b0852 Binary files /dev/null and b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_06.png differ diff --git a/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_06.png.meta b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_06.png.meta new file mode 100644 index 0000000..42c8bd5 --- /dev/null +++ b/Runtime/Shaders/Avatar/DCL_Toon/Matcaps/Matcap_06.png.meta @@ -0,0 +1,117 @@ +fileFormatVersion: 2 +guid: fe3d6696fe6f413e9afef8f25b6a0ca8 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 256 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 4 + buildTarget: DefaultTexturePlatform + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Standalone + maxTextureSize: 256 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + customData: + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spriteCustomMetadata: + entries: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Shaders/Avatar/DCL_Toon/Runtime.meta b/Runtime/Shaders/Avatar/DCL_Toon/Runtime.meta new file mode 100644 index 0000000..4c4c0a2 --- /dev/null +++ b/Runtime/Shaders/Avatar/DCL_Toon/Runtime.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a129ef4f207c4b0187f8504b33f0b551 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Shaders/Avatar/DCL_Toon/Runtime/DCL.AvatarRendering.Shaders.DCL_Toon.Runtime.asmdef b/Runtime/Shaders/Avatar/DCL_Toon/Runtime/DCL.AvatarRendering.Shaders.DCL_Toon.Runtime.asmdef new file mode 100644 index 0000000..ff49778 --- /dev/null +++ b/Runtime/Shaders/Avatar/DCL_Toon/Runtime/DCL.AvatarRendering.Shaders.DCL_Toon.Runtime.asmdef @@ -0,0 +1,14 @@ +{ + "name": "DCL.AvatarRendering.Shaders.DCL_Toon.Runtime", + "rootNamespace": "", + "references": [], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} diff --git a/Runtime/Shaders/Avatar/DCL_Toon/Runtime/DCL.AvatarRendering.Shaders.DCL_Toon.Runtime.asmdef.meta b/Runtime/Shaders/Avatar/DCL_Toon/Runtime/DCL.AvatarRendering.Shaders.DCL_Toon.Runtime.asmdef.meta new file mode 100644 index 0000000..1ff58ac --- /dev/null +++ b/Runtime/Shaders/Avatar/DCL_Toon/Runtime/DCL.AvatarRendering.Shaders.DCL_Toon.Runtime.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 249c0c47d4df40778e320662fd049ad1 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Shaders/Avatar/DCL_Toon/Runtime/MatcapPresets.cs b/Runtime/Shaders/Avatar/DCL_Toon/Runtime/MatcapPresets.cs new file mode 100644 index 0000000..d88531d --- /dev/null +++ b/Runtime/Shaders/Avatar/DCL_Toon/Runtime/MatcapPresets.cs @@ -0,0 +1,94 @@ +using System; +using UnityEngine; + +namespace DCL.Rendering.DCL_Toon +{ + /// + /// Shared, ordered library of stylized-metallic matcap presets for the DCL_Toon shader. This is + /// the single source of truth across consuming apps (aang-renderer, unity-explorer, ...): each app + /// pulls this asset from the package instead of shipping its own matcap textures. + /// + /// Wearables reference a matcap by its stable in their JSON; consumers + /// resolve that name to an array index with . That index is the contract + /// for the shader's _MatCap_SamplerArr_ID (texture-array path) and the slice in a matcap + /// Texture2DArray — so the ORDER of presets is significant and must stay stable once + /// wearables reference them. The non-array path (aang) binds directly + /// to _MatCap_Sampler. + /// + [CreateAssetMenu(menuName = "DCL/Toon/Matcap Presets", fileName = "MatcapPresets")] + public class MatcapPresets : ScriptableObject + { + [Serializable] + public struct Preset + { + [Tooltip("Stable identifier referenced by wearable JSON. Must be unique and must not " + + "change once wearables reference it.")] + public string name; + + public Texture2D texture; + + [Tooltip("Optional per-matcap tint applied to the shader's _MatCapColor. White = no tint.")] + public Color tint; + + [Tooltip("Optional per-matcap blur applied to the shader's _BlurLevelMatcap (matcap mip LOD).")] + [Range(0f, 8f)] public float blur; + } + + [SerializeField] private Preset[] presets; + + /// Number of presets in the library. + public int Count => presets?.Length ?? 0; + + /// The preset at a given slice index (the shader's _MatCap_SamplerArr_ID value). + public Preset this[int index] => presets[index]; + + /// + /// Resolves a preset name to its array index — i.e. the shader slice id. Case-sensitive. + /// Returns false (index = -1) when the name is unknown, so callers can fall back gracefully. + /// + public bool TryGetIndex(string presetName, out int index) + { + if (presets != null) + { + for (var i = 0; i < presets.Length; i++) + { + if (presets[i].name == presetName) + { + index = i; + return true; + } + } + } + + index = -1; + return false; + } + + /// Resolves a preset name to the preset itself. + public bool TryGet(string presetName, out Preset preset) + { + if (TryGetIndex(presetName, out var index)) + { + preset = presets[index]; + return true; + } + + preset = default; + return false; + } + + private void OnValidate() + { + if (presets == null) return; + + // A freshly-added inspector element defaults every field to zero; a zero (transparent + // black) tint would zero out the matcap contribution, which is never intended, so treat + // an unset tint as "no tint" = white. Intentional non-white tints are preserved. + for (var i = 0; i < presets.Length; i++) + { + if (presets[i].tint == default) + presets[i].tint = Color.white; + } + } + } +} diff --git a/Runtime/Shaders/Avatar/DCL_Toon/Runtime/MatcapPresets.cs.meta b/Runtime/Shaders/Avatar/DCL_Toon/Runtime/MatcapPresets.cs.meta new file mode 100644 index 0000000..ac5d72f --- /dev/null +++ b/Runtime/Shaders/Avatar/DCL_Toon/Runtime/MatcapPresets.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f8bd9755480e4e43b45ef448fa6e780e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/package.json b/package.json index 3454e68..05812ea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.decentraland.unity-shared-dependencies", - "version": "1.1.8", + "version": "1.1.12", "displayName": "Decentraland.SharedDependencies", "description": "This package contains shared dependencies between unity-renderer, aang-renderer and asset-bundle-converter repositories, this includes gltf importer wrappers, shaders and wearable utils", "unity": "2021.3",