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_MATERIAL_EXTENSION_COMPONENT_H) || defined(IMPLEMENT_MANAGER)
17 #define API_3D_ECS_COMPONENTS_MATERIAL_EXTENSION_COMPONENT_H
18 
19 #if !defined(IMPLEMENT_MANAGER)
20 #include <3d/namespace.h>
21 #include <core/ecs/component_struct_macros.h>
22 #include <core/ecs/entity_reference.h>
23 #include <core/ecs/intf_component_manager.h>
24 
25 CORE3D_BEGIN_NAMESPACE()
26 /** \addtogroup group_material_materialextensioncomponent
27  *  @{
28  */
29 #endif
30 
31 /** Material extension component properties.
32  * NOTE: "DEPRECATED" prefer using MaterialComponent::customResources and EnvironmentComponent::customResources
33  * Can extend default material model with additional resources for custom shaders.
34  * GPU resources are owned by the component and destroyed when the component is destroyed.
35  * Can be used to default material render slots and default material env node.
36  */
37 BEGIN_COMPONENT(IMaterialExtensionComponentManager, MaterialExtensionComponent)
38 #if !defined(IMPLEMENT_MANAGER)
39     /** Custom resources which will be bound to pre-defined set and their bindings in order */
40     enum ResourceIndex : uint8_t {
41         /** Custom resource which will be bound to pre-defined set and binding 0 */
42         RESOURCE_INDEX_0,
43         /** Custom resource which will be bound to pre-defined set and binding 1 */
44         RESOURCE_INDEX_1,
45         /** Custom resource which will be bound to pre-defined set and binding 2 */
46         RESOURCE_INDEX_2,
47         /** Custom resource which will be bound to pre-defined set and binding 3 */
48         RESOURCE_INDEX_3,
49         /** Number of resources */
50         RESOURCE_COUNT,
51     };
52 #endif
53 
54     /** Array of resources. With default material model these are bound in order to predefined set.
55      * One needs to use custom shader with custom pipeline layout (predefined set) to access these in shader.
56      * Resources are owned by the component and destroyed when it's destroyed.
57      */
58     DEFINE_ARRAY_PROPERTY(
59         CORE_NS::EntityReference, ResourceIndex::RESOURCE_COUNT, resources, "Custom Material Resources", 0, )
60 
61 END_COMPONENT(IMaterialExtensionComponentManager, MaterialExtensionComponent, "98416b5a-8780-4444-be4f-d0c972a09a2f")
62 #if !defined(IMPLEMENT_MANAGER)
63 CORE3D_END_NAMESPACE()
64 #endif
65 #endif
66