|
Shader "nekomimiStudio/nekomimiDisplayShader" //VERSION 1.0, 2021-09-28 14:40 |
|
{ |
|
Properties |
|
{ |
|
_Color ("Color", Color) = (1,1,1,1) |
|
[NoScaleOffset] _ColorMask ("ColorMask", 2D) = "white" {} |
|
_MainTex ("Albedo (RGB)", 2D) = "white" {} |
|
[NoScaleOffset] _BumpMap ("Bump Map", 2D) = "bump" {} |
|
[NoScaleOffset] _EmissionMap ("Emission Map", 2D) = "black" {} |
|
[HDR] _EmissionColor ("Emission Color", Color) = (0,0,0) |
|
[NoScaleOffset] _MetallicGlossMap("M/S Map", 2D) = "white" {} |
|
|
|
_LCDRange ("LCD Pos", Vector) = (0,0,0.5,0.5) |
|
[NoScaleOffset] _LCDTex ("LCD Color", 2D) = "black" {} |
|
|
|
[Toggle(_LCDUSEMASK)] _LCDUSEMASK ("Use LCD Mask", Int) = 0 |
|
[NoScaleOffset] _LCDMask ("LCD Mask", 2D) = "black" {} |
|
[ToggleOff] _LCDUseOverlay ("Use LCD Overlay", Int) = 0 |
|
[NoScaleOffset] _LCDOverlay ("LCD Overlay", 2D) = "black" {} |
|
[HDR] _LCDColor ("LCD Brightness", Color) = (1,1,1) |
|
|
|
[Toggle(_LCDISMIRROR)] _LCDISMIRROR ("LCD Flip (isSelfie)", Int) = 0 |
|
|
|
} |
|
SubShader |
|
{ |
|
Tags { "RenderType"="Opaque" } |
|
LOD 200 |
|
|
|
CGPROGRAM |
|
// Physically based Standard lighting model, and enable shadows on all light types |
|
#pragma surface surf Standard fullforwardshadows |
|
|
|
#pragma multi_compile _ _LCDUSEMASK _LCDISMIRROR |
|
|
|
// Use shader model 3.0 target, to get nicer looking lighting |
|
#pragma target 3.0 |
|
|
|
sampler2D _MainTex; |
|
sampler2D _ColorMask; |
|
sampler2D _LCDTex; |
|
sampler2D _LCDMask; |
|
sampler2D _LCDOverlay; |
|
sampler2D _BumpMap; |
|
sampler2D _EmissionMap; |
|
sampler2D _MetallicGlossMap; |
|
|
|
struct Input |
|
{ |
|
float2 uv_MainTex; |
|
}; |
|
|
|
half _Glossiness; |
|
fixed4 _Color; |
|
fixed4 _EmissionColor; |
|
fixed4 _LCDEmissionColor; |
|
fixed4 _LCDColor; |
|
fixed4 _LCDRange; |
|
// int _LCDUseMask; |
|
int _LCDUseOverlay; |
|
// int _LCDisMirror; |
|
|
|
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader. |
|
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing. |
|
// #pragma instancing_options assumeuniformscaling |
|
UNITY_INSTANCING_BUFFER_START(Props) |
|
// put more per-instance properties here |
|
UNITY_INSTANCING_BUFFER_END(Props) |
|
|
|
void surf (Input IN, inout SurfaceOutputStandard o) |
|
{ |
|
// Albedo comes from a texture tinted by color |
|
fixed4 c; |
|
fixed4 e; |
|
fixed4 m = tex2D (_MetallicGlossMap, IN.uv_MainTex); |
|
|
|
float2 uv; //LCD部を0-1にしたUV |
|
uv.x = ((IN.uv_MainTex.x - _LCDRange.x) / (_LCDRange.z - _LCDRange.x)); |
|
uv.y = ((IN.uv_MainTex.y - _LCDRange.y) / (_LCDRange.w - _LCDRange.y)); |
|
|
|
_Color.rgb = _Color.rgb + ((1 - tex2D (_ColorMask, IN.uv_MainTex).a) * (1 - _Color.rgb)); |
|
|
|
fixed4 Color_Main = tex2D (_MainTex, IN.uv_MainTex) * _Color; |
|
fixed4 Color_Emission = tex2D (_EmissionMap, IN.uv_MainTex) * _EmissionColor; |
|
float4 Color_Overlay = tex2D (_LCDOverlay, uv) * _LCDColor; |
|
|
|
#ifdef _LCDISMIRROR |
|
//LCD左右反転 オーバーレイは反転させないので、この(変な)タイミングになる |
|
uv.x = ((IN.uv_MainTex.x - _LCDRange.z) / (_LCDRange.x - _LCDRange.z)); |
|
#endif |
|
|
|
fixed4 Color_LCD = tex2D (_LCDTex, uv) * _LCDColor; |
|
|
|
// オーバーレイが無効ならAlphaを0にしてしまう そうでないならオーバーレイ画像のAlphaを使って混ぜる |
|
float OverlayAlpha = Color_Overlay.a * _LCDUseOverlay; |
|
|
|
#ifdef _LCDUSEMASK |
|
// if (_LCDUseMask) { // マスク使う |
|
float Mask_LCDMask = tex2D (_LCDMask, IN.uv_MainTex).a; |
|
c = (Color_Main * (1 - Mask_LCDMask)) |
|
+ (Color_LCD * (1 - OverlayAlpha) + Color_Overlay * (OverlayAlpha)) * Mask_LCDMask; |
|
e = (Color_Emission * (1 - Mask_LCDMask)) |
|
+ (Color_LCD * (1 - OverlayAlpha) + Color_Overlay * (OverlayAlpha)) * Mask_LCDMask; |
|
#else |
|
// } else { // マスク使わない |
|
if (( _LCDRange.x <= IN.uv_MainTex.x && IN.uv_MainTex.x <= _LCDRange.z) && (_LCDRange.y <= IN.uv_MainTex.y && IN.uv_MainTex.y <= _LCDRange.w)){ |
|
c = Color_LCD * (1 - OverlayAlpha) + Color_Overlay * (OverlayAlpha); |
|
e = Color_LCD * (1 - OverlayAlpha) + Color_Overlay * (OverlayAlpha); |
|
} else { |
|
c = Color_Main; |
|
e = Color_Emission; |
|
} |
|
// } |
|
#endif |
|
|
|
o.Albedo = c.rgb; |
|
o.Emission = e.rgb; |
|
o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_MainTex)); |
|
o.Smoothness = m.a; |
|
o.Metallic = m.r; |
|
// o.Alpha = c.a; |
|
} |
|
ENDCG |
|
} |
|
FallBack "Diffuse" |
|
} |