diff options
author | Freya Murphy <freya@freyacat.org> | 2024-12-27 00:56:58 -0500 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2024-12-27 00:58:02 -0500 |
commit | 799e6680d40119dc9c2a9e0b320054a40324bebe (patch) | |
tree | dbcd308d59eb6e4f937a5547dd77d9f91d4fec20 /VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main | |
parent | move to self host (diff) | |
download | unityprojects-799e6680d40119dc9c2a9e0b320054a40324bebe.tar.gz unityprojects-799e6680d40119dc9c2a9e0b320054a40324bebe.tar.bz2 unityprojects-799e6680d40119dc9c2a9e0b320054a40324bebe.zip |
VRCSDK3Avatars found!
Diffstat (limited to 'VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main')
40 files changed, 2777 insertions, 0 deletions
diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes.meta b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes.meta new file mode 100644 index 00000000..09908463 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f9f24ad9b2b1c9440b5ed1fa0d11306c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSDefines.cginc b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSDefines.cginc new file mode 100644 index 00000000..b59d96f7 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSDefines.cginc @@ -0,0 +1,216 @@ +#include "UnityPBSLighting.cginc" +#include "AutoLight.cginc" +#include "UnityCG.cginc" + +struct VertexInput +{ + float4 vertex : POSITION; + float2 uv : TEXCOORD0; + float2 uv1 : TEXCOORD1; + float2 uv2 : TEXCOORD2; + float3 normal : NORMAL; + float4 tangent : TANGENT; + float4 color : COLOR; +}; + +struct VertexOutput +{ + #if defined(Geometry) + float4 pos : CLIP_POS; + float4 vertex : SV_POSITION; // We need both of these in order to shadow Outlines correctly + #else + float4 pos : SV_POSITION; + #endif + + float2 uv : TEXCOORD0; + float2 uv1 : TEXCOORD1; + float3 ntb[3] : TEXCOORD2; //texcoord 3, 4 || Holds World Normal, Tangent, and Bitangent + float4 worldPos : TEXCOORD5; + float4 color : TEXCOORD6; + float3 normal : TEXCOORD8; + float4 screenPos : TEXCOORD9; + float3 objPos : TEXCOORD11; + float2 uv2 : TEXCOORD12; + + #if !defined(UNITY_PASS_SHADOWCASTER) + SHADOW_COORDS(7) + UNITY_FOG_COORDS(10) + #endif +}; + +#if defined(Geometry) + struct v2g + { + float4 pos : CLIP_POS; + float4 vertex : SV_POSITION; + float2 uv : TEXCOORD0; + float2 uv1 : TEXCOORD1; + float3 ntb[3] : TEXCOORD2; //texcoord 3, 4 || Holds World Normal, Tangent, and Bitangent + float4 worldPos : TEXCOORD5; + float4 color : TEXCOORD6; + float3 normal : TEXCOORD8; + float4 screenPos : TEXCOORD9; + float3 objPos : TEXCOORD11; + float2 uv2 : TEXCOORD12; + + #if !defined(UNITY_PASS_SHADOWCASTER) + SHADOW_COORDS(7) + UNITY_FOG_COORDS(10) + #endif + }; + + struct g2f + { + float4 pos : SV_POSITION; + float2 uv : TEXCOORD0; + float2 uv1 : TEXCOORD1; + float3 ntb[3] : TEXCOORD2; //texcoord 3, 4 || Holds World Normal, Tangent, and Bitangent + float4 worldPos : TEXCOORD5; + float4 color : TEXCOORD6; + float4 screenPos : TEXCOORD8; + float3 objPos : TEXCOORD10; + + #if !defined(UNITY_PASS_SHADOWCASTER) + SHADOW_COORDS(7) + UNITY_FOG_COORDS(9) + #endif + }; +#endif + +struct XSLighting +{ + half4 albedo; + half4 normalMap; + half4 detailNormal; + half4 detailMask; + half4 metallicGlossMap; + half4 reflectivityMask; + half4 specularMap; + half4 thickness; + half4 occlusion; + half4 emissionMap; + half4 rampMask; + half4 hsvMask; + half4 clipMap; + half4 dissolveMask; + half3 diffuseColor; + half attenuation; + half3 normal; + half3 tangent; + half3 bitangent; + half4 worldPos; + half3 color; + half alpha; + float isOutline; + float4 screenPos; + float2 screenUV; + float3 objPos; +}; + +struct TextureUV +{ + half2 uv0; + half2 uv1; + half2 albedoUV; + half2 specularMapUV; + half2 metallicGlossMapUV; + half2 detailMaskUV; + half2 normalMapUV; + half2 detailNormalUV; + half2 thicknessMapUV; + half2 occlusionUV; + half2 reflectivityMaskUV; + half2 emissionMapUV; + half2 outlineMaskUV; + half2 clipMapUV; + half2 dissolveUV; +}; + +struct DotProducts +{ + half ndl; + half vdn; + half vdh; + half tdh; + half bdh; + half ndh; + half rdv; + half ldh; + half svdn; +}; + +struct VertexLightInformation { + float3 Direction[4]; + float3 ColorFalloff[4]; + float Attenuation[4]; +}; + +UNITY_DECLARE_TEX2D(_MainTex); half4 _MainTex_ST; +UNITY_DECLARE_TEX2D_NOSAMPLER(_ClipMap); half4 _ClipMap_ST; +UNITY_DECLARE_TEX2D_NOSAMPLER(_DissolveTexture); half4 _DissolveTexture_ST; +UNITY_DECLARE_TEX2D_NOSAMPLER(_BumpMap); half4 _BumpMap_ST; +UNITY_DECLARE_TEX2D_NOSAMPLER(_DetailNormalMap); half4 _DetailNormalMap_ST; +UNITY_DECLARE_TEX2D_NOSAMPLER(_DetailMask); half4 _DetailMask_ST; +UNITY_DECLARE_TEX2D_NOSAMPLER(_SpecularMap); half4 _SpecularMap_ST; +UNITY_DECLARE_TEX2D_NOSAMPLER(_MetallicGlossMap); half4 _MetallicGlossMap_ST; +UNITY_DECLARE_TEX2D_NOSAMPLER(_ReflectivityMask); half4 _ReflectivityMask_ST; +UNITY_DECLARE_TEX2D_NOSAMPLER(_ThicknessMap); half4 _ThicknessMap_ST; +UNITY_DECLARE_TEX2D_NOSAMPLER(_EmissionMap); half4 _EmissionMap_ST; +UNITY_DECLARE_TEX2D_NOSAMPLER(_RampSelectionMask); +UNITY_DECLARE_TEX2D_NOSAMPLER(_HSVMask); +sampler2D _OcclusionMap; half4 _OcclusionMap_ST; +sampler2D _OutlineMask; +sampler2D _Matcap; +sampler2D _Ramp; +samplerCUBE _BakedCubemap; +sampler2D _GrabTexture; +float4 _GrabTexture_TexelSize; + +#if defined(UNITY_PASS_SHADOWCASTER) + sampler3D _DitherMaskLOD; +#endif + +half4 _Color; +half4 _ClipAgainstVertexColorGreaterZeroFive, _ClipAgainstVertexColorLessZeroFive; +half _Cutoff; +half _DissolveProgress, _DissolveStrength; +int _DissolveCoordinates; +int _UseClipsForDissolve; + +half4 _ShadowRim, + _OutlineColor, _SSColor, + _EmissionColor, _MatcapTint, + _RimColor, _DissolveColor; + +half _MatcapTintToDiffuse; + +half _FadeDitherDistance; +half _EmissionToDiffuse, _ScaleWithLightSensitivity; +half _Hue, _Saturation, _Value; +half _Metallic, _Glossiness, _OcclusionIntensity, _Reflectivity, _ClearcoatStrength, _ClearcoatSmoothness; +half _BumpScale, _DetailNormalMapScale; +half _SpecularIntensity, _SpecularSharpness, _SpecularArea, _AnisotropicSpecular, _AnisotropicReflection, _SpecularAlbedoTint; +half _IOR; +half _HalftoneDotSize, _HalftoneDotAmount, _HalftoneLineAmount, _HalftoneLineIntensity; +half _RimRange, _RimThreshold, _RimIntensity, _RimSharpness, _RimAlbedoTint, _RimCubemapTint, _RimAttenEffect; +half _ShadowRimRange, _ShadowRimThreshold, _ShadowRimSharpness, _ShadowSharpness, _ShadowRimAlbedoTint; +half _SSDistortion, _SSPower, _SSScale; +half _OutlineWidth; + +int _HalftoneType; +int _FadeDither; +int _BlendMode; +int _OcclusionMode; +int _UseRefraction; +int _ReflectionMode, _ReflectionBlendMode, _ClearCoat; +int _TilingMode, _VertexColorAlbedo, _ScaleWithLight; +int _OutlineAlbedoTint, _OutlineLighting, _OutlineNormalMode; +int _UVSetAlbedo, _UVSetNormal, _UVSetDetNormal, + _UVSetDetMask, _UVSetMetallic, _UVSetSpecular, + _UVSetThickness, _UVSetOcclusion, _UVSetReflectivity, + _UVSetEmission, _UVSetClipMap, _UVSetDissolve; +int _NormalMapMode, _OutlineUVSelect; + +//Defines for helper functions +#define grayscaleVec float3(0.2125, 0.7154, 0.0721) +#define WorldNormalVector(normal0, normal) half3(dot(normal0,normal), dot(normal0, normal), dot(normal0,normal))
\ No newline at end of file diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSDefines.cginc.meta b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSDefines.cginc.meta new file mode 100644 index 00000000..d41dd6af --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSDefines.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 475129dd3056c984bbe2c6c2203c9759 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSFrag.cginc b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSFrag.cginc new file mode 100644 index 00000000..eef3aef5 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSFrag.cginc @@ -0,0 +1,88 @@ +float4 frag ( + #if defined(Geometry) + g2f i + #else + VertexOutput i + #endif + , uint facing : SV_IsFrontFace + ) : SV_Target +{ + TextureUV t = (TextureUV)0; // Populate UVs + if(_TilingMode != 1) { InitializeTextureUVs(i, t); } else { InitializeTextureUVsMerged(i, t); }; + + #ifdef UNITY_PASS_SHADOWCASTER + XSLighting o = (XSLighting)0; //Populate Lighting Struct, but only with important shadowcaster stuff! + o.albedo = UNITY_SAMPLE_TEX2D(_MainTex, t.albedoUV) * _Color * lerp(1, float4(i.color.rgb, 1), _VertexColorAlbedo); + o.clipMap = UNITY_SAMPLE_TEX2D_SAMPLER(_ClipMap, _MainTex, t.clipMapUV); + o.dissolveMask = UNITY_SAMPLE_TEX2D_SAMPLER(_DissolveTexture, _MainTex, t.dissolveUV); + + o.worldPos = i.worldPos; + o.screenUV = calcScreenUVs(i.screenPos); + o.screenPos = i.screenPos; + o.objPos = i.objPos; + + float4 outCol = 0; + calcAlpha(o); + calcDissolve(o, outCol); + SHADOW_CASTER_FRAGMENT(i); + #else + UNITY_LIGHT_ATTENUATION(attenuation, i, i.worldPos.xyz); + + // fix for rare bug where light atten is 0 when there is no directional light in the scene + #ifdef UNITY_PASS_FORWARDBASE + if(all(_LightColor0.rgb == 0.0)) + { + attenuation = 1.0; + } + #endif + + #if defined(DIRECTIONAL) + half sharp = _ShadowSharpness * 0.5; + attenuation = smoothstep(sharp, 1-sharp, attenuation); //Converge at the center line + #endif + + bool face = facing > 0; // True if on front face, False if on back face + if (!face) // Invert Normals based on face + { + if(i.color.a > 0.99) { discard; }//Discard outlines front face always. This way cull off and outlines can be enabled. + + i.ntb[0] = -i.ntb[0]; + i.ntb[1] = -i.ntb[1]; + i.ntb[2] = -i.ntb[2]; + } + + XSLighting o = (XSLighting)0; //Populate Lighting Struct + o.albedo = UNITY_SAMPLE_TEX2D(_MainTex, t.albedoUV) * _Color * lerp(1, float4(i.color.rgb, 1), _VertexColorAlbedo); + o.specularMap = UNITY_SAMPLE_TEX2D_SAMPLER(_SpecularMap, _MainTex, t.specularMapUV); + o.metallicGlossMap = UNITY_SAMPLE_TEX2D_SAMPLER(_MetallicGlossMap, _MainTex, t.metallicGlossMapUV); + o.detailMask = UNITY_SAMPLE_TEX2D_SAMPLER(_DetailMask, _MainTex, t.detailMaskUV); + o.normalMap = UNITY_SAMPLE_TEX2D_SAMPLER(_BumpMap, _MainTex, t.normalMapUV); + o.detailNormal = UNITY_SAMPLE_TEX2D_SAMPLER(_DetailNormalMap, _MainTex, t.detailNormalUV); + o.thickness = UNITY_SAMPLE_TEX2D_SAMPLER(_ThicknessMap, _MainTex, t.thicknessMapUV); + o.occlusion = tex2D(_OcclusionMap, t.occlusionUV); + o.reflectivityMask = UNITY_SAMPLE_TEX2D_SAMPLER(_ReflectivityMask, _MainTex, t.reflectivityMaskUV) * _Reflectivity; + o.emissionMap = UNITY_SAMPLE_TEX2D_SAMPLER(_EmissionMap, _MainTex, t.emissionMapUV) * _EmissionColor; + o.rampMask = UNITY_SAMPLE_TEX2D_SAMPLER(_RampSelectionMask, _MainTex, i.uv); // This texture doesn't need to ever be on a second uv channel, and doesn't need tiling, convince me otherwise. + o.hsvMask = UNITY_SAMPLE_TEX2D_SAMPLER(_HSVMask, _MainTex, t.albedoUV); + o.clipMap = UNITY_SAMPLE_TEX2D_SAMPLER(_ClipMap, _MainTex, t.clipMapUV); + o.dissolveMask = UNITY_SAMPLE_TEX2D_SAMPLER(_DissolveTexture, _MainTex, t.dissolveUV); + + o.diffuseColor = o.albedo.rgb; //Store this to separate the texture color and diffuse color for later. + o.attenuation = attenuation; + o.normal = i.ntb[0]; + o.tangent = i.ntb[1]; + o.bitangent = i.ntb[2]; + o.worldPos = i.worldPos; + o.color = i.color.rgb; + o.isOutline = i.color.a; + o.screenUV = calcScreenUVs(i.screenPos); + o.screenPos = i.screenPos; + o.objPos = i.objPos; + + float4 col = BRDF_XSLighting(o); + calcAlpha(o); + calcDissolve(o, col); + UNITY_APPLY_FOG(i.fogCoord, col); + return float4(col.rgb, o.alpha); + #endif +}
\ No newline at end of file diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSFrag.cginc.meta b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSFrag.cginc.meta new file mode 100644 index 00000000..02ff2f77 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSFrag.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: b6800622dae7e6f4bba02dffcc5f5868 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSGeom.cginc b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSGeom.cginc new file mode 100644 index 00000000..f1077558 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSGeom.cginc @@ -0,0 +1,95 @@ +#if defined(Geometry) + #define TRANSFER_SHADOW_CASTER_NOPOS_GEOMETRY(o, opos, vertexPosition, vertexNormal) \ + opos = UnityClipSpaceShadowCasterPos(vertexPosition, vertexNormal); \ + opos = UnityApplyLinearShadowBias(opos); + + [maxvertexcount(6)] + void geom(triangle v2g IN[3], inout TriangleStream<g2f> tristream) + { + g2f o = (g2f)0; + + //Main Mesh loop + for (int i = 0; i < 3; i++) + { + o.pos = UnityObjectToClipPos(IN[i].vertex); + o.worldPos = IN[i].worldPos; + o.ntb[0] = IN[i].ntb[0]; + o.ntb[1] = IN[i].ntb[1]; + o.ntb[2] = IN[i].ntb[2]; + o.uv = IN[i].uv; + o.uv1 = IN[i].uv1; + o.color = float4(IN[i].color.rgb,0); // store if outline in alpha channel of vertex colors | 0 = not an outline + o.screenPos = ComputeScreenPos(o.pos); + o.objPos = normalize(IN[i].vertex); + + #if !defined(UNITY_PASS_SHADOWCASTER) + UNITY_TRANSFER_SHADOW(o, o.uv); + UNITY_TRANSFER_FOG(o, o.pos); + #else + TRANSFER_SHADOW_CASTER_NOPOS_GEOMETRY(o, o.pos, IN[i].vertex, IN[i].ntb[0]); + #endif + tristream.Append(o); + } + tristream.RestartStrip(); + + //Outlines loop + for (int i = 2; i >= 0; i--) + { + float4 worldPos = (mul(unity_ObjectToWorld, IN[i].vertex)); + half outlineWidthMask = tex2Dlod(_OutlineMask, float4(IN[i].uv, 0, 0)); + float3 outlineWidth = outlineWidthMask * _OutlineWidth * .01; + outlineWidth *= min(distance(worldPos, _WorldSpaceCameraPos) * 3, 1); + + float3 vc = IN[i].color.rgb; + if(_OutlineNormalMode == 2) + { + float2 xy = IN[i].uv1; + if(_OutlineUVSelect == 1) + xy = IN[i].uv2; + + float reconstructedZ = sqrt(1-saturate(dot(xy, xy))); + vc = normalize(float3(xy, reconstructedZ)); + } + vc = vc * 2 - 1; + float3 t = mul(unity_WorldToObject, IN[i].ntb[1]); + float3 b = mul(unity_WorldToObject, IN[i].ntb[2]); + float3 n = mul(unity_WorldToObject, IN[i].ntb[0]); + half3 tspace0 = half3(t.x, b.x, n.x); + half3 tspace1 = half3(t.y, b.y, n.y); + half3 tspace2 = half3(t.z, b.z, n.z); + + half3 calcedNormal; + calcedNormal.x = dot(tspace0, vc); + calcedNormal.y = dot(tspace1, vc); + calcedNormal.z = dot(tspace2, vc); + + half3 normalDir = normalize(lerp(IN[i].normal, calcedNormal, saturate(_OutlineNormalMode))); + float4 outlinePos = float4(IN[i].vertex + normalDir * outlineWidth, 1); + + if(outlineWidthMask == 0) + return; + + o.pos = UnityObjectToClipPos(outlinePos); + o.worldPos = worldPos; + o.ntb[0] = IN[i].ntb[0]; + o.ntb[1] = IN[i].ntb[1]; + o.ntb[2] = IN[i].ntb[2]; + o.uv = IN[i].uv; + o.uv1 = IN[i].uv1; + o.color = float4(IN[i].color.rgb, 1); // store if outline in alpha channel of vertex colors | 1 = is an outline + o.screenPos = ComputeScreenPos(o.pos); + o.objPos = normalize(outlinePos); + + #if !defined(UNITY_PASS_SHADOWCASTER) + UNITY_TRANSFER_SHADOW(o, o.uv); + UNITY_TRANSFER_FOG(o, o.pos); + #else + TRANSFER_SHADOW_CASTER_NOPOS_GEOMETRY(o, o.pos, outlinePos, IN[i].ntb[0]); + #endif + tristream.Append(o); + } + tristream.RestartStrip(); + + + } +#endif
\ No newline at end of file diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSGeom.cginc.meta b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSGeom.cginc.meta new file mode 100644 index 00000000..857ba3e7 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSGeom.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 8ab351cd01215a74fbe8f1227faf9487 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSHelperFunctions.cginc b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSHelperFunctions.cginc new file mode 100644 index 00000000..011fe0fe --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSHelperFunctions.cginc @@ -0,0 +1,395 @@ +void calcNormal(inout XSLighting i) +{ + if(_NormalMapMode == 0) + { + half3 nMap = UnpackScaleNormal(i.normalMap, _BumpScale); + half3 detNMap = UnpackScaleNormal(i.detailNormal, _DetailNormalMapScale); + + half3 blendedNormal = lerp(nMap, BlendNormals(nMap, detNMap), i.detailMask.r); + + half3 tspace0 = half3(i.tangent.x, i.bitangent.x, i.normal.x); + half3 tspace1 = half3(i.tangent.y, i.bitangent.y, i.normal.y); + half3 tspace2 = half3(i.tangent.z, i.bitangent.z, i.normal.z); + + half3 calcedNormal; + calcedNormal.x = dot(tspace0, blendedNormal); + calcedNormal.y = dot(tspace1, blendedNormal); + calcedNormal.z = dot(tspace2, blendedNormal); + + calcedNormal = normalize(calcedNormal); + half3 bumpedTangent = cross(i.bitangent, calcedNormal); + half3 bumpedBitangent = cross(calcedNormal, bumpedTangent); + + i.normal = calcedNormal; + i.tangent = bumpedTangent; + i.bitangent = bumpedBitangent; + } + else + { + float3 vcol = i.color.rgb * 2 - 1; + + half3 tspace0 = half3(i.tangent.x, i.bitangent.x, i.normal.x); + half3 tspace1 = half3(i.tangent.y, i.bitangent.y, i.normal.y); + half3 tspace2 = half3(i.tangent.z, i.bitangent.z, i.normal.z); + + half3 calcedNormal; + calcedNormal.x = dot(tspace0, vcol); + calcedNormal.y = dot(tspace1, vcol); + calcedNormal.z = dot(tspace2, vcol); + + //calcedNormal = calcedNormal; + i.normal = normalize(calcedNormal); + } +} + +void InitializeTextureUVs( + #if defined(Geometry) + in g2f i, + #else + in VertexOutput i, + #endif + inout TextureUV t) +{ + #if defined(PatreonEyeTracking) + float2 eyeUvOffset = eyeOffsets(i.uv, i.objPos, i.worldPos, i.ntb[0]); + i.uv = eyeUvOffset; + i.uv1 = eyeUvOffset; + #endif + + half2 uvSetAlbedo = (_UVSetAlbedo == 0) ? i.uv : i.uv1; + t.albedoUV = TRANSFORM_TEX(uvSetAlbedo, _MainTex); + + half2 uvSetClipMap = (_UVSetClipMap == 0) ? i.uv : i.uv1; + t.clipMapUV = TRANSFORM_TEX(uvSetClipMap, _ClipMap); + + half2 uvSetDissolveMap = (_UVSetDissolve == 0) ? i.uv : i.uv1; + t.dissolveUV = TRANSFORM_TEX(uvSetDissolveMap, _DissolveTexture); + + #if !defined(UNITY_PASS_SHADOWCASTER) + half2 uvSetNormalMap = (_UVSetNormal == 0) ? i.uv : i.uv1; + t.normalMapUV = TRANSFORM_TEX(uvSetNormalMap, _BumpMap); + + half2 uvSetEmissionMap = (_UVSetEmission == 0) ? i.uv : i.uv1; + t.emissionMapUV = TRANSFORM_TEX(uvSetEmissionMap, _EmissionMap); + + half2 uvSetMetallicGlossMap = (_UVSetMetallic == 0) ? i.uv : i.uv1; + t.metallicGlossMapUV = TRANSFORM_TEX(uvSetMetallicGlossMap, _MetallicGlossMap); + + half2 uvSetOcclusion = (_UVSetOcclusion == 0) ? i.uv : i.uv1; + t.occlusionUV = TRANSFORM_TEX(uvSetOcclusion, _OcclusionMap); + + half2 uvSetDetailNormal = (_UVSetDetNormal == 0) ? i.uv : i.uv1; + t.detailNormalUV = TRANSFORM_TEX(uvSetDetailNormal, _DetailNormalMap); + + half2 uvSetDetailMask = (_UVSetDetMask == 0) ? i.uv : i.uv1; + t.detailMaskUV = TRANSFORM_TEX(uvSetDetailMask, _DetailMask); + + half2 uvSetSpecularMap = (_UVSetSpecular == 0) ? i.uv : i.uv1; + t.specularMapUV = TRANSFORM_TEX(uvSetSpecularMap, _SpecularMap); + + half2 uvSetThickness = (_UVSetThickness == 0) ? i.uv : i.uv1; + t.thicknessMapUV = TRANSFORM_TEX(uvSetThickness, _ThicknessMap); + + half2 uvSetReflectivityMask = (_UVSetReflectivity == 0) ? i.uv : i.uv1; + t.reflectivityMaskUV = TRANSFORM_TEX(uvSetReflectivityMask, _ReflectivityMask); + #endif +} + +float Remap_Float(float In, float2 InMinMax, float2 OutMinMax) +{ + return OutMinMax.x + (In - InMinMax.x) * (OutMinMax.y - OutMinMax.x) / (InMinMax.y - InMinMax.x); +} + +half3 rgb2hsv(half3 c) +{ + half4 K = half4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); + half4 p = lerp(half4(c.bg, K.wz), half4(c.gb, K.xy), step(c.b, c.g)); + half4 q = lerp(half4(p.xyw, c.r), half4(c.r, p.yzx), step(p.x, c.r)); + + float d = q.x - min(q.w, q.y); + float e = 1.0e-10; + return half3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); +} + +half3 hsv2rgb(half3 c) +{ + half4 K = half4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); + half3 p = abs(frac(c.xxx + K.xyz) * 6.0 - K.www); + return c.z * lerp(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); +} + +void InitializeTextureUVsMerged( + #if defined(Geometry) + in g2f i, + #else + in VertexOutput i, + #endif + inout TextureUV t) +{ + half2 uvSetAlbedo = (_UVSetAlbedo == 0) ? i.uv : i.uv1; + t.albedoUV = TRANSFORM_TEX(uvSetAlbedo, _MainTex); + t.normalMapUV = t.albedoUV; + t.emissionMapUV = t.albedoUV; + t.metallicGlossMapUV = t.albedoUV; + t.occlusionUV = t.albedoUV; + t.detailNormalUV = t.albedoUV; + t.detailMaskUV = t.albedoUV; + t.specularMapUV = t.albedoUV; + t.thicknessMapUV = t.albedoUV; + t.reflectivityMaskUV = t.albedoUV; + t.clipMapUV = t.albedoUV; + + //Dissolve map makes sense to be on a sep. UV always. + half2 uvSetDissolveMap = (_UVSetDissolve == 0) ? i.uv : i.uv1; + t.dissolveUV = TRANSFORM_TEX(uvSetDissolveMap, _DissolveTexture); +} + +bool IsInMirror() +{ + return unity_CameraProjection[2][0] != 0.f || unity_CameraProjection[2][1] != 0.f; +} + +inline half Dither8x8Bayer( int x, int y ) +{ + const half dither[ 64 ] = { + 1, 49, 13, 61, 4, 52, 16, 64, + 33, 17, 45, 29, 36, 20, 48, 32, + 9, 57, 5, 53, 12, 60, 8, 56, + 41, 25, 37, 21, 44, 28, 40, 24, + 3, 51, 15, 63, 2, 50, 14, 62, + 35, 19, 47, 31, 34, 18, 46, 30, + 11, 59, 7, 55, 10, 58, 6, 54, + 43, 27, 39, 23, 42, 26, 38, 22}; + int r = y * 8 + x; + return dither[r] / 64; +} + +half calcDither(half2 screenPos) +{ + half dither = Dither8x8Bayer(fmod(screenPos.x, 8), fmod(screenPos.y, 8)); + return dither; +} + +half2 calcScreenUVs(half4 screenPos) +{ + half2 uv = screenPos / (screenPos.w + 0.0000000001); //0.0x1 Stops division by 0 warning in console. + #if UNITY_SINGLE_PASS_STEREO + uv.xy *= half2(_ScreenParams.x * 2, _ScreenParams.y); + #else + uv.xy *= _ScreenParams.xy; + #endif + + return uv; +} + +half3 calcViewDir(half3 worldPos) +{ + half3 viewDir = _WorldSpaceCameraPos - worldPos; + return normalize(viewDir); +} + +half3 calcStereoViewDir(half3 worldPos) +{ + #if UNITY_SINGLE_PASS_STEREO + half3 cameraPos = half3((unity_StereoWorldSpaceCameraPos[0]+ unity_StereoWorldSpaceCameraPos[1])*.5); + #else + half3 cameraPos = _WorldSpaceCameraPos; + #endif + half3 viewDir = cameraPos - worldPos; + return normalize(viewDir); +} + +half2 matcapSample(half3 worldUp, half3 viewDirection, half3 normalDirection) +{ + half3 worldViewUp = normalize(worldUp - viewDirection * dot(viewDirection, worldUp)); + half3 worldViewRight = normalize(cross(viewDirection, worldViewUp)); + half2 matcapUV = half2(dot(worldViewRight, normalDirection), dot(worldViewUp, normalDirection)) * 0.5 + 0.5; + return matcapUV; +} + //Reflection direction, worldPos, unity_SpecCube0_ProbePosition, unity_SpecCube0_BoxMin, unity_SpecCube0_BoxMax +half3 getReflectionUV(half3 direction, half3 position, half4 cubemapPosition, half3 boxMin, half3 boxMax) +{ + #if UNITY_SPECCUBE_BOX_PROJECTION + if (cubemapPosition.w > 0) { + half3 factors = ((direction > 0 ? boxMax : boxMin) - position) / direction; + half scalar = min(min(factors.x, factors.y), factors.z); + direction = direction * scalar + (position - cubemapPosition); + } + #endif + return direction; +} + +half3 getEnvMap(XSLighting i, DotProducts d, float blur, half3 reflDir, half3 indirectLight, half3 wnormal) +{//This function handls Unity style reflections, Matcaps, and a baked in fallback cubemap. + half3 envMap = half3(0,0,0); + + #if defined(UNITY_PASS_FORWARDBASE) //Indirect PBR specular should only happen in the forward base pass. Otherwise each extra light adds another indirect sample, which could mean you're getting too much light. + half3 reflectionUV1 = getReflectionUV(reflDir, i.worldPos, unity_SpecCube0_ProbePosition, unity_SpecCube0_BoxMin, unity_SpecCube0_BoxMax); + half4 probe0 = UNITY_SAMPLE_TEXCUBE_LOD(unity_SpecCube0, reflectionUV1, blur); + half3 probe0sample = DecodeHDR(probe0, unity_SpecCube0_HDR); + + half3 indirectSpecular; + half interpolator = unity_SpecCube0_BoxMin.w; + + UNITY_BRANCH + if (interpolator < 0.99999) + { + half3 reflectionUV2 = getReflectionUV(reflDir, i.worldPos, unity_SpecCube1_ProbePosition, unity_SpecCube1_BoxMin, unity_SpecCube1_BoxMax); + half4 probe1 = UNITY_SAMPLE_TEXCUBE_SAMPLER_LOD(unity_SpecCube1, unity_SpecCube0, reflectionUV2, blur); + half3 probe1sample = DecodeHDR(probe1, unity_SpecCube1_HDR); + indirectSpecular = lerp(probe1sample, probe0sample, interpolator); + } + else + { + indirectSpecular = probe0sample; + } + + envMap = indirectSpecular; + #endif + + return envMap; +} + +float AlphaAdjust(float alphaToAdj, float3 vColor) +{ + _ClipAgainstVertexColorGreaterZeroFive = saturate(_ClipAgainstVertexColorGreaterZeroFive); //So the lerp doesn't go crazy + _ClipAgainstVertexColorLessZeroFive = saturate(_ClipAgainstVertexColorLessZeroFive); + + float modR = vColor.r < 0.5 ? _ClipAgainstVertexColorLessZeroFive.r : _ClipAgainstVertexColorGreaterZeroFive.r; + float modG = vColor.g < 0.5 ? _ClipAgainstVertexColorLessZeroFive.g : _ClipAgainstVertexColorGreaterZeroFive.g; + float modB = vColor.b < 0.5 ? _ClipAgainstVertexColorLessZeroFive.b : _ClipAgainstVertexColorGreaterZeroFive.b; + + alphaToAdj *= lerp(0, 1, lerp(1, modR, step(0.01, vColor.r))); + alphaToAdj *= lerp(0, 1, lerp(1, modG, step(0.01, vColor.g))); + alphaToAdj *= lerp(0, 1, lerp(1, modB, step(0.01, vColor.b))); + + return alphaToAdj; +} + +void calcDissolve(inout XSLighting i, inout float4 col) +{ + #ifdef _ALPHATEST_ON + half dissolveAmt = Remap_Float(i.dissolveMask.x, float2(0,1), float2(0.1, 0.9)); + half dissolveProgress = saturate(_DissolveProgress + lerp(0, 1-AlphaAdjust(1, i.clipMap.rgb), _UseClipsForDissolve)); + half dissolve = 0; + if (_DissolveCoordinates == 0) + { + dissolve = dissolveAmt - dissolveProgress; + clip(dissolve); + } + + if(_DissolveCoordinates == 1) + { + half distToCenter = 1-length(i.objPos); + dissolve = ((distToCenter + dissolveAmt) * 0.5) - dissolveProgress; + clip(dissolve); + } + + if(_DissolveCoordinates == 2) + { + half distToCenter = (1-i.objPos.y) * 0.5 + 0.5; + dissolve = ((distToCenter + dissolveAmt) * 0.5) - dissolveProgress; + clip(dissolve); + } + + #if !defined(UNITY_PASS_SHADOWCASTER) + float4 dissCol = _DissolveColor; + dissCol.rgb = rgb2hsv(dissCol.rgb); + dissCol.x += fmod(_Hue, 360); + dissCol.y = saturate(dissCol.y * _Saturation); + dissCol.z *= _Value; + dissCol.rgb = hsv2rgb(dissCol.rgb); + + half dissolveEdge = smoothstep(dissolve, dissolve - (_DissolveStrength * 0.01), dissolve * dissolveAmt); + col.rgb += (1-dissolveEdge) * dissCol.rgb; + #endif + #endif +} + +void calcAlpha(inout XSLighting i) +{ + i.alpha = 1; + + #ifdef _ALPHABLEND_ON + i.alpha = i.albedo.a; + + #ifdef UNITY_PASS_SHADOWCASTER + half dither = calcDither(i.screenUV.xy); + clip(i.alpha - dither); + #endif + #endif + + #ifdef _ALPHATEST_ON + float modifiedAlpha = lerp(AlphaAdjust(i.albedo.a, i.clipMap.rgb), i.albedo.a, _UseClipsForDissolve); + if(_BlendMode >= 3) + { + half dither = calcDither(i.screenUV.xy); + i.alpha = modifiedAlpha - (dither * (1-i.albedo.a) * 0.15); + } + + if(_BlendMode == 2) + { + half dither = calcDither(i.screenUV.xy); + float fadeDist = abs(_FadeDitherDistance); + float d = distance(_WorldSpaceCameraPos, i.worldPos); + d = smoothstep(fadeDist, fadeDist + 0.05, d); + d = lerp(d, 1-d, saturate(step(0, _FadeDitherDistance))); + dither += lerp(0, d, saturate(_FadeDither)); + clip(modifiedAlpha - dither); + } + + if(_BlendMode == 1) + { + clip(modifiedAlpha - _Cutoff); + } + #endif +} + +// //Halftone functions, finish implementing later.. Not correct right now. +float2 SphereUV( float3 coords /*viewDir?*/) +{ + float3 nc = normalize(coords); + float lat = acos(nc.y); + float lon = atan2(nc.z, nc.x); + float2 coord = 1.0 - (float2(lon, lat) * float2(1.0/UNITY_PI, 1.0/UNITY_PI)); + return (coord + float4(0, 1-unity_StereoEyeIndex,1,1.0).xy) * float4(0, 1-unity_StereoEyeIndex,1,1.0).zw; +} + +half2 rotateUV(half2 uv, half rotation) +{ + half mid = 0.5; + return half2( + cos(rotation) * (uv.x - mid) + sin(rotation) * (uv.y - mid) + mid, + cos(rotation) * (uv.y - mid) - sin(rotation) * (uv.x - mid) + mid + ); +} + +half DotHalftone(XSLighting i, half scalar) //Scalar can be anything from attenuation to a dot product +{ + bool inMirror = IsInMirror(); + half2 uv = SphereUV(calcViewDir(i.worldPos)); + uv.xy *= _HalftoneDotAmount; + half2 nearest = 2 * frac(100 * uv) - 1; + half dist = length(nearest); + half dotSize = 100 * _HalftoneDotSize * scalar; + half dotMask = step(dotSize, dist); + + return lerp(1, 1-dotMask, smoothstep(0, 0.4, 1/distance(i.worldPos, _WorldSpaceCameraPos)));; +} + +half LineHalftone(XSLighting i, half scalar) +{ + // #if defined(DIRECTIONAL) + // scalar = saturate(scalar + ((1-i.attenuation) * 0.2)); + // #endif + bool inMirror = IsInMirror(); + half2 uv = SphereUV(calcViewDir(i.worldPos)); + uv = rotateUV(uv, -0.785398); + uv.x = sin(uv.x * _HalftoneLineAmount * scalar); + + half2 steppedUV = smoothstep(0,0.2,uv.x); + half lineMask = lerp(1, steppedUV, smoothstep(0, 0.4, 1/distance(i.worldPos, _WorldSpaceCameraPos))); + + return saturate(lineMask); +} +//
\ No newline at end of file diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSHelperFunctions.cginc.meta b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSHelperFunctions.cginc.meta new file mode 100644 index 00000000..0177033b --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSHelperFunctions.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: ebd21331063545043946502d33e9244f +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSLighting.cginc b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSLighting.cginc new file mode 100644 index 00000000..fead4f8d --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSLighting.cginc @@ -0,0 +1,118 @@ +half4 BRDF_XSLighting(XSLighting i) +{ + float3 untouchedNormal = i.normal; + i.tangent = normalize(i.tangent); + i.bitangent = normalize(i.bitangent); + calcNormal(i); + + half3 indirectDiffuse = calcIndirectDiffuse(i); + bool lightEnv = any(_WorldSpaceLightPos0.xyz); + half3 lightDir = calcLightDir(i); + half3 viewDir = calcViewDir(i.worldPos); + half3 stereoViewDir = calcStereoViewDir(i.worldPos); + half4 metallicSmoothness = calcMetallicSmoothness(i); + half3 halfVector = normalize(lightDir + viewDir); + half3 reflView = calcReflView(viewDir, i.normal); + half3 reflLight = calcReflLight(lightDir, i.normal); + half3 reflViewAniso = getAnisotropicReflectionVector(viewDir, i.bitangent, i.tangent, i.normal, metallicSmoothness.a, _AnisotropicReflection); + + DotProducts d = (DotProducts)0; + d.ndl = dot(i.normal, lightDir); + d.vdn = abs(dot(viewDir, i.normal)); + d.vdh = DotClamped(viewDir, halfVector); + d.tdh = dot(i.tangent, halfVector); + d.bdh = dot(i.bitangent, halfVector); + d.ndh = DotClamped(i.normal, halfVector); + d.rdv = saturate(dot(reflLight, float4(-viewDir, 0))); + d.ldh = DotClamped(lightDir, halfVector); + d.svdn = abs(dot(stereoViewDir, i.normal)); + + i.albedo.rgb = rgb2hsv(i.albedo.rgb); + i.albedo.x += fmod(lerp(0, _Hue, i.hsvMask.r), 360); + i.albedo.y = saturate(i.albedo.y * lerp(1, _Saturation, i.hsvMask.g)); + i.albedo.z *= lerp(1, _Value, i.hsvMask.b); + i.albedo.rgb = hsv2rgb(i.albedo.rgb); + + i.diffuseColor.rgb = i.albedo.rgb; + i.albedo.rgb *= (1-metallicSmoothness.x); + half occlusion = lerp(1, i.occlusion.r, _OcclusionIntensity); + indirectDiffuse *= lerp(occlusion, 1, _OcclusionMode); + + half4 lightCol = half4(0,0,0,0); + calcLightCol(lightEnv, indirectDiffuse, lightCol); + + float3 vertexLightDiffuse = 0; + float3 vertexLightSpec = 0; + #if defined(VERTEXLIGHT_ON) + VertexLightInformation vLight = (VertexLightInformation)0; + float4 vertexLightAtten = float4(0,0,0,0); + float3 vertexLightColor = get4VertexLightsColFalloff(vLight, i.worldPos, i.normal, vertexLightAtten); + float3 vertexLightDir = getVertexLightsDir(vLight, i.worldPos, vertexLightAtten); + vertexLightDiffuse = getVertexLightsDiffuse(i, vLight); + indirectDiffuse += vertexLightDiffuse; + + vertexLightSpec = getVertexLightSpecular(i, d, vLight, i.normal, viewDir, _AnisotropicSpecular) * occlusion; + #endif + + half lightAvg = (dot(indirectDiffuse.rgb, grayscaleVec) + dot(lightCol.rgb, grayscaleVec)) / 2; + half3 envMapBlurred = getEnvMap(i, d, 5, reflView, indirectDiffuse, i.normal); + + half4 ramp = calcRamp(i,d); + half4 diffuse = calcDiffuse(i, d, indirectDiffuse, lightCol, ramp); + half4 rimLight = calcRimLight(i, d, lightCol, indirectDiffuse, envMapBlurred); + half4 shadowRim = calcShadowRim(i, d, indirectDiffuse); + + float3 f0 = 0.16 * _Reflectivity * _Reflectivity * (1.0 - metallicSmoothness.r) + i.diffuseColor * metallicSmoothness.r; + float3 fresnel = F_Schlick(d.vdn, f0); + half3 indirectSpecular = calcIndirectSpecular(i, d, metallicSmoothness, reflViewAniso, indirectDiffuse, viewDir, fresnel, ramp) * occlusion; + half3 directSpecular = calcDirectSpecular(i, d.ndl, d.ndh, d.vdn, d.ldh, lightCol, halfVector, _AnisotropicSpecular) * d.ndl * occlusion * i.attenuation; + half4 subsurface = calcSubsurfaceScattering(i, d, lightDir, viewDir, i.normal, lightCol, indirectDiffuse); + half4 outlineColor = calcOutlineColor(i, d, indirectDiffuse, lightCol); + + half lineHalftone = 0; + half stipplingDirect = 0; + half stipplingRim = 0; + half stipplingIndirect = 0; + bool usingLineHalftone = 0; + if(_HalftoneType == 0 || _HalftoneType == 2) + { + lineHalftone = lerp(1, LineHalftone(i, 1), 1-saturate(dot(shadowRim * ramp, grayscaleVec))); + usingLineHalftone = 1; + } + + if(_HalftoneType == 1 || _HalftoneType == 2) + { + stipplingDirect = DotHalftone(i, saturate(dot(directSpecular, grayscaleVec))) * saturate(dot(shadowRim * ramp, grayscaleVec)); + stipplingRim = DotHalftone(i, saturate(dot(rimLight, grayscaleVec))) * saturate(dot(shadowRim * ramp, grayscaleVec)); + stipplingIndirect = DotHalftone(i, saturate(dot(indirectSpecular, grayscaleVec))) * saturate(dot(shadowRim * ramp, grayscaleVec)); + + directSpecular *= stipplingDirect; + rimLight *= stipplingRim; + indirectSpecular *= lerp(0.5, 1, stipplingIndirect); // Don't want these to go completely black, looks weird + } + + #if defined(_COLOROVERLAY_ON) + float refractFresnel = 1-d.vdn; + float distanceToPixel = distance(_WorldSpaceCameraPos, i.worldPos); + float distanceScalar = saturate(1 / distanceToPixel) * saturate(distanceToPixel); + float3 refractDir = refract(viewDir, i.normal, max(0, _IOR - 1) * 0.03 * distanceScalar * refractFresnel); + float3x3 worldToTangentMatrix = float3x3(i.tangent, i.bitangent, i.normal); + refractDir = mul(worldToTangentMatrix, refractDir); + float4 backgroundColor = tex2Dproj(_GrabTexture, float4(i.screenPos.xyz + refractDir, i.screenPos.w)); + #endif + + half4 col; + #if !defined(_COLOROVERLAY_ON) + col = diffuse * shadowRim; + #else + col = backgroundColor * diffuse * shadowRim; + #endif + calcReflectionBlending(i, col, indirectSpecular.xyzz); + col += max(directSpecular.xyzz, rimLight); + col.rgb += max(vertexLightSpec.rgb, rimLight); + col += subsurface; + calcClearcoat(col, i, d, untouchedNormal, indirectDiffuse, lightCol, viewDir, lightDir, ramp); + col += calcEmission(i, lightAvg); + float4 finalColor = lerp(col, outlineColor, i.isOutline) * lerp(1, lineHalftone, _HalftoneLineIntensity * usingLineHalftone); + return finalColor; +}
\ No newline at end of file diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSLighting.cginc.meta b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSLighting.cginc.meta new file mode 100644 index 00000000..b11ced2b --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSLighting.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 786da05e6d64ae844853fdca78e33aef +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSLightingFunctions.cginc b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSLightingFunctions.cginc new file mode 100644 index 00000000..f28f6f29 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSLightingFunctions.cginc @@ -0,0 +1,428 @@ +//Helper Functions for Reflections +float pow5(float a) +{ + return a * a * a * a * a; +} + +float3 F_Schlick(float u, float3 f0) +{ + return f0 + (1.0 - f0) * pow(1.0 - u, 5.0); +} + +float3 F_FresnelLerp (float3 F0, float3 F90, float cosA) +{ + float t = pow5(1 - cosA); // ala Schlick interpoliation + return lerp (F0, F90, t); +} + +float D_GGX(float NoH, float roughness) +{ + float a2 = roughness * roughness; + float f = (NoH * a2 - NoH) * NoH + 1.0; + return a2 / (UNITY_PI * f * f); +} + +float D_GGX_Anisotropic(float NoH, const float3 h, const float3 t, const float3 b, float at, float ab) +{ + float ToH = dot(t, h); + float BoH = dot(b, h); + float a2 = at * ab; + float3 v = float3(ab * ToH, at * BoH, a2 * NoH); + float v2 = dot(v, v); + float w2 = a2 / v2; + return a2 * w2 * w2 * (1.0 / UNITY_PI); +} + +float V_SmithGGXCorrelated(float NoV, float NoL, float a) +{ + float a2 = a * a; + float GGXL = NoV * sqrt((-NoL * a2 + NoL) * NoL + a2); + float GGXV = NoL * sqrt((-NoV * a2 + NoV) * NoV + a2); + return 0.5 / (GGXV + GGXL); +} + +half3 calcReflView(half3 viewDir, half3 normal) +{ + return reflect(-viewDir, normal); +} + +half3 calcReflLight(half3 lightDir, half3 normal) +{ + return reflect(lightDir, normal); +} +// + +//Returns the average direction of all lights and writes to a struct contraining individual directions +float3 getVertexLightsDir(inout VertexLightInformation vLights, float3 worldPos, float4 vertexLightAtten) +{ + float3 dir = float3(0,0,0); + float3 toLightX = float3(unity_4LightPosX0.x, unity_4LightPosY0.x, unity_4LightPosZ0.x); + float3 toLightY = float3(unity_4LightPosX0.y, unity_4LightPosY0.y, unity_4LightPosZ0.y); + float3 toLightZ = float3(unity_4LightPosX0.z, unity_4LightPosY0.z, unity_4LightPosZ0.z); + float3 toLightW = float3(unity_4LightPosX0.w, unity_4LightPosY0.w, unity_4LightPosZ0.w); + + float3 dirX = toLightX - worldPos; + float3 dirY = toLightY - worldPos; + float3 dirZ = toLightZ - worldPos; + float3 dirW = toLightW - worldPos; + + dirX *= length(toLightX) * vertexLightAtten.x; + dirY *= length(toLightY) * vertexLightAtten.y; + dirZ *= length(toLightZ) * vertexLightAtten.z; + dirW *= length(toLightW) * vertexLightAtten.w; + + vLights.Direction[0] = dirX; + vLights.Direction[1] = dirY; + vLights.Direction[2] = dirZ; + vLights.Direction[3] = dirW; + + dir = (dirX + dirY + dirZ + dirW) / 4; + return dir; +} + +// Get the most intense light Dir from probes OR from a light source. Method developed by Xiexe / Merlin +half3 calcLightDir(XSLighting i) +{ + half3 lightDir = UnityWorldSpaceLightDir(i.worldPos); + half3 probeLightDir = unity_SHAr.xyz + unity_SHAg.xyz + unity_SHAb.xyz; + lightDir = (lightDir + probeLightDir); //Make light dir the average of the probe direction and the light source direction. + #if !defined(POINT) && !defined(SPOT)// if the average length of the light probes is null, and we don't have a directional light in the scene, fall back to our fallback lightDir + if(length(unity_SHAr.xyz*unity_SHAr.w + unity_SHAg.xyz*unity_SHAg.w + unity_SHAb.xyz*unity_SHAb.w) == 0 && length(lightDir) < 0.1) + { + lightDir = half4(1, 1, 1, 0); + } + #endif + return normalize(lightDir); +} + +void calcLightCol(bool lightEnv, inout half3 indirectDiffuse, inout half4 lightColor) +{ + //If we're in an environment with a realtime light, then we should use the light color, and indirect color raw. + //... + if(lightEnv) + { + lightColor = _LightColor0; + indirectDiffuse = indirectDiffuse; + } + else + { + lightColor = indirectDiffuse.xyzz * 0.6; // ...Otherwise + indirectDiffuse = indirectDiffuse * 0.4; // Keep overall light to 100% - these should never go over 100% + // ex. If we have indirect 100% as the light color and Indirect 50% as the indirect color, + // we end up with 150% of the light from the scene. + } +} + +float3 get4VertexLightsColFalloff(inout VertexLightInformation vLight, float3 worldPos, float3 normal, inout float4 vertexLightAtten) +{ + float3 lightColor = 0; + #if defined(VERTEXLIGHT_ON) + float4 toLightX = unity_4LightPosX0 - worldPos.x; + float4 toLightY = unity_4LightPosY0 - worldPos.y; + float4 toLightZ = unity_4LightPosZ0 - worldPos.z; + + float4 lengthSq = 0; + lengthSq += toLightX * toLightX; + lengthSq += toLightY * toLightY; + lengthSq += toLightZ * toLightZ; + + float4 atten = 1.0 / (1.0 + lengthSq * unity_4LightAtten0); + float4 atten2 = saturate(1 - (lengthSq * unity_4LightAtten0 / 25)); + atten = min(atten, atten2 * atten2); + // Cleaner, nicer looking falloff. Also prevents the "Snapping in" effect that Unity's normal integration of vertex lights has. + vertexLightAtten = atten; + + lightColor.rgb += unity_LightColor[0] * atten.x; + lightColor.rgb += unity_LightColor[1] * atten.y; + lightColor.rgb += unity_LightColor[2] * atten.z; + lightColor.rgb += unity_LightColor[3] * atten.w; + + vLight.ColorFalloff[0] = unity_LightColor[0] * atten.x; + vLight.ColorFalloff[1] = unity_LightColor[1] * atten.y; + vLight.ColorFalloff[2] = unity_LightColor[2] * atten.z; + vLight.ColorFalloff[3] = unity_LightColor[3] * atten.w; + + vLight.Attenuation[0] = atten.x; + vLight.Attenuation[1] = atten.y; + vLight.Attenuation[2] = atten.z; + vLight.Attenuation[3] = atten.w; + #endif + return lightColor; +} + +half4 calcRamp(XSLighting i, DotProducts d) +{ + half remapRamp; + remapRamp = (d.ndl * 0.5 + 0.5) * lerp(1, i.occlusion.r, _OcclusionMode) ; + #if defined(UNITY_PASS_FORWARDBASE) + remapRamp *= i.attenuation; + #endif + half4 ramp = tex2D(_Ramp, half2(remapRamp, i.rampMask.r)); + return ramp; +} + +half4 calcRampShadowOverride(XSLighting i, float ndl) +{ + half remapRamp; + remapRamp = (ndl * 0.5 + 0.5) * lerp(1, i.occlusion.r, _OcclusionMode); + half4 ramp = tex2D(_Ramp, half2(remapRamp, i.rampMask.r)); + return ramp; +} + +float3 getVertexLightsDiffuse(XSLighting i, VertexLightInformation vLight) +{ + float3 vertexLightsDiffuse = 0; + #if defined(VERTEXLIGHT_ON) + for(int light = 0; light < 4; light++) // I know, I know, not using i. Blame my structs. + { + float vLightNdl = dot(vLight.Direction[light], i.normal); + vertexLightsDiffuse += calcRampShadowOverride(i, vLightNdl) * vLight.ColorFalloff[light]; + } + #endif + return vertexLightsDiffuse; +} + +half4 calcMetallicSmoothness(XSLighting i) +{ + half roughness = 1-(_Glossiness * i.metallicGlossMap.a); + roughness *= 1.7 - 0.7 * roughness; + half metallic = lerp(0, i.metallicGlossMap.r * _Metallic, i.reflectivityMask.r); + return half4(metallic, 0, 0, roughness); +} + +half4 calcRimLight(XSLighting i, DotProducts d, half4 lightCol, half3 indirectDiffuse, half3 envMap) +{ + half rimIntensity = saturate((1-d.svdn)) * pow(d.ndl, _RimThreshold); + rimIntensity = smoothstep(_RimRange - _RimSharpness, _RimRange + _RimSharpness, rimIntensity); + half4 rim = rimIntensity * _RimIntensity * (lightCol + indirectDiffuse.xyzz); + rim *= lerp(1, i.attenuation + indirectDiffuse.xyzz, _RimAttenEffect); + return rim * _RimColor * lerp(1, i.diffuseColor.rgbb, _RimAlbedoTint) * lerp(1, envMap.rgbb, _RimCubemapTint); +} + +half4 calcShadowRim(XSLighting i, DotProducts d, half3 indirectDiffuse) +{ + half rimIntensity = saturate((1-d.svdn)) * pow(1-d.ndl, _ShadowRimThreshold * 2); + rimIntensity = smoothstep(_ShadowRimRange - _ShadowRimSharpness, _ShadowRimRange + _ShadowRimSharpness, rimIntensity); + half4 shadowRim = lerp(1, (_ShadowRim * lerp(1, i.diffuseColor.rgbb, _ShadowRimAlbedoTint)) + (indirectDiffuse.xyzz * 0.1), rimIntensity); + + return shadowRim ; +} + +float3 getAnisotropicReflectionVector(float3 viewDir, float3 bitangent, float3 tangent, float3 normal, float roughness, float anisotropy) +{ + //_Anisotropy = lerp(-0.2, 0.2, sin(_Time.y / 20)); //This is pretty fun + float3 anisotropicDirection = anisotropy >= 0.0 ? bitangent : tangent; + float3 anisotropicTangent = cross(anisotropicDirection, viewDir); + float3 anisotropicNormal = cross(anisotropicTangent, anisotropicDirection); + float bendFactor = abs(anisotropy) * saturate(5.0 * roughness); + float3 bentNormal = normalize(lerp(normal, anisotropicNormal, bendFactor)); + return reflect(-viewDir, bentNormal); +} + +half3 calcDirectSpecular(XSLighting i, float ndl, float ndh, float vdn, float ldh, half4 lightCol, half3 halfVector, half anisotropy) +{ + half specularIntensity = _SpecularIntensity * i.specularMap.r; + half3 specular = half3(0,0,0); + half smoothness = max(0.01, (_SpecularArea * i.specularMap.b)); + smoothness *= 1.7 - 0.7 * smoothness; + + float rough = max(smoothness * smoothness, 0.0045); + float Dn = D_GGX(ndh, rough); + float3 F = 1-F_Schlick(ldh, 0); + float V = V_SmithGGXCorrelated(vdn, ndl, rough); + float3 directSpecularNonAniso = max(0, (Dn * V) * F); + + anisotropy *= saturate(5.0 * smoothness); + float at = max(rough * (1.0 + anisotropy), 0.001); + float ab = max(rough * (1.0 - anisotropy), 0.001); + float D = D_GGX_Anisotropic(ndh, halfVector, i.tangent, i.bitangent, at, ab); + float3 directSpecularAniso = max(0, (D * V) * F); + + specular = lerp(directSpecularNonAniso, directSpecularAniso, saturate(abs(anisotropy * 100))); + specular = lerp(specular, smoothstep(0.5, 0.51, specular), _SpecularSharpness) * 3 * lightCol * specularIntensity; // Multiply by 3 to bring up to brightness of standard + specular *= lerp(1, i.diffuseColor, _SpecularAlbedoTint * i.specularMap.g); + return specular; +} + +float3 getVertexLightSpecular(XSLighting i, DotProducts d, VertexLightInformation vLight, float3 normal, float3 viewDir, float anisotropy) +{ + float3 vertexLightSpec = 0; + #if defined(VERTEXLIGHT_ON) + for(int light = 0; light < 4; light++) + { + // All of these need to be recalculated for each individual light to treat them how we want to treat them. + float3 vHalfVector = normalize(vLight.Direction[light] + viewDir); + float vNDL = saturate(dot(vLight.Direction[light], normal)); + float vLDH = saturate(dot(vLight.Direction[light], vHalfVector)); + float vNDH = saturate(dot(normal, vHalfVector)); + vertexLightSpec += calcDirectSpecular(i, vNDL, vNDH, d.vdn, vLDH, vLight.ColorFalloff[light].rgbb, vHalfVector, anisotropy) * vNDL; + } + #endif + return vertexLightSpec; +} + +half3 calcIndirectSpecular(XSLighting i, DotProducts d, half4 metallicSmoothness, half3 reflDir, half3 indirectLight, half3 viewDir, float3 fresnel, half4 ramp) +{//This function handls Unity style reflections, Matcaps, and a baked in fallback cubemap. + half3 spec = half3(0,0,0); + + UNITY_BRANCH + if(_ReflectionMode == 0) // PBR + { + #if defined(UNITY_PASS_FORWARDBASE) //Indirect PBR specular should only happen in the forward base pass. Otherwise each extra light adds another indirect sample, which could mean you're getting too much light. + half3 reflectionUV1 = getReflectionUV(reflDir, i.worldPos, unity_SpecCube0_ProbePosition, unity_SpecCube0_BoxMin, unity_SpecCube0_BoxMax); + half4 probe0 = UNITY_SAMPLE_TEXCUBE_LOD(unity_SpecCube0, reflectionUV1, metallicSmoothness.w * UNITY_SPECCUBE_LOD_STEPS); + half3 probe0sample = DecodeHDR(probe0, unity_SpecCube0_HDR); + + half3 indirectSpecular; + half interpolator = unity_SpecCube0_BoxMin.w; + + UNITY_BRANCH + if (interpolator < 0.99999) + { + half3 reflectionUV2 = getReflectionUV(reflDir, i.worldPos, unity_SpecCube1_ProbePosition, unity_SpecCube1_BoxMin, unity_SpecCube1_BoxMax); + half4 probe1 = UNITY_SAMPLE_TEXCUBE_SAMPLER_LOD(unity_SpecCube1, unity_SpecCube0, reflectionUV2, metallicSmoothness.w * UNITY_SPECCUBE_LOD_STEPS); + half3 probe1sample = DecodeHDR(probe1, unity_SpecCube1_HDR); + indirectSpecular = lerp(probe1sample, probe0sample, interpolator); + } + else + { + indirectSpecular = probe0sample; + } + + if (!any(indirectSpecular)) + { + indirectSpecular = texCUBElod(_BakedCubemap, half4(reflDir, metallicSmoothness.w * UNITY_SPECCUBE_LOD_STEPS)); + indirectSpecular *= indirectLight; + } + spec = indirectSpecular * fresnel; + #endif + } + else if(_ReflectionMode == 1) //Baked Cubemap + { + half3 indirectSpecular = texCUBElod(_BakedCubemap, half4(reflDir, metallicSmoothness.w * UNITY_SPECCUBE_LOD_STEPS));; + spec = indirectSpecular * fresnel; + + if(_ReflectionBlendMode != 1) + { + spec *= (indirectLight + (_LightColor0 * i.attenuation) * 0.5); + } + } + else if (_ReflectionMode == 2) //Matcap + { + half3 upVector = half3(0,1,0); + half2 remapUV = matcapSample(upVector, viewDir, i.normal); + spec = tex2Dlod(_Matcap, half4(remapUV, 0, ((1-metallicSmoothness.w) * UNITY_SPECCUBE_LOD_STEPS))) * _MatcapTint; + + if(_ReflectionBlendMode != 1) + { + spec *= (indirectLight + (_LightColor0 * i.attenuation) * 0.5); + } + + spec *= lerp(1, i.diffuseColor, _MatcapTintToDiffuse); + } + return spec; +} + +half4 calcOutlineColor(XSLighting i, DotProducts d, half3 indirectDiffuse, half4 lightCol) +{ + half3 outlineColor = half3(0,0,0); + #if defined(Geometry) + half3 ol = lerp(_OutlineColor, _OutlineColor * i.diffuseColor, _OutlineAlbedoTint); + outlineColor = ol * saturate(i.attenuation * d.ndl) * lightCol.rgb; + outlineColor += indirectDiffuse * ol; + outlineColor = lerp(outlineColor, ol, _OutlineLighting); + #endif + return half4(outlineColor,1); +} + +half3 calcIndirectDiffuse(XSLighting i) +{// We don't care about anything other than the color from probes for toon lighting. + half3 indirectDiffuse = ShadeSH9(float4(0,0.5,0,1));//half3(unity_SHAr.w, unity_SHAg.w, unity_SHAb.w); + return indirectDiffuse; +} + +half4 calcDiffuse(XSLighting i, DotProducts d, half3 indirectDiffuse, half4 lightCol, half4 ramp) +{ + half4 diffuse; + half4 indirect = indirectDiffuse.xyzz; + + half grayIndirect = dot(indirectDiffuse, float3(1,1,1)); + half attenFactor = lerp(i.attenuation, 1, smoothstep(0, 0.2, grayIndirect)); + + diffuse = ramp * attenFactor * lightCol + indirect; + diffuse = i.albedo * diffuse; + return diffuse; +} + +//Subsurface Scattering - Based on a 2011 GDC Conference from by Colin Barre-Bresebois & Marc Bouchard +//Modified by Xiexe +half4 calcSubsurfaceScattering(XSLighting i, DotProducts d, half3 lightDir, half3 viewDir, half3 normal, half4 lightCol, half3 indirectDiffuse) +{ + UNITY_BRANCH + if(any(_SSColor.rgb)) // Skip all the SSS stuff if the color is 0. + { + //d.ndl = smoothstep(_SSSRange - _SSSSharpness, _SSSRange + _SSSSharpness, d.ndl); + half attenuation = saturate(i.attenuation * (d.ndl * 0.5 + 0.5)); + half3 H = normalize(lightDir + normal * _SSDistortion); + half VdotH = pow(saturate(dot(viewDir, -H)), _SSPower); + half3 I = _SSColor * (VdotH + indirectDiffuse) * attenuation * i.thickness * _SSScale; + half4 SSS = half4(lightCol.rgb * I * i.albedo.rgb, 1); + SSS = max(0, SSS); // Make sure it doesn't go NaN + + return SSS; + } + else + { + return 0; + } +} + +half4 calcEmission(XSLighting i, half lightAvg) +{ + #if defined(UNITY_PASS_FORWARDBASE) // Emission only in Base Pass, and vertex lights + float4 emission = lerp(i.emissionMap, i.emissionMap * i.diffuseColor.xyzz, _EmissionToDiffuse); + float4 scaledEmission = emission * saturate(smoothstep(1-_ScaleWithLightSensitivity, 1+_ScaleWithLightSensitivity, 1-lightAvg)); + float4 em = lerp(scaledEmission, emission, _ScaleWithLight); + + em.rgb = rgb2hsv(em.rgb); + em.x += fmod(_Hue, 360); + em.y = saturate(em.y * _Saturation); + em.z *= _Value; + em.rgb = hsv2rgb(em.rgb); + + return em; + #else + return 0; + #endif +} + +void calcReflectionBlending(XSLighting i, inout half4 col, half3 indirectSpecular) +{ + if(_ReflectionBlendMode == 0) // Additive + col += indirectSpecular.xyzz * i.reflectivityMask.r; + else if(_ReflectionBlendMode == 1) //Multiplicitive + col = lerp(col, col * indirectSpecular.xyzz, i.reflectivityMask.r); + else if(_ReflectionBlendMode == 2) //Subtractive + col -= indirectSpecular.xyzz * i.reflectivityMask.r; +} + +void calcClearcoat(inout half4 col, XSLighting i, DotProducts d, half3 untouchedNormal, half3 indirectDiffuse, half3 lightCol, half3 viewDir, half3 lightDir, half4 ramp) +{ + UNITY_BRANCH + if(_ClearCoat != 0) + { + untouchedNormal = normalize(untouchedNormal); + half clearcoatSmoothness = _ClearcoatSmoothness * i.metallicGlossMap.g; + half clearcoatStrength = _ClearcoatStrength * i.metallicGlossMap.b; + + half3 reflView = calcReflView(viewDir, untouchedNormal); + half3 reflLight = calcReflLight(lightDir, untouchedNormal); + half rdv = saturate( dot( reflLight, half4(-viewDir, 0) )); + half3 clearcoatIndirect = calcIndirectSpecular(i, d, half4(0, 0, 0, 1-clearcoatSmoothness), reflView, indirectDiffuse, viewDir, 1, ramp); + half3 clearcoatDirect = saturate(pow(rdv, clearcoatSmoothness * 256)) * i.attenuation * lightCol; + + half3 clearcoat = (clearcoatIndirect + clearcoatDirect) * clearcoatStrength; + clearcoat = lerp(clearcoat * 0.5, clearcoat, saturate(pow(1-dot(viewDir, untouchedNormal), 0.8)) ); + col += clearcoat.xyzz; + } +} diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSLightingFunctions.cginc.meta b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSLightingFunctions.cginc.meta new file mode 100644 index 00000000..c2e52936 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSLightingFunctions.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 6a2a36080e04c18489c0c9d2ddc2543a +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSShadowCaster.cginc b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSShadowCaster.cginc new file mode 100644 index 00000000..c3baae39 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSShadowCaster.cginc @@ -0,0 +1,170 @@ +#include "UnityCG.cginc" +#include "UnityShaderVariables.cginc" + +// Do dithering for alpha blended shadows on SM3+/desktop, and Dithered transparency; +// on lesser systems do simple alpha-tested shadows +#if defined(_ALPHABLEND_ON) || defined(_ALPHATEST_ON) + #if !((SHADER_TARGET < 30) || defined (SHADER_API_MOBILE) || defined(SHADER_API_D3D11_9X) || defined (SHADER_API_PSP2) || defined (SHADER_API_PSM)) + #define UNITY_STANDARD_USE_DITHER_MASK 1 + #endif +#endif + +// Need to output UVs in shadow caster, since we need to sample texture and do clip/dithering based on it +#if defined(_ALPHABLEND_ON) || defined(_ALPHATEST_ON) + #define UNITY_STANDARD_USE_SHADOW_UVS 1 +#endif + +uniform float4 _ClipAgainstVertexColorGreaterZeroFive, _ClipAgainstVertexColorLessZeroFive; +uniform float4 _Color; +uniform float _Cutoff; +uniform sampler2D _MainTex; +uniform sampler2D _CutoutMask; +uniform sampler2D _ClipMap; +uniform float4 _MainTex_ST; +uniform float _FadeDither; +uniform float _FadeDitherDistance; +uniform int _BlendMode; +#ifdef UNITY_STANDARD_USE_DITHER_MASK + uniform sampler3D _DitherMaskLOD; +#endif + +struct VertexInput +{ + float4 vertex : POSITION; + float3 normal : NORMAL; + float2 uv0 : TEXCOORD0; + float4 color : COLOR; +}; + + +// Don't make the structure if it's empty (it's an error to have empty structs on some platforms...) +#if !defined(V2F_SHADOW_CASTER_NOPOS_IS_EMPTY) || defined(UNITY_STANDARD_USE_SHADOW_UVS) +struct VertexOutputShadowCaster +{ + V2F_SHADOW_CASTER_NOPOS + // Need to output UVs in shadow caster, since we need to sample texture and do clip/dithering based on it + #if defined(UNITY_STANDARD_USE_SHADOW_UVS) + float2 tex : TEXCOORD1; + #endif + + float4 worldPos : TEXCOORD2; + float4 screenPos : TEXCOORD3; + float4 color : COLOR; +}; +#endif + +half2 calcScreenUVs(half4 screenPos) +{ + half2 uv = screenPos / (screenPos.w + 0.0000000001); //0.0x1 Stops division by 0 warning in console. + #if UNITY_SINGLE_PASS_STEREO + uv.xy *= half2(_ScreenParams.x * 2, _ScreenParams.y); + #else + uv.xy *= _ScreenParams.xy; + #endif + + return uv; +} + +inline half Dither8x8Bayer( int x, int y ) +{ + const half dither[ 64 ] = { + 1, 49, 13, 61, 4, 52, 16, 64, + 33, 17, 45, 29, 36, 20, 48, 32, + 9, 57, 5, 53, 12, 60, 8, 56, + 41, 25, 37, 21, 44, 28, 40, 24, + 3, 51, 15, 63, 2, 50, 14, 62, + 35, 19, 47, 31, 34, 18, 46, 30, + 11, 59, 7, 55, 10, 58, 6, 54, + 43, 27, 39, 23, 42, 26, 38, 22}; + int r = y * 8 + x; + return dither[r] / 64; +} + +half calcDither(half2 screenPos) +{ + half dither = Dither8x8Bayer(fmod(screenPos.x, 8), fmod(screenPos.y, 8)); + return dither; +} + +// We have to do these dances of outputting SV_POSITION separately from the vertex shader, +// and inputting VPOS in the pixel shader, since they both map to "POSITION" semantic on +// some platforms, and then things don't go well. + + +void vertShadowCaster(VertexInput v, + #if !defined(V2F_SHADOW_CASTER_NOPOS_IS_EMPTY) || defined(UNITY_STANDARD_USE_SHADOW_UVS) + out VertexOutputShadowCaster o, + #endif + out float4 opos : SV_POSITION) +{ + TRANSFER_SHADOW_CASTER_NOPOS(o, opos) + #if defined(UNITY_STANDARD_USE_SHADOW_UVS) + o.tex = TRANSFORM_TEX(v.uv0, _MainTex); + o.color = v.color; + o.worldPos = mul(unity_ObjectToWorld, v.vertex); + o.screenPos = ComputeScreenPos(opos); + #endif +} + +float AlphaAdjust(float alphaToAdj, float3 vColor) +{ + _ClipAgainstVertexColorGreaterZeroFive = saturate(_ClipAgainstVertexColorGreaterZeroFive); //So the lerp doesn't go crazy + _ClipAgainstVertexColorLessZeroFive = saturate(_ClipAgainstVertexColorLessZeroFive); + + float modR = vColor.r < 0.5 ? _ClipAgainstVertexColorLessZeroFive.r : _ClipAgainstVertexColorGreaterZeroFive.r; + float modG = vColor.g < 0.5 ? _ClipAgainstVertexColorLessZeroFive.g : _ClipAgainstVertexColorGreaterZeroFive.g; + float modB = vColor.b < 0.5 ? _ClipAgainstVertexColorLessZeroFive.b : _ClipAgainstVertexColorGreaterZeroFive.b; + + alphaToAdj *= lerp(0, 1, lerp(1, modR, step(0.01, vColor.r))); + alphaToAdj *= lerp(0, 1, lerp(1, modG, step(0.01, vColor.g))); + alphaToAdj *= lerp(0, 1, lerp(1, modB, step(0.01, vColor.b))); + + return alphaToAdj; +} + +half4 fragShadowCaster( + #if !defined(V2F_SHADOW_CASTER_NOPOS_IS_EMPTY) || defined(UNITY_STANDARD_USE_SHADOW_UVS) + VertexOutputShadowCaster i + #endif + #ifdef UNITY_STANDARD_USE_DITHER_MASK + , UNITY_VPOS_TYPE vpos : VPOS + #endif +) : SV_Target +{ + #if defined(UNITY_STANDARD_USE_SHADOW_UVS) + half alpha = 1; + float4 albedo = tex2D(_MainTex, i.tex).a * _Color.a; + float4 clipMap = tex2D(_ClipMap, i.tex); + float modifiedAlpha = AlphaAdjust(albedo.a, clipMap.rgb); + + #if defined(_ALPHABLEND_ON) || defined(_ALPHATEST_ON) + float2 screenUV = calcScreenUVs(i.screenPos); + if(_BlendMode >= 3) + { + half dither = calcDither(screenUV); + alpha = modifiedAlpha - (dither * (1-albedo.a) * 0.15); + } + + if(_BlendMode == 2) + { + half dither = calcDither(screenUV); + + float fadeDist = abs(_FadeDitherDistance); + float d = distance(_WorldSpaceCameraPos, i.worldPos); + d = smoothstep(fadeDist, fadeDist + 0.05, d); + d = lerp(d, 1-d, saturate(step(0, _FadeDitherDistance))); + dither += lerp(0, d, saturate(_FadeDither)); + clip(modifiedAlpha - dither); + } + + if(_BlendMode == 1) + { + clip(modifiedAlpha - _Cutoff); + } + #else + alpha = modifiedAlpha; + #endif + #endif + + SHADOW_CASTER_FRAGMENT(i) +}
\ No newline at end of file diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSShadowCaster.cginc.meta b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSShadowCaster.cginc.meta new file mode 100644 index 00000000..03c14eb0 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSShadowCaster.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: cc6de506a13e7c347814e14820c6f710 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSVert.cginc b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSVert.cginc new file mode 100644 index 00000000..90a36907 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSVert.cginc @@ -0,0 +1,32 @@ +VertexOutput vert (VertexInput v) +{ + VertexOutput o = (VertexOutput)0; + float3 wnormal = UnityObjectToWorldNormal(v.normal); + float3 tangent = UnityObjectToWorldDir(v.tangent.xyz); + half tangentSign = v.tangent.w * unity_WorldTransformParams.w; + float3 bitangent = cross(wnormal, tangent) * tangentSign; + + #if defined(Geometry) + o.vertex = v.vertex; + #endif + + o.pos = UnityObjectToClipPos(v.vertex); + o.worldPos = mul(unity_ObjectToWorld, v.vertex); + o.ntb[0] = wnormal; + o.ntb[1] = tangent; + o.ntb[2] = bitangent; + o.uv = v.uv; + o.uv1 = v.uv1; + o.color = float4(v.color.rgb, 0); // store if outline in alpha channel of vertex colors | 0 = not an outline + o.normal = v.normal; + o.screenPos = ComputeScreenPos(o.pos); + o.objPos = normalize(v.vertex); + + #if !defined(UNITY_PASS_SHADOWCASTER) + UNITY_TRANSFER_SHADOW(o, o.uv); + UNITY_TRANSFER_FOG(o, o.pos); + #else + TRANSFER_SHADOW_CASTER_NOPOS(o, o.pos); + #endif + return o; +}
\ No newline at end of file diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSVert.cginc.meta b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSVert.cginc.meta new file mode 100644 index 00000000..d38ab884 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/CGIncludes/XSVert.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: c7cd982b7344d2c42b273a1734f935e3 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins.meta b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins.meta new file mode 100644 index 00000000..66b31554 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8624f7d3d918c134bb09ecbb9a677bd0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin.meta b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin.meta new file mode 100644 index 00000000..ad17328e --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cd886fcc7a158ed46b9f817fcf7552f1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc.meta b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc.meta new file mode 100644 index 00000000..07e64430 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4fee41c9956e7314ca1c268d3db37137 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/OrificeDefines.cginc b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/OrificeDefines.cginc new file mode 100644 index 00000000..c46dbd14 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/OrificeDefines.cginc @@ -0,0 +1,12 @@ +// Orifice Properties + half _OrificeChannel; + uniform sampler2D _OrificeData; + half _EntryOpenDuration; + half _Shape1Depth; + half _Shape1Duration; + half _Shape2Depth; + half _Shape2Duration; + half _Shape3Depth; + half _Shape3Duration; + half _BlendshapePower; + float _BlendshapeBadScaleFix; diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/OrificeDefines.cginc.meta b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/OrificeDefines.cginc.meta new file mode 100644 index 00000000..7cd24286 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/OrificeDefines.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 057f738dfbffe6342bf3e4dc93ea8a9a +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/PenetratorDefines.cginc b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/PenetratorDefines.cginc new file mode 100644 index 00000000..e9224568 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/PenetratorDefines.cginc @@ -0,0 +1,12 @@ +// Penetrator Properties +half _Squeeze; +half _SqueezeDist; +half _BulgeOffset; +half _BulgePower; +half _Length; +half _EntranceStiffness; +half _Curvature; +half _ReCurvature; +half _WriggleSpeed; +half _Wriggle; +half _OrificeChannel;
\ No newline at end of file diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/PenetratorDefines.cginc.meta b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/PenetratorDefines.cginc.meta new file mode 100644 index 00000000..c73ad480 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/PenetratorDefines.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: bd16464122aff8341902ef7761cd9e9b +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/XSDefinesOrifice.cginc b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/XSDefinesOrifice.cginc new file mode 100644 index 00000000..de88da5a --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/XSDefinesOrifice.cginc @@ -0,0 +1,217 @@ +#include "UnityPBSLighting.cginc" +#include "AutoLight.cginc" +#include "UnityCG.cginc" + +struct VertexInput +{ + float4 vertex : POSITION; + float2 uv : TEXCOORD0; + float2 uv1 : TEXCOORD1; + float2 uv2 : TEXCOORD2; + float3 normal : NORMAL; + float4 tangent : TANGENT; + float4 color : COLOR; + uint vertexId : SV_VertexID; +}; + +struct VertexOutput +{ + #if defined(Geometry) + float4 pos : CLIP_POS; + float4 vertex : SV_POSITION; // We need both of these in order to shadow Outlines correctly + #else + float4 pos : SV_POSITION; + #endif + + float2 uv : TEXCOORD0; + float2 uv1 : TEXCOORD1; + float3 ntb[3] : TEXCOORD2; //texcoord 3, 4 || Holds World Normal, Tangent, and Bitangent + float4 worldPos : TEXCOORD5; + float4 color : TEXCOORD6; + float3 normal : TEXCOORD8; + float4 screenPos : TEXCOORD9; + float3 objPos : TEXCOORD11; + float2 uv2 : TEXCOORD12; + + #if !defined(UNITY_PASS_SHADOWCASTER) + SHADOW_COORDS(7) + UNITY_FOG_COORDS(10) + #endif +}; + +#if defined(Geometry) + struct v2g + { + float4 pos : CLIP_POS; + float4 vertex : SV_POSITION; + float2 uv : TEXCOORD0; + float2 uv1 : TEXCOORD1; + float3 ntb[3] : TEXCOORD2; //texcoord 3, 4 || Holds World Normal, Tangent, and Bitangent + float4 worldPos : TEXCOORD5; + float4 color : TEXCOORD6; + float3 normal : TEXCOORD8; + float4 screenPos : TEXCOORD9; + float3 objPos : TEXCOORD11; + float2 uv2 : TEXCOORD12; + + #if !defined(UNITY_PASS_SHADOWCASTER) + SHADOW_COORDS(7) + UNITY_FOG_COORDS(10) + #endif + }; + + struct g2f + { + float4 pos : SV_POSITION; + float2 uv : TEXCOORD0; + float2 uv1 : TEXCOORD1; + float3 ntb[3] : TEXCOORD2; //texcoord 3, 4 || Holds World Normal, Tangent, and Bitangent + float4 worldPos : TEXCOORD5; + float4 color : TEXCOORD6; + float4 screenPos : TEXCOORD8; + float3 objPos : TEXCOORD10; + + #if !defined(UNITY_PASS_SHADOWCASTER) + SHADOW_COORDS(7) + UNITY_FOG_COORDS(9) + #endif + }; +#endif + +struct XSLighting +{ + half4 albedo; + half4 normalMap; + half4 detailNormal; + half4 detailMask; + half4 metallicGlossMap; + half4 reflectivityMask; + half4 specularMap; + half4 thickness; + half4 occlusion; + half4 emissionMap; + half4 rampMask; + half4 hsvMask; + half4 clipMap; + half4 dissolveMask; + half3 diffuseColor; + half attenuation; + half3 normal; + half3 tangent; + half3 bitangent; + half4 worldPos; + half3 color; + half alpha; + float isOutline; + float4 screenPos; + float2 screenUV; + float3 objPos; +}; + +struct TextureUV +{ + half2 uv0; + half2 uv1; + half2 albedoUV; + half2 specularMapUV; + half2 metallicGlossMapUV; + half2 detailMaskUV; + half2 normalMapUV; + half2 detailNormalUV; + half2 thicknessMapUV; + half2 occlusionUV; + half2 reflectivityMaskUV; + half2 emissionMapUV; + half2 outlineMaskUV; + half2 clipMapUV; + half2 dissolveUV; +}; + +struct DotProducts +{ + half ndl; + half vdn; + half vdh; + half tdh; + half bdh; + half ndh; + half rdv; + half ldh; + half svdn; +}; + +struct VertexLightInformation { + float3 Direction[4]; + float3 ColorFalloff[4]; + float Attenuation[4]; +}; + +UNITY_DECLARE_TEX2D(_MainTex); half4 _MainTex_ST; +UNITY_DECLARE_TEX2D_NOSAMPLER(_ClipMap); half4 _ClipMap_ST; +UNITY_DECLARE_TEX2D_NOSAMPLER(_DissolveTexture); half4 _DissolveTexture_ST; +UNITY_DECLARE_TEX2D_NOSAMPLER(_BumpMap); half4 _BumpMap_ST; +UNITY_DECLARE_TEX2D_NOSAMPLER(_DetailNormalMap); half4 _DetailNormalMap_ST; +UNITY_DECLARE_TEX2D_NOSAMPLER(_DetailMask); half4 _DetailMask_ST; +UNITY_DECLARE_TEX2D_NOSAMPLER(_SpecularMap); half4 _SpecularMap_ST; +UNITY_DECLARE_TEX2D_NOSAMPLER(_MetallicGlossMap); half4 _MetallicGlossMap_ST; +UNITY_DECLARE_TEX2D_NOSAMPLER(_ReflectivityMask); half4 _ReflectivityMask_ST; +UNITY_DECLARE_TEX2D_NOSAMPLER(_ThicknessMap); half4 _ThicknessMap_ST; +UNITY_DECLARE_TEX2D_NOSAMPLER(_EmissionMap); half4 _EmissionMap_ST; +UNITY_DECLARE_TEX2D_NOSAMPLER(_RampSelectionMask); +UNITY_DECLARE_TEX2D_NOSAMPLER(_HSVMask); +sampler2D _OcclusionMap; half4 _OcclusionMap_ST; +sampler2D _OutlineMask; +sampler2D _Matcap; +sampler2D _Ramp; +samplerCUBE _BakedCubemap; +sampler2D _GrabTexture; +float4 _GrabTexture_TexelSize; + +#if defined(UNITY_PASS_SHADOWCASTER) + sampler3D _DitherMaskLOD; +#endif + +half4 _Color; +half4 _ClipAgainstVertexColorGreaterZeroFive, _ClipAgainstVertexColorLessZeroFive; +half _Cutoff; +half _DissolveProgress, _DissolveStrength; +int _DissolveCoordinates; +int _UseClipsForDissolve; + +half4 _ShadowRim, + _OutlineColor, _SSColor, + _EmissionColor, _MatcapTint, + _RimColor, _DissolveColor; + +half _MatcapTintToDiffuse; + +half _FadeDitherDistance; +half _EmissionToDiffuse, _ScaleWithLightSensitivity; +half _Hue, _Saturation, _Value; +half _Metallic, _Glossiness, _OcclusionIntensity, _Reflectivity, _ClearcoatStrength, _ClearcoatSmoothness; +half _BumpScale, _DetailNormalMapScale; +half _SpecularIntensity, _SpecularSharpness, _SpecularArea, _AnisotropicSpecular, _AnisotropicReflection, _SpecularAlbedoTint; +half _IOR; +half _HalftoneDotSize, _HalftoneDotAmount, _HalftoneLineAmount, _HalftoneLineIntensity; +half _RimRange, _RimThreshold, _RimIntensity, _RimSharpness, _RimAlbedoTint, _RimCubemapTint, _RimAttenEffect; +half _ShadowRimRange, _ShadowRimThreshold, _ShadowRimSharpness, _ShadowSharpness, _ShadowRimAlbedoTint; +half _SSDistortion, _SSPower, _SSScale; +half _OutlineWidth; + +int _HalftoneType; +int _FadeDither; +int _BlendMode; +int _OcclusionMode; +int _UseRefraction; +int _ReflectionMode, _ReflectionBlendMode, _ClearCoat; +int _TilingMode, _VertexColorAlbedo, _ScaleWithLight; +int _OutlineAlbedoTint, _OutlineLighting, _OutlineNormalMode; +int _UVSetAlbedo, _UVSetNormal, _UVSetDetNormal, + _UVSetDetMask, _UVSetMetallic, _UVSetSpecular, + _UVSetThickness, _UVSetOcclusion, _UVSetReflectivity, + _UVSetEmission, _UVSetClipMap, _UVSetDissolve; +int _NormalMapMode, _OutlineUVSelect; + +//Defines for helper functions +#define grayscaleVec float3(0.2125, 0.7154, 0.0721) +#define WorldNormalVector(normal0, normal) half3(dot(normal0,normal), dot(normal0, normal), dot(normal0,normal))
\ No newline at end of file diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/XSDefinesOrifice.cginc.meta b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/XSDefinesOrifice.cginc.meta new file mode 100644 index 00000000..86dcb986 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/XSDefinesOrifice.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 760e4c2f910bbc9469a1faf16d677a08 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/XSFrag.cginc b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/XSFrag.cginc new file mode 100644 index 00000000..e759d766 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/XSFrag.cginc @@ -0,0 +1,90 @@ +float4 frag ( + #if defined(Geometry) + g2f i + #else + VertexOutput i + #endif + , uint facing : SV_IsFrontFace + ) : SV_Target +{ + TextureUV t = (TextureUV)0; // Populate UVs + if(_TilingMode != 1) { InitializeTextureUVs(i, t); } else { InitializeTextureUVsMerged(i, t); }; + + #ifdef UNITY_PASS_SHADOWCASTER + XSLighting o = (XSLighting)0; //Populate Lighting Struct, but only with important shadowcaster stuff! + o.albedo = UNITY_SAMPLE_TEX2D(_MainTex, t.albedoUV) * _Color * lerp(1, float4(i.color.rgb, 1), _VertexColorAlbedo); + o.clipMap = UNITY_SAMPLE_TEX2D_SAMPLER(_ClipMap, _MainTex, t.clipMapUV); + o.dissolveMask = UNITY_SAMPLE_TEX2D_SAMPLER(_DissolveTexture, _MainTex, t.dissolveUV); + + o.worldPos = i.worldPos; + o.screenUV = calcScreenUVs(i.screenPos); + o.screenPos = i.screenPos; + o.objPos = i.objPos; + + float4 outCol = 0; + calcAlpha(o); + calcDissolve(o, outCol); + SHADOW_CASTER_FRAGMENT(i); + #else + /* + UNITY_LIGHT_ATTENUATION(attenuation, i, i.worldPos.xyz); + + // fix for rare bug where light atten is 0 when there is no directional light in the scene + #ifdef UNITY_PASS_FORWARDBASE + if(all(_LightColor0.rgb == 0.0)) + { + attenuation = 1.0; + } + #endif + + #if defined(DIRECTIONAL) + half sharp = _ShadowSharpness * 0.5; + attenuation = smoothstep(sharp, 1-sharp, attenuation); //Converge at the center line + #endif + */ + + bool face = facing > 0; // True if on front face, False if on back face + if (!face) // Invert Normals based on face + { + if(i.color.a > 0.99) { discard; }//Discard outlines front face always. This way cull off and outlines can be enabled. + + i.ntb[0] = -i.ntb[0]; + i.ntb[1] = -i.ntb[1]; + i.ntb[2] = -i.ntb[2]; + } + + XSLighting o = (XSLighting)0; //Populate Lighting Struct + o.albedo = UNITY_SAMPLE_TEX2D(_MainTex, t.albedoUV) * _Color * lerp(1, float4(i.color.rgb, 1), _VertexColorAlbedo); + o.specularMap = UNITY_SAMPLE_TEX2D_SAMPLER(_SpecularMap, _MainTex, t.specularMapUV); + o.metallicGlossMap = UNITY_SAMPLE_TEX2D_SAMPLER(_MetallicGlossMap, _MainTex, t.metallicGlossMapUV); + o.detailMask = UNITY_SAMPLE_TEX2D_SAMPLER(_DetailMask, _MainTex, t.detailMaskUV); + o.normalMap = UNITY_SAMPLE_TEX2D_SAMPLER(_BumpMap, _MainTex, t.normalMapUV); + o.detailNormal = UNITY_SAMPLE_TEX2D_SAMPLER(_DetailNormalMap, _MainTex, t.detailNormalUV); + o.thickness = UNITY_SAMPLE_TEX2D_SAMPLER(_ThicknessMap, _MainTex, t.thicknessMapUV); + o.occlusion = tex2D(_OcclusionMap, t.occlusionUV); + o.reflectivityMask = UNITY_SAMPLE_TEX2D_SAMPLER(_ReflectivityMask, _MainTex, t.reflectivityMaskUV) * _Reflectivity; + o.emissionMap = UNITY_SAMPLE_TEX2D_SAMPLER(_EmissionMap, _MainTex, t.emissionMapUV) * _EmissionColor; + o.rampMask = UNITY_SAMPLE_TEX2D_SAMPLER(_RampSelectionMask, _MainTex, i.uv); // This texture doesn't need to ever be on a second uv channel, and doesn't need tiling, convince me otherwise. + o.hsvMask = UNITY_SAMPLE_TEX2D_SAMPLER(_HSVMask, _MainTex, t.albedoUV); + o.clipMap = UNITY_SAMPLE_TEX2D_SAMPLER(_ClipMap, _MainTex, t.clipMapUV); + o.dissolveMask = UNITY_SAMPLE_TEX2D_SAMPLER(_DissolveTexture, _MainTex, t.dissolveUV); + + o.diffuseColor = o.albedo.rgb; //Store this to separate the texture color and diffuse color for later. + o.attenuation = 1.0; + o.normal = i.ntb[0]; + o.tangent = i.ntb[1]; + o.bitangent = i.ntb[2]; + o.worldPos = i.worldPos; + o.color = i.color.rgb; + o.isOutline = i.color.a; + o.screenUV = calcScreenUVs(i.screenPos); + o.screenPos = i.screenPos; + o.objPos = i.objPos; + + float4 col = BRDF_XSLighting(o); + calcAlpha(o); + calcDissolve(o, col); + UNITY_APPLY_FOG(i.fogCoord, col); + return float4(col.rgb, o.alpha); + #endif +}
\ No newline at end of file diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/XSFrag.cginc.meta b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/XSFrag.cginc.meta new file mode 100644 index 00000000..6b19f27f --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/XSFrag.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: ced9d254377abc8499a65fdd16c7e636 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/XSVert.cginc b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/XSVert.cginc new file mode 100644 index 00000000..61250dd6 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/XSVert.cginc @@ -0,0 +1,152 @@ +void GetBestLights( float Channel, inout int orificeType, inout float3 orificePositionTracker, inout float3 orificeNormalTracker, inout float3 penetratorPositionTracker, inout float penetratorLength ) { + float ID = step( 0.5 , Channel ); + float baseID = ( ID * 0.02 ); + float holeID = ( baseID + 0.01 ); + float ringID = ( baseID + 0.02 ); + float normalID = ( 0.05 + ( ID * 0.01 ) ); + float penetratorID = ( 0.09 + ( ID * -0.01 ) ); + float4 orificeWorld; + float4 orificeNormalWorld; + float4 penetratorWorld; + float penetratorDist=100; + for (int i=0;i<4;i++) { + float range = (0.005 * sqrt(1000000 - unity_4LightAtten0[i])) / sqrt(unity_4LightAtten0[i]); + if (length(unity_LightColor[i].rgb) < 0.01) { + if (abs(fmod(range,0.1)-holeID)<0.005) { + orificeType=0; + orificeWorld = float4(unity_4LightPosX0[i], unity_4LightPosY0[i], unity_4LightPosZ0[i], 1); + orificePositionTracker = mul( unity_WorldToObject, orificeWorld ).xyz; + } + if (abs(fmod(range,0.1)-ringID)<0.005) { + orificeType=1; + orificeWorld = float4(unity_4LightPosX0[i], unity_4LightPosY0[i], unity_4LightPosZ0[i], 1); + orificePositionTracker = mul( unity_WorldToObject, orificeWorld ).xyz; + } + if (abs(fmod(range,0.1)-normalID)<0.005) { + orificeNormalWorld = float4(unity_4LightPosX0[i], unity_4LightPosY0[i], unity_4LightPosZ0[i], 1); + orificeNormalTracker = mul( unity_WorldToObject, orificeNormalWorld ).xyz; + } + if (abs(fmod(range,0.1)-penetratorID)<0.005) { + float3 tempPenetratorPositionTracker = penetratorPositionTracker; + penetratorWorld = float4(unity_4LightPosX0[i], unity_4LightPosY0[i], unity_4LightPosZ0[i], 1); + penetratorPositionTracker = mul( unity_WorldToObject, penetratorWorld ).xyz; + if (length(penetratorPositionTracker)>length(tempPenetratorPositionTracker)) { + penetratorPositionTracker = tempPenetratorPositionTracker; + } else { + penetratorLength=unity_LightColor[i].a; + } + } + } + } +} + +void PenetratorReshape(inout float4 vertex, inout float3 normal) { + float orificeChannel=0; + float orificeType = 0; + float3 orificePositionTracker = float3(0,0,100); + float3 orificeNormalTracker = float3(0,0,99); + float3 penetratorPositionTracker = float3(0,0,1); + float3 penetratorNormalTracker = float3(0,0,1); + float pl=0; + GetBestLights(orificeChannel, orificeType, orificePositionTracker, orificeNormalTracker, penetratorNormalTracker, pl); + float3 orificeNormal = normalize( lerp( ( orificePositionTracker - orificeNormalTracker ) , orificePositionTracker , max( _EntranceStiffness , 0.01 )) ); + float behind = smoothstep(-_Length*0.5, _Length*0.2, orificePositionTracker.z); + //orificePositionTracker.xy = behind * orificePositionTracker.xy; + //orificeNormal.xy = behind * orificeNormal.xy; + orificePositionTracker.z=(abs(orificePositionTracker.z+(_Length*0.2))-(_Length*0.2))*(1+step(orificePositionTracker.z,0)*2); + orificePositionTracker.z=smoothstep(-_Length*0.2, _Length*0.2, orificePositionTracker.z) * orificePositionTracker.z; + float distanceToOrifice = length( orificePositionTracker ); + float3 PhysicsNormal = normalize(penetratorNormalTracker.xyz); + float enterFactor = smoothstep( _Length , _Length+0.05 , distanceToOrifice); + float wriggleTimeY = _Time.y * _WriggleSpeed; + float curvatureMod = ( _Length * ( ( cos( wriggleTimeY ) * _Wriggle ) + _Curvature ) ); + float wriggleTimeX = _Time.y * ( _WriggleSpeed * 0.79 ); + float3 finalOrificeNormal = normalize( lerp( orificeNormal , ( PhysicsNormal + ( ( float3(0,1,0) * ( curvatureMod + ( _Length * ( _ReCurvature + ( ( sin( wriggleTimeY ) * 0.3 ) * _Wriggle ) ) * 2.0 ) ) ) + ( float3(0.5,0,0) * ( cos( wriggleTimeX ) * _Wriggle ) ) ) ) , enterFactor) ); + float3 finalOrificePosition = lerp( orificePositionTracker , ( ( normalize(penetratorNormalTracker) * _Length ) + ( float3(0,0.2,0) * ( sin( ( wriggleTimeY + UNITY_PI ) ) * _Wriggle ) * _Length ) + ( float3(0.2,0,0) * _Length * ( sin( ( wriggleTimeX + UNITY_PI ) ) * _Wriggle ) ) ) , enterFactor); + float finalOrificeDistance = length( finalOrificePosition ); + float3 bezierBasePosition = float3(0,0,0); + float bezierDistanceThird = ( finalOrificeDistance / 3.0 ); + float3 curvatureOffset = lerp( float3( 0,0,0 ) , ( float3(0,1,0) * ( curvatureMod * -0.2 ) ) , saturate( ( distanceToOrifice / _Length ) )); + float3 bezierBaseNormal = ( ( bezierDistanceThird * float3(0,0,1) ) + curvatureOffset ); + float3 bezierOrificeNormal = ( finalOrificePosition - ( bezierDistanceThird * finalOrificeNormal ) ); + float3 bezierOrificePosition = finalOrificePosition; + float vertexBaseTipPosition = ( vertex.z / finalOrificeDistance ); + + float3 sphereifyDistance = ( vertex.xyz - float3(0,0, distanceToOrifice) ); + float3 sphereifyNormal = normalize( sphereifyDistance ); + float sphereifyFactor = smoothstep( 0.01 , -0.01 , distanceToOrifice - vertex.z); + sphereifyFactor *= 1-orificeType; + vertex.xyz = lerp( vertex.xyz , ( float3(0,0, distanceToOrifice) + ( min( length( sphereifyDistance ) , _Squeeze ) * sphereifyNormal ) ) , sphereifyFactor); + + float squeezeFactor = smoothstep( 0.0 , _SqueezeDist , vertex.z - distanceToOrifice); + squeezeFactor = max( squeezeFactor , smoothstep( 0.0 , _SqueezeDist , distanceToOrifice - vertex.z)); + squeezeFactor = 1- (1-squeezeFactor) * smoothstep(0,0.01,vertex.z) * behind * (1-enterFactor); + vertex.xy = lerp( ( normalize(vertex.xy) * min( length( vertex.xy ) , _Squeeze ) ) , vertex.xy , squeezeFactor); + + float bulgeFactor = 1-smoothstep( 0.0 , _BulgeOffset , abs( ( finalOrificeDistance - vertex.z ) )); + float bulgeFactorBaseClip = smoothstep( 0.0 , 0.05 , vertex.z); + vertex.xy *= lerp( 1.0 , ( 1.0 + _BulgePower ) , ( bulgeFactor * bulgeFactorBaseClip * behind * (1-enterFactor))); + + float t = saturate(vertexBaseTipPosition); + float oneMinusT = 1 - t; + float3 bezierPoint = oneMinusT * oneMinusT * oneMinusT * bezierBasePosition + 3 * oneMinusT * oneMinusT * t * bezierBaseNormal + 3 * oneMinusT * t * t * bezierOrificeNormal + t * t * t * bezierOrificePosition; + float3 straightLine = (float3(0.0 , 0.0 , vertex.z)); + float baseFactor = smoothstep( 0.05 , -0.05 , vertex.z); + bezierPoint = lerp( bezierPoint , straightLine , baseFactor); + bezierPoint = lerp( ( ( finalOrificeNormal * ( vertex.z - finalOrificeDistance ) ) + finalOrificePosition ) , bezierPoint , step( vertexBaseTipPosition , 1.0 )); + float3 bezierDerivitive = 3 * oneMinusT * oneMinusT * (bezierBaseNormal - bezierBasePosition) + 6 * oneMinusT * t * (bezierOrificeNormal - bezierBaseNormal) + 3 * t * t * (bezierOrificePosition - bezierOrificeNormal); + bezierDerivitive = normalize( lerp( bezierDerivitive , float3(0,0,1) , baseFactor) ); + float bezierUpness = dot( bezierDerivitive , float3( 0,1,0 ) ); + float3 bezierUp = lerp( float3(0,1,0) , float3( 0,0,-1 ) , saturate( bezierUpness )); + float bezierDownness = dot( bezierDerivitive , float3( 0,-1,0 ) ); + bezierUp = normalize( lerp( bezierUp , float3( 0,0,1 ) , saturate( bezierDownness )) ); + float3 bezierSpaceX = normalize( cross( bezierDerivitive , bezierUp ) ); + float3 bezierSpaceY = normalize( cross( bezierDerivitive , -bezierSpaceX ) ); + float3 bezierSpaceVertexOffset = ( ( vertex.y * bezierSpaceY ) + ( vertex.x * -bezierSpaceX ) ); + float3 bezierSpaceVertexOffsetNormal = normalize( bezierSpaceVertexOffset ); + float distanceFromTip = ( finalOrificeDistance - vertex.z ); + + float3 bezierSpaceVertexOffsetFinal = lerp( bezierSpaceVertexOffset , bezierSpaceVertexOffset , enterFactor); + float3 bezierConstructedVertex = ( bezierPoint + bezierSpaceVertexOffsetFinal ); + + normal = normalize( ( ( -bezierSpaceX * normal.x ) + ( bezierSpaceY * normal.y ) + ( bezierDerivitive * normal.z ) ) ); + vertex.xyz = bezierConstructedVertex; + + vertex.w = 1; +} + +VertexOutput vert (VertexInput v) +{ + PenetratorReshape(v.vertex, v.normal); + v.vertex.w = 1; + + VertexOutput o = (VertexOutput)0; + float3 wnormal = UnityObjectToWorldNormal(v.normal); + float3 tangent = UnityObjectToWorldDir(v.tangent.xyz); + half tangentSign = v.tangent.w * unity_WorldTransformParams.w; + float3 bitangent = cross(wnormal, tangent) * tangentSign; + + #if defined(Geometry) + o.vertex = v.vertex; + #endif + + o.pos = UnityObjectToClipPos(v.vertex); + o.worldPos = mul(unity_ObjectToWorld, v.vertex); + o.ntb[0] = wnormal; + o.ntb[1] = tangent; + o.ntb[2] = bitangent; + o.uv = v.uv; + o.uv1 = v.uv1; + o.color = float4(v.color.rgb, 0); // store if outline in alpha channel of vertex colors | 0 = not an outline + o.normal = v.normal; + o.screenPos = ComputeScreenPos(o.pos); + o.objPos = normalize(v.vertex); + + #if !defined(UNITY_PASS_SHADOWCASTER) + UNITY_TRANSFER_SHADOW(o, o.uv); + UNITY_TRANSFER_FOG(o, o.pos); + #else + TRANSFER_SHADOW_CASTER_NOPOS(o, o.pos); + #endif + return o; +}
\ No newline at end of file diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/XSVert.cginc.meta b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/XSVert.cginc.meta new file mode 100644 index 00000000..33ba4aaa --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/XSVert.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 3aee5b5b0a75a1b418750bcbb63d4e19 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/XSVertOrifice.cginc b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/XSVertOrifice.cginc new file mode 100644 index 00000000..69217835 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/XSVertOrifice.cginc @@ -0,0 +1,118 @@ +void GetBestLights( float Channel, inout int orificeType, inout float3 orificePositionTracker, inout float3 orificeNormalTracker, inout float3 penetratorPositionTracker, inout float penetratorLength ) { + float ID = step( 0.5 , Channel ); + float baseID = ( ID * 0.02 ); + float holeID = ( baseID + 0.01 ); + float ringID = ( baseID + 0.02 ); + float normalID = ( 0.05 + ( ID * 0.01 ) ); + float penetratorID = ( 0.09 + ( ID * -0.01 ) ); + float4 orificeWorld; + float4 orificeNormalWorld; + float4 penetratorWorld; + float penetratorDist=100; + for (int i=0;i<4;i++) { + float range = (0.005 * sqrt(1000000 - unity_4LightAtten0[i])) / sqrt(unity_4LightAtten0[i]); + if (length(unity_LightColor[i].rgb) < 0.01) { + if (abs(fmod(range,0.1)-holeID)<0.005) { + orificeType=0; + orificeWorld = float4(unity_4LightPosX0[i], unity_4LightPosY0[i], unity_4LightPosZ0[i], 1); + orificePositionTracker = mul( unity_WorldToObject, orificeWorld ).xyz; + } + if (abs(fmod(range,0.1)-ringID)<0.005) { + orificeType=1; + orificeWorld = float4(unity_4LightPosX0[i], unity_4LightPosY0[i], unity_4LightPosZ0[i], 1); + orificePositionTracker = mul( unity_WorldToObject, orificeWorld ).xyz; + } + if (abs(fmod(range,0.1)-normalID)<0.005) { + orificeNormalWorld = float4(unity_4LightPosX0[i], unity_4LightPosY0[i], unity_4LightPosZ0[i], 1); + orificeNormalTracker = mul( unity_WorldToObject, orificeNormalWorld ).xyz; + } + if (abs(fmod(range,0.1)-penetratorID)<0.005) { + float3 tempPenetratorPositionTracker = penetratorPositionTracker; + penetratorWorld = float4(unity_4LightPosX0[i], unity_4LightPosY0[i], unity_4LightPosZ0[i], 1); + penetratorPositionTracker = mul( unity_WorldToObject, penetratorWorld ).xyz; + if (length(penetratorPositionTracker)>length(tempPenetratorPositionTracker)) { + penetratorPositionTracker = tempPenetratorPositionTracker; + } else { + penetratorLength=unity_LightColor[i].a; + } + } + } + } +} + +float3 getBlendOffset(float blendSampleIndex, float activationDepth, float activationSmooth, int vertexID, float penetrationDepth, float3 normal, float3 tangent, float3 binormal) { + float blendTextureSize = 1024; + float2 blendSampleUV = (float2(( ( fmod( (float)vertexID , blendTextureSize ) + 0.5 ) / (blendTextureSize) ) , ( ( ( floor( ( vertexID / (blendTextureSize) ) ) + 0.5 ) / (blendTextureSize) ) + blendSampleIndex/8 ))); + float3 sampledBlend = tex2Dlod( _OrificeData, float4( blendSampleUV, 0, 0.0) ).rgb; + float blendActivation = smoothstep( ( activationDepth ) , ( activationDepth + activationSmooth ) , penetrationDepth); + blendActivation = -cos(blendActivation*3.1416)*0.5+0.5; + float3 blendOffset = ( ( sampledBlend - float3(1,1,1)) * (blendActivation) * _BlendshapePower * _BlendshapeBadScaleFix ); + return ( ( blendOffset.x * normal ) + ( blendOffset.y * tangent ) + ( blendOffset.z * binormal ) ); +} + +void OrificeReshape(inout float4 vertex, inout float3 normal, float3 tangent, int vertexId) { + float penetratorLength = 0.1; + float penetratorDistance; + float3 orificePositionTracker = float3(0,0,-100); + float3 orificeNormalTracker = float3(0,0,-99); + float3 penetratorPositionTracker = float3(0,0,100); + float3 penetratorNormalTracker = float3(0,0,100); + float orificeType=0; + + GetBestLights(orificeType, orificePositionTracker, orificeNormalTracker, penetratorPositionTracker, penetratorNormalTracker, penetratorLength); + penetratorDistance = distance(orificePositionTracker, penetratorPositionTracker ); + float penetrationDepth = max(0, penetratorLength - penetratorDistance); + + float3 binormal = normalize(cross( normal , tangent )); + + vertex.xyz += getBlendOffset(0, 0, _EntryOpenDuration, vertexId, penetrationDepth, normal, tangent, binormal); + vertex.xyz += getBlendOffset(2, _Shape1Depth, _Shape1Duration, vertexId, penetrationDepth, normal, tangent, binormal); + vertex.xyz += getBlendOffset(4, _Shape2Depth, _Shape2Duration, vertexId, penetrationDepth, normal, tangent, binormal); + vertex.xyz += getBlendOffset(6, _Shape3Depth, _Shape3Duration, vertexId, penetrationDepth, normal, tangent, binormal); + vertex.w = 1; + + normal += getBlendOffset(1, 0, _EntryOpenDuration, vertexId, penetrationDepth, normal, tangent, binormal); + normal += getBlendOffset(3, _Shape1Depth, _Shape1Duration, vertexId, penetrationDepth, normal, tangent, binormal); + normal += getBlendOffset(5, _Shape2Depth, _Shape2Duration, vertexId, penetrationDepth, normal, tangent, binormal); + normal += getBlendOffset(7, _Shape3Depth, _Shape3Duration, vertexId, penetrationDepth, normal, tangent, binormal); + normal = normalize(normal); +} + +VertexOutput vert (VertexInput v) +{ + float3 normal = normalize( v.normal ); + float3 tangent = normalize( v.tangent.xyz ); + float3 binormal = normalize(cross( normal , tangent )); + + OrificeReshape(v.vertex, v.normal, v.tangent.xyz, v.vertexId); + + VertexOutput o = (VertexOutput)0; + float3 wnormal = UnityObjectToWorldNormal(v.normal); + tangent = UnityObjectToWorldDir(v.tangent.xyz); + half tangentSign = v.tangent.w * unity_WorldTransformParams.w; + float3 bitangent = cross(wnormal, tangent) * tangentSign; + + #if defined(Geometry) + o.vertex = v.vertex; + #endif + + o.pos = UnityObjectToClipPos(v.vertex); + o.worldPos = mul(unity_ObjectToWorld, v.vertex); + o.ntb[0] = wnormal; + o.ntb[1] = tangent; + o.ntb[2] = bitangent; + o.uv = v.uv; + o.uv1 = v.uv1; + o.color = float4(v.color.rgb, 0); // store if outline in alpha channel of vertex colors | 0 = not an outline + o.normal = v.normal; + o.screenPos = ComputeScreenPos(o.pos); + o.objPos = normalize(v.vertex); + + #if !defined(UNITY_PASS_SHADOWCASTER) + UNITY_TRANSFER_SHADOW(o, o.uv); + UNITY_TRANSFER_FOG(o, o.pos); + #else + TRANSFER_SHADOW_CASTER_NOPOS(o, o.pos); + #endif + return o; +}
\ No newline at end of file diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/XSVertOrifice.cginc.meta b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/XSVertOrifice.cginc.meta new file mode 100644 index 00000000..1128c47b --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/CGInc/XSVertOrifice.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 10605fcc6c3a2c44e8590ea5ab00c824 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/Shaders.meta b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/Shaders.meta new file mode 100644 index 00000000..a14da936 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/Shaders.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 59e6c81fc5e33ca42849706dfa987886 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/Shaders/XSToon2.0 Orifice.shader b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/Shaders/XSToon2.0 Orifice.shader new file mode 100644 index 00000000..a56569a0 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/Shaders/XSToon2.0 Orifice.shader @@ -0,0 +1,202 @@ +Shader "Xiexe/Toon2.0/XSToon2.0_Orifice" +{ + Properties + { + [Enum(Off, 0, On, 1)] _VertexColorAlbedo ("Vertex Color Albedo", Int) = 0 + [Enum(Separated, 0, Merged, 1)] _TilingMode ("Tiling Mode", Int) = 0 + [Enum(Off,0,Front,1,Back,2)] _Culling ("Culling Mode", Int) = 2 + [Enum(Opaque, 0, Cutout, 1, Dithered, 2, Alpha To Coverage, 3, Transparent, 4, Fade, 5, Additive, 6)]_BlendMode("Blend Mode", Int) = 0 + [Enum(None, 0, Plane, 1, Sphere, 2)]_RefractionModel("Refraction Model", Int) = 0 + [Toggle(_COLOROVERLAY_ON)]_UseRefraction("Refraction", Int) = 0 + + // Penetrator Properties + _OrificeData("OrificeData", 2D) = "white" {} + _OrificeChannel("OrificeChannel Please Use 0", Float) = 0 + _EntryOpenDuration("EntryOpenDuration", Range( 0 , 1)) = 0.1 + _Shape1Depth("Shape1Depth", Range( 0 , 5)) = 0.1 + _Shape1Duration("Shape1Duration", Range( 0 , 1)) = 0.1 + _Shape2Depth("Shape2Depth", Range( 0 , 5)) = 0.2 + _Shape2Duration("Shape2Duration", Range( 0 , 1)) = 0.1 + _Shape3Depth("Shape3Depth", Range( 0 , 5)) = 0.3 + _Shape3Duration("Shape3Duration", Range( 0 , 1)) = 0.1 + _BlendshapePower("Blend Shape Power", Range(0,5)) = 1 + _BlendshapeBadScaleFix("Blend Shape Bad Scale Fix", Range(1,100)) = 1 + + _MainTex("Texture", 2D) = "white" {} + _HSVMask("HSV Mask", 2D) = "white" {} + _Hue("Hue", Range(0,1)) = 0 + _Saturation("Main Texture Saturation", Range(0,3)) = 1 + _Value("Value", Range(0,3)) = 1 + + _Color("Color Tint", Color) = (1,1,1,1) + _Cutoff("Cutoff", Float) = 0.5 + + [ToggleUI]_FadeDither("Dither Distance Fading", Float) = 0 + _FadeDitherDistance("Fade Dither Distance", Float) = 0 + + _BumpMap("Normal Map", 2D) = "bump" {} + _BumpScale("Normal Scale", Range(-2,2)) = 1 + + [Enum(Texture,0,Vertex Colors,1)] _NormalMapMode ("Normal Map Mode", Int) = 0 + _DetailNormalMap("Detail Normal Map", 2D) = "bump" {} + _DetailMask("Detail Mask", 2D) = "white" {} + _DetailNormalMapScale("Detail Normal Scale", Range(-2,2)) = 1.0 + + [Enum(PBR(Unity Metallic Standard),0,Baked Cubemap,1,Matcap,2,Off,3)] _ReflectionMode ("Reflection Mode", Int) = 3 + [Enum(Disabled,0, Enabled, 1)]_ClearCoat("ClearCoat", Int) = 0 + [Enum(Additive,0,Multiply,1,Subtract,2)] _ReflectionBlendMode("Reflection Blend Mode", Int) = 0 + _MetallicGlossMap("Metallic", 2D) = "white" {} //Metallic, 0, 0, Smoothness + _BakedCubemap("Baked Cubemap", CUBE) = "black" {} + _Matcap("Matcap", 2D) = "black" {} + [HDR]_MatcapTint("Matcap Tint", Color) = (1,1,1,1) + _MatcapTintToDiffuse("Matcap Tint To Diffuse", Range(0,1)) = 0 + _ReflectivityMask("Reflection Mask" , 2D) = "white" {} + _Metallic("Metallic", Range(0,1)) = 0 + _Glossiness("Smoothness", Range(0,1)) = 0 + _Reflectivity("Reflectivity", Range(0,1)) = 0.5 + _IOR("Index of Refraction", Range(1, 4)) = 0 + _ClearcoatStrength("Clearcoat Reflectivity", Range(0, 1)) = 1 + _ClearcoatSmoothness("Clearcoat Smoothness", Range(0, 1)) = 0.8 + + [Enum(Yes,0, No,1)] _ScaleWithLight("Emission Scale w/ Light", Int) = 1 + _EmissionMap("Emission Map", 2D) = "white" {} + [HDR]_EmissionColor("Emission Color", Color) = (0,0,0,0) + _EmissionToDiffuse("Emission Tint To Diffuse", Range(0,1)) = 0 + _ScaleWithLightSensitivity("Scaling Sensitivity", Range(0,1)) = 1 + + _RimColor("Rimlight Tint", Color) = (1,1,1,1) + _RimAlbedoTint("Rim Albedo Tint", Range(0,1)) = 0 + _RimCubemapTint("Rim Environment Tint", Range(0,1)) = 0 + _RimAttenEffect("Rim Attenuation Effect", Range(0,1)) = 1 + _RimIntensity("Rimlight Intensity", Float) = 0 + _RimRange("Rim Range", Range(0,1)) = 0.7 + _RimThreshold("Rim Threshold", Range(0, 1)) = 0.1 + _RimSharpness("Rim Sharpness", Range(0,1)) = 0.1 + + _SpecularSharpness("Specular Sharpness", Range(0,1)) = 0 + _SpecularMap("Specular Map", 2D) = "white" {} + _SpecularIntensity("Specular Intensity", Float) = 0 + _SpecularArea("Specular Smoothness", Range(0,1)) = 0.5 + _AnisotropicSpecular("Specular Anisotropic", Range(-1,1)) = 0 + _AnisotropicReflection("Reflection Anisotropic", Range(-1,1)) = 0 + _SpecularAlbedoTint("Specular Albedo Tint", Range(0,1)) = 1 + + _RampSelectionMask("Ramp Mask", 2D) = "black" {} + _Ramp("Shadow Ramp", 2D) = "white" {} + _ShadowSharpness("Received Shadow Sharpness", Range(0,1)) = 0.5 + _ShadowRim("Shadow Rim Tint", Color) = (1,1,1,1) + _ShadowRimRange("Shadow Rim Range", Range(0,1)) = 0.7 + _ShadowRimThreshold("Shadow Rim Threshold", Range(0, 1)) = 0.1 + _ShadowRimSharpness("Shadow Rim Sharpness", Range(0,1)) = 0.3 + _ShadowRimAlbedoTint("Shadow Rim Albedo Tint", Range(0, 1)) = 0 + + [Enum(Indirect, 0, Integrated, 1)]_OcclusionMode("Occlusion Mode", Int) = 0 + _OcclusionMap("Occlusion", 2D) = "white" {} + _OcclusionIntensity("Occlusion Intensity", Range(0,1)) = 1 + + [Enum(Off, 0, On, 1)]_OutlineAlbedoTint("Outline Albedo Tint", Int) = 0 + [Enum(Lit, 0, Emissive, 1)]_OutlineLighting("Outline Lighting", Int) = 0 + [Enum(Mesh Normals, 0, Vertex Color Normals, 1, UVChannel, 2)]_OutlineNormalMode("Outline Normal Mode", Int) = 0 + [Enum(UV2, 1, UV3, 2)]_OutlineUVSelect("Altered Normal UV Channel", Int) = 2 + _OutlineMask("Outline Mask", 2D) = "white" {} + _OutlineWidth("Outline Width", Range(0, 5)) = 1 + [HDR]_OutlineColor("Outline Color", Color) = (0,0,0,1) + + _ThicknessMap("Thickness Map", 2D) = "white" {} + _SSColor ("Subsurface Color", Color) = (0,0,0,0) + _SSDistortion("Normal Distortion", Range(0,3)) = 1 + _SSPower("Subsurface Power", Range(0,3)) = 1 + _SSScale("Subsurface Scale", Range(0,3)) = 1 + + [Enum(Shadows, 0, Highlights, 1, Shadows And Highlights, 2, Off, 3)] _HalftoneType("Halftones Type", Int) = 3 + _HalftoneDotSize("Halftone Dot Size", Float) = 0.5 + _HalftoneDotAmount("Halftone Dot Amount", Float) = 5 + _HalftoneLineAmount("Halftone Line Amount", Float) = 2000 + _HalftoneLineIntensity("Halftone Line Intensity", Range(0,1)) = 1 + + [Enum(UV, 0, Root Distance (Spherical), 1, Height, 2)]_DissolveCoordinates("Dissolve Shape", Int) = 0 + _DissolveTexture("Dissolve Texture", 2D) = "black" {} + _DissolveStrength("Dissolve Sharpness", Float) = 1 + [HDR]_DissolveColor("Dissolve Color", Color) = (1,1,1,1) + _DissolveProgress("Dissolve Amount", Range(0,1)) = 0 + [ToggleUI]_UseClipsForDissolve("Do Dissolve", Int) = 0 + + _ClipAgainstVertexColorGreaterZeroFive("Clip Vert Color > 0.5", Vector) = (1,1,1,1) + _ClipAgainstVertexColorLessZeroFive("Clip Vert Color < 0.5", Vector) = (1,1,1,1) + + [Enum(UV1,0,UV2,1)] _UVSetAlbedo("Albedo UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetNormal("Normal Map UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetDetNormal("Detail Normal UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetDetMask("Detail Mask UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetMetallic("Metallic Map UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetSpecular("Specular Map UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetReflectivity("Reflection Mask UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetThickness("Thickness Map UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetOcclusion("Occlusion Map UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetEmission("Emission Map UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetClipMap("Clip Map UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetDissolve("Dissolve Map UVs", Int) = 0 + + _ClipMap("Clip Map", 2D) = "black" {} + [HideInInspector][Enum(Basic, 0, Advanced, 1)]_AdvMode("Shader Mode", Int) = 0 + [IntRange] _Stencil ("Stencil ID [0;255]", Range(0,255)) = 0 + [Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp ("Stencil Comparison", Int) = 0 + [Enum(UnityEngine.Rendering.StencilOp)] _StencilOp ("Stencil Operation", Int) = 0 + + [HideInInspector] _SrcBlend ("__src", int) = 1 + [HideInInspector] _DstBlend ("__dst", int) = 0 + [HideInInspector] _ZWrite ("__zw", int) = 1 + [HideInInspector] _AlphaToMask("__am", int) = 0 + } + + SubShader + { + Tags { "RenderType"="Opaque" "Queue"="Geometry" } + Cull [_Culling] + AlphaToMask [_AlphaToMask] + Stencil + { + Ref [_Stencil] + Comp [_StencilComp] + Pass [_StencilOp] + } + Grabpass // Gets disabled via the editor script when not in use through the Lightmode Tag. + { + Tags{"LightMode" = "Always"} + "_GrabTexture" + } + Pass + { + Name "FORWARD" + Tags { "LightMode" = "ForwardBase" } + Blend [_SrcBlend] [_DstBlend] + ZWrite [_ZWrite] + CGPROGRAM + #pragma target 3.0 + #pragma vertex vert + #pragma fragment frag + #pragma shader_feature _ALPHABLEND_ON + #pragma shader_feature _ALPHATEST_ON + #pragma multi_compile _ VERTEXLIGHT_ON + #pragma shader_feature _COLOROVERLAY_ON + #pragma multi_compile_fog + #pragma multi_compile_fwdbase + + #ifndef UNITY_PASS_FORWARDBASE + #define UNITY_PASS_FORWARDBASE + #endif + + #include "../CGInc/XSDefinesOrifice.cginc" + #include "../CGInc/OrificeDefines.cginc" + #include "../../../CGIncludes/XSHelperFunctions.cginc" + #include "../../../CGIncludes/XSLightingFunctions.cginc" + #include "../../../CGIncludes/XSLighting.cginc" + #include "../CGInc/XSVertOrifice.cginc" + #include "../../../CGIncludes/XSGeom.cginc" + #include "../CGInc/XSFrag.cginc" + ENDCG + } + } + + CustomEditor "XSToonDynamicPenetration.XSToonInspector" +}
\ No newline at end of file diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/Shaders/XSToon2.0 Orifice.shader.meta b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/Shaders/XSToon2.0 Orifice.shader.meta new file mode 100644 index 00000000..4709171a --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/Shaders/XSToon2.0 Orifice.shader.meta @@ -0,0 +1,24 @@ +fileFormatVersion: 2 +guid: 2271bf3c1ed3db248b45cd571f507a29 +ShaderImporter: + externalObjects: {} + defaultTextures: + - _MainTex: {instanceID: 0} + - _BumpMap: {instanceID: 0} + - _DetailNormalMap: {instanceID: 0} + - _DetailMask: {instanceID: 0} + - _MetallicGlossMap: {instanceID: 0} + - _BakedCubemap: {instanceID: 0} + - _Matcap: {instanceID: 0} + - _ReflectivityMask: {instanceID: 0} + - _EmissionMap: {instanceID: 0} + - _SpecularMap: {instanceID: 0} + - _RampSelectionMask: {instanceID: 0} + - _Ramp: {fileID: 2800000, guid: 529b95e318b684643b47bd73e037118a, type: 3} + - _OcclusionMap: {instanceID: 0} + - _OutlineMask: {instanceID: 0} + - _ThicknessMap: {instanceID: 0} + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/Shaders/XSToon2.0 Penetrator.shader b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/Shaders/XSToon2.0 Penetrator.shader new file mode 100644 index 00000000..4563e290 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/Shaders/XSToon2.0 Penetrator.shader @@ -0,0 +1,202 @@ +Shader "Xiexe/Toon2.0/XSToon2.0_Penetrator" +{ + Properties + { + [Enum(Off, 0, On, 1)] _VertexColorAlbedo ("Vertex Color Albedo", Int) = 0 + [Enum(Separated, 0, Merged, 1)] _TilingMode ("Tiling Mode", Int) = 0 + [Enum(Off,0,Front,1,Back,2)] _Culling ("Culling Mode", Int) = 2 + [Enum(Opaque, 0, Cutout, 1, Dithered, 2, Alpha To Coverage, 3, Transparent, 4, Fade, 5, Additive, 6)]_BlendMode("Blend Mode", Int) = 0 + [Enum(None, 0, Plane, 1, Sphere, 2)]_RefractionModel("Refraction Model", Int) = 0 + [Toggle(_COLOROVERLAY_ON)]_UseRefraction("Refraction", Int) = 0 + + // Penetrator Properties + _Squeeze("squeeze", Range( 0 , 0.2)) = 0.0266 + _SqueezeDist("SqueezeDist", Range( 0 , 0.1)) = 0.0289 + _BulgeOffset("BulgeOffset", Range( 0 , 0.3)) = 0.139 + _BulgePower("BulgePower", Range( 0 , 1)) = 0.00272 + _Length("Penetrator Length", Range( 0 , 3)) = 0.3541295 + _EntranceStiffness("EntranceStiffness", Range( 0.01 , 1)) = 0.01 + _Curvature("Curvature", Range( -1 , 1)) = 0 + _ReCurvature("ReCurvature", Range( -1 , 1)) = 0 + _WriggleSpeed("WriggleSpeed", Range( 0.1 , 30)) = 6.2 + _Wriggle("Wriggle", Range( 0 , 1)) = 0 + _OrificeChannel("OrificeChannel Please Use 0", Float) = 0 + + _MainTex("Texture", 2D) = "white" {} + _HSVMask("HSV Mask", 2D) = "white" {} + _Hue("Hue", Range(0,1)) = 0 + _Saturation("Main Texture Saturation", Range(0,3)) = 1 + _Value("Value", Range(0,3)) = 1 + + _Color("Color Tint", Color) = (1,1,1,1) + _Cutoff("Cutoff", Float) = 0.5 + + [ToggleUI]_FadeDither("Dither Distance Fading", Float) = 0 + _FadeDitherDistance("Fade Dither Distance", Float) = 0 + + _BumpMap("Normal Map", 2D) = "bump" {} + _BumpScale("Normal Scale", Range(-2,2)) = 1 + + [Enum(Texture,0,Vertex Colors,1)] _NormalMapMode ("Normal Map Mode", Int) = 0 + _DetailNormalMap("Detail Normal Map", 2D) = "bump" {} + _DetailMask("Detail Mask", 2D) = "white" {} + _DetailNormalMapScale("Detail Normal Scale", Range(-2,2)) = 1.0 + + [Enum(PBR(Unity Metallic Standard),0,Baked Cubemap,1,Matcap,2,Off,3)] _ReflectionMode ("Reflection Mode", Int) = 3 + [Enum(Disabled,0, Enabled, 1)]_ClearCoat("ClearCoat", Int) = 0 + [Enum(Additive,0,Multiply,1,Subtract,2)] _ReflectionBlendMode("Reflection Blend Mode", Int) = 0 + _MetallicGlossMap("Metallic", 2D) = "white" {} //Metallic, 0, 0, Smoothness + _BakedCubemap("Baked Cubemap", CUBE) = "black" {} + _Matcap("Matcap", 2D) = "black" {} + [HDR]_MatcapTint("Matcap Tint", Color) = (1,1,1,1) + _MatcapTintToDiffuse("Matcap Tint To Diffuse", Range(0,1)) = 0 + _ReflectivityMask("Reflection Mask" , 2D) = "white" {} + _Metallic("Metallic", Range(0,1)) = 0 + _Glossiness("Smoothness", Range(0,1)) = 0 + _Reflectivity("Reflectivity", Range(0,1)) = 0.5 + _IOR("Index of Refraction", Range(1, 4)) = 0 + _ClearcoatStrength("Clearcoat Reflectivity", Range(0, 1)) = 1 + _ClearcoatSmoothness("Clearcoat Smoothness", Range(0, 1)) = 0.8 + + [Enum(Yes,0, No,1)] _ScaleWithLight("Emission Scale w/ Light", Int) = 1 + _EmissionMap("Emission Map", 2D) = "white" {} + [HDR]_EmissionColor("Emission Color", Color) = (0,0,0,0) + _EmissionToDiffuse("Emission Tint To Diffuse", Range(0,1)) = 0 + _ScaleWithLightSensitivity("Scaling Sensitivity", Range(0,1)) = 1 + + _RimColor("Rimlight Tint", Color) = (1,1,1,1) + _RimAlbedoTint("Rim Albedo Tint", Range(0,1)) = 0 + _RimCubemapTint("Rim Environment Tint", Range(0,1)) = 0 + _RimAttenEffect("Rim Attenuation Effect", Range(0,1)) = 1 + _RimIntensity("Rimlight Intensity", Float) = 0 + _RimRange("Rim Range", Range(0,1)) = 0.7 + _RimThreshold("Rim Threshold", Range(0, 1)) = 0.1 + _RimSharpness("Rim Sharpness", Range(0,1)) = 0.1 + + _SpecularSharpness("Specular Sharpness", Range(0,1)) = 0 + _SpecularMap("Specular Map", 2D) = "white" {} + _SpecularIntensity("Specular Intensity", Float) = 0 + _SpecularArea("Specular Smoothness", Range(0,1)) = 0.5 + _AnisotropicSpecular("Specular Anisotropic", Range(-1,1)) = 0 + _AnisotropicReflection("Reflection Anisotropic", Range(-1,1)) = 0 + _SpecularAlbedoTint("Specular Albedo Tint", Range(0,1)) = 1 + + _RampSelectionMask("Ramp Mask", 2D) = "black" {} + _Ramp("Shadow Ramp", 2D) = "white" {} + _ShadowSharpness("Received Shadow Sharpness", Range(0,1)) = 0.5 + _ShadowRim("Shadow Rim Tint", Color) = (1,1,1,1) + _ShadowRimRange("Shadow Rim Range", Range(0,1)) = 0.7 + _ShadowRimThreshold("Shadow Rim Threshold", Range(0, 1)) = 0.1 + _ShadowRimSharpness("Shadow Rim Sharpness", Range(0,1)) = 0.3 + _ShadowRimAlbedoTint("Shadow Rim Albedo Tint", Range(0, 1)) = 0 + + [Enum(Indirect, 0, Integrated, 1)]_OcclusionMode("Occlusion Mode", Int) = 0 + _OcclusionMap("Occlusion", 2D) = "white" {} + _OcclusionIntensity("Occlusion Intensity", Range(0,1)) = 1 + + [Enum(Off, 0, On, 1)]_OutlineAlbedoTint("Outline Albedo Tint", Int) = 0 + [Enum(Lit, 0, Emissive, 1)]_OutlineLighting("Outline Lighting", Int) = 0 + [Enum(Mesh Normals, 0, Vertex Color Normals, 1, UVChannel, 2)]_OutlineNormalMode("Outline Normal Mode", Int) = 0 + [Enum(UV2, 1, UV3, 2)]_OutlineUVSelect("Altered Normal UV Channel", Int) = 2 + _OutlineMask("Outline Mask", 2D) = "white" {} + _OutlineWidth("Outline Width", Range(0, 5)) = 1 + [HDR]_OutlineColor("Outline Color", Color) = (0,0,0,1) + + _ThicknessMap("Thickness Map", 2D) = "white" {} + _SSColor ("Subsurface Color", Color) = (0,0,0,0) + _SSDistortion("Normal Distortion", Range(0,3)) = 1 + _SSPower("Subsurface Power", Range(0,3)) = 1 + _SSScale("Subsurface Scale", Range(0,3)) = 1 + + [Enum(Shadows, 0, Highlights, 1, Shadows And Highlights, 2, Off, 3)] _HalftoneType("Halftones Type", Int) = 3 + _HalftoneDotSize("Halftone Dot Size", Float) = 0.5 + _HalftoneDotAmount("Halftone Dot Amount", Float) = 5 + _HalftoneLineAmount("Halftone Line Amount", Float) = 2000 + _HalftoneLineIntensity("Halftone Line Intensity", Range(0,1)) = 1 + + [Enum(UV, 0, Root Distance (Spherical), 1, Height, 2)]_DissolveCoordinates("Dissolve Shape", Int) = 0 + _DissolveTexture("Dissolve Texture", 2D) = "black" {} + _DissolveStrength("Dissolve Sharpness", Float) = 1 + [HDR]_DissolveColor("Dissolve Color", Color) = (1,1,1,1) + _DissolveProgress("Dissolve Amount", Range(0,1)) = 0 + [ToggleUI]_UseClipsForDissolve("Do Dissolve", Int) = 0 + + _ClipAgainstVertexColorGreaterZeroFive("Clip Vert Color > 0.5", Vector) = (1,1,1,1) + _ClipAgainstVertexColorLessZeroFive("Clip Vert Color < 0.5", Vector) = (1,1,1,1) + + [Enum(UV1,0,UV2,1)] _UVSetAlbedo("Albedo UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetNormal("Normal Map UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetDetNormal("Detail Normal UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetDetMask("Detail Mask UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetMetallic("Metallic Map UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetSpecular("Specular Map UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetReflectivity("Reflection Mask UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetThickness("Thickness Map UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetOcclusion("Occlusion Map UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetEmission("Emission Map UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetClipMap("Clip Map UVs", Int) = 0 + [Enum(UV1,0,UV2,1)] _UVSetDissolve("Dissolve Map UVs", Int) = 0 + + _ClipMap("Clip Map", 2D) = "black" {} + [HideInInspector][Enum(Basic, 0, Advanced, 1)]_AdvMode("Shader Mode", Int) = 0 + [IntRange] _Stencil ("Stencil ID [0;255]", Range(0,255)) = 0 + [Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp ("Stencil Comparison", Int) = 0 + [Enum(UnityEngine.Rendering.StencilOp)] _StencilOp ("Stencil Operation", Int) = 0 + + [HideInInspector] _SrcBlend ("__src", int) = 1 + [HideInInspector] _DstBlend ("__dst", int) = 0 + [HideInInspector] _ZWrite ("__zw", int) = 1 + [HideInInspector] _AlphaToMask("__am", int) = 0 + } + + SubShader + { + Tags { "RenderType"="Opaque" "Queue"="Geometry" } + Cull [_Culling] + AlphaToMask [_AlphaToMask] + Stencil + { + Ref [_Stencil] + Comp [_StencilComp] + Pass [_StencilOp] + } + Grabpass // Gets disabled via the editor script when not in use through the Lightmode Tag. + { + Tags{"LightMode" = "Always"} + "_GrabTexture" + } + Pass + { + Name "FORWARD" + Tags { "LightMode" = "ForwardBase" } + Blend [_SrcBlend] [_DstBlend] + ZWrite [_ZWrite] + CGPROGRAM + #pragma target 3.0 + #pragma vertex vert + #pragma fragment frag + #pragma shader_feature _ALPHABLEND_ON + #pragma shader_feature _ALPHATEST_ON + #pragma multi_compile _ VERTEXLIGHT_ON + #pragma shader_feature _COLOROVERLAY_ON + #pragma multi_compile_fog + #pragma multi_compile_fwdbase + + #ifndef UNITY_PASS_FORWARDBASE + #define UNITY_PASS_FORWARDBASE + #endif + + #include "../../../CGIncludes/XSDefines.cginc" + #include "../CGInc/PenetratorDefines.cginc" + #include "../../../CGIncludes/XSHelperFunctions.cginc" + #include "../../../CGIncludes/XSLightingFunctions.cginc" + #include "../../../CGIncludes/XSLighting.cginc" + #include "../CGInc/XSVert.cginc" + #include "../../../CGIncludes/XSGeom.cginc" + #include "../CGInc/XSFrag.cginc" + ENDCG + } + } + + CustomEditor "XSToonDynamicPenetration.XSToonInspector" +}
\ No newline at end of file diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/Shaders/XSToon2.0 Penetrator.shader.meta b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/Shaders/XSToon2.0 Penetrator.shader.meta new file mode 100644 index 00000000..b1362c62 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Plugins/DynamicPenetrationSystem XS Plugin/Shaders/XSToon2.0 Penetrator.shader.meta @@ -0,0 +1,24 @@ +fileFormatVersion: 2 +guid: 662671fda57976d4dbecf70a929ad463 +ShaderImporter: + externalObjects: {} + defaultTextures: + - _MainTex: {instanceID: 0} + - _BumpMap: {instanceID: 0} + - _DetailNormalMap: {instanceID: 0} + - _DetailMask: {instanceID: 0} + - _MetallicGlossMap: {instanceID: 0} + - _BakedCubemap: {instanceID: 0} + - _Matcap: {instanceID: 0} + - _ReflectivityMask: {instanceID: 0} + - _EmissionMap: {instanceID: 0} + - _SpecularMap: {instanceID: 0} + - _RampSelectionMask: {instanceID: 0} + - _Ramp: {fileID: 2800000, guid: 529b95e318b684643b47bd73e037118a, type: 3} + - _OcclusionMap: {instanceID: 0} + - _OutlineMask: {instanceID: 0} + - _ThicknessMap: {instanceID: 0} + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Shaders.meta b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Shaders.meta new file mode 100644 index 00000000..4bb86e76 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Shaders.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b0550db3d6e73834a854cb7a4117d4ee +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Shaders/Nothing Here.txt b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Shaders/Nothing Here.txt new file mode 100644 index 00000000..9be9bcf8 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Shaders/Nothing Here.txt @@ -0,0 +1 @@ +Nothing
\ No newline at end of file diff --git a/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Shaders/Nothing Here.txt.meta b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Shaders/Nothing Here.txt.meta new file mode 100644 index 00000000..2a839ec4 --- /dev/null +++ b/VRCSDK3Avatars/Assets/Resources/RalivDynamicPenetrationSystem/Plugins/Xiexes-Unity-Shaders-development/Main/Shaders/Nothing Here.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 5faf1b199cd442c4ca4c70e5d4cd7dd7 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: |