[dali_2.1.32] 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) 2022 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 // INTERNAL INCLUDES
21 #include "dali-scene3d/public-api/api.h"
22 #include "dali-scene3d/public-api/loader/cube-data.h"
23
24 // EXTERNAL INCLUDES
25 #include "dali/public-api/math/quaternion.h"
26 #include "dali/public-api/rendering/texture.h"
27
28 namespace Dali
29 {
30 namespace Scene3D
31 {
32 namespace Loader
33 {
34 /**
35  * @brief Defines an environment map with either or both of radiance
36  *  and irradiance maps.
37  */
38 struct DALI_SCENE3D_API EnvironmentDefinition
39 {
40   struct Textures
41   {
42     Texture mDiffuse;  // irradiance
43     Texture mSpecular; // radiance
44     Texture mBrdf;     // pre-computed brdf
45
46     bool IsLoaded() const
47     {
48       return mDiffuse || mSpecular;
49     }
50   };
51
52   struct RawData
53   {
54     CubeData  mDiffuse;
55     CubeData  mSpecular;
56     PixelData mBrdf;
57   };
58
59   using EnvironmentData = std::pair<EnvironmentDefinition, Textures>;
60   using Vector          = std::vector<EnvironmentData>;
61
62   EnvironmentDefinition() = default;
63
64   EnvironmentDefinition(const EnvironmentDefinition&) = delete;
65   EnvironmentDefinition& operator=(const EnvironmentDefinition&) = delete;
66
67   EnvironmentDefinition(EnvironmentDefinition&&) = default;
68   EnvironmentDefinition& operator=(EnvironmentDefinition&&) = default;
69
70   /**
71    * @brief Loads raw pixel data for the given diffuse and specular maps.
72    * @note This can be done on any thread.
73    */
74   RawData LoadRaw(const std::string& environmentsPath) const;
75
76   /**
77    * @brief Creates DALi cubemap Textures from the pixel data in @a raw, then
78    *  returns them in a Textures object.
79    * @note This must only be called from the event thread.
80    */
81   Textures Load(RawData&& raw) const;
82
83 public: // DATA
84   std::string mDiffuseMapPath;
85   std::string mSpecularMapPath;
86   Quaternion  mCubeOrientation = Quaternion::IDENTITY;
87   Vector3     mYDirection      = Vector3::ONE;
88   float       mIblIntensity    = 1.0f;
89   bool        mUseBrdfTexture  = false;
90 };
91
92 } // namespace Loader
93 } // namespace Scene3D
94 } // namespace Dali
95
96 #endif //DALI_SCENE3D_LOADER_ENVIRONMENT_DEFINITION_H