Chrome.shader 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // $Id: Chrome.shader 172 2015-03-13 14:05:02Z dirk $
  2. //
  3. // Virtence VFont package
  4. // Copyright 2014 by Virtence GmbH
  5. // http://www.virtence.com
  6. //
  7. Shader "Virtence/Chrome" {
  8. Properties {
  9. _MainTex ("Base (RGB)", 2D) = "white" {}
  10. }
  11. SubShader {
  12. Tags { "RenderType"="Opaque" }
  13. CGPROGRAM
  14. #pragma surface surf Lambert vertex:vert
  15. sampler2D _MainTex;
  16. struct Input {
  17. float2 uv_MainTex;
  18. float2 SpUV;
  19. };
  20. void vert (inout appdata_full v, out Input o) {
  21. UNITY_INITIALIZE_OUTPUT(Input, o);
  22. float4 mvv = mul(UNITY_MATRIX_MV, v.vertex);
  23. float3 Nn = normalize(COMPUTE_VIEW_NORMAL);
  24. float3 Neye = normalize(-mvv.xyz/mvv.z);
  25. float3 refl = Neye - Nn * 2.0 * dot(Neye,Nn);
  26. refl.z += 1.0;
  27. float m = 1.0/(2.0*sqrt(dot(refl,refl)));
  28. o.SpUV = refl.xy*m + float2(0.5,0.5);
  29. }
  30. void surf (Input IN, inout SurfaceOutput o) {
  31. half4 c = tex2D (_MainTex, IN.SpUV);
  32. o.Albedo = c.rgb;
  33. //o.Albedo = half3(abs(IN.SpUV), 0.0);
  34. o.Alpha = 1.0;
  35. }
  36. ENDCG
  37. }
  38. FallBack "Diffuse"
  39. }