squash commits

This commit is contained in:
2025-01-07 18:54:46 +02:00
parent 855639487b
commit 62c0a21987
3632 changed files with 708443 additions and 999 deletions
@@ -0,0 +1,423 @@
Shader "Hair/Hair Mark 9"
{
Properties
{
_Color("Color", Color) = (1,1,1,1)
_MainTex ("Texture", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.4
_CutoffOffset ("Alpha cutoff shadows", Range(0,1)) = 0.4
_MipScale ("Mip Level Alpha Scale", Range(0,1)) = 0.25
_MipScaleOffset ("Shadow Scale", Range(0,3)) = 1.5
_ShadowScaleOffset ("Shadow Scale Offset", float) = -0.001
_Spec("Spec Color", Color) = (1,1,1,1)
_Gloss("Gloss", float) = 1.0
_AnisoOffset("Aniso Offset", float) = 1.0
_Flatness("Flatness", float) = 0.5
_Smoother("Lighting Smoother", float) = 4
_RimPower("Rim Lighting", Range(0,2)) = 0
_RimAngle("Rim Angle", Range(0,20)) = 1
_AnisoTwo("Aniso", float) = 1.0
_AnisoThree("Strandiness", float) = 1.0
_AnisoFour("Strand Highlight Cutoff", float) = 1.0
_AnisoDir("Aniso Dir", Vector) = (0.5,0.5,1.0,1.0)
_BlueNoiseCrossfade("Blue Noise Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderQueue"="AlphaTest" "RenderType"="TransparentCutout" }
Cull Off
Pass
{
Tags { "LightMode"="ForwardBase" }
//AlphaToMask On
ZWrite On
ColorMask RGB
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fwdbase
#include "UnityCG.cginc"
#include "Lighting.cginc"
#include "AutoLight.cginc"
#include "DitherFunctions.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
half3 normal : NORMAL;
};
struct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
half3 worldNormal : NORMAL;
half3 viewDir : TEXCOORD1;
float4 screenPos : TEXCOORD2;
LIGHTING_COORDS(3,4)
};
sampler2D _MainTex;
float4 _MainTex_ST;
float4 _MainTex_TexelSize;
fixed _Cutoff;
half _MipScale;
fixed _Gloss;
fixed4 _Spec;
half _AnisoOffset;
half _Flatness;
fixed4 _Color;
float4 _AnisoDir;
float _AnisoTwo;
float _AnisoThree;
float _AnisoFour;
float _Smoother;
float CalcMipLevel(float2 texture_coord)
{
float2 dx = ddx(texture_coord);
float2 dy = ddy(texture_coord);
float delta_max_sqr = max(dot(dx, dx), dot(dy, dy));
return max(0.0, 0.5 * log2(delta_max_sqr));
}
v2f vert (appdata v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
o.worldNormal = UnityObjectToWorldNormal(v.normal);
o.viewDir = ObjSpaceViewDir(v.vertex);
o.screenPos = ComputeScreenPos(UnityObjectToClipPos(v.vertex));
TRANSFER_VERTEX_TO_FRAGMENT(o);
return o;
}
float _RimAngle;
float _RimPower;
inline fixed4 CalculateLighting(v2f i, fixed facing : VFACE, fixed4 albedo) {
float3 lightDir = normalize(_WorldSpaceLightPos0.xyz);
float3 worldNormal = i.worldNormal * facing;
fixed3 h = normalize(normalize(lightDir) + normalize(i.viewDir));
float d = max(dot(lightDir, worldNormal), dot(lightDir, worldNormal * -1));
float NdotL = saturate(d * _Smoother + _Flatness);
fixed HdotA = dot(normalize(worldNormal + _AnisoDir.rgb), h);
float aniso = max(0, sin(radians((HdotA + _AnisoOffset) * 180)));
float specX = saturate(dot(worldNormal, h));
float rim = saturate(pow(max(dot(i.worldNormal * facing, i.viewDir), dot(i.worldNormal * facing, i.viewDir)), _RimAngle)) * _RimPower;
float3 spec = saturate((pow(lerp(specX, aniso, _AnisoTwo), _Gloss * 128) + rim) * _Spec);
float maxAlbedo = max(max(albedo.r, albedo.g), albedo.b);
spec = lerp(spec, spec*saturate(((maxAlbedo - _AnisoFour)*(1.0 / _AnisoFour))), _AnisoThree);
fixed4 c;
half3 sh9 = ShadeSH9(float4(worldNormal.rgb,1.0));
c.rgb = ((albedo * _LightColor0.rgb * NdotL * 0.5) + (_LightColor0.rgb * spec * maxAlbedo))
* (LIGHT_ATTENUATION(i) * 2)
+ (sh9 * albedo);
c.a = albedo.a;
//clip(albedo.Alpha - _Cutoff);
return c;
}
fixed4 frag (v2f i, fixed facing : VFACE) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv) * _Color;
// rescale alpha by mip level (if not using preserved coverage mip maps)
col.a *= 1 + max(0, CalcMipLevel(i.uv * _MainTex_TexelSize.zw)) * _MipScale;
// rescale alpha by partial derivative
col.a = (col.a - _Cutoff) / max(fwidth(col.a), 0.0001) + 0.5;
half3 worldNormal = normalize(i.worldNormal * facing);
col = CalculateLighting(i, facing, col);
//col.rg = (i.screenPos.xy / i.screenPos.w);
ditherClip(i.screenPos.xy / i.screenPos.w, col.a, _Cutoff);
return col;
}
ENDCG
}
Pass
{
Tags { "LightMode"="ForwardBase" }
AlphaToMask Off
ZWrite Off
ZTest Less
Cull Off
ColorMask RGB
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fwdbase
#include "UnityCG.cginc"
#include "Lighting.cginc"
#include "AutoLight.cginc"
#include "DitherFunctions.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
half3 normal : NORMAL;
};
struct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
half3 worldNormal : NORMAL;
half3 viewDir : TEXCOORD1;
float4 screenPos : TEXCOORD2;
LIGHTING_COORDS(3,4)
};
sampler2D _MainTex;
float4 _MainTex_ST;
float4 _MainTex_TexelSize;
fixed _Cutoff;
half _MipScale;
fixed _Gloss;
fixed4 _Spec;
half _AnisoOffset;
half _Flatness;
fixed4 _Color;
float4 _AnisoDir;
float _AnisoTwo;
float _AnisoThree;
float _AnisoFour;
float _Smoother;
float CalcMipLevel(float2 texture_coord)
{
float2 dx = ddx(texture_coord);
float2 dy = ddy(texture_coord);
float delta_max_sqr = max(dot(dx, dx), dot(dy, dy));
return max(0.0, 0.5 * log2(delta_max_sqr));
}
v2f vert (appdata v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
o.worldNormal = UnityObjectToWorldNormal(v.normal);
o.viewDir = ObjSpaceViewDir(v.vertex);
o.screenPos = ComputeScreenPos(UnityObjectToClipPos(v.vertex));
TRANSFER_VERTEX_TO_FRAGMENT(o);
return o;
}
float _RimAngle;
float _RimPower;
inline fixed4 CalculateLighting(v2f i, fixed facing : VFACE, fixed4 albedo) {
float3 lightDir = normalize(_WorldSpaceLightPos0.xyz);
float3 worldNormal = i.worldNormal * facing;
fixed3 h = normalize(normalize(lightDir) + normalize(i.viewDir));
float d = max(dot(lightDir, worldNormal), dot(lightDir, worldNormal * -1));
float NdotL = saturate(d * _Smoother + _Flatness);
fixed HdotA = dot(normalize(worldNormal + _AnisoDir.rgb), h);
float aniso = max(0, sin(radians((HdotA + _AnisoOffset) * 180)));
float specX = saturate(dot(worldNormal, h));
float rim = saturate(pow(max(dot(i.worldNormal * facing, i.viewDir), dot(i.worldNormal * facing, i.viewDir)), _RimAngle)) * _RimPower;
float3 spec = saturate((pow(lerp(specX, aniso, _AnisoTwo), _Gloss * 128) + rim) * _Spec);
float maxAlbedo = max(max(albedo.r, albedo.g), albedo.b);
spec = lerp(spec, spec*saturate(((maxAlbedo - _AnisoFour)*(1.0 / _AnisoFour))), _AnisoThree);
fixed4 c;
half3 sh9 = ShadeSH9(float4(worldNormal.rgb,1.0));
c.rgb = ((albedo * _LightColor0.rgb * NdotL * 0.5) + (_LightColor0.rgb * spec * maxAlbedo))
* (LIGHT_ATTENUATION(i) * 2)
+ (sh9 * albedo);
c.a = albedo.a;
//clip(albedo.Alpha - _Cutoff);
return c;
}
fixed4 frag (v2f i, fixed facing : VFACE) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv) * _Color;
// rescale alpha by mip level (if not using preserved coverage mip maps)
//col.a *= 1 + max(0, CalcMipLevel(i.uv * _MainTex_TexelSize.zw)) * _MipScale;
// rescale alpha by partial derivative
//col.a = (col.a - _Cutoff) / max(fwidth(col.a), 0.0001) + 0.5;
half3 worldNormal = normalize(i.worldNormal * facing);
col = CalculateLighting(i, facing, col);
//ditherClip(i.screenPos.xy / i.screenPos.w, 1.0 - col.a, _Cutoff);
col.a = saturate(col.a * (1/_Cutoff));
return col;
}
ENDCG
}
/*
Pass {
Name "CASTER"
Tags { "LIGHTMODE"="SHADOWCASTER" "QUEUE"="AlphaTest" "IGNOREPROJECTOR"="true" "SHADOWSUPPORT"="true" "RenderType"="TransparentCutout" }
//AlphaToMask On
Cull Off
ZWrite On
CGPROGRAM
#include "HLSLSupport.cginc"
#include "UnityShaderVariables.cginc"
#include "UnityShaderUtilities.cginc"
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#pragma multi_compile_shadowcaster
#pragma multi_compile_instancing // allow instanced shadow pass for most of the shaders
#include "UnityCG.cginc"
struct v2f {
V2F_SHADOW_CASTER;
float2 uv : TEXCOORD1;
UNITY_VERTEX_OUTPUT_STEREO
};
uniform float4 _MainTex_ST;
float _ShadowScaleOffset;
v2f vert( appdata_base v )
{
v2f o;
v.vertex.xyz += v.normal.xyz * _ShadowScaleOffset;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
TRANSFER_SHADOW_CASTER_NORMALOFFSET(o)
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
return o;
}
uniform sampler2D _MainTex;
float4 _MainTex_TexelSize;
uniform fixed _CutoffOffset;
uniform fixed4 _Color;
half _MipScaleOffset;
float CalcMipLevel(float2 texture_coord)
{
float2 dx = ddx(texture_coord);
float2 dy = ddy(texture_coord);
float delta_max_sqr = max(dot(dx, dx), dot(dy, dy));
return max(0.0, 0.5 * log2(delta_max_sqr));
}
float4 frag( v2f i ) : SV_Target
{
fixed4 col = tex2D( _MainTex, i.uv );
//col.a *= 1 + max(0, CalcMipLevel(i.uv * _MainTex_TexelSize.zw)) * _MipScaleOffset;
//col.a -= _CutoffOffset + 0.1;
//col.a = (col.a - _CutoffOffset) / max(fwidth(col.a), 0.0) + 0.5;
clip( col.a - _CutoffOffset);
SHADOW_CASTER_FRAGMENT(i)
}
ENDCG
}
*/
Pass
{
Name "CASTER"
Tags { "LIGHTMODE"="SHADOWCASTER" "QUEUE"="AlphaTest" "IGNOREPROJECTOR"="true" "SHADOWSUPPORT"="true" "RenderType"="TransparentCutout" }
CGPROGRAM
#include "UnityCG.cginc"
#include "DitherFunctions.cginc"
#pragma vertex vert
#pragma fragment frag
float4 _Color;
float4 _MainTex_ST; // For the Main Tex UV transform
sampler2D _MainTex; // Texture used for the line
float _MipScaleOffset;
float _CutoffOffset;
struct v2f
{
float4 pos : POSITION;
float2 uv : TEXCOORD0;
float4 screenPos : TEXCOORD1;
};
v2f vert(appdata_base v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
o.screenPos = ComputeScreenPos(UnityObjectToClipPos(v.vertex));
return o;
}
float4 frag(v2f i) : COLOR
{
float4 col = _Color * tex2D(_MainTex, i.uv);
ditherClip(i.screenPos.xy / i.screenPos.w, col.a * _MipScaleOffset, _CutoffOffset);
return float4(0,0,0,0);
}
ENDCG
}
}
FallBack "Transparent/Cutout/Specular"
}
@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: def76a94c229c2a4dae4e0ec3bcd8cca
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 35611
packageName: UMA 2
packageVersion: 2.13
assetPath: Assets/UMA/Content/Hair/Shader/UnityHairShader-master/Version9/AlphaCoverageAnisoHair.shader
uploadId: 679826
@@ -0,0 +1,136 @@
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
Shader "Legacy Shaders/Transparent/Cutout/VertexLit" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_SpecColor ("Spec Color", Color) = (1,1,1,0)
_Emission ("Emissive Color", Color) = (0,0,0,0)
_Shininess ("Shininess", Range (0.1, 1)) = 0.7
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
}
SubShader {
Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
LOD 100
// Non-lightmapped
Pass {
Tags { "LightMode" = "Vertex" }
Alphatest Greater [_Cutoff]
AlphaToMask True
ColorMask RGB
Material {
Diffuse [_Color]
Ambient [_Color]
Shininess [_Shininess]
Specular [_SpecColor]
Emission [_Emission]
}
Lighting On
SeparateSpecular On
SetTexture [_MainTex] {
Combine texture * primary DOUBLE, texture * primary
}
}
// Lightmapped, encoded as dLDR
Pass {
Tags { "LightMode" = "VertexLM" }
Alphatest Greater [_Cutoff]
AlphaToMask True
ColorMask RGB
BindChannels {
Bind "Vertex", vertex
Bind "normal", normal
Bind "texcoord1", texcoord0 // lightmap uses 2nd uv
Bind "texcoord", texcoord1 // main uses 1st uv
}
SetTexture [unity_Lightmap] {
matrix [unity_LightmapMatrix]
constantColor [_Color]
combine texture * constant
}
SetTexture [_MainTex] {
combine texture * previous DOUBLE, texture * primary
}
}
// Lightmapped, encoded as RGBM
Pass {
Tags { "LightMode" = "VertexLMRGBM" }
Alphatest Greater [_Cutoff]
AlphaToMask True
ColorMask RGB
BindChannels {
Bind "Vertex", vertex
Bind "normal", normal
Bind "texcoord1", texcoord0 // lightmap uses 2nd uv
Bind "texcoord1", texcoord1 // unused
Bind "texcoord", texcoord2 // main uses 1st uv
}
SetTexture [unity_Lightmap] {
matrix [unity_LightmapMatrix]
combine texture * texture alpha DOUBLE
}
SetTexture [unity_Lightmap] {
constantColor [_Color]
combine previous * constant
}
SetTexture [_MainTex] {
combine texture * previous QUAD, texture * primary
}
}
// Pass to render object as a shadow caster
Pass {
Name "Caster"
Tags { "LightMode" = "ShadowCaster" }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#pragma multi_compile_shadowcaster
#pragma multi_compile_instancing // allow instanced shadow pass for most of the shaders
#include "UnityCG.cginc"
struct v2f {
V2F_SHADOW_CASTER;
float2 uv : TEXCOORD1;
UNITY_VERTEX_OUTPUT_STEREO
};
uniform float4 _MainTex_ST;
v2f vert( appdata_base v )
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
TRANSFER_SHADOW_CASTER_NORMALOFFSET(o)
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
return o;
}
uniform sampler2D _MainTex;
uniform fixed _Cutoff;
uniform fixed4 _Color;
float4 frag( v2f i ) : SV_Target
{
fixed4 texcol = tex2D( _MainTex, i.uv );
clip( texcol.a*_Color.a - _Cutoff );
SHADOW_CASTER_FRAGMENT(i)
}
ENDCG
}
}
}
@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: e58e02fdda99e774fb09e5cd2ebc3a11
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 35611
packageName: UMA 2
packageVersion: 2.13
assetPath: Assets/UMA/Content/Hair/Shader/UnityHairShader-master/Version9/AlphaTest-VertexLit.shader
uploadId: 679826
Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

@@ -0,0 +1,153 @@
fileFormatVersion: 2
guid: 23fd7a3ab1a69344a9eda1a6ca4223f7
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: -1
mipBias: -1
wrapU: 0
wrapV: 1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: iPhone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: tvOS
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Tizen
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Windows Store Apps
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Samsung TV
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 35611
packageName: UMA 2
packageVersion: 2.13
assetPath: Assets/UMA/Content/Hair/Shader/UnityHairShader-master/Version9/BlueNoiseCrossfade_16x256.png
uploadId: 679826
@@ -0,0 +1,95 @@
// From: https://github.com/gkjohnson/unity-dithered-transparency-shader
// MIT License
//Copyright (c) 2017 Garrett Johnson
//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:
//The above copyright notice and this permission notice shall be included in all
//copies or substantial portions of the Software.
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//SOFTWARE.
#ifndef __DITHER_FUNCTIONS__
#define __DITHER_FUNCTIONS__
#include "UnityCG.cginc"
// Returns > 0 if not clipped, < 0 if clipped based
// on the dither
// For use with the "clip" function
// pos is the fragment position in screen space from [0,1]
float isDithered(float2 pos, float alpha) {
pos *= _ScreenParams.xy;
// Define a dither threshold matrix which can
// be used to define how a 4x4 set of pixels
// will be dithered
float DITHER_THRESHOLDS[16] =
{
1.0 / 17.0, 9.0 / 17.0, 3.0 / 17.0, 11.0 / 17.0,
13.0 / 17.0, 5.0 / 17.0, 15.0 / 17.0, 7.0 / 17.0,
4.0 / 17.0, 12.0 / 17.0, 2.0 / 17.0, 10.0 / 17.0,
16.0 / 17.0, 8.0 / 17.0, 14.0 / 17.0, 6.0 / 17.0
};
uint index = (uint(pos.x) % 4) * 4 + uint(pos.y) % 4;
return alpha - DITHER_THRESHOLDS[index];
}
// Returns whether the pixel should be discarded based
// on the dither texture
// pos is the fragment position in screen space from [0,1]
float isDithered(float2 pos, float alpha, sampler2D tex, float scale) {
pos *= _ScreenParams.xy;
// offset so we're centered
pos.x -= _ScreenParams.x / 2;
pos.y -= _ScreenParams.y / 2;
// scale the texture
pos.x /= scale;
pos.y /= scale;
// ensure that we clip if the alpha is zero by
// subtracting a small value when alpha == 0, because
// the clip function only clips when < 0
return alpha - tex2D(tex, pos.xy).r - 0.0001 * (1 - ceil(alpha));
}
// Helpers that call the above functions and clip if necessary
void ditherClip(float2 pos, float alpha) {
clip(isDithered(pos, alpha));
}
sampler2D _BlueNoiseCrossfade;
float4 _BlueNoiseCrossfade_TexelSize;
float rand(float2 co){
return frac(sin(dot(co.xy ,float2(12.9898,78.233))) * 43758.5453);
}
void ditherClip(float2 pos, float alpha, float clipV) {
pos *= _ScreenParams.xy;
//clip(isDithered(pos, alpha));
float2 vpos = float2((pos.x + pos.y), alpha);
clip(tex2D(_BlueNoiseCrossfade, vpos).r - clipV);
}
void ditherClip(float2 pos, float alpha, sampler2D tex, float scale) {
clip(isDithered(pos, alpha, tex, scale));
}
#endif
@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: 4005a78a9c44dfb4db4801941bd1768a
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 35611
packageName: UMA 2
packageVersion: 2.13
assetPath: Assets/UMA/Content/Hair/Shader/UnityHairShader-master/Version9/DitherFunctions.cginc
uploadId: 679826