Add SDF shaders

This commit is contained in:
2020-06-11 14:14:59 -07:00
parent e2f54cb4f7
commit b24a2c1bbe
5 changed files with 352 additions and 11 deletions

View File

@ -76,10 +76,18 @@ float4 _Background;
inline void decalClipAlpha(float alpha) {
#ifndef DECAL_PREVIEW
clip(alpha - _Cutoff + 0.01);
clip(alpha - 0.001);
#endif
}
inline 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 0.5 * log2(delta_max_sqr);
}
// modifed version of the KSP BlinnPhong because it does some weird things
inline fixed4 LightingBlinnPhongDecal(SurfaceOutput s, fixed3 lightDir, half3 viewDir, fixed atten)
{