Shader "ACP/watter"
{
Properties
{
_watercolor("水颜色", Color) = (0,0.8714788,0.9433962,0.627451)
_smoothness("平滑度", Float) = 0
_Metallic("金属度", Float) = 0
_bianyuanSpeed("荡漾速度", Float) = 0.5
_Opacity("透明度", Float) = 0
_BianyuanWidth("边缘宽度", Float) = 33
_bianyuanLiangdu("波纹亮度", Float) = 2.8
_shenchucolor("深度控制", Float) = -33
_Vector7("平铺", Vector) = (1,1,0,0)
_Texture1("波纹贴图", 2D) = "white" {}
_Texture0("法线贴图", 2D) = "white" {}
[HideInInspector] _texcoord( "", 2D ) = "white" {}
[HideInInspector] __dirty( "", Int ) = 1
}
SubShader
{
Tags{ "RenderType" = "Transparent" "Queue" = "Transparent+0" "IgnoreProjector" = "True" "IsEmissive" = "true" }
Cull Back
CGINCLUDE
#include "UnityShaderVariables.cginc"
#include "UnityCG.cginc"
#include "UnityPBSLighting.cginc"
#include "Lighting.cginc"
#pragma target 3.0
struct Input
{
float2 uv_texcoord;
float4 screenPos;
float3 worldPos;
};
uniform sampler2D _Texture0;
uniform float _bianyuanSpeed;
uniform float2 _Vector7;
UNITY_DECLARE_DEPTH_TEXTURE( _CameraDepthTexture );
uniform float4 _CameraDepthTexture_TexelSize;
uniform float _shenchucolor;
uniform float4 _watercolor;
uniform float _BianyuanWidth;
uniform sampler2D _Texture1;
uniform float _bianyuanLiangdu;
uniform float _Metallic;
uniform float _smoothness;
uniform float _Opacity;
void surf( Input i , inout SurfaceOutputStandard o )
{
float temp_output_23_0 = ( _Time.y * _bianyuanSpeed );
float2 _Vector3 = float2(0.5,0.5);
float2 uv_TexCoord27 = i.uv_texcoord * _Vector7;
float2 panner28 = ( temp_output_23_0 * _Vector3 + uv_TexCoord27);
float2 panner29 = ( temp_output_23_0 * ( _Vector3 * -1.0 ) + uv_TexCoord27);
o.Normal = ( ( tex2D( _Texture0, panner28 ) + tex2D( _Texture0, panner29 ) ) / 2.0 ).rgb;
float4 ase_screenPos = float4( i.screenPos.xyz , i.screenPos.w + 0.00000000001 );
float4 ase_screenPosNorm = ase_screenPos / ase_screenPos.w;
ase_screenPosNorm.z = ( UNITY_NEAR_CLIP_VALUE >= 0 ) ? ase_screenPosNorm.z : ase_screenPosNorm.z * 0.5 + 0.5;
float screenDepth60 = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE( _CameraDepthTexture, ase_screenPosNorm.xy ));
float distanceDepth60 = abs( ( screenDepth60 - LinearEyeDepth( ase_screenPosNorm.z ) ) / ( _shenchucolor ) );
o.Albedo = ( saturate( distanceDepth60 ) * _watercolor ).rgb;
float screenDepth45 = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE( _CameraDepthTexture, ase_screenPosNorm.xy ));
float distanceDepth45 = abs( ( screenDepth45 - LinearEyeDepth( ase_screenPosNorm.z ) ) / ( _BianyuanWidth ) );
float3 ase_worldPos = i.worldPos;
#if defined(LIGHTMAP_ON) && UNITY_VERSION < 560 //aseld
float3 ase_worldlightDir = 0;
#else //aseld
float3 ase_worldlightDir = normalize( UnityWorldSpaceLightDir( ase_worldPos ) );
#endif //aseld
o.Emission = ( saturate( ( 1.0 - distanceDepth45 ) ) * ( ( tex2D( _Texture1, panner28 ) + tex2D( _Texture1, panner29 ) ) / _bianyuanLiangdu ) * ase_worldlightDir.y ).rgb;
o.Metallic = _Metallic;
o.Smoothness = _smoothness;
o.Alpha = _Opacity;
}
ENDCG
CGPROGRAM
#pragma surface surf Standard alpha:fade keepalpha fullforwardshadows
ENDCG
Pass
{
Name "ShadowCaster"
Tags{ "LightMode" = "ShadowCaster" }
ZWrite On
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 3.0
#pragma multi_compile_shadowcaster
#pragma multi_compile UNITY_PASS_SHADOWCASTER
#pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
#include "HLSLSupport.cginc"
#if ( SHADER_API_D3D11 || SHADER_API_GLCORE || SHADER_API_GLES || SHADER_API_GLES3 || SHADER_API_METAL || SHADER_API_VULKAN )
#define CAN_SKIP_VPOS
#endif
#include "UnityCG.cginc"
#include "Lighting.cginc"
#include "UnityPBSLighting.cginc"
sampler3D _DitherMaskLOD;
struct v2f
{
V2F_SHADOW_CASTER;
float2 customPack1 : TEXCOORD1;
float3 worldPos : TEXCOORD2;
float4 screenPos : TEXCOORD3;
float4 tSpace0 : TEXCOORD4;
float4 tSpace1 : TEXCOORD5;
float4 tSpace2 : TEXCOORD6;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert( appdata_full v )
{
v2f o;
UNITY_SETUP_INSTANCE_ID( v );
UNITY_INITIALIZE_OUTPUT( v2f, o );
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o );
UNITY_TRANSFER_INSTANCE_ID( v, o );
Input customInputData;
float3 worldPos = mul( unity_ObjectToWorld, v.vertex ).xyz;
half3 worldNormal = UnityObjectToWorldNormal( v.normal );
half3 worldTangent = UnityObjectToWorldDir( v.tangent.xyz );
half tangentSign = v.tangent.w * unity_WorldTransformParams.w;
half3 worldBinormal = cross( worldNormal, worldTangent ) * tangentSign;
o.tSpace0 = float4( worldTangent.x, worldBinormal.x, worldNormal.x, worldPos.x );
o.tSpace1 = float4( worldTangent.y, worldBinormal.y, worldNormal.y, worldPos.y );
o.tSpace2 = float4( worldTangent.z, worldBinormal.z, worldNormal.z, worldPos.z );
o.customPack1.xy = customInputData.uv_texcoord;
o.customPack1.xy = v.texcoord;
o.worldPos = worldPos;
TRANSFER_SHADOW_CASTER_NORMALOFFSET( o )
o.screenPos = ComputeScreenPos( o.pos );
return o;
}
half4 frag( v2f IN
#if !defined( CAN_SKIP_VPOS )
, UNITY_VPOS_TYPE vpos : VPOS
#endif
) : SV_Target
{
UNITY_SETUP_INSTANCE_ID( IN );
Input surfIN;
UNITY_INITIALIZE_OUTPUT( Input, surfIN );
surfIN.uv_texcoord = IN.customPack1.xy;
float3 worldPos = IN.worldPos;
half3 worldViewDir = normalize( UnityWorldSpaceViewDir( worldPos ) );
surfIN.worldPos = worldPos;
surfIN.screenPos = IN.screenPos;
SurfaceOutputStandard o;
UNITY_INITIALIZE_OUTPUT( SurfaceOutputStandard, o )
surf( surfIN, o );
#if defined( CAN_SKIP_VPOS )
float2 vpos = IN.pos;
#endif
half alphaRef = tex3D( _DitherMaskLOD, float3( vpos.xy * 0.25, o.Alpha * 0.9375 ) ).a;
clip( alphaRef - 0.01 );
SHADOW_CASTER_FRAGMENT( IN )
}
ENDCG
}
}
Fallback "Diffuse"
CustomEditor "ASEMaterialInspector"
}
Unity水shader
于 2023-01-09 07:35:54 首次发布