Création d'un petit party-game anonyme de Build + Bagar sous Unity
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

wMaillageShader.shader 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. Shader "Custom/wMaillageShader"
  2. {
  3. <<<<<<< HEAD
  4. Properties
  5. {
  6. _MainTex("Texture", 2D) = "white" {}
  7. _Color("Color", Color) = (1,1,1,1)
  8. _Threshold("Threshold", float) = 0.01
  9. _EdgeColor("Edge color", Color) = (1,0,0,1)
  10. _Glossiness("Smoothness", Range(0,1)) = 0.5
  11. _Metallic("Metallic", Range(0,1)) = 0.0
  12. }
  13. SubShader
  14. {
  15. Cull Off ZWrite Off ZTest Always
  16. Tags { "RenderType" = "Opaque" }
  17. Pass
  18. {
  19. CGPROGRAM
  20. #pragma vertex vert
  21. #pragma fragment frag
  22. #include "UnityCG.cginc"
  23. struct appdata
  24. {
  25. float4 vertex : POSITION;
  26. float2 uv : TEXCOORD0;
  27. };
  28. struct v2f
  29. {
  30. float2 uv : TEXCOORD0;
  31. float4 vertex : SV_POSITION;
  32. };
  33. sampler2D _CameraDepthNormalsTexture;
  34. float4 _MainTex_ST;
  35. v2f vert(appdata v)
  36. {
  37. v2f o;
  38. o.vertex = UnityObjectToClipPos(v.vertex);
  39. o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  40. return o;
  41. }
  42. sampler2D _MainTex;
  43. float4 _MainTex_TexelSize;
  44. float _Threshold;
  45. fixed4 _EdgeColor;
  46. float4 GetPixelValue(in float2 uv) {
  47. half3 normal;
  48. float depth;
  49. DecodeDepthNormal(tex2D(_CameraDepthNormalsTexture, uv), depth, normal);
  50. return fixed4(normal, depth);
  51. }
  52. fixed4 frag(v2f i) : SV_Target
  53. {
  54. fixed4 col = tex2D(_MainTex, i.uv);
  55. fixed4 orValue = GetPixelValue(i.uv);
  56. float2 offsets[8] = {
  57. float2(-1, -1),
  58. float2(-1, 0),
  59. float2(-1, 1),
  60. float2(0, -1),
  61. float2(0, 1),
  62. float2(1, -1),
  63. float2(1, 0),
  64. float2(1, 1)
  65. };
  66. fixed4 sampledValue = fixed4(0,0,0,0);
  67. for (int j = 0; j < 8; j++) {
  68. sampledValue += GetPixelValue(i.uv + offsets[j] * _MainTex_TexelSize.xy);
  69. }
  70. sampledValue /= 8;
  71. return lerp(col, _EdgeColor, step(_Threshold, length(orValue - sampledValue)));
  72. }
  73. ENDCG
  74. }
  75. }
  76. =======
  77. Properties
  78. {
  79. _InnerColor("Inner Color", Color) = (0.0, 0.0, 0.0, 0.5)
  80. _RimColor("Rim Color", Color) = (1.0,1.0,1.0,0.5)
  81. _RimPower("Rim Power", Range(0.5,8.0)) = 2.47
  82. }
  83. SubShader
  84. {
  85. Tags { "Queue" = "Transparent" }
  86. Cull Off ZWrite Off ZTest Less
  87. //Blend based on output Alpha, not color value
  88. Blend One OneMinusSrcAlpha
  89. CGPROGRAM
  90. #pragma surface surf Lambert alpha:fade
  91. struct Input
  92. {
  93. float3 viewDir;
  94. };
  95. float4 _InnerColor;
  96. float4 _RimColor;
  97. float _RimPower;
  98. void surf(Input IN, inout SurfaceOutput o)
  99. {
  100. half rim = 1.0 - saturate(dot(normalize(IN.viewDir), o.Normal));
  101. rim = pow(rim, _RimPower);
  102. //Shift inner color to rim color by rim value adjusted by _InnerColor transparency to reduce its effect
  103. //on semi-transparent part of rim color the more transparent inner color becomes.
  104. o.Emission = lerp(_InnerColor.rgb, _RimColor.rgb, saturate(rim + (1 - _InnerColor.a) - (1 - _RimColor.a)));
  105. o.Alpha = lerp(_InnerColor.a, _RimColor.a, rim);
  106. }
  107. ENDCG
  108. }
  109. Fallback "Diffuse"
  110. >>>>>>> shader
  111. }