Skip to content

Instantly share code, notes, and snippets.

@27Cobalter
Last active October 27, 2022 04:22
Show Gist options
  • Save 27Cobalter/36f0b92b1490363160c3c1ff34f3b931 to your computer and use it in GitHub Desktop.
Save 27Cobalter/36f0b92b1490363160c3c1ff34f3b931 to your computer and use it in GitHub Desktop.
KawaiiCameraをカメラで映らなくするシェーダ+最前面表示
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
// Unlit alpha-blended shader.
// - no lighting
// - no lightmap support
// - no per-material color
Shader "Custom/Unlit_Alpha_Trans_hide" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 100
ZWrite Off
ZTest Always
Blend SrcAlpha OneMinusSrcAlpha
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
half2 texcoord : TEXCOORD0;
UNITY_FOG_COORDS(1)
};
sampler2D _MainTex;
float4 _MainTex_ST;
fixed4 _Color;
v2f vert (appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
UNITY_TRANSFER_FOG(o,o.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = (
// 4Kカメラ
(_ScreenParams.x==3840&&_ScreenParams.y==2160) ||
// 2Kカメラ
(_ScreenParams.x==1920&&_ScreenParams.y==1080) ||
// PostBlurLens視界ジャックテクスチャ(4K)
(_ScreenParams.x==4096&&_ScreenParams.y==2304) ||
// PostBlurLens視界ジャックテクスチャ(2K)
(_ScreenParams.x==2048&&_ScreenParams.y==1152) ||
// PostBlurLensゲーム内プレビュー
(_ScreenParams.x==256&&_ScreenParams.y==256) ||
// SilentClubミラー
(_ScreenParams.x==1024&&_ScreenParams.y==512) ||
// ゲーム内カメラプレビュー
(_ScreenParams.x==1280&&_ScreenParams.y==720)
)
? 0 : tex2D(_MainTex, i.texcoord) * _Color;
UNITY_APPLY_FOG(i.fogCoord, col);
return col;
}
ENDCG
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment