This commit is contained in:
CortexCore
2024-11-16 16:00:16 +08:00
parent 99cf181bbe
commit 99253854e8
284 changed files with 112566 additions and 21 deletions

View File

@@ -0,0 +1,37 @@
Shader "Unlit/FaceOrientation"
{
Properties
{
_ColorFront ("Front Color", Color) = (1,0.7,0.7,1)
_ColorBack ("Back Color", Color) = (0.7,1,0.7,1)
}
SubShader
{
Pass
{
Cull Off // 裏向きのカリングをオフにします
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 3.0
float4 vert (float4 vertex : POSITION) : SV_POSITION
{
return UnityObjectToClipPos(vertex);
}
fixed4 _ColorFront;
fixed4 _ColorBack;
fixed4 frag (fixed facing : VFACE) : SV_Target
{
// VFACE 入力は正面向きでは負の値、
// 裏向きでは負の値です。その値によって
// 2 色のうちの 1 つを出力します。
return facing > 0 ? _ColorFront : _ColorBack;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,45 @@
Shader "Hidden/UnityChan/MirrorReflection"
{
Properties
{
_MainTex ("Base (RGB)", 2D) = "white" {}
[HideInInspector] _ReflectionTex ("", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct v2f
{
float2 uv : TEXCOORD0;
float4 refl : TEXCOORD1;
float4 pos : SV_POSITION;
};
float4 _MainTex_ST;
v2f vert(float4 pos : POSITION, float2 uv : TEXCOORD0)
{
v2f o;
o.pos = UnityObjectToClipPos (pos);
o.uv = TRANSFORM_TEX(uv, _MainTex);
o.refl = ComputeScreenPos (o.pos);
return o;
}
sampler2D _MainTex;
sampler2D _ReflectionTex;
fixed4 frag(v2f i) : SV_Target
{
fixed4 wcoord = (i.refl.xyzw/i.refl.w);
fixed4 tex = tex2D(_MainTex, i.uv);
fixed4 refl = tex2Dproj(_ReflectionTex, UNITY_PROJ_COORD(wcoord));
return tex * refl;
}
ENDCG
}
}
}