Initial Commit
This commit is contained in:
parent
53eb92e9af
commit
270ab7d11f
15341 changed files with 700234 additions and 0 deletions
|
@ -0,0 +1,85 @@
|
|||
// UI Editable properties
|
||||
uniform sampler2D _FaceTex; // Alpha : Signed Distance
|
||||
uniform float _FaceUVSpeedX;
|
||||
uniform float _FaceUVSpeedY;
|
||||
uniform fixed4 _FaceColor; // RGBA : Color + Opacity
|
||||
uniform float _FaceDilate; // v[ 0, 1]
|
||||
uniform float _OutlineSoftness; // v[ 0, 1]
|
||||
|
||||
uniform sampler2D _OutlineTex; // RGBA : Color + Opacity
|
||||
uniform float _OutlineUVSpeedX;
|
||||
uniform float _OutlineUVSpeedY;
|
||||
uniform fixed4 _OutlineColor; // RGBA : Color + Opacity
|
||||
uniform float _OutlineWidth; // v[ 0, 1]
|
||||
|
||||
uniform float _Bevel; // v[ 0, 1]
|
||||
uniform float _BevelOffset; // v[-1, 1]
|
||||
uniform float _BevelWidth; // v[-1, 1]
|
||||
uniform float _BevelClamp; // v[ 0, 1]
|
||||
uniform float _BevelRoundness; // v[ 0, 1]
|
||||
|
||||
uniform sampler2D _BumpMap; // Normal map
|
||||
uniform float _BumpOutline; // v[ 0, 1]
|
||||
uniform float _BumpFace; // v[ 0, 1]
|
||||
|
||||
uniform samplerCUBE _Cube; // Cube / sphere map
|
||||
uniform fixed4 _ReflectFaceColor; // RGB intensity
|
||||
uniform fixed4 _ReflectOutlineColor;
|
||||
//uniform float _EnvTiltX; // v[-1, 1]
|
||||
//uniform float _EnvTiltY; // v[-1, 1]
|
||||
uniform float3 _EnvMatrixRotation;
|
||||
uniform float4x4 _EnvMatrix;
|
||||
|
||||
uniform fixed4 _SpecularColor; // RGB intensity
|
||||
uniform float _LightAngle; // v[ 0,Tau]
|
||||
uniform float _SpecularPower; // v[ 0, 1]
|
||||
uniform float _Reflectivity; // v[ 5, 15]
|
||||
uniform float _Diffuse; // v[ 0, 1]
|
||||
uniform float _Ambient; // v[ 0, 1]
|
||||
|
||||
uniform fixed4 _UnderlayColor; // RGBA : Color + Opacity
|
||||
uniform float _UnderlayOffsetX; // v[-1, 1]
|
||||
uniform float _UnderlayOffsetY; // v[-1, 1]
|
||||
uniform float _UnderlayDilate; // v[-1, 1]
|
||||
uniform float _UnderlaySoftness; // v[ 0, 1]
|
||||
|
||||
uniform fixed4 _GlowColor; // RGBA : Color + Intesity
|
||||
uniform float _GlowOffset; // v[-1, 1]
|
||||
uniform float _GlowOuter; // v[ 0, 1]
|
||||
uniform float _GlowInner; // v[ 0, 1]
|
||||
uniform float _GlowPower; // v[ 1, 1/(1+4*4)]
|
||||
|
||||
// API Editable properties
|
||||
uniform float _ShaderFlags;
|
||||
uniform float _WeightNormal;
|
||||
uniform float _WeightBold;
|
||||
|
||||
uniform float _ScaleRatioA;
|
||||
uniform float _ScaleRatioB;
|
||||
uniform float _ScaleRatioC;
|
||||
|
||||
uniform float _VertexOffsetX;
|
||||
uniform float _VertexOffsetY;
|
||||
|
||||
//uniform float _UseClipRect;
|
||||
uniform float _MaskID;
|
||||
uniform sampler2D _MaskTex;
|
||||
uniform float4 _MaskCoord;
|
||||
uniform float4 _ClipRect; // bottom left(x,y) : top right(z,w)
|
||||
//uniform float _MaskWipeControl;
|
||||
//uniform float _MaskEdgeSoftness;
|
||||
//uniform fixed4 _MaskEdgeColor;
|
||||
//uniform bool _MaskInverse;
|
||||
|
||||
uniform float _MaskSoftnessX;
|
||||
uniform float _MaskSoftnessY;
|
||||
|
||||
// Font Atlas properties
|
||||
uniform sampler2D _MainTex;
|
||||
uniform float _TextureWidth;
|
||||
uniform float _TextureHeight;
|
||||
uniform float _GradientScale;
|
||||
uniform float _ScaleX;
|
||||
uniform float _ScaleY;
|
||||
uniform float _PerspectiveFilter;
|
||||
uniform float _Sharpness;
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3c6c403084eacec478a1129ce20061ea
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,75 @@
|
|||
// Simplified SDF shader:
|
||||
// - No Shading Option (bevel / bump / env map)
|
||||
// - No Glow Option
|
||||
// - Softness is applied on both side of the outline
|
||||
|
||||
Shader "Hidden/TMP/Internal/Editor/Distance Field SSD" {
|
||||
|
||||
Properties{
|
||||
_FaceColor("Face Color", Color) = (1,1,1,1)
|
||||
_FaceDilate("Face Dilate", Range(-1,1)) = 0
|
||||
|
||||
_OutlineColor("Outline Color", Color) = (0,0,0,1)
|
||||
_OutlineWidth("Outline Thickness", Range(0,1)) = 0
|
||||
_OutlineSoftness("Outline Softness", Range(0,1)) = 0
|
||||
|
||||
_UnderlayColor("Border Color", Color) = (0,0,0,.5)
|
||||
_UnderlayOffsetX("Border OffsetX", Range(-1,1)) = 0
|
||||
_UnderlayOffsetY("Border OffsetY", Range(-1,1)) = 0
|
||||
_UnderlayDilate("Border Dilate", Range(-1,1)) = 0
|
||||
_UnderlaySoftness("Border Softness", Range(0,1)) = 0
|
||||
|
||||
_WeightNormal("Weight Normal", float) = 0
|
||||
_WeightBold("Weight Bold", float) = .5
|
||||
|
||||
_ShaderFlags("Flags", float) = 0
|
||||
_ScaleRatioA("Scale RatioA", float) = 1
|
||||
_ScaleRatioB("Scale RatioB", float) = 1
|
||||
_ScaleRatioC("Scale RatioC", float) = 1
|
||||
|
||||
_MainTex("Font Atlas", 2D) = "white" {}
|
||||
_TextureWidth("Texture Width", float) = 1024
|
||||
_TextureHeight("Texture Height", float) = 1024
|
||||
_GradientScale("Gradient Scale", float) = 1
|
||||
_ScaleX("Scale X", float) = 1
|
||||
_ScaleY("Scale Y", float) = 1
|
||||
_PerspectiveFilter("Perspective Correction", Range(0, 1)) = 0.875
|
||||
_Sharpness("Sharpness", Range(-1,1)) = 0
|
||||
|
||||
_VertexOffsetX("Vertex OffsetX", float) = 0
|
||||
_VertexOffsetY("Vertex OffsetY", float) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"ForceSupported" = "True"
|
||||
}
|
||||
|
||||
Lighting Off
|
||||
Blend One OneMinusSrcAlpha
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
ZTest Always
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex VertShader
|
||||
#pragma fragment PixShader
|
||||
#pragma shader_feature __ OUTLINE_ON
|
||||
#pragma shader_feature __ UNDERLAY_ON UNDERLAY_INNER
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
#include "TMP_Properties.cginc"
|
||||
|
||||
#include "TMP_SDF_SSD.cginc"
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
CustomEditor "TMPro.EditorUtilities.TMP_SDFShaderGUI"
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9c442dc870b456e48b615cd8add0e9ef
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,132 @@
|
|||
struct vertex_t
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
struct pixel_t
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
float4 faceColor : COLOR;
|
||||
float4 outlineColor : COLOR1;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float4 param : TEXCOORD1; // weight, scaleRatio
|
||||
float2 clipUV : TEXCOORD2;
|
||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
||||
float4 texcoord2 : TEXCOORD3;
|
||||
float4 underlayColor : COLOR2;
|
||||
#endif
|
||||
};
|
||||
|
||||
sampler2D _GUIClipTexture;
|
||||
uniform float4x4 unity_GUIClipTextureMatrix;
|
||||
float4 _MainTex_TexelSize;
|
||||
|
||||
float4 SRGBToLinear(float4 rgba)
|
||||
{
|
||||
return float4(lerp(rgba.rgb / 12.92f, pow((rgba.rgb + 0.055f) / 1.055f, 2.4f), step(0.04045f, rgba.rgb)), rgba.a);
|
||||
}
|
||||
|
||||
pixel_t VertShader(vertex_t input)
|
||||
{
|
||||
pixel_t output;
|
||||
|
||||
float bold = step(input.texcoord1.y, 0);
|
||||
|
||||
float4 vert = input.position;
|
||||
vert.x += _VertexOffsetX;
|
||||
vert.y += _VertexOffsetY;
|
||||
|
||||
float4 vPosition = UnityObjectToClipPos(vert);
|
||||
|
||||
float weight = lerp(_WeightNormal, _WeightBold, bold) / 4.0;
|
||||
weight = (weight + _FaceDilate) * _ScaleRatioA * 0.5;
|
||||
|
||||
// Generate UV for the Clip Texture
|
||||
float3 eyePos = UnityObjectToViewPos(input.position);
|
||||
float2 clipUV = mul(unity_GUIClipTextureMatrix, float4(eyePos.xy, 0, 1.0));
|
||||
|
||||
float4 color = input.color;
|
||||
#if (FORCE_LINEAR && !UNITY_COLORSPACE_GAMMA)
|
||||
color = SRGBToLinear(input.color);
|
||||
#endif
|
||||
|
||||
float opacity = color.a;
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
opacity = 1.0;
|
||||
#endif
|
||||
|
||||
float4 faceColor = float4(color.rgb, opacity) * _FaceColor;
|
||||
faceColor.rgb *= faceColor.a;
|
||||
|
||||
float4 outlineColor = _OutlineColor;
|
||||
outlineColor.a *= opacity;
|
||||
outlineColor.rgb *= outlineColor.a;
|
||||
|
||||
output.position = vPosition;
|
||||
output.faceColor = faceColor;
|
||||
output.outlineColor = outlineColor;
|
||||
output.texcoord0 = float2(input.texcoord0.xy);
|
||||
output.param = float4(0.5 - weight, 1.3333 * _GradientScale * (_Sharpness + 1) / _MainTex_TexelSize.z , _OutlineWidth * _ScaleRatioA * 0.5, 0);
|
||||
output.clipUV = clipUV;
|
||||
|
||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
||||
float4 underlayColor = _UnderlayColor;
|
||||
underlayColor.rgb *= underlayColor.a;
|
||||
|
||||
float x = -(_UnderlayOffsetX * _ScaleRatioC) * _GradientScale / _MainTex_TexelSize.z;
|
||||
float y = -(_UnderlayOffsetY * _ScaleRatioC) * _GradientScale / _MainTex_TexelSize.w;
|
||||
|
||||
output.texcoord2 = float4(input.texcoord0 + float2(x, y), input.color.a, 0);
|
||||
output.underlayColor = underlayColor;
|
||||
#endif
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
float4 PixShader(pixel_t input) : SV_Target
|
||||
{
|
||||
float d = tex2D(_MainTex, input.texcoord0.xy).a;
|
||||
|
||||
float2 UV = input.texcoord0.xy;
|
||||
float scale = rsqrt(abs(ddx(UV.x) * ddy(UV.y) - ddy(UV.x) * ddx(UV.y))) * input.param.y;
|
||||
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
float layerScale = scale;
|
||||
layerScale /= 1 + ((_UnderlaySoftness * _ScaleRatioC) * layerScale);
|
||||
float layerBias = input.param.x * layerScale - .5 - ((_UnderlayDilate * _ScaleRatioC) * .5 * layerScale);
|
||||
#endif
|
||||
|
||||
scale /= 1 + (_OutlineSoftness * _ScaleRatioA * scale);
|
||||
|
||||
float4 faceColor = input.faceColor * saturate((d - input.param.x) * scale + 0.5);
|
||||
|
||||
#ifdef OUTLINE_ON
|
||||
float4 outlineColor = lerp(input.faceColor, input.outlineColor, sqrt(min(1.0, input.param.z * scale * 2)));
|
||||
faceColor = lerp(outlineColor, input.faceColor, saturate((d - input.param.x - input.param.z) * scale + 0.5));
|
||||
faceColor *= saturate((d - input.param.x + input.param.z) * scale + 0.5);
|
||||
#endif
|
||||
|
||||
#if UNDERLAY_ON
|
||||
d = tex2D(_MainTex, input.texcoord2.xy).a * layerScale;
|
||||
faceColor += float4(_UnderlayColor.rgb * _UnderlayColor.a, _UnderlayColor.a) * saturate(d - layerBias) * (1 - faceColor.a);
|
||||
#endif
|
||||
|
||||
#if UNDERLAY_INNER
|
||||
float bias = input.param.x * scale - 0.5;
|
||||
float sd = saturate(d * scale - bias - input.param.z);
|
||||
d = tex2D(_MainTex, input.texcoord2.xy).a * layerScale;
|
||||
faceColor += float4(_UnderlayColor.rgb * _UnderlayColor.a, _UnderlayColor.a) * (1 - saturate(d - layerBias)) * sd * (1 - faceColor.a);
|
||||
#endif
|
||||
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
faceColor *= input.texcoord2.z;
|
||||
#endif
|
||||
|
||||
faceColor *= tex2D(_GUIClipTexture, input.clipUV).a;
|
||||
|
||||
return faceColor;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: abe6991365a27d341a10580f3b7c0f44
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue