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.

63 lines
1.3 KiB

  1. Shader "Toon/Basic" {
  2. Properties {
  3. _Color ("Main Color", Color) = (.5,.5,.5,1)
  4. _MainTex ("Base (RGB)", 2D) = "white" {}
  5. _ToonShade ("ToonShader Cubemap(RGB)", CUBE) = "" { }
  6. }
  7. SubShader {
  8. Tags { "RenderType"="Opaque" }
  9. Pass {
  10. Name "BASE"
  11. Cull Off
  12. CGPROGRAM
  13. #pragma vertex vert
  14. #pragma fragment frag
  15. #pragma multi_compile_fog
  16. #include "UnityCG.cginc"
  17. sampler2D _MainTex;
  18. samplerCUBE _ToonShade;
  19. float4 _MainTex_ST;
  20. float4 _Color;
  21. struct appdata {
  22. float4 vertex : POSITION;
  23. float2 texcoord : TEXCOORD0;
  24. float3 normal : NORMAL;
  25. };
  26. struct v2f {
  27. float4 pos : SV_POSITION;
  28. float2 texcoord : TEXCOORD0;
  29. float3 cubenormal : TEXCOORD1;
  30. UNITY_FOG_COORDS(2)
  31. };
  32. v2f vert (appdata v)
  33. {
  34. v2f o;
  35. o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
  36. o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
  37. o.cubenormal = mul (UNITY_MATRIX_MV, float4(v.normal,0));
  38. UNITY_TRANSFER_FOG(o,o.pos);
  39. return o;
  40. }
  41. fixed4 frag (v2f i) : SV_Target
  42. {
  43. fixed4 col = _Color * tex2D(_MainTex, i.texcoord);
  44. fixed4 cube = texCUBE(_ToonShade, i.cubenormal);
  45. fixed4 c = fixed4(2.0f * cube.rgb * col.rgb, col.a);
  46. UNITY_APPLY_FOG(i.fogCoord, c);
  47. return c;
  48. }
  49. ENDCG
  50. }
  51. }
  52. Fallback "VertexLit"
  53. }