BakeMaterial.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // Copyright (c) 2014-2017, THUNDERBEAST GAMES LLC All rights reserved
  2. //
  3. // Permission is hereby granted, free of charge, to any person obtaining a copy
  4. // of this software and associated documentation files (the "Software"), to deal
  5. // in the Software without restriction, including without limitation the rights
  6. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. // copies of the Software, and to permit persons to whom the Software is
  8. // furnished to do so, subject to the following conditions:
  9. //
  10. // The above copyright notice and this permission notice shall be included in
  11. // all copies or substantial portions of the Software.
  12. //
  13. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. // THE SOFTWARE.
  20. //
  21. #pragma once
  22. #include <Atomic/Resource/Image.h>
  23. #include <Atomic/Graphics/Material.h>
  24. using namespace Atomic;
  25. namespace AtomicGlow
  26. {
  27. class BakeMaterial : public Object
  28. {
  29. ATOMIC_OBJECT(BakeMaterial, Object)
  30. public:
  31. BakeMaterial(Context* context);
  32. virtual ~BakeMaterial();
  33. bool LoadMaterial(Material* material);
  34. Material* GetMaterial() { return material_; }
  35. Image* GetDiffuseTexture() const { return diffuseTexture_; }
  36. bool GetOcclusionMasked() const { return occlusionMasked_; }
  37. const Vector4& GetUOffset() const { return uoffset_; }
  38. const Vector4& GetVOffset() const { return voffset_; }
  39. private:
  40. Variant ParseShaderParameterValue(const String& value);
  41. SharedPtr<Material> material_;
  42. // parameters which are loaded out of material xml
  43. // as we don't load material in headless graphics mode
  44. SharedPtr<Image> diffuseTexture_;
  45. bool occlusionMasked_;
  46. Vector4 uoffset_;
  47. Vector4 voffset_;
  48. };
  49. class BakeMaterialCache : public Object
  50. {
  51. friend class BakeMaterial;
  52. ATOMIC_OBJECT(BakeMaterialCache, Object)
  53. public:
  54. BakeMaterialCache(Context* context);
  55. virtual ~BakeMaterialCache();
  56. BakeMaterial* GetBakeMaterial(Material* material);
  57. private:
  58. /// Material->GetName -> BakeMaterial
  59. HashMap<StringHash, SharedPtr<BakeMaterial>> bakeCache_;
  60. };
  61. }