standard-surface-entry.chunk 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
  2. #include <legacy/shading-standard-base>
  3. #include <legacy/output-standard>
  4. #include <legacy/fog-fs>
  5. #include <legacy/shadow-map-fs>
  6. #pragma define CC_STANDARD_SURFACE_ENTRY() \
  7. #if CC_FORWARD_ADD \
  8. #include <legacy/shading-standard-additive> \
  9. #if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1 \
  10. #include <legacy/shading-cluster-additive> \
  11. #endif \
  12. \
  13. layout(location = 0) out vec4 fragColorX; \
  14. \
  15. void main () { \
  16. StandardSurface s; surf(s); \
  17. #if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1 \
  18. vec4 color = CCClusterShadingAdditive(s, CC_SHADOW_POSITION); \
  19. #else \
  20. vec4 color = CCStandardShadingAdditive(s, CC_SHADOW_POSITION); \
  21. #endif \
  22. fragColorX = CCFragOutput(color); \
  23. } \
  24. \
  25. #elif (CC_PIPELINE_TYPE == CC_PIPELINE_TYPE_FORWARD || CC_FORCE_FORWARD_SHADING) \
  26. \
  27. layout(location = 0) out vec4 fragColorX; \
  28. \
  29. void main () { \
  30. StandardSurface s; surf(s); \
  31. vec4 color = CCStandardShadingBase(s, CC_SHADOW_POSITION); \
  32. #if CC_USE_FOG != CC_FOG_NONE \
  33. #if CC_USE_FLOAT_OUTPUT \
  34. CC_APPLY_FOG(color, s.position.xyz); \
  35. #elif !CC_FORWARD_ADD \
  36. CC_APPLY_FOG(color, s.position.xyz); \
  37. #endif \
  38. #endif \
  39. fragColorX = CCFragOutput(color); \
  40. } \
  41. \
  42. #elif CC_PIPELINE_TYPE == CC_PIPELINE_TYPE_DEFERRED \
  43. #include <common/math/octahedron-transform> \
  44. \
  45. layout(location = 0) out vec4 albedoOut; \
  46. layout(location = 1) out vec4 emissiveOut; \
  47. layout(location = 2) out vec4 normalOut; \
  48. \
  49. void main () { \
  50. StandardSurface s; surf(s); \
  51. albedoOut = s.albedo; \
  52. normalOut = vec4(float32x3_to_oct(s.normal), s.roughness, s.metallic); \
  53. emissiveOut = vec4(s.emissive, s.occlusion); \
  54. } \
  55. \
  56. #endif \
  57. #pragma // empty pragma trick to get rid of trailing semicolons at effect compile time