123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- Shader "URP/RimLightAdd"
- {
- Properties
- {
- _MainTex ("Texture", 2D) = "white" {}
- _TintColor ("texColor", Color) = (0.5,0.5,0.5,1)
- _fangwei ("fangwei", Float ) = 0
- _Fcolor ("Fcolor", Color) = (0.5,0.5,0.5,1)
- _liangdu ("liangdu", Float ) = 0
- }
- SubShader
- {
- Tags { "RenderPipeline"="UniversalPipline" }
-
- HLSLINCLUDE
- #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
- CBUFFER_START(UnityPerMaterial)
- float4 _MainTex_ST;
- half4 _TintColor;
- half _fangwei;
- half4 _Fcolor;
- half _liangdu;
- CBUFFER_END
- ENDHLSL
- Pass
- {
- Blend One One
-
- HLSLPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
- TEXTURE2D(_MainTex);
- SAMPLER(sampler_MainTex);
- struct a2v
- {
- float4 positionOS:POSITION;
- float3 normal : NORMAL;
- float4 texcoord:TEXCOORD0;
- float4 vertexColor : COLOR;
- };
- struct v2f
- {
- float4 positionCS:SV_POSITION;
- half2 uv:TEXCOORD0;
- float4 posWorld : TEXCOORD1;
- float3 normalDir : TEXCOORD2;
- float4 vertexColor : COLOR;
- };
- v2f vert(a2v v)
- {
- v2f o;
- o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
- o.positionCS = TransformObjectToHClip(v.positionOS);
- o.vertexColor=v.vertexColor;
- o.normalDir= TransformObjectToWorldNormal(v.normal);
- o.posWorld= mul(unity_ObjectToWorld, v.positionOS);
- return o;
- }
- half4 frag(v2f i):SV_TARGET
- {
- half4 renderTex=SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex,i.uv);
- i.normalDir=normalize(i.normalDir);
- float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
- float3 normalDirection = i.normalDir;
- float3 emissive = renderTex.rgb;
- float3 finalColor = (pow(1.0-max(0,dot(i.normalDir, viewDirection)),_fangwei)*_Fcolor.rgb*_liangdu);
- half4 finalRGBA = half4(finalColor,1);
- return finalRGBA;
- }
- ENDHLSL
- }
- }
- }
|