Skip to content

Commit 5c66159

Browse files
authored
Merge pull request #18 from coherence/2.1.0
upgrade to 2.1.0
2 parents bdaa5ce + ca9ecef commit 5c66159

119 files changed

Lines changed: 53338 additions & 642 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Assets/Art/Effects/SelectionHighlight/HighlightOutline.mat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Material:
1010
m_Name: HighlightOutline
1111
m_Shader: {fileID: -6465566751694194690, guid: abcf3ae5e7fa4422da83e0d051f08dea,
1212
type: 3}
13+
m_Parent: {fileID: 0}
14+
m_ModifiedSerializedProperties: 0
1315
m_ValidKeywords: []
1416
m_InvalidKeywords: []
1517
m_LightmapFlags: 4
@@ -18,6 +20,7 @@ Material:
1820
m_CustomRenderQueue: -1
1921
stringTagMap: {}
2022
disabledShaderPasses: []
23+
m_LockedProperties:
2124
m_SavedProperties:
2225
serializedVersion: 3
2326
m_TexEnvs:
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
float2 UnpackUV(float uv)
2+
{
3+
float2 output;
4+
output.x = floor(uv / 4096.0);
5+
output.y = uv - 4096.0 * output.x;
6+
7+
return output * 0.001953125;
8+
}
9+
10+
float4 BlendARGB(float4 overlying, float4 underlying)
11+
{
12+
overlying.rgb *= overlying.a;
13+
underlying.rgb *= underlying.a;
14+
float3 blended = overlying.rgb + ((1 - overlying.a) * underlying.rgb);
15+
float alpha = underlying.a + (1 - underlying.a) * overlying.a;
16+
return float4(blended / alpha, alpha);
17+
}
18+
19+
float3 GetSpecular(float3 n, float3 l)
20+
{
21+
float spec = pow(max(0.0, dot(n, l)), _Reflectivity);
22+
return _SpecularColor.rgb * spec * _SpecularPower;
23+
}
24+
25+
void GetSurfaceNormal_float(texture2D atlas, float textureWidth, float textureHeight, float2 uv, bool isFront, out float3 nornmal)
26+
{
27+
float3 delta = float3(1.0 / textureWidth, 1.0 / textureHeight, 0.0);
28+
29+
// Read "height field"
30+
float4 h = float4(
31+
SAMPLE_TEXTURE2D(atlas, SamplerState_Linear_Clamp, uv - delta.xz).a,
32+
SAMPLE_TEXTURE2D(atlas, SamplerState_Linear_Clamp, uv + delta.xz).a,
33+
SAMPLE_TEXTURE2D(atlas, SamplerState_Linear_Clamp, uv - delta.zy).a,
34+
SAMPLE_TEXTURE2D(atlas, SamplerState_Linear_Clamp, uv + delta.zy).a);
35+
36+
bool raisedBevel = _BevelType;
37+
38+
h += _BevelOffset;
39+
40+
float bevelWidth = max(.01, _BevelWidth);
41+
42+
// Track outline
43+
h -= .5;
44+
h /= bevelWidth;
45+
h = saturate(h + .5);
46+
47+
if (raisedBevel) h = 1 - abs(h * 2.0 - 1.0);
48+
h = lerp(h, sin(h * 3.141592 / 2.0), float4(_BevelRoundness, _BevelRoundness, _BevelRoundness, _BevelRoundness));
49+
h = min(h, 1.0 - float4(_BevelClamp, _BevelClamp, _BevelClamp, _BevelClamp));
50+
h *= _BevelAmount * bevelWidth * _GradientScale * -2.0;
51+
52+
float3 va = normalize(float3(-1.0, 0.0, h.y - h.x));
53+
float3 vb = normalize(float3(0.0, 1.0, h.w - h.z));
54+
55+
float3 f = float3(1, 1, 1);
56+
if (isFront) f = float3(1, 1, -1);
57+
nornmal = cross(va, vb) * f;
58+
}
59+
60+
void EvaluateLight_float(float4 faceColor, float3 n, out float4 color)
61+
{
62+
n.z = abs(n.z);
63+
float3 light = normalize(float3(sin(_LightAngle), cos(_LightAngle), 1.0));
64+
65+
float3 col = max(faceColor.rgb, 0) + GetSpecular(n, light)* faceColor.a;
66+
//faceColor.rgb += col * faceColor.a;
67+
col *= 1 - (dot(n, light) * _Diffuse);
68+
col *= lerp(_Ambient, 1, n.z * n.z);
69+
70+
//fixed4 reflcol = texCUBE(_Cube, reflect(input.viewDir, -n));
71+
//faceColor.rgb += reflcol.rgb * lerp(_ReflectFaceColor.rgb, _ReflectOutlineColor.rgb, saturate(sd + outline * 0.5)) * faceColor.a;
72+
73+
color = float4(col, faceColor.a);
74+
}
75+
76+
// Add custom function to handle time in HDRP
77+
78+
79+
//
80+
void GenerateUV_float(float2 inUV, float4 transform, float2 animSpeed, out float2 outUV)
81+
{
82+
outUV = inUV * transform.xy + transform.zw + (animSpeed * _Time.y);
83+
}
84+
85+
void ComputeUVOffset_float(float texWidth, float texHeight, float2 offset, float SDR, out float2 uvOffset)
86+
{
87+
uvOffset = float2(-offset.x * SDR / texWidth, -offset.y * SDR / texHeight);
88+
}
89+
90+
void ScreenSpaceRatio2_float(float4x4 projection, float4 position, float2 objectScale, float screenWidth, float screenHeight, float fontScale, out float SSR)
91+
{
92+
float2 pixelSize = position.w;
93+
pixelSize /= (objectScale * mul((float2x2)projection, float2(screenWidth, screenHeight)));
94+
SSR = rsqrt(dot(pixelSize, pixelSize)*2) * fontScale;
95+
}
96+
97+
// UV : Texture coordinate of the source distance field texture
98+
// TextureSize : Size of the source distance field texture
99+
// Filter : Enable perspective filter (soften)
100+
void ScreenSpaceRatio_float(float2 UV, float TextureSize, bool Filter, out float SSR)
101+
{
102+
if(Filter)
103+
{
104+
float2 a = float2(ddx(UV.x), ddy(UV.x));
105+
float2 b = float2(ddx(UV.y), ddy(UV.y));
106+
float s = lerp(dot(a,a), dot(b,b), 0.5);
107+
SSR = rsqrt(s) / TextureSize;
108+
}
109+
else
110+
{
111+
float s = rsqrt(abs(ddx(UV.x) * ddy(UV.y) - ddy(UV.x) * ddx(UV.y)));
112+
SSR = s / TextureSize;
113+
}
114+
}
115+
116+
// SSR : Screen Space Ratio
117+
// SD : Signed Distance (encoded : Distance / SDR + .5)
118+
// SDR : Signed Distance Ratio
119+
//
120+
// IsoPerimeter : Dilate / Contract the shape
121+
void ComputeSDF_float(float SSR, float SD, float SDR, float isoPerimeter, float softness, out float outAlpha)
122+
{
123+
softness *= SSR * SDR;
124+
float d = (SD - 0.5) * SDR; // Signed distance to edge, in Texture space
125+
outAlpha = saturate((d * 2.0 * SSR + 0.5 + isoPerimeter * SDR * SSR + softness * 0.5) / (1.0 + softness)); // Screen pixel coverage (alpha)
126+
}
127+
128+
void ComputeSDF2_float(float SSR, float SD, float SDR, float2 isoPerimeter, float2 softness, out float2 outAlpha)
129+
{
130+
softness *= SSR * SDR;
131+
float d = (SD - 0.5f) * SDR;
132+
outAlpha = saturate((d * 2.0f * SSR + 0.5f + isoPerimeter * SDR * SSR + softness * 0.5) / (1.0 + softness));
133+
}
134+
135+
void ComputeSDF4_float(float SSR, float SD, float SDR, float4 isoPerimeter, float4 softness, out float4 outAlpha)
136+
{
137+
softness *= SSR * SDR;
138+
float d = (SD - 0.5f) * SDR;
139+
outAlpha = saturate((d * 2.0f * SSR + 0.5f + isoPerimeter * SDR * SSR + softness * 0.5) / (1.0 + softness));
140+
}
141+
142+
void ComputeSDF44_float(float SSR, float4 SD, float SDR, float4 isoPerimeter, float4 softness, bool outline, out float4 outAlpha)
143+
{
144+
softness *= SSR * SDR;
145+
float4 d = (SD - 0.5f) * SDR;
146+
if(outline) d.w = max(max(d.x, d.y), d.z);
147+
outAlpha = saturate((d * 2.0f * SSR + 0.5f + isoPerimeter * SDR * SSR + softness * 0.5) / (1.0 + softness));
148+
}
149+
150+
void Composite_float(float4 overlying, float4 underlying, out float4 outColor)
151+
{
152+
outColor = BlendARGB(overlying, underlying);
153+
}
154+
155+
// Face only
156+
void Layer1_float(float alpha, float4 color0, out float4 outColor)
157+
{
158+
color0.a *= alpha;
159+
outColor = color0;
160+
}
161+
162+
// Face + 1 Outline
163+
void Layer2_float(float2 alpha, float4 color0, float4 color1, out float4 outColor)
164+
{
165+
color1.a *= alpha.y;
166+
color0.rgb *= color0.a; color1.rgb *= color1.a;
167+
outColor = lerp(color1, color0, alpha.x);
168+
outColor.rgb /= outColor.a;
169+
}
170+
171+
// Face + 3 Outline
172+
void Layer4_float(float4 alpha, float4 color0, float4 color1, float4 color2, float4 color3, out float4 outColor)
173+
{
174+
color3.a *= alpha.w;
175+
color0.rgb *= color0.a; color1.rgb *= color1.a; color2.rgb *= color2.a; color3.rgb *= color3.a;
176+
outColor = lerp(lerp(lerp(color3, color2, alpha.z), color1, alpha.y), color0, alpha.x);
177+
outColor.rgb /= outColor.a;
178+
}

Assets/Art/UI/TextMeshPro/Shaders/SDFFunctions.hlsl.meta

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)