• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #if !defined(API_3D_ECS_COMPONENTS_ENVIRONMENT_COMPONENT_H) || defined(IMPLEMENT_MANAGER)
17 #define API_3D_ECS_COMPONENTS_ENVIRONMENT_COMPONENT_H
18 
19 #if !defined(IMPLEMENT_MANAGER)
20 #include <3d/namespace.h>
21 #include <base/math/quaternion.h>
22 #include <base/math/vector.h>
23 #include <core/ecs/component_struct_macros.h>
24 #include <core/ecs/entity_reference.h>
25 #include <core/ecs/intf_component_manager.h>
26 #include <core/namespace.h>
27 
28 CORE3D_BEGIN_NAMESPACE()
29 #endif
30 
31 /** Environment component can be used to configure per camera environment lighting.
32  * With full customization one can use custom resources property
33  */
34 BEGIN_COMPONENT(IEnvironmentComponentManager, EnvironmentComponent)
35 #if !defined(IMPLEMENT_MANAGER)
36     enum class Background : uint8_t {
37         /** Background none */
38         NONE = 0,
39         /** Background image */
40         IMAGE = 1,
41         /** Background cubemap */
42         CUBEMAP = 2,
43         /** Background equirectangular */
44         EQUIRECTANGULAR = 3,
45     };
46 #endif
47     /** The type of the background fill when rendering.
48      */
49     DEFINE_PROPERTY(Background, background, "Background", 0, VALUE(Background::NONE))
50 
51     /** Indirect diffuse factor with intensity in alpha.
52      */
53     DEFINE_PROPERTY(
54         BASE_NS::Math::Vec4, indirectDiffuseFactor, "Indirect Diffuse Factor", 0, ARRAY_VALUE(1.0f, 1.0f, 1.0f, 1.0f))
55 
56     /** Indirect specular factor with intensity in alpha.
57      */
58     DEFINE_PROPERTY(
59         BASE_NS::Math::Vec4, indirectSpecularFactor, "Indirect Specular Factor", 0, ARRAY_VALUE(1.0f, 1.0f, 1.0f, 1.0f))
60 
61     /** Environment map factor with intensity in alpha.
62      */
63     DEFINE_PROPERTY(BASE_NS::Math::Vec4, envMapFactor, "Environment Map Factor", 0, ARRAY_VALUE(1.0f, 1.0f, 1.0f, 1.0f))
64 
65     /** Radiance cubemap.
66      */
67     DEFINE_PROPERTY(CORE_NS::EntityReference, radianceCubemap, "Radiance Cubemap", 0,)
68 
69     /** Number of mip map levels in radiance cubemap, zero value indicates that full mip chain is available.
70      */
71     DEFINE_PROPERTY(uint32_t, radianceCubemapMipCount, "Radiance Cubemap Mip Count", 0, VALUE(0))
72 
73     /** Environment map. (Cubemap, Equirect, Image)
74      */
75     DEFINE_PROPERTY(CORE_NS::EntityReference, envMap, "Environment Map", 0,)
76 
77     /** Mip lod level for env map sampling, allows to have blurred / gradient background for the scene.
78      */
79     DEFINE_PROPERTY(float, envMapLodLevel, "Envmap Lod Level", 0, VALUE(0.0f))
80 
81     /** Irradiance lighting coefficients.
82      * Values are expected to be prescaled with 1.0 / PI for Lambertian diffuse
83      */
84     DEFINE_ARRAY_PROPERTY(BASE_NS::Math::Vec3, 9, irradianceCoefficients, "Irradiance Coefficients", 0, ARRAY_VALUE())
85 
86     /** IBL environment rotation.
87      */
88     DEFINE_PROPERTY(
89         BASE_NS::Math::Quat, environmentRotation, "IBL Environment Rotation", 0, ARRAY_VALUE(0.f, 0.f, 0.f, 1.f))
90 
91     /** Shader. Prefer using automatic selection if no custom shaders.
92      * Needs to match default material env layouts and specializations (api/3d/shaders/common).
93      */
94     DEFINE_PROPERTY(CORE_NS::EntityReference, shader, "Custom Environment Shader", 0,)
95 
96     /** Custom material extension resources. Deprecates and prevents MaterialExtensionComponent usage.
97      * Are automatically bound to custom shader, custom pipeline layout custom descriptor set if they are in order.
98      */
99     DEFINE_PROPERTY(
100         BASE_NS::vector<CORE_NS::EntityReference>, customResources, "Custom Material Extension Resources", 0,)
101 
102     /** Reflection probe that is used in probing the scenery.
103      * Create one using scene util's CreateReflectionProbe for example and attach it to this slot.
104      * When this slot is not empty, the render system automatically picks it in to use.
105      */
106     DEFINE_PROPERTY(CORE_NS::EntityReference, reflectionProbe, "Reflection Probe", 0,)
107 
108     /** Entity containing dynamic environment blender component, from where environments are pushed to camera buffers
109      * and can be blended. Controls indirect and environment lighting. If empty, no blending will happen. */
110     DEFINE_PROPERTY(CORE_NS::EntityReference, blendEnvironments, "Blend Environments", 0,)
111 
112 END_COMPONENT(IEnvironmentComponentManager, EnvironmentComponent, "a603b2e8-27f0-4c03-9538-70eaef88e3d3")
113 #if !defined(IMPLEMENT_MANAGER)
114 CORE3D_END_NAMESPACE()
115 #endif
116 #endif
117