先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
96 lines
3.3 KiB
Plaintext
96 lines
3.3 KiB
Plaintext
Shader "Custom/FresnelFishAdv"
|
|
{
|
|
Properties
|
|
{
|
|
_fresnelIntensity ("Fresnel", Range(0.0, 5)) = 1.0
|
|
_thresh ("Fresnel Threshold", Range(0.0, 1.0)) = 0
|
|
_colorEdge ("Color Edge", Color) = (1, 1, 1, 1)
|
|
_color ("Color", Color) = (0, 0, 0, 1)
|
|
[NoScaleOffset][SingleLineTexture]_BaseMap("Texture", 2D) = "white" {}
|
|
[NoScaleOffset][SingleLineTexture]_BumpMap("Normal Map", 2D) = "bump" {}
|
|
[NoScaleOffset][SingleLineTexture]_rimtex("Rim Texture", 2D) = "white" {}
|
|
_rimTilling ("Rim Tilling", Vector) = (1,1,5,0)
|
|
_grayScale("GrayScale", Range(0.0, 2.0)) = 2.0
|
|
}
|
|
SubShader
|
|
{
|
|
Tags { "RenderType"="Opaque" "Queue" = "Geometry" }
|
|
//Tags { "RenderType"="Opaque" }
|
|
Pass
|
|
{
|
|
Cull Back
|
|
ZWrite On
|
|
// Blend One One
|
|
|
|
HLSLPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#pragma multi_compile_instancing
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
|
float _fresnelIntensity, _thresh, _grayScale;
|
|
float4 _color, _colorEdge, _rimTilling;
|
|
sampler2D _BumpMap, _BaseMap;
|
|
|
|
sampler2D _rimtex;
|
|
|
|
struct meshData
|
|
{
|
|
float4 vertex : POSITION;
|
|
float2 uv : TEXCOORD0;
|
|
float3 normal : NORMAL;
|
|
float4 tangent : TANGENT;
|
|
};
|
|
|
|
struct v2f
|
|
{
|
|
float4 vertex : SV_POSITION;
|
|
float2 uv : TEXCOORD0;
|
|
float4 tangent : TANGENT;
|
|
|
|
float3 wPos : TEXCOORD1;
|
|
float3 wNor : TEXCOORD2;
|
|
float3 wTan : TEXCOORD3;
|
|
float3 wBitan : TEXCOORD4;
|
|
float3 oPos : TEXCOORD5;
|
|
};
|
|
|
|
v2f vert (meshData v)
|
|
{
|
|
v2f o;
|
|
VertexPositionInputs pos = GetVertexPositionInputs(v.vertex);
|
|
VertexNormalInputs norm = GetVertexNormalInputs(v.normal, v.tangent);
|
|
o.vertex = pos.positionCS;//mvp matrix
|
|
o.uv = v.uv;
|
|
o.wPos = pos.positionWS;
|
|
o.wNor = normalize(norm.normalWS);
|
|
o.wTan = normalize(norm.tangentWS);
|
|
o.wBitan = normalize(norm.bitangentWS);
|
|
o.oPos = v.vertex.xyz;
|
|
return o;
|
|
}
|
|
|
|
half4 frag (v2f i) : SV_Target
|
|
{
|
|
|
|
float3 N = UnpackNormal(tex2D(_BumpMap, i.uv));
|
|
float3x3 TBN = float3x3 (i.wTan, i.wBitan, i.wNor);
|
|
N = normalize(mul(N, TBN));
|
|
|
|
half4 rimColor = tex2D(_rimtex, i.oPos.xz * _rimTilling.xy + _rimTilling.zw * _Time.x + N.xz);
|
|
|
|
// return half4(N, 1);
|
|
// N = TransformObjectToWorldNormal(N);
|
|
float3 V = normalize(_WorldSpaceCameraPos - i.wPos);
|
|
float fresnel = pow(1.0 - saturate(dot(N, V)), _fresnelIntensity);
|
|
fresnel *= (fresnel > _thresh);
|
|
half4 tex = tex2D(_BaseMap, i.uv);
|
|
|
|
half4 col = lerp(_color, _colorEdge, fresnel);
|
|
clip(tex.a - 0.1);
|
|
return saturate(col * _grayScale - rimColor);
|
|
}
|
|
ENDHLSL
|
|
}
|
|
}
|
|
}
|