HeadSnapperShader.shader 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. Shader "Custom/HeadSnapperShader"
  3. {
  4. Properties
  5. {
  6. _MainTex ("Texture", 2D) = "white" {} //include a texture as a property
  7. }
  8. SubShader
  9. {
  10. // No culling or depth
  11. Cull Off ZWrite Off //ZTest Always
  12. Pass
  13. {
  14. CGPROGRAM
  15. #pragma vertex vertexToFragment
  16. #pragma fragment giveColor
  17. #include "UnityCG.cginc"
  18. //info from vertex on the mesh
  19. struct appdata
  20. {
  21. float4 vertex : POSITION;
  22. float2 uv : TEXCOORD0;
  23. };
  24. //info for fragment function
  25. struct v2f
  26. {
  27. float2 uv : TEXCOORD0;
  28. float4 vertex : SV_POSITION;
  29. };
  30. v2f vertexToFragment (appdata v)
  31. {
  32. v2f o;
  33. o.vertex = UnityObjectToClipPos(v.vertex);
  34. o.uv = v.uv;
  35. return o;
  36. }
  37. sampler2D _MainTex;
  38. float4 _MainTex_TexelSize;
  39. float _darkness;
  40. //returns color in float 4 variable given our v2f
  41. float4 giveColor (v2f i) : SV_Target
  42. {
  43. float4 col = tex2D(_MainTex,i.uv+float2(_MainTex_TexelSize.x * 0, _MainTex_TexelSize.y * 0));
  44. return col * (1.0 - _darkness);
  45. }
  46. ENDCG
  47. }
  48. }
  49. }