Functions.hlsl 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // UNITY_SHADER_NO_UPGRADE
  2. #ifndef UNITY_GRAPHFUNCTIONS_INCLUDED
  3. #define UNITY_GRAPHFUNCTIONS_INCLUDED
  4. // ----------------------------------------------------------------------------
  5. // Included in generated graph shaders
  6. // ----------------------------------------------------------------------------
  7. bool IsGammaSpace()
  8. {
  9. #ifdef UNITY_COLORSPACE_GAMMA
  10. return true;
  11. #else
  12. return false;
  13. #endif
  14. }
  15. float4 ComputeScreenPos (float4 pos, float projectionSign)
  16. {
  17. float4 o = pos * 0.5f;
  18. o.xy = float2(o.x, o.y * projectionSign) + o.w;
  19. o.zw = pos.zw;
  20. return o;
  21. }
  22. struct Gradient
  23. {
  24. int type;
  25. int colorsLength;
  26. int alphasLength;
  27. float4 colors[8];
  28. float2 alphas[8];
  29. };
  30. Gradient NewGradient(int type, int colorsLength, int alphasLength,
  31. float4 colors0, float4 colors1, float4 colors2, float4 colors3, float4 colors4, float4 colors5, float4 colors6, float4 colors7,
  32. float2 alphas0, float2 alphas1, float2 alphas2, float2 alphas3, float2 alphas4, float2 alphas5, float2 alphas6, float2 alphas7)
  33. {
  34. Gradient output =
  35. {
  36. type, colorsLength, alphasLength,
  37. {colors0, colors1, colors2, colors3, colors4, colors5, colors6, colors7},
  38. {alphas0, alphas1, alphas2, alphas3, alphas4, alphas5, alphas6, alphas7}
  39. };
  40. return output;
  41. }
  42. #ifndef SHADERGRAPH_SAMPLE_SCENE_DEPTH
  43. #define SHADERGRAPH_SAMPLE_SCENE_DEPTH(uv) shadergraph_SampleSceneDepth(uv)
  44. #endif
  45. #ifndef SHADERGRAPH_SAMPLE_SCENE_COLOR
  46. #define SHADERGRAPH_SAMPLE_SCENE_COLOR(uv) shadergraph_SampleSceneColor(uv)
  47. #endif
  48. #ifndef SHADERGRAPH_BAKED_GI
  49. #define SHADERGRAPH_BAKED_GI(positionWS, normalWS, uvStaticLightmap, uvDynamicLightmap, applyScaling) shadergraph_BakedGI(positionWS, normalWS, uvStaticLightmap, uvDynamicLightmap, applyScaling)
  50. #endif
  51. #ifndef SHADERGRAPH_REFLECTION_PROBE
  52. #define SHADERGRAPH_REFLECTION_PROBE(viewDir, normalOS, lod) shadergraph_ReflectionProbe(viewDir, normalOS, lod)
  53. #endif
  54. #ifndef SHADERGRAPH_FOG
  55. #define SHADERGRAPH_FOG(position, color, density) shadergraph_Fog(position, color, density)
  56. #endif
  57. #ifndef SHADERGRAPH_AMBIENT_SKY
  58. #define SHADERGRAPH_AMBIENT_SKY float3(0,0,0)
  59. #endif
  60. #ifndef SHADERGRAPH_AMBIENT_EQUATOR
  61. #define SHADERGRAPH_AMBIENT_EQUATOR float3(0,0,0)
  62. #endif
  63. #ifndef SHADERGRAPH_AMBIENT_GROUND
  64. #define SHADERGRAPH_AMBIENT_GROUND float3(0,0,0)
  65. #endif
  66. #ifndef SHADERGRAPH_OBJECT_POSITION
  67. #define SHADERGRAPH_OBJECT_POSITION UNITY_MATRIX_M._m03_m13_m23
  68. #endif
  69. float shadergraph_SampleSceneDepth(float2 uv)
  70. {
  71. return 1;
  72. }
  73. float3 shadergraph_SampleSceneColor(float2 uv)
  74. {
  75. return 0;
  76. }
  77. float3 shadergraph_BakedGI(float3 positionWS, float3 normalWS, float2 uvStaticLightmap, float2 uvDynamicLightmap, bool applyScaling)
  78. {
  79. return 0;
  80. }
  81. float3 shadergraph_ReflectionProbe(float3 viewDir, float3 normalOS, float lod)
  82. {
  83. return 0;
  84. }
  85. void shadergraph_Fog(float3 position, out float4 color, out float density)
  86. {
  87. color = 0;
  88. density = 0;
  89. }
  90. #endif // UNITY_GRAPHFUNCTIONS_INCLUDED