#include "ShaderApiReflectionSupport.hlsl"
namespace ShaderFunctionReflectionExamples {
///
/// SG.NodeReference.Antialias.Example
/// Antialias
/// Reference/Shader Functions
/// Antialias
/// Antialias
///
///
/// 0.5
///
UNITY_EXPORT_REFLECTION
float Antialias(float gradient, float cutoff)
{
float c = cutoff - gradient;
float d = length(float2(ddx(c), ddy(c)));
return saturate(0.5 - (c / d));
}
///
/// SG.NodeReference.Grid.Example
/// Grid
/// Reference/Shader Functions
/// Grid
/// Grid
///
///
///
/// UV0
///
///
/// 5,5
///
///
/// 0.01
///
///
///
/// 0.2,0.7,0.8
///
///
///
///
UNITY_EXPORT_REFLECTION
float3 Grid(
float2 uv,
float2 spacing,
float thickness,
float3 lineColor,
bool antialiased,
out float mask)
{
float2 g = uv * spacing;
float2 gridDist = abs(frac(g - 0.5) - 0.5) / fwidth(g);
float l = min(gridDist.x, gridDist.y);
mask = 1.0 - saturate(l - thickness);
if (antialiased)
mask = Antialias(mask, 0.5);
return lineColor * mask;
}
///
/// SG.NodeReference.UV_Swirl.Example
/// UV Swirl
/// Reference/Shader Functions
/// UV Swirl
/// UV, Distorion, Swirl
///
///
///
/// UV0
///
///
/// 0.5,0.5
///
///
///
///
UNITY_EXPORT_REFLECTION
void UV_Swirl(
inout float2 uv,
bool animated,
float time,
float2 center,
float strength)
{
float2 d = uv - center;
float r = length(d);
float a = atan2(d.y, d.x);
a += strength * (1 - r);
[branch]
if (animated)
a += time;
uv = center + float2(cos(a), sin(a)) * r;
}
}