SpriteUnlit.cginc 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef SPRITE_UNLIT_INCLUDED
  2. #define SPRITE_UNLIT_INCLUDED
  3. #include "ShaderShared.cginc"
  4. ////////////////////////////////////////
  5. // Vertex structs
  6. //
  7. struct VertexInput
  8. {
  9. float4 vertex : POSITION;
  10. float4 texcoord : TEXCOORD0;
  11. fixed4 color : COLOR;
  12. UNITY_VERTEX_INPUT_INSTANCE_ID
  13. };
  14. struct VertexOutput
  15. {
  16. float4 pos : SV_POSITION;
  17. float2 texcoord : TEXCOORD0;
  18. fixed4 color : COLOR;
  19. #if defined(_FOG)
  20. UNITY_FOG_COORDS(1)
  21. #endif // _FOG
  22. UNITY_VERTEX_OUTPUT_STEREO
  23. };
  24. ////////////////////////////////////////
  25. // Vertex program
  26. //
  27. VertexOutput vert(VertexInput input)
  28. {
  29. VertexOutput output;
  30. UNITY_SETUP_INSTANCE_ID(input);
  31. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
  32. output.pos = calculateLocalPos(input.vertex);
  33. output.texcoord = calculateTextureCoord(input.texcoord);
  34. output.color = calculateVertexColor(input.color);
  35. #if defined(_FOG)
  36. UNITY_TRANSFER_FOG(output,output.pos);
  37. #endif // _FOG
  38. return output;
  39. }
  40. ////////////////////////////////////////
  41. // Fragment program
  42. //
  43. fixed4 frag(VertexOutput input) : SV_Target
  44. {
  45. fixed4 texureColor = calculateTexturePixel(input.texcoord.xy);
  46. RETURN_UNLIT_IF_ADDITIVE_SLOT(texureColor, input.color) // shall be called before ALPHA_CLIP
  47. ALPHA_CLIP(texureColor, input.color)
  48. fixed4 pixel = calculatePixel(texureColor, input.color);
  49. COLORISE(pixel)
  50. APPLY_FOG(pixel, input)
  51. return pixel;
  52. }
  53. #endif // SPRITE_UNLIT_INCLUDED