[dali_2.2.17] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-scene3d / public-api / loader / environment-definition.h
1 #ifndef DALI_SCENE3D_LOADER_ENVIRONMENT_DEFINITION_H
2 #define DALI_SCENE3D_LOADER_ENVIRONMENT_DEFINITION_H
3 /*
4  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 // EXTERNAL INCLUDES
21 #include <dali/public-api/math/quaternion.h>
22 #include <dali/public-api/rendering/texture.h>
23 #include <memory>
24
25 // INTERNAL INCLUDES
26 #include <dali-scene3d/public-api/api.h>
27 #include <dali-scene3d/public-api/loader/environment-map-data.h>
28
29 namespace Dali::Scene3D::Loader
30 {
31 /**
32  * @brief Defines an environment map with either or both of radiance
33  *  and irradiance maps.
34  */
35 struct DALI_SCENE3D_API EnvironmentDefinition
36 {
37   struct Textures
38   {
39     Texture mDiffuse;  // irradiance
40     Texture mSpecular; // radiance
41     Texture mBrdf;     // pre-computed brdf
42
43     bool IsLoaded() const
44     {
45       return mDiffuse || mSpecular;
46     }
47   };
48
49   struct RawData
50   {
51     EnvironmentMapData mDiffuse;
52     EnvironmentMapData mSpecular;
53     PixelData          mBrdf;
54   };
55
56   using EnvironmentData = std::pair<EnvironmentDefinition, Textures>;
57   using Vector          = std::vector<EnvironmentData>;
58
59   EnvironmentDefinition() = default;
60
61   EnvironmentDefinition(const EnvironmentDefinition&) = delete;
62   EnvironmentDefinition& operator=(const EnvironmentDefinition&) = delete;
63
64   EnvironmentDefinition(EnvironmentDefinition&&) = default;
65   EnvironmentDefinition& operator=(EnvironmentDefinition&&) = default;
66
67   /**
68    * @brief Loads raw pixel data for the given diffuse and specular maps.
69    * @note This can be done on any thread.
70    */
71   RawData LoadRaw(const std::string& environmentsPath) const;
72
73   /**
74    * @brief Creates DALi cubemap Textures from the pixel data in @a raw, then
75    *  returns them in a Textures object.
76    * @note This must only be called from the event thread.
77    */
78   Textures Load(RawData&& raw) const;
79
80   /**
81    * @brief Get default intensity value.
82    * @return Default intensity. (1.0f)
83    */
84   static float GetDefaultIntensity();
85
86 public: // DATA
87   std::string              mDiffuseMapPath;
88   std::string              mSpecularMapPath;
89   std::shared_ptr<RawData> mRawData;
90   Quaternion               mCubeOrientation = Quaternion::IDENTITY;
91   Vector3                  mYDirection      = Vector3::ONE;
92   float                    mIblIntensity    = 1.0f;
93   bool                     mUseBrdfTexture  = false;
94 };
95
96 } // namespace Dali::Scene3D::Loader
97
98 #endif // DALI_SCENE3D_LOADER_ENVIRONMENT_DEFINITION_H