testss
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
Shader "Hidden/Universal Render Pipeline/Editor/CurveBackground"
|
||||
{
|
||||
CGINCLUDE
|
||||
|
||||
#pragma target 3.0
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
float _DisabledState;
|
||||
|
||||
float3 HsvToRgb(float3 c)
|
||||
{
|
||||
float4 K = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
float3 p = abs(frac(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * lerp(K.xxx, saturate(p - K.xxx), c.y);
|
||||
}
|
||||
|
||||
float4 FragHue(v2f_img i) : SV_Target
|
||||
{
|
||||
float3 hsv = HsvToRgb(float3(i.uv.x, 1.0, 0.2));
|
||||
float4 color = float4((0.0).xxx, 1.0);
|
||||
color.rgb = lerp(color.rgb, hsv, smoothstep(0.5, 1.1, 1.0 - i.uv.y)) + lerp(color.rgb, hsv, smoothstep(0.5, 1.1, i.uv.y));
|
||||
color.rgb += GammaToLinearSpace(0.15).xxx;
|
||||
return float4(color.rgb, color.a * _DisabledState);
|
||||
}
|
||||
|
||||
float4 FragSat(v2f_img i) : SV_Target
|
||||
{
|
||||
float4 color = float4((0.0).xxx, 1.0);
|
||||
float sat = i.uv.x / 2;
|
||||
color.rgb += lerp(color.rgb, (sat).xxx, smoothstep(0.5, 1.2, 1.0 - i.uv.y)) + lerp(color.rgb, (sat).xxx, smoothstep(0.5, 1.2, i.uv.y));
|
||||
color.rgb += GammaToLinearSpace(0.15).xxx;
|
||||
return float4(color.rgb, color.a * _DisabledState);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
|
||||
SubShader
|
||||
{
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
|
||||
// (0) Hue
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment FragHue
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// (1) Sat/lum
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment FragSat
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,90 @@
|
||||
Shader "Hidden/Universal Render Pipeline/Editor/Shadows Midtones Highlights Curve"
|
||||
{
|
||||
CGINCLUDE
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#pragma editor_sync_compilation
|
||||
#pragma target 3.5
|
||||
|
||||
float4 _ShaHiLimits; // xy: shadows min/max, zw: highlight min/max
|
||||
float4 _Variants; // x: disabled state, y: x-scale, wz: unused
|
||||
|
||||
float3 BlendScreen(float3 base, float3 blend)
|
||||
{
|
||||
return 1.0 - (1.0 - blend) * (1.0 - base);
|
||||
}
|
||||
|
||||
float4 DrawCurve(v2f_img i, float3 background, float3 shadowsCurveColor, float3 midtonesCurveColor, float3 highlightsCurveColor)
|
||||
{
|
||||
float x = i.uv.x * _Variants.y;
|
||||
float y = i.uv.y;
|
||||
float aa = fwidth(i.uv.y) * 2.0;
|
||||
|
||||
float shadowsY = 1.0 - smoothstep(_ShaHiLimits.x, _ShaHiLimits.y, x);
|
||||
float shadowsCurve = smoothstep(shadowsY + aa, shadowsY, y);
|
||||
float shadowsLine = smoothstep(shadowsY - aa, shadowsY, y) - smoothstep(shadowsY, shadowsY + aa, y);
|
||||
|
||||
float highlightsY = smoothstep(_ShaHiLimits.z, _ShaHiLimits.w, x);
|
||||
float highlightsCurve = smoothstep(highlightsY + aa, highlightsY, y);
|
||||
float highlightsLine = smoothstep(highlightsY - aa, highlightsY, y) - smoothstep(highlightsY, highlightsY + aa, y);
|
||||
|
||||
float midtonesY = 1.0 - shadowsY - highlightsY;
|
||||
float midtonesCurve = smoothstep(midtonesY + aa, midtonesY, y);
|
||||
float midtonesLine = smoothstep(midtonesY - aa, midtonesY, y) - smoothstep(midtonesY, midtonesY + aa, y);
|
||||
|
||||
float grad = lerp(0.7, 1.0, y);
|
||||
float3 shadowsColor = shadowsCurveColor * shadowsCurve * grad;
|
||||
float3 midtonesColor = midtonesCurveColor * midtonesCurve * grad;
|
||||
float3 highlightsColor = highlightsCurveColor * highlightsCurve * grad;
|
||||
|
||||
float3 color = BlendScreen(shadowsColor, midtonesColor);
|
||||
color = BlendScreen(color, highlightsColor);
|
||||
color = BlendScreen(background, color * _Variants.xxx);
|
||||
|
||||
const float kAlpha = 0.3 * _Variants.xxx;
|
||||
color += shadowsLine * shadowsColor * kAlpha;
|
||||
color += midtonesLine * midtonesColor * kAlpha;
|
||||
color += highlightsLine * highlightsColor * kAlpha;
|
||||
|
||||
return float4(color, 1.0);
|
||||
}
|
||||
|
||||
float4 FragCurveDark(v2f_img i) : SV_Target
|
||||
{
|
||||
return DrawCurve(i, (pow(0.196, 2.2)).xxx, pow(float3(0.161, 0.851, 0.761), 2.2), pow(float3(0.741, 0.949, 0.443), 2.2), pow(float3(0.9, 0.9, 0.651), 2.2));
|
||||
}
|
||||
|
||||
float4 FragCurveLight(v2f_img i) : SV_Target
|
||||
{
|
||||
return DrawCurve(i, (pow(0.635, 2.2)).xxx, pow(float3(0.161, 0.851, 0.761), 2.2), pow(float3(0.741, 0.949, 0.443), 2.2), pow(float3(1.0, 1.0, 0.651), 2.2));
|
||||
}
|
||||
|
||||
ENDCG
|
||||
|
||||
SubShader
|
||||
{
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
|
||||
// (0) Dark skin
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment FragCurveDark
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// (1) Light skin
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment FragCurveLight
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,126 @@
|
||||
Shader "Hidden/Universal Render Pipeline/Editor/Trackball"
|
||||
{
|
||||
CGINCLUDE
|
||||
|
||||
#pragma editor_sync_compilation
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
#define PI 3.14159265359
|
||||
#define PI2 6.28318530718
|
||||
|
||||
float _Offset;
|
||||
float _DisabledState;
|
||||
float2 _Resolution; // x: size, y: size / 2
|
||||
|
||||
float3 HsvToRgb(float3 c)
|
||||
{
|
||||
float4 K = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
float3 p = abs(frac(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * lerp(K.xxx, saturate(p - K.xxx), c.y);
|
||||
}
|
||||
|
||||
float4 CreateWheel(v2f_img i, float crossColor, float offsetColor)
|
||||
{
|
||||
const float kHueOuterRadius = 0.45;
|
||||
const float kHueInnerRadius = 0.38;
|
||||
const float kLumOuterRadius = 0.495;
|
||||
const float kLumInnerRadius = 0.48;
|
||||
|
||||
float4 color = (0.0).xxxx;
|
||||
float2 uvc = i.uv - (0.5).xx;
|
||||
float dist = sqrt(dot(uvc, uvc));
|
||||
float delta = fwidth(dist);
|
||||
float angle = atan2(uvc.x, uvc.y);
|
||||
|
||||
// Cross
|
||||
{
|
||||
float radius = (0.5 - kHueInnerRadius) * _Resolution.x + 1.0;
|
||||
float2 pixel = (_Resolution.xx - 1.0) * i.uv + 1.0;
|
||||
|
||||
float vline = step(floor(fmod(pixel.x, _Resolution.y)), 0.0);
|
||||
vline *= step(radius, pixel.y) * step(pixel.y, _Resolution.x - radius);
|
||||
|
||||
float hline = step(floor(fmod(pixel.y, _Resolution.y)), 0.0);
|
||||
hline *= step(radius, pixel.x) * step(pixel.x, _Resolution.x - radius);
|
||||
|
||||
color += hline.xxxx * (1.0).xxxx;
|
||||
color += vline.xxxx * (1.0).xxxx;
|
||||
color = saturate(color);
|
||||
color *= half4((crossColor).xxx, 0.05);
|
||||
}
|
||||
|
||||
// Hue
|
||||
{
|
||||
float alphaOut = smoothstep(kHueOuterRadius - delta, kHueOuterRadius + delta, dist);
|
||||
float alphaIn = smoothstep(kHueInnerRadius - delta, kHueInnerRadius + delta, dist);
|
||||
|
||||
float hue = angle;
|
||||
hue = 1.0 - ((hue > 0.0) ? hue : PI2 + hue) / PI2;
|
||||
float4 c = float4(HsvToRgb(float3(hue, 1.0, 1.0)), 1.0);
|
||||
color += lerp((0.0).xxxx, c, alphaIn - alphaOut);
|
||||
}
|
||||
|
||||
// Offset
|
||||
{
|
||||
float alphaOut = smoothstep(kLumOuterRadius - delta, kLumOuterRadius + delta, dist);
|
||||
float alphaIn = smoothstep(kLumInnerRadius - delta, kLumInnerRadius + delta / 2, dist);
|
||||
float4 c = float4((offsetColor).xxx, 1.0);
|
||||
|
||||
float a = PI * _Offset;
|
||||
if (_Offset >= 0 && angle < a && angle > 0.0)
|
||||
c = float4((1.0).xxx, 0.5);
|
||||
else if (angle > a && angle < 0.0)
|
||||
c = float4((1.0).xxx, 0.5);
|
||||
|
||||
color += lerp((0.0).xxxx, c, alphaIn - alphaOut);
|
||||
}
|
||||
|
||||
color = color * _DisabledState;
|
||||
|
||||
#if !UNITY_COLORSPACE_GAMMA
|
||||
color = half4(GammaToLinearSpace(color.xyz), color.w);
|
||||
#endif
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
float4 FragTrackballDark(v2f_img i) : SV_Target
|
||||
{
|
||||
return CreateWheel(i, 1.0, 0.15);
|
||||
}
|
||||
|
||||
float4 FragTrackballLight(v2f_img i) : SV_Target
|
||||
{
|
||||
return CreateWheel(i, 0.0, 0.3);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
|
||||
SubShader
|
||||
{
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
|
||||
// (0) Dark skin
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment FragTrackballDark
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// (1) Light skin
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment FragTrackballLight
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user