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_RENDER_CONFIGURATION_COMPONENT_H) || defined(IMPLEMENT_MANAGER)
17 #define API_3D_ECS_COMPONENTS_RENDER_CONFIGURATION_COMPONENT_H
18 
19 #if !defined(IMPLEMENT_MANAGER)
20 #include <3d/namespace.h>
21 #include <base/containers/string.h>
22 #include <core/ecs/component_struct_macros.h>
23 #include <core/ecs/entity.h>
24 #include <core/ecs/entity_reference.h>
25 #include <core/ecs/intf_component_manager.h>
26 
27 CORE3D_BEGIN_NAMESPACE()
28 #endif
29 
30 /** Render configuration component can be used to configure scene properties.
31  */
32 BEGIN_COMPONENT(IRenderConfigurationComponentManager, RenderConfigurationComponent)
33 #if !defined(IMPLEMENT_MANAGER)
34     enum class SceneShadowType : uint8_t {
35         /* Percentage closer shadow filtering. Filtering done per pixel in screenspace. */
36         PCF = 0,
37         /* Variance shadow maps. Filtering done in separate blur passes in texture space. */
38         VSM = 1,
39     };
40 
41     enum class SceneShadowQuality : uint8_t {
42         /* Low shadow quality. (Low resulution shadow map) */
43         LOW = 0,
44         /* Normal shadow quality. (Normal resolution shadow map) */
45         NORMAL = 1,
46         /* High shadow quality. (High resolution shadow map) */
47         HIGH = 2,
48         /* Ultra shadow quality. (Ultra resolution shadow map) */
49         ULTRA = 3,
50     };
51 
52     enum class SceneShadowSmoothness : uint8_t {
53         /* Hard shadows. */
54         HARD = 0,
55         /* Normal (smooth) shadows. */
56         NORMAL = 1,
57         /* Extra soft and smooth shadows. */
58         SOFT = 2,
59     };
60 
61     enum SceneRenderingFlagBits : uint8_t {
62         /* Create render node graphs automatically in RenderSystem. */
63         CREATE_RNGS_BIT = (1 << 0),
64     };
65     /** Container for scene rendering flag bits */
66     using SceneRenderingFlags = uint8_t;
67 #endif
68 
69     /** Entity containing an environment component that is used by default when rendering. Controls indirect and
70      * environment lighting options.
71      */
72     DEFINE_PROPERTY(CORE_NS::Entity, environment, "Environment", 0, )
73 
74     /** Entity containing a fog component that is used by default when rendering.
75      */
76     DEFINE_PROPERTY(CORE_NS::Entity, fog, "Fog", 0, )
77 
78     /** Shadow type for the (ECS) scene.
79      */
80     DEFINE_PROPERTY(SceneShadowType, shadowType, "Shadow Type", 0, VALUE(SceneShadowType::PCF))
81 
82     /** Shadow quality for the (ECS) scene.
83      */
84     DEFINE_PROPERTY(SceneShadowQuality, shadowQuality, "Shadow Quality", 0, VALUE(SceneShadowQuality::NORMAL))
85 
86     /** Shadow smoothness for the (ECS) scene. (Might behave differently with shadow types)
87      */
88     DEFINE_PROPERTY(
89         SceneShadowSmoothness, shadowSmoothness, "Shadow Smoothness", 0, VALUE(SceneShadowSmoothness::NORMAL))
90 
91     /** Scene rendering processing. Related to RNG processing and creation in RenderSystem.
92      * If flags are 0, no processing is done automatically. SceneRenderingFlagBits::CREATE_RNGS_BIT must be enabled for
93      * processing
94      */
95     DEFINE_BITFIELD_PROPERTY(SceneRenderingFlags, renderingFlags, "Rendering Flags", PropertyFlags::IS_BITFIELD,
96         VALUE(CREATE_RNGS_BIT), RenderConfigurationComponent::SceneRenderingFlagBits)
97 
98     /** Custom scene render node graph file. (Can be patched with some scene specific ids)
99      * Replaces the built-in scene render node graph when processing custom render node graphs with ECS (RenderSystem).
100      */
101     DEFINE_PROPERTY(BASE_NS::string, customRenderNodeGraphFile, "Custom Scene Render Node Graph File", 0, )
102 
103     /** Custom post scene render node graph file. (Can be patched with some scene specific ids)
104      * Is added as a final render node graph from ECS (RenderSystem) when processing render node graphs.
105      */
106     DEFINE_PROPERTY(
107         BASE_NS::string, customPostSceneRenderNodeGraphFile, "Custom Post Scene Render Node Graph File", 0, )
108 
109 END_COMPONENT(
110     IRenderConfigurationComponentManager, RenderConfigurationComponent, "7e655b3d-3cad-40b9-8179-c749be17f60b")
111 #if !defined(IMPLEMENT_MANAGER)
112 CORE3D_END_NAMESPACE()
113 #endif
114 
115 #endif
116