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_LIGHT_COMPONENT_H) || defined(IMPLEMENT_MANAGER) 17 #define API_3D_ECS_COMPONENTS_LIGHT_COMPONENT_H 18 19 #if !defined(IMPLEMENT_MANAGER) 20 #include <3d/ecs/components/layer_defines.h> 21 #include <3d/namespace.h> 22 #include <base/math/vector.h> 23 #include <core/ecs/component_struct_macros.h> 24 #include <core/ecs/intf_component_manager.h> 25 26 CORE3D_BEGIN_NAMESPACE() 27 #endif 28 29 BEGIN_COMPONENT(ILightComponentManager, LightComponent) 30 #if !defined(IMPLEMENT_MANAGER) 31 enum class Type : uint8_t { DIRECTIONAL = 0, POINT = 1, SPOT = 2 }; 32 #endif 33 34 /** Type of the light. 35 */ 36 DEFINE_PROPERTY(Type, type, "Type", 0, VALUE(Type::DIRECTIONAL)) 37 38 /** Diffuse color of the light. Values from 0.0 to 1.0 39 */ 40 DEFINE_PROPERTY(BASE_NS::Math::Vec3, color, "Color", 0, ARRAY_VALUE(1.0f, 1.0f, 1.0f)) 41 42 /** Intensity of the light. 43 */ 44 DEFINE_PROPERTY(float, intensity, "Intensity", 0, VALUE(1.0f)) 45 46 /** Range, distance cutoff for points and spots. 47 */ 48 DEFINE_PROPERTY(float, range, "Range", 0, VALUE(0.0f)) 49 50 /** Near plane distance from the light source. 51 */ 52 DEFINE_PROPERTY(float, nearPlane, "Shadow Near Plane", 0, VALUE(0.5f)) 53 54 /** Spotlight inner angle. 55 */ 56 DEFINE_PROPERTY(float, spotInnerAngle, "Spot Cone Inner Angle", 0, VALUE(0.0f)) 57 58 /** Spotlight outer angle. 59 */ 60 DEFINE_PROPERTY(float, spotOuterAngle, "Spot Cone Outer Angle", 0, VALUE(0.78539816339f)) 61 62 /** Shadow strength. 63 */ 64 DEFINE_PROPERTY(float, shadowStrength, "Shadow Strength", 0, VALUE(1.0f)) 65 66 /** Shadow depth bias. 67 */ 68 DEFINE_PROPERTY(float, shadowDepthBias, "Shadow Depth Bias", 0, VALUE(0.005f)) 69 70 /** Shadow normal bias. 71 */ 72 DEFINE_PROPERTY(float, shadowNormalBias, "Shadow Normal Bias", 0, VALUE(0.025f)) 73 74 /** Shadow enabled. 75 */ 76 DEFINE_PROPERTY(bool, shadowEnabled, "Shadow Enabled", 0, VALUE(false)) 77 78 /** Additional factor for e.g. shader customization. 79 */ 80 DEFINE_PROPERTY(BASE_NS::Math::Vec4, additionalFactor, "Additional Factor", 0, ARRAY_VALUE(0.0f, 0.0f, 0.0f, 0.0f)) 81 82 /** Defines a layer mask which affects lighting of layer objects. Default is all layer mask, and then the 83 * light affects objects on all layers. */ 84 DEFINE_BITFIELD_PROPERTY(uint64_t, lightLayerMask, "Light Layer Mask", PropertyFlags::IS_BITFIELD, 85 VALUE(LayerConstants::ALL_LAYER_MASK), LayerFlagBits) 86 87 /** Defines a layer mask which affects shadow camera's rendering. Default is all layer mask, and then the 88 * shadow camera renders objects from all layers. */ 89 DEFINE_BITFIELD_PROPERTY(uint64_t, shadowLayerMask, "Shadow Layer Mask", PropertyFlags::IS_BITFIELD, 90 VALUE(LayerConstants::ALL_LAYER_MASK), LayerFlagBits) 91 92 END_COMPONENT(ILightComponentManager, LightComponent, "8047c9cd-4e83-45b3-91d9-dd32d643f0c8") 93 #if !defined(IMPLEMENT_MANAGER) 94 CORE3D_END_NAMESPACE() 95 #endif 96 97 #endif 98