1 /* 2 * Copyright (c) 2022 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 /** Sky atmosphere */ 46 SKY = 4, 47 }; 48 #endif 49 /** The type of the background fill when rendering. 50 */ 51 DEFINE_PROPERTY(Background, background, "Background", 0, VALUE(Background::NONE)) 52 53 /** Indirect diffuse factor with intensity in alpha. 54 */ 55 DEFINE_PROPERTY( 56 BASE_NS::Math::Vec4, indirectDiffuseFactor, "Indirect Diffuse Factor", 0, ARRAY_VALUE(1.0f, 1.0f, 1.0f, 1.0f)) 57 58 /** Indirect specular factor with intensity in alpha. 59 */ 60 DEFINE_PROPERTY( 61 BASE_NS::Math::Vec4, indirectSpecularFactor, "Indirect Specular Factor", 0, ARRAY_VALUE(1.0f, 1.0f, 1.0f, 1.0f)) 62 63 /** Environment map factor with intensity in alpha. 64 */ 65 DEFINE_PROPERTY(BASE_NS::Math::Vec4, envMapFactor, "Environment Map Factor", 0, ARRAY_VALUE(1.0f, 1.0f, 1.0f, 1.0f)) 66 67 /** Radiance cubemap. 68 */ 69 DEFINE_PROPERTY(CORE_NS::EntityReference, radianceCubemap, "Radiance Cubemap", 0, ) 70 71 /** Number of mip map levels in radiance cubemap, zero value indicates that full mip chain is available. 72 */ 73 DEFINE_PROPERTY(uint32_t, radianceCubemapMipCount, "Radiance Cubemap Mip Count", 0, VALUE(0)) 74 75 /** Environment map. (Cubemap, Equirect, Image) 76 */ 77 DEFINE_PROPERTY(CORE_NS::EntityReference, envMap, "Environment Map", 0, ) 78 79 /** Mip lod level for env map sampling, allows to have blurred / gradient background for the scene. 80 */ 81 DEFINE_PROPERTY(float, envMapLodLevel, "Envmap Lod Level", 0, VALUE(0.0f)) 82 83 /** Irradiance lighting coefficients. 84 * Values are expected to be prescaled with 1.0 / PI for Lambertian diffuse 85 */ 86 DEFINE_ARRAY_PROPERTY(BASE_NS::Math::Vec3, 9, irradianceCoefficients, "Irradiance Coefficients", 0, ARRAY_VALUE()) 87 88 /** IBL environment rotation. 89 */ 90 DEFINE_PROPERTY( 91 BASE_NS::Math::Quat, environmentRotation, "IBL Environment Rotation", 0, ARRAY_VALUE(0.f, 0.f, 0.f, 1.f)) 92 93 /** Shader. Prefer using automatic selection if no custom shaders. 94 * Needs to match default material env layouts and specializations (api/3d/shaders/common). 95 */ 96 DEFINE_PROPERTY(CORE_NS::EntityReference, shader, "Custom Environment Shader", 0, ) 97 98 /** Custom material extension resources. Deprecates and prevents MaterialExtensionComponent usage. 99 * Are automatically bound to custom shader, custom pipeline layout custom descriptor set if they are in order. 100 */ 101 DEFINE_PROPERTY( 102 BASE_NS::vector<CORE_NS::EntityReference>, customResources, "Custom Material Extension Resources", 0, ) 103 104 /** Reflection probe that is used in probing the scenery. 105 * Create one using scene util's CreateReflectionProbe for example and attach it to this slot. 106 * When this slot is not empty, the render system automatically picks it in to use. 107 */ 108 DEFINE_PROPERTY(CORE_NS::EntityReference, reflectionProbe, "Reflection Probe", 0, ) 109 110 /** Entity containing dynamic environment blender component, from where environments are pushed to camera buffers 111 * and can be blended. Controls indirect and environment lighting. If empty, no blending will happen. */ 112 DEFINE_PROPERTY(CORE_NS::EntityReference, blendEnvironments, "Blend Environments", 0, ) 113 114 /** Entity for weather component 115 * One can share the same weather component with different environments (and different cameras) 116 */ 117 DEFINE_PROPERTY(CORE_NS::EntityReference, weather, "Weather", 0, ) 118 119 END_COMPONENT(IEnvironmentComponentManager, EnvironmentComponent, "a603b2e8-27f0-4c03-9538-70eaef88e3d3") 120 #if !defined(IMPLEMENT_MANAGER) 121 CORE3D_END_NAMESPACE() 122 #endif 123 #endif 124