Flatkit 추가 및 설정

This commit is contained in:
2026-01-25 11:27:33 +09:00
parent 05233497e7
commit cf16910a32
1938 changed files with 408633 additions and 244 deletions

View File

@@ -0,0 +1,74 @@
Shader "Hidden/FlatKit/CopyTexture"
{
SubShader
{
Tags { "RenderType"="Opaque" "RenderPipeline" = "UniversalPipeline"}
LOD 100
ZWrite Off Cull Off
Pass
{
Name "Custom Copy Texture"
HLSLPROGRAM
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#pragma multi_compile _ _USE_DRAW_PROCEDURAL
float4 _SourceSize;
TEXTURE2D_X(_EffectTexture);
SAMPLER(sampler_EffectTexture);
float4 SampleEffectTexture(float2 uv)
{
return SAMPLE_TEXTURE2D_X(_EffectTexture, sampler_EffectTexture, UnityStereoTransformScreenSpaceTex(uv));
}
struct Attributes
{
float4 positionHCS : POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct Varyings
{
float4 positionCS : SV_POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_OUTPUT_STEREO
};
Varyings vert(Attributes input)
{
Varyings output;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
#if _USE_DRAW_PROCEDURAL
output.positionCS = float4(input.positionHCS.xyz, 1.0);
#if UNITY_UV_STARTS_AT_TOP
output.positionCS.y *= -1;
#endif
#else
output.positionCS = TransformObjectToHClip(input.positionHCS.xyz);
#endif
output.uv = input.uv;
return output;
}
half4 frag(Varyings input) : SV_Target
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
float4 c = SampleEffectTexture(input.uv);
return c;
}
#pragma vertex vert
#pragma fragment frag
ENDHLSL
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: e05a9f4f2755f3941a86a256f16c0d82
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,179 @@
Shader "Hidden/FlatKit/FogFilter"
{
Properties
{
[Toggle(USE_DISTANCE_FOG)]_UseDistanceFog ("Use Distance", Float) = 0
[Toggle(USE_DISTANCE_FOG_ON_SKY)]_UseDistanceFogOnSky ("Use Distance Fog On Sky", Float) = 0
[Space]
_Near ("Near", Float) = 0
_Far ("Far", Float) = 100
[Space]
_DistanceFogIntensity ("Distance Fog Intensity", Range(0, 1)) = 1
[Space(25)]
[Toggle(USE_HEGHT_FOG)]_UseHeightFog ("Use Height", Float) = 0
[Toggle(USE_HEGHT_FOG_ON_SKY)]_UseHeightFogOnSky ("Use Height Fog On Sky", Float) = 0
[Space]
_LowWorldY ("Low", Float) = 0
_HighWorldY ("High", Float) = 10
[Space]
_HeightFogIntensity ("Height Fog Intensity", Range(0, 1)) = 1
[Space(25)]
_DistanceHeightBlend ("Distance / Height blend", Range(0, 1)) = 0.5
}
SubShader
{
Tags
{
"RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline"
}
LOD 100
ZWrite Off Cull Off
Pass
{
Name "Fog"
HLSLPROGRAM
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareNormalsTexture.hlsl"
#pragma multi_compile _ _USE_DRAW_PROCEDURAL
sampler2D _DistanceLUT;
float _Near;
float _Far;
half _UseDistanceFog;
half _UseDistanceFogOnSky;
sampler2D _HeightLUT;
float _LowWorldY;
float _HighWorldY;
half _UseHeightFog;
half _UseHeightFogOnSky;
float _DistanceFogIntensity;
float _HeightFogIntensity;
float _DistanceHeightBlend;
#define ALMOST_ONE 0.999
// Using `_CameraColorTexture` instead of the opaque texture `SampleSceneColor` to handle transparency.
TEXTURE2D_X(_CameraColorTexture);
SAMPLER(sampler_CameraColorTexture);
float4 _CameraColorTexture_TexelSize;
// Z buffer depth to linear 0-1 depth
// Handles orthographic projection correctly
float Linear01Depth(float z)
{
float isOrtho = unity_OrthoParams.w;
float isPers = 1.0 - unity_OrthoParams.w;
z *= _ZBufferParams.x;
return (1.0 - isOrtho * z) / (isPers * z + _ZBufferParams.y);
}
float4 SampleCameraColor(float2 uv)
{
return SAMPLE_TEXTURE2D_X(_CameraColorTexture, sampler_CameraColorTexture, UnityStereoTransformScreenSpaceTex(uv));
}
float LinearEyeDepth(float z)
{
return rcp(_ZBufferParams.z * z + _ZBufferParams.w);
}
float4 Fog(float2 uv, float3 screen_pos)
{
float4 original = SampleCameraColor(uv);
const float depthPacked = SampleSceneDepth(uv);
const float depthEye = LinearEyeDepth(depthPacked);
const float depthCameraPlanes = Linear01Depth(depthPacked);
const float depthAbsolute = _ProjectionParams.y + (_ProjectionParams.z - _ProjectionParams.y) *
depthCameraPlanes;
const float depthFogPlanes = saturate((depthAbsolute - _Near) / (_Far - _Near));
const float isSky = step(ALMOST_ONE, depthCameraPlanes);
float4 distanceFog = tex2D(_DistanceLUT, float2(depthFogPlanes, 0.5));
distanceFog.a *= step(isSky, _UseDistanceFogOnSky);
distanceFog.a *= _UseDistanceFog * _DistanceFogIntensity;
const float3 worldPos = screen_pos * depthEye + _WorldSpaceCameraPos;
const float heightUV = saturate((worldPos.y - _LowWorldY) / (_HighWorldY - _LowWorldY));
float4 heightFog = tex2D(_HeightLUT, float2(heightUV, 0.5));
heightFog.a *= step(isSky, _UseHeightFogOnSky);
heightFog.a *= _UseHeightFog * _HeightFogIntensity;
float fogBlend = _DistanceHeightBlend;
if (!_UseDistanceFog) fogBlend = 1.0;
if (!_UseHeightFog) fogBlend = 0.0;
const float4 fog = lerp(distanceFog, heightFog, fogBlend);
float4 final = lerp(original, fog, fog.a);
final.a = original.a;
return final;
}
struct Attributes
{
float4 positionOS: POSITION;
float2 uv: TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct Varyings
{
float2 uv: TEXCOORD0;
float3 screen_pos: TEXCOORD1;
float4 vertex: SV_POSITION;
UNITY_VERTEX_OUTPUT_STEREO
};
Varyings vert(Attributes input)
{
Varyings output = (Varyings)0;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
#if _USE_DRAW_PROCEDURAL
output.vertex = float4(input.positionOS.xyz, 1.0);
#if UNITY_UV_STARTS_AT_TOP
output.vertex.y *= -1;
#endif
#else
const VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
output.vertex = vertexInput.positionCS;
#endif
output.uv = input.uv;
output.screen_pos = ComputeScreenPos(output.vertex).xyz;
return output;
}
half4 frag(Varyings input): SV_Target
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
float4 c = Fog(input.uv, input.screen_pos);
return c;
}
#pragma vertex vert
#pragma fragment frag
ENDHLSL
}
}
FallBack "Diffuse"
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 6eb928abe872c4fd5a7acead14922715
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,218 @@
Shader "Hidden/FlatKit/OutlineFilter"
{
Properties
{
[HideInInspector]_BaseMap ("Base (RGB)", 2D) = "white" {}
_EdgeColor ("Outline Color", Color) = (1, 1, 1, 1)
_Thickness ("Thickness", Range(0, 5)) = 1
[Space(15)]
[Toggle(OUTLINE_USE_DEPTH)]_UseDepth ("Use Depth", Float) = 1
_DepthThresholdMin ("Min Depth Threshold", Range(0, 1)) = 0
_DepthThresholdMax ("Max Depth Threshold", Range(0, 1)) = 0.25
[Space(15)]
[Toggle(OUTLINE_USE_NORMALS)]_UseNormals ("Use Normals", Float) = 0
_NormalThresholdMin ("Min Normal Threshold", Range(0, 1)) = 0.5
_NormalThresholdMax ("Max Normal Threshold", Range(0, 1)) = 1.0
[Space(15)]
[Toggle(OUTLINE_USE_COLOR)]_UseColor ("Use Color", Float) = 0
_ColorThresholdMin ("Min Color Threshold", Range(0, 1)) = 0
_ColorThresholdMax ("Max Color Threshold", Range(0, 1)) = 0.25
[Space(15)]
[Toggle(OUTLINE_ONLY)]_OutlineOnly ("Outline Only", Float) = 0
}
SubShader
{
Tags { "RenderType"="Opaque" "RenderPipeline" = "UniversalPipeline"}
LOD 100
ZWrite Off Cull Off
Pass
{
Name "Outline"
HLSLPROGRAM
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareNormalsTexture.hlsl"
#pragma shader_feature OUTLINE_USE_DEPTH
#pragma shader_feature OUTLINE_USE_NORMALS
#pragma shader_feature OUTLINE_USE_COLOR
#pragma shader_feature OUTLINE_ONLY
#pragma shader_feature RESOLUTION_INVARIANT_THICKNESS
#pragma multi_compile _ _USE_DRAW_PROCEDURAL
uniform half _Thickness;
uniform half4 _EdgeColor;
uniform half _DepthThresholdMin, _DepthThresholdMax;
uniform half _NormalThresholdMin, _NormalThresholdMax;
uniform half _ColorThresholdMin, _ColorThresholdMax;
TEXTURE2D_X(_CameraColorTexture);
SAMPLER(sampler_CameraColorTexture);
// #define OUTLINE_USE_TRANSPARENT_DEPTH
#ifdef OUTLINE_USE_TRANSPARENT_DEPTH
TEXTURE2D_X(_CameraTransparentDepthTexture);
#endif
float4 _SourceSize;
// Z buffer depth to linear 0-1 depth
// Handles orthographic projection correctly
float Linear01Depth(float z)
{
const float isOrtho = unity_OrthoParams.w;
const float isPers = 1.0 - unity_OrthoParams.w;
z *= _ZBufferParams.x;
return (1.0 - isOrtho * z) / (isPers * z + _ZBufferParams.y);
}
float SampleDepth(float2 uv)
{
float d = SampleSceneDepth(uv);
#ifdef OUTLINE_USE_TRANSPARENT_DEPTH
d += SAMPLE_TEXTURE2D_X(_CameraTransparentDepthTexture, sampler_CameraColorTexture, UnityStereoTransformScreenSpaceTex(uv)).r;
#endif
return Linear01Depth(d);
}
float4 SampleCameraColor(float2 uv)
{
return SAMPLE_TEXTURE2D_X(_CameraColorTexture, sampler_CameraColorTexture, UnityStereoTransformScreenSpaceTex(uv));
}
float4 Outline(float2 uv)
{
float4 original = SampleCameraColor(uv);
const float offset_positive = +ceil(_Thickness * 0.5f);
const float offset_negative = -floor(_Thickness * 0.5f);
#if RESOLUTION_INVARIANT_THICKNESS
const float screen_ratio = _SourceSize.x / _SourceSize.y;
const float2 texel_size = 1.0 / 800.0 * float2(1.0, screen_ratio);
#else
const float2 texel_size = _SourceSize.zw;
#endif
float left = texel_size.x * offset_negative;
float right = texel_size.x * offset_positive;
float top = texel_size.y * offset_negative;
float bottom = texel_size.y * offset_positive;
const float2 uv0 = uv + float2(left, top);
const float2 uv1 = uv + float2(right, bottom);
const float2 uv2 = uv + float2(right, top);
const float2 uv3 = uv + float2(left, bottom);
#ifdef OUTLINE_USE_DEPTH
const float d0 = SampleDepth(uv0);
const float d1 = SampleDepth(uv1);
const float d2 = SampleDepth(uv2);
const float d3 = SampleDepth(uv3);
const float depth_threshold_scale = 300.0f;
float d = length(float2(d1 - d0, d3 - d2)) * depth_threshold_scale;
d = smoothstep(_DepthThresholdMin, _DepthThresholdMax, d);
#else
float d = 0.0f;
#endif // OUTLINE_USE_DEPTH
#ifdef OUTLINE_USE_NORMALS
const float3 n0 = SampleSceneNormals(uv0);
const float3 n1 = SampleSceneNormals(uv1);
const float3 n2 = SampleSceneNormals(uv2);
const float3 n3 = SampleSceneNormals(uv3);
const float3 nd1 = n1 - n0;
const float3 nd2 = n3 - n2;
float n = sqrt(dot(nd1, nd1) + dot(nd2, nd2));
n = smoothstep(_NormalThresholdMin, _NormalThresholdMax, n);
#else
float n = 0.0f;
#endif // OUTLINE_USE_NORMALS
#ifdef OUTLINE_USE_COLOR
const float3 c0 = SampleCameraColor(uv0).rgb;
const float3 c1 = SampleCameraColor(uv1).rgb;
const float3 c2 = SampleCameraColor(uv2).rgb;
const float3 c3 = SampleCameraColor(uv3).rgb;
const float3 cd1 = c1 - c0;
const float3 cd2 = c3 - c2;
float c = sqrt(dot(cd1, cd1) + dot(cd2, cd2));
c = smoothstep(_ColorThresholdMin, _ColorThresholdMax, c);
#else
float c = 0;
#endif // OUTLINE_USE_COLOR
const float g = max(d, max(n, c));
#ifdef OUTLINE_ONLY
original.rgb = lerp(1.0 - _EdgeColor.rgb, _EdgeColor.rgb, g * _EdgeColor.a);
#endif // OUTLINE_ONLY
float4 output;
output.rgb = lerp(original.rgb, _EdgeColor.rgb, g * _EdgeColor.a);
output.a = original.a;
return output;
}
struct Attributes
{
float4 positionHCS : POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct Varyings
{
float4 positionCS : SV_POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_OUTPUT_STEREO
};
Varyings vert(Attributes input)
{
Varyings output;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
#if _USE_DRAW_PROCEDURAL
output.positionCS = float4(input.positionHCS.xyz, 1.0);
#if UNITY_UV_STARTS_AT_TOP
output.positionCS.y *= -1;
#endif
#else
output.positionCS = TransformObjectToHClip(input.positionHCS.xyz);
#endif
output.uv = input.uv;
return output;
}
half4 frag(Varyings input) : SV_Target
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
float4 c = Outline(input.uv);
return c;
}
#pragma vertex vert
#pragma fragment frag
ENDHLSL
}
}
FallBack "Diffuse"
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 2e4419296dd04b32bcc48a56ac645aa9
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1 @@
This folder is used only in Unity 2021 or older.

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 657891af2ead49a2b9cbfd069f5cead2
timeCreated: 1701333515