RimLightAdd.shader 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. Shader "URP/RimLightAdd"
  2. {
  3. Properties
  4. {
  5. _MainTex ("Texture", 2D) = "white" {}
  6. _TintColor ("texColor", Color) = (0.5,0.5,0.5,1)
  7. _fangwei ("fangwei", Float ) = 0
  8. _Fcolor ("Fcolor", Color) = (0.5,0.5,0.5,1)
  9. _liangdu ("liangdu", Float ) = 0
  10. }
  11. SubShader
  12. {
  13. Tags { "RenderPipeline"="UniversalPipline" }
  14. HLSLINCLUDE
  15. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  16. CBUFFER_START(UnityPerMaterial)
  17. float4 _MainTex_ST;
  18. half4 _TintColor;
  19. half _fangwei;
  20. half4 _Fcolor;
  21. half _liangdu;
  22. CBUFFER_END
  23. ENDHLSL
  24. Pass
  25. {
  26. Blend One One
  27. //ZWrite Off
  28. HLSLPROGRAM
  29. #pragma vertex vert
  30. #pragma fragment frag
  31. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  32. TEXTURE2D(_MainTex);
  33. SAMPLER(sampler_MainTex);
  34. struct a2v
  35. {
  36. float4 positionOS:POSITION;
  37. float3 normal : NORMAL;
  38. float4 texcoord:TEXCOORD0;
  39. float4 vertexColor : COLOR;
  40. };
  41. struct v2f
  42. {
  43. float4 positionCS:SV_POSITION;
  44. half2 uv:TEXCOORD0;
  45. float4 posWorld : TEXCOORD1;
  46. float3 normalDir : TEXCOORD2;
  47. float4 vertexColor : COLOR;
  48. };
  49. v2f vert(a2v v)
  50. {
  51. v2f o;
  52. o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
  53. o.positionCS = TransformObjectToHClip(v.positionOS);
  54. o.vertexColor=v.vertexColor;
  55. o.normalDir= TransformObjectToWorldNormal(v.normal);
  56. o.posWorld= mul(unity_ObjectToWorld, v.positionOS);
  57. return o;
  58. }
  59. half4 frag(v2f i):SV_TARGET
  60. {
  61. half4 renderTex=SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex,i.uv);
  62. i.normalDir=normalize(i.normalDir);
  63. float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
  64. float3 normalDirection = i.normalDir;
  65. float3 emissive = renderTex.rgb;
  66. float3 finalColor = (pow(1.0-max(0,dot(i.normalDir, viewDirection)),_fangwei)*_Fcolor.rgb*_liangdu);
  67. half4 finalRGBA = half4(finalColor,1);
  68. return finalRGBA;
  69. }
  70. ENDHLSL
  71. }
  72. }
  73. }