Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. Shader "Metropolia/Damage"
  2. {
  3. Properties
  4. {
  5. _Damage("Damage", range(0,1)) = 0
  6. }
  7.  
  8. SubShader
  9. {
  10. Pass
  11. {
  12. CGPROGRAM
  13.  
  14. #pragma vertex vert
  15. #pragma fragment frag
  16. #include "Lighting.cginc"
  17.  
  18. struct appdata
  19. {
  20. float4 pos : POSITION;
  21. float3 nor : NORMAL;
  22. };
  23.  
  24. struct v2f
  25. {
  26. float4 pos : SV_POSITION;
  27. float3 nor : NORMAL;
  28. };
  29.  
  30. float _Damage;
  31.  
  32. v2f vert(appdata i)
  33. {
  34. v2f o;
  35. o.pos = UnityObjectToClipPos(i.pos);
  36. o.nor = UnityObjectToWorldNormal(i.nor);
  37. return o;
  38. }
  39.  
  40. fixed4 frag(v2f i) : SV_Target
  41. {
  42. float ndl = max(0, dot(i.nor, _WorldSpaceLightPos0));
  43. fixed4 col = lerp(
  44. fixed4(0.5, 0.5, 0.5, 1),
  45. fixed4(1.0, 0.5, 0.5, 1),
  46. _Damage);
  47. return col * ndl * 2;
  48. }
  49.  
  50. ENDCG
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement