Files
Assets
BuiltinAssets
Material
Shader
DefaultResources
DefaultResourcesExtra
Cubemaps
GIDebug
Mobile
Nature
TerrainShaders
UI
UI-Default.shader
UI-Default.shader.meta
UI-DefaultETC1.shader
UI-DefaultETC1.shader.meta
UI-DefaultFont.shader
UI-DefaultFont.shader.meta
UI-Lit-Bumped.shader
UI-Lit-Bumped.shader.meta
UI-Lit-Detail.shader
UI-Lit-Detail.shader.meta
UI-Lit-Refraction.shader
UI-Lit-Refraction.shader.meta
UI-Lit-RefractionDetail.shader
UI-Lit-RefractionDetail.shader.meta
UI-Lit-Transparent.shader
UI-Lit-Transparent.shader.meta
UI-Unlit-Detail.shader
UI-Unlit-Detail.shader.meta
UI-Unlit-Text.shader
UI-Unlit-Text.shader.meta
UI-Unlit-TextDetail.shader
UI-Unlit-TextDetail.shader.meta
UI-Unlit-Transparent.shader
UI-Unlit-Transparent.shader.meta
Unlit
Alpha-BumpSpec.shader
Alpha-BumpSpec.shader.meta
Alpha-Bumped.shader
Alpha-Bumped.shader.meta
Alpha-Diffuse.shader
Alpha-Diffuse.shader.meta
Alpha-Glossy.shader
Alpha-Glossy.shader.meta
Alpha-Parallax.shader
Alpha-Parallax.shader.meta
Alpha-ParallaxSpec.shader
Alpha-ParallaxSpec.shader.meta
Alpha-VertexLit.shader
Alpha-VertexLit.shader.meta
AlphaTest-BumpSpec.shader
AlphaTest-BumpSpec.shader.meta
AlphaTest-Bumped.shader
AlphaTest-Bumped.shader.meta
AlphaTest-Diffuse.shader
AlphaTest-Diffuse.shader.meta
AlphaTest-Glossy.shader
AlphaTest-Glossy.shader.meta
AlphaTest-SoftEdgeUnlit.shader
AlphaTest-SoftEdgeUnlit.shader.meta
AlphaTest-VertexLit.shader
AlphaTest-VertexLit.shader.meta
Cubemaps.meta
Decal.shader
Decal.shader.meta
Flare.shader
Flare.shader.meta
GIDebug.meta
Illumin-BumpSpec.shader
Illumin-BumpSpec.shader.meta
Illumin-Bumped.shader
Illumin-Bumped.shader.meta
Illumin-Diffuse.shader
Illumin-Diffuse.shader.meta
Illumin-Glossy.shader
Illumin-Glossy.shader.meta
Illumin-Parallax.shader
Illumin-Parallax.shader.meta
Illumin-ParallaxSpec.shader
Illumin-ParallaxSpec.shader.meta
Illumin-VertexLit.shader
Illumin-VertexLit.shader.meta
Internal-BlitCopy.shader
Internal-BlitCopy.shader.meta
Internal-CombineDepthNormals.shader
Internal-CombineDepthNormals.shader.meta
Internal-DeferredReflections.shader
Internal-DeferredReflections.shader.meta
Internal-DeferredShading.shader
Internal-DeferredShading.shader.meta
Internal-DepthNormalsTexture.shader
Internal-DepthNormalsTexture.shader.meta
Internal-Flare.shader
Internal-Flare.shader.meta
Internal-GUITexture.shader
Internal-GUITexture.shader.meta
Internal-GUITextureBlit.shader
Internal-GUITextureBlit.shader.meta
Internal-GUITextureClip.shader
Internal-GUITextureClip.shader.meta
Internal-GUITextureClipText.shader
Internal-GUITextureClipText.shader.meta
Internal-Halo.shader
Internal-Halo.shader.meta
Internal-MotionVectors.shader
Internal-MotionVectors.shader.meta
Internal-PrePassLighting.shader
Internal-PrePassLighting.shader.meta
Internal-ScreenSpaceShadows.shader
Internal-ScreenSpaceShadows.shader.meta
Internal-StencilWrite.shader
Internal-StencilWrite.shader.meta
Lightmap-BumpSpec.shader
Lightmap-BumpSpec.shader.meta
Lightmap-Bumped.shader
Lightmap-Bumped.shader.meta
Lightmap-Diffuse.shader
Lightmap-Diffuse.shader.meta
Lightmap-Glossy.shader
Lightmap-Glossy.shader.meta
Lightmap-VertexLit.shader
Lightmap-VertexLit.shader.meta
Mobile.meta
Nature.meta
Normal-BumpSpec.shader
Normal-BumpSpec.shader.meta
Normal-Bumped.shader
Normal-Bumped.shader.meta
Normal-Diffuse.shader
Normal-Diffuse.shader.meta
Normal-DiffuseDetail.shader
Normal-DiffuseDetail.shader.meta
Normal-DiffuseFast.shader
Normal-DiffuseFast.shader.meta
Normal-Glossy.shader
Normal-Glossy.shader.meta
Normal-Parallax.shader
Normal-Parallax.shader.meta
Normal-ParallaxSpec.shader
Normal-ParallaxSpec.shader.meta
Normal-VertexLit.shader
Normal-VertexLit.shader.meta
Particle Add.shader
Particle Add.shader.meta
Particle AddMultiply.shader
Particle AddMultiply.shader.meta
Particle AddSmooth.shader
Particle AddSmooth.shader.meta
Particle Alpha Blend.shader
Particle Alpha Blend.shader.meta
Particle Blend.shader
Particle Blend.shader.meta
Particle Multiply.shader
Particle Multiply.shader.meta
Particle MultiplyDouble.shader
Particle MultiplyDouble.shader.meta
Particle Premultiply Blend.shader
Particle Premultiply Blend.shader.meta
Particle VertexLit Blended.shader
Particle VertexLit Blended.shader.meta
Reflect-BumpNolight.shader
Reflect-BumpNolight.shader.meta
Reflect-BumpSpec.shader
Reflect-BumpSpec.shader.meta
Reflect-BumpVertexLit.shader
Reflect-BumpVertexLit.shader.meta
Reflect-Bumped.shader
Reflect-Bumped.shader.meta
Reflect-Diffuse.shader
Reflect-Diffuse.shader.meta
Reflect-Glossy.shader
Reflect-Glossy.shader.meta
Reflect-Parallax.shader
Reflect-Parallax.shader.meta
Reflect-ParallaxSpec.shader
Reflect-ParallaxSpec.shader.meta
Reflect-VertexLit.shader
Reflect-VertexLit.shader.meta
Skybox-Cubed.shader
Skybox-Cubed.shader.meta
Skybox-Procedural.shader
Skybox-Procedural.shader.meta
Skybox.shader
Skybox.shader.meta
Sprites-Default.shader
Sprites-Default.shader.meta
Sprites-Diffuse.shader
Sprites-Diffuse.shader.meta
Standard.shader
Standard.shader.meta
StandardSpecular.shader
StandardSpecular.shader.meta
TerrainShaders.meta
UI.meta
Unlit.meta
DefaultResources.meta
DefaultResourcesExtra.meta
Texture
Material.meta
Shader.meta
Texture.meta
config.txt
config.txt.meta
CSAssets
Editor
Gizmos
Plugins
Project
Project3D
Res_newMS
StreamingAssets
T4M
T4MOBJ
UnusedAssets
XLua
BuiltinAssets.meta
CSAssets.meta
Editor.meta
Gizmos.meta
Plugins.meta
Project.meta
Project3D.meta
Res_newMS.meta
StreamingAssets.meta
T4M.meta
T4MOBJ.meta
UnusedAssets.meta
XLua.meta
ChannelConfig
ExcelC#
ExcelExport
ExcelTexts
JjbbDll
ProjectSettings
Sdk
UnityPackageManager
UnusedAssets
.gitignore
README.md
JJBB/Assets/BuiltinAssets/Shader/DefaultResourcesExtra/UI/UI-Lit-RefractionDetail.shader
2024-08-23 15:49:34 +08:00

199 lines
5.2 KiB
Plaintext

Shader "UI/Lit/Refraction Detail"
{
Properties
{
_Color ("Main Color", Color) = (1,1,1,1)
_Specular ("Specular Color", Color) = (0,0,0,0)
_MainTex ("Diffuse (RGB), Alpha (A)", 2D) = "white" {}
_MainBump ("Diffuse Bump Map", 2D) = "bump" {}
_Mask ("Mask (Specularity, Shininess, Refraction)", 2D) = "white" {}
_DetailTex ("Detail (RGB)", 2D) = "white" {}
_DetailBump ("Detail Bump Map", 2D) = "bump" {}
_DetailMask ("Detail Mask (Spec, Shin, Ref)", 2D) = "white" {}
_Shininess ("Shininess", Range(0.01, 1.0)) = 0.2
_Focus ("Focus", Range(-100.0, 100.0)) = -100.0
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
_StencilWriteMask ("Stencil Write Mask", Float) = 255
_StencilReadMask ("Stencil Read Mask", Float) = 255
_ColorMask ("Color Mask", Float) = 15
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
}
// SM 3.0
SubShader
{
LOD 400
GrabPass
{
Name "BASE"
Tags { "LightMode" = "Always" }
}
Tags
{
"Queue" = "Transparent"
"IgnoreProjector" = "True"
"RenderType" = "Transparent"
"PreviewType"="Plane"
}
Stencil
{
Ref [_Stencil]
Comp [_StencilComp]
Pass [_StencilOp]
ReadMask [_StencilReadMask]
WriteMask [_StencilWriteMask]
}
Cull Off
Lighting Off
ZWrite Off
ZTest [unity_GUIZTestMode]
Blend SrcAlpha OneMinusSrcAlpha
ColorMask [_ColorMask]
CGPROGRAM
#pragma target 3.0
#pragma surface surf PPL alpha noshadow novertexlights nolightmap vertex:vert nofog
#include "UnityCG.cginc"
#include "UnityUI.cginc"
#pragma multi_compile __ UNITY_UI_ALPHACLIP
struct appdata_t
{
float4 vertex : POSITION;
float2 texcoord1 : TEXCOORD0;
float2 texcoord2 : TEXCOORD1;
fixed4 color : COLOR;
float3 normal : NORMAL;
float4 tangent : TANGENT;
};
struct Input
{
float4 texcoord1;
float4 texcoord2;
float2 texcoord3;
float4 proj;
fixed4 color : COLOR;
float4 worldPosition;
};
sampler2D _GrabTexture;
sampler2D _MainTex;
sampler2D _MainBump;
sampler2D _Mask;
sampler2D _DetailTex;
sampler2D _DetailBump;
sampler2D _DetailMask;
float4 _MainTex_ST;
float4 _MainBump_ST;
float4 _Mask_ST;
float4 _DetailTex_ST;
float4 _DetailBump_ST;
float4 _DetailMask_ST;
float4 _DetailTex_TexelSize;
float4 _DetailBump_TexelSize;
float4 _DetailMask_TexelSize;
half4 _GrabTexture_TexelSize;
fixed4 _Color;
fixed4 _Specular;
half _Shininess;
half _Focus;
fixed4 _TextureSampleAdd;
float4 _ClipRect;
void vert (inout appdata_t v, out Input o)
{
UNITY_INITIALIZE_OUTPUT(Input, o);
o.worldPosition = v.vertex;
v.vertex = o.worldPosition;
v.color = v.color * _Color;
o.texcoord1.xy = TRANSFORM_TEX(v.texcoord1, _MainTex);
o.texcoord1.zw = TRANSFORM_TEX(v.texcoord1, _MainBump);
o.texcoord2.xy = TRANSFORM_TEX(v.texcoord2 * _DetailTex_TexelSize.xy, _DetailTex);
o.texcoord2.zw = TRANSFORM_TEX(v.texcoord2 * _DetailBump_TexelSize.xy, _DetailBump);
o.texcoord3 = TRANSFORM_TEX(v.texcoord2 * _DetailMask_TexelSize.xy, _DetailMask);
#if UNITY_UV_STARTS_AT_TOP
o.proj.xy = (float2(v.vertex.x, -v.vertex.y) + v.vertex.w) * 0.5;
#else
o.proj.xy = (float2(v.vertex.x, v.vertex.y) + v.vertex.w) * 0.5;
#endif
o.proj.zw = v.vertex.zw;
}
void surf (Input IN, inout SurfaceOutput o)
{
fixed4 col = tex2D(_MainTex, IN.texcoord1.xy) + _TextureSampleAdd;
fixed4 detail = tex2D(_DetailTex, IN.texcoord2.xy);
half3 normal = UnpackNormal(tex2D(_MainBump, IN.texcoord1.zw)) +
UnpackNormal(tex2D(_DetailBump, IN.texcoord2.zw));
half3 mask = tex2D(_Mask, IN.texcoord1.xy) *
tex2D(_DetailMask, IN.texcoord3);
float2 offset = normal.xy * _GrabTexture_TexelSize.xy * _Focus;
IN.proj.xy = offset * IN.proj.z + IN.proj.xy;
half4 ref = tex2Dproj( _GrabTexture, UNITY_PROJ_COORD(IN.proj));
col.rgb = lerp(col.rgb, ref.rgb, mask.b);
col.rgb = lerp(col.rgb, col.rgb * detail.rgb, detail.a);
col *= IN.color;
o.Albedo = col.rgb;
o.Normal = normalize(normal);
o.Specular = _Specular.a * mask.r;
o.Gloss = _Shininess * mask.g;
o.Alpha = col.a;
o.Alpha *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
#ifdef UNITY_UI_ALPHACLIP
clip (o.Alpha - 0.001);
#endif
}
half4 LightingPPL (SurfaceOutput s, half3 lightDir, half3 viewDir, half atten)
{
half3 nNormal = normalize(s.Normal);
half shininess = s.Gloss * 250.0 + 4.0;
#ifndef USING_DIRECTIONAL_LIGHT
lightDir = normalize(lightDir);
#endif
// Phong shading model
half reflectiveFactor = max(0.0, dot(-viewDir, reflect(lightDir, nNormal)));
// Blinn-Phong shading model
//half reflectiveFactor = max(0.0, dot(nNormal, normalize(lightDir + viewDir)));
half diffuseFactor = max(0.0, dot(nNormal, lightDir));
half specularFactor = pow(reflectiveFactor, shininess) * s.Specular;
half4 c;
c.rgb = (s.Albedo * diffuseFactor + _Specular.rgb * specularFactor) * _LightColor0.rgb;
c.rgb *= atten;
c.a = s.Alpha;
return c;
}
ENDCG
}
Fallback "UI/Lit/Detail"
}