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_FOG_COMPONENT_H) || defined(IMPLEMENT_MANAGER)
17 #define API_3D_ECS_COMPONENTS_FOG_COMPONENT_H
18 
19 #if !defined(IMPLEMENT_MANAGER)
20 #include <3d/namespace.h>
21 #include <base/math/vector.h>
22 #include <core/ecs/component_struct_macros.h>
23 #include <core/ecs/intf_component_manager.h>
24 #include <core/namespace.h>
25 
26 CORE3D_BEGIN_NAMESPACE()
27 #endif
28 
29 /** Fog component can be used to configure per camera scene fogging.
30  */
31 BEGIN_COMPONENT(IFogComponentManager, FogComponent)
32     /** Global density factor. Fog layer's thickness.
33      */
34     DEFINE_PROPERTY(float, density, "Density Factor", 0, VALUE(0.005f))
35 
36     /** Height density factor. Controls how the density increases as height decreases. Smaller values for larger
37      * transition.
38      */
39     DEFINE_PROPERTY(float, heightFalloff, "Height Falloff", 0, VALUE(1.0f))
40 
41     /** Offset to "ground" plane. Y value in world space.
42      */
43     DEFINE_PROPERTY(float, heightFogOffset, "Height Offset (to ground plane)", 0, VALUE(0.0f))
44 
45     /** Second layer. Density of the second layer. Value of 0 will disable the second layer.
46      */
47     DEFINE_PROPERTY(float, layerDensity, "Second Layer Density", 0, VALUE(0.04f))
48 
49     /** Second layer. Height density factor.
50      */
51     DEFINE_PROPERTY(float, layerHeightFalloff, "Second Layer Height Falloff", 0, VALUE(1.0f))
52 
53     /** Second layer. Offset to "ground" plane.
54      */
55     DEFINE_PROPERTY(float, layerHeightFogOffset, "Second Layer Height Offset", 0, VALUE(0.0f))
56 
57     /** Start distance of the fog from the camera.
58      */
59     DEFINE_PROPERTY(float, startDistance, "Start Distance From Camera", 0, VALUE(1.0f))
60 
61     /** Scene objects past this distance will not have fog applied. Some skyboxes, environments might have baked fog.
62      * Negative value applies fog to everything.
63      */
64     DEFINE_PROPERTY(float, cuttoffDistance, "Cutoff Distance", 0, VALUE(-1.0f))
65 
66     /** The opacity limit of both layers of the the fog. 1.0 is fully opaque. 0.0 is invisible, no fog at all.
67      */
68     DEFINE_PROPERTY(float, maxOpacity, "Maximum Opacity", 0, VALUE(0.2f))
69 
70     /** Primary color of the fog. The w-value is multiplier.
71      */
72     DEFINE_PROPERTY(BASE_NS::Math::Vec4, inscatteringColor, "Fog Primary Color (Intensity In Alpha)", 0,
73         ARRAY_VALUE(1.0f, 1.0f, 1.0f, 1.0f))
74 
75     /** Environment map factor with intensity in alpha.
76      */
77     DEFINE_PROPERTY(BASE_NS::Math::Vec4, envMapFactor, "Environment Map Factor", 0, ARRAY_VALUE(1.0f, 1.0f, 1.0f, 0.1f))
78 
79     /** Additional factor for e.g. shader customization.
80      */
81     DEFINE_PROPERTY(BASE_NS::Math::Vec4, additionalFactor, "Additional Factor For Customization", 0,
82         ARRAY_VALUE(0.0f, 0.0f, 0.0f, 0.0f))
83 
84 END_COMPONENT(IFogComponentManager, FogComponent, "7a5faa64-7e5e-4ec6-90c5-e7ce24eee7b1")
85 #if !defined(IMPLEMENT_MANAGER)
86 CORE3D_END_NAMESPACE()
87 #endif
88 #endif
89