BakeLight.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. // Copyright (c) 2014-2017, THUNDERBEAST GAMES LLC All rights reserved
  2. // Copyright 2009-2017 Intel Corporation
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #pragma once
  23. #include <Atomic/Core/Mutex.h>
  24. #include "BakeNode.h"
  25. namespace Atomic
  26. {
  27. class Light;
  28. class Zone;
  29. }
  30. using namespace Atomic;
  31. namespace AtomicGlow
  32. {
  33. class LightRay;
  34. class BakeMesh;
  35. class BakeLight : public BakeNode
  36. {
  37. ATOMIC_OBJECT(BakeLight, BakeNode)
  38. public:
  39. BakeLight(Context* context, SceneBaker *sceneBaker);
  40. virtual ~BakeLight();
  41. virtual void SetLight(Atomic::Light* light) = 0;
  42. virtual void Light(LightRay* ray) = 0;
  43. protected:
  44. // Common light properties
  45. Color color_;
  46. Vector3 position_;
  47. Vector3 direction_;
  48. float range_;
  49. private:
  50. };
  51. // Zone ambient, etc
  52. class ZoneBakeLight : public BakeLight
  53. {
  54. ATOMIC_OBJECT(ZoneBakeLight, BakeLight)
  55. public:
  56. ZoneBakeLight(Context* context, SceneBaker* sceneBaker);
  57. virtual ~ZoneBakeLight();
  58. void Light(LightRay* lightRay);
  59. void SetLight(Atomic::Light* light) {}
  60. void SetZone(Zone* zone);
  61. protected:
  62. private:
  63. Zone* zone_;
  64. };
  65. class DirectionalBakeLight : public BakeLight
  66. {
  67. ATOMIC_OBJECT(DirectionalBakeLight, BakeLight)
  68. public:
  69. DirectionalBakeLight(Context* context, SceneBaker* sceneBaker);
  70. virtual ~DirectionalBakeLight();
  71. void Set(const Vector3& direction, const Vector3& radiance, float cosAngle);
  72. void Light(LightRay* lightRay);
  73. void SetLight(Atomic::Light* light);
  74. protected:
  75. private:
  76. };
  77. class PointBakeLight : public BakeLight
  78. {
  79. ATOMIC_OBJECT(PointBakeLight, BakeLight)
  80. public:
  81. PointBakeLight(Context* context, SceneBaker* sceneBaker);
  82. virtual ~PointBakeLight();
  83. void Light(LightRay* lightRay);
  84. void SetLight(Atomic::Light* light);
  85. protected:
  86. private:
  87. };
  88. // BakeMesh Bounce Lighting
  89. class BounceBakeLight : public BakeLight
  90. {
  91. ATOMIC_OBJECT(BounceBakeLight, BakeLight)
  92. public:
  93. BounceBakeLight(Context* context, SceneBaker* sceneBaker);
  94. virtual ~BounceBakeLight();
  95. void Light(LightRay* lightRay);
  96. void SetLight(Atomic::Light* light);
  97. void SetBakeMesh(BakeMesh* bakeMesh);
  98. void SetBounceSamples(const PODVector<BounceSample>& bounceSamples);
  99. unsigned GetNumBounceSamples() const { return bounceSamples_.Size(); }
  100. protected:
  101. private:
  102. static Mutex sortMutex_;
  103. PODVector<BounceSample> bounceSamples_;
  104. WeakPtr<BakeMesh> bakeMesh_;
  105. };
  106. }