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_POST_PROCESS_CONFIGURATION_COMPONENT_H) || defined(IMPLEMENT_MANAGER)
17 #define API_3D_ECS_COMPONENTS_POST_PROCESS_CONFIGURATION_COMPONENT_H
18 
19 #if !defined(IMPLEMENT_MANAGER)
20 #include <3d/namespace.h>
21 #include <base/containers/string.h>
22 #include <base/containers/vector.h>
23 #include <base/math/vector.h>
24 #include <core/ecs/component_struct_macros.h>
25 #include <core/ecs/entity_reference.h>
26 #include <core/ecs/intf_component_manager.h>
27 #include <core/property/intf_property_handle.h>
28 #include <render/datastore/render_data_store_render_pods.h>
29 
30 CORE3D_BEGIN_NAMESPACE()
31 #endif
32 
33 /** Post-process component that can be used with cameras.
34  * Uses the core configuration of PostProcessConfiguration, expect fog control not used/implemented.
35  */
36 BEGIN_COMPONENT(IPostProcessConfigurationComponentManager, PostProcessConfigurationComponent)
37 #if !defined(IMPLEMENT_MANAGER)
38     /** Custom post process effect */
39     struct PostProcessEffect {
40         /** Name of the post process (e.g. "custom_effect"). The name enables finding of the data. */
41         BASE_NS::string name {};
42         /** Optional: global user factor index if the post process factor is to be used in generic pipelines. */
43         uint32_t globalUserFactorIndex { ~0u };
44         /** Optional: custom post process shader from which the custom properties are tried to fetch. */
45         CORE_NS::EntityReference shader {};
46 
47         /** Enabled. The built-in post processing render nodes support enabling these effects. */
48         bool enabled { false };
49 
50         /** Additional customization flags. */
51         uint32_t flags { 0u };
52 
53         /** Factor data. Used in global user factor and in local post process push data. */
54         BASE_NS::Math::Vec4 factor { 0.0f, 0.0f, 0.0f, 0.0f };
55         /** Custom effect property data. Used in local factors. Tries to fetch these from the shader. */
56         CORE_NS::IPropertyHandle* customProperties { nullptr };
57     };
58 #endif
59 
60     /** Post processes.
61      */
62     DEFINE_PROPERTY(BASE_NS::vector<PostProcessEffect>, postProcesses, "Post Processes", 0, )
63 
64     /** Custom post process render node graph file. (Can be patched with e.g. post process ids etc.)
65      * Chosen automatically to camera post processes if the entity of the component is attached
66      * to CameraComponent::postProcess
67      */
68     DEFINE_PROPERTY(BASE_NS::string, customRenderNodeGraphFile, "Custom Post Process RNG File", 0, )
69 
70 END_COMPONENT(IPostProcessConfigurationComponentManager, PostProcessConfigurationComponent,
71     "050af984-be02-49ae-b950-19b829252769")
72 #if !defined(IMPLEMENT_MANAGER)
73 CORE3D_END_NAMESPACE()
74 #endif
75 #endif
76