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_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 * Safe range is calculated automatically if the value is default (0.0) 48 * Do not modify if one wants the default bahaviour 49 */ 50 DEFINE_PROPERTY(float, range, "Range", 0, VALUE(0.0f)) 51 52 /** Near plane distance from the light source. 53 */ 54 DEFINE_PROPERTY(float, nearPlane, "Shadow Near Plane", 0, VALUE(0.5f)) 55 56 /** Spotlight inner angle. 57 */ 58 DEFINE_PROPERTY(float, spotInnerAngle, "Spot Cone Inner Angle", 0, VALUE(0.0f)) 59 60 /** Spotlight outer angle. 61 */ 62 DEFINE_PROPERTY(float, spotOuterAngle, "Spot Cone Outer Angle", 0, VALUE(0.78539816339f)) 63 64 /** Shadow strength. 65 */ 66 DEFINE_PROPERTY(float, shadowStrength, "Shadow Strength", 0, VALUE(1.0f)) 67 68 /** Shadow depth bias. 69 */ 70 DEFINE_PROPERTY(float, shadowDepthBias, "Shadow Depth Bias", 0, VALUE(0.005f)) 71 72 /** Shadow normal bias. 73 */ 74 DEFINE_PROPERTY(float, shadowNormalBias, "Shadow Normal Bias", 0, VALUE(0.025f)) 75 76 /** Shadow enabled. 77 */ 78 DEFINE_PROPERTY(bool, shadowEnabled, "Shadow Enabled", 0, VALUE(false)) 79 80 /** Additional factor for e.g. shader customization. 81 */ 82 DEFINE_PROPERTY(BASE_NS::Math::Vec4, additionalFactor, "Additional Factor", 0, ARRAY_VALUE(0.0f, 0.0f, 0.0f, 0.0f)) 83 84 /** Defines a layer mask which affects lighting of layer objects. Default is all layer mask, and then the 85 * light affects objects on all layers. */ 86 DEFINE_BITFIELD_PROPERTY(uint64_t, lightLayerMask, "Light Layer Mask", PropertyFlags::IS_BITFIELD, 87 VALUE(LayerConstants::ALL_LAYER_MASK), LayerFlagBits) 88 89 /** Defines a layer mask which affects shadow camera's rendering. Default is all layer mask, and then the 90 * shadow camera renders objects from all layers. */ 91 DEFINE_BITFIELD_PROPERTY(uint64_t, shadowLayerMask, "Shadow Layer Mask", PropertyFlags::IS_BITFIELD, 92 VALUE(LayerConstants::ALL_LAYER_MASK), LayerFlagBits) 93 94 END_COMPONENT(ILightComponentManager, LightComponent, "8047c9cd-4e83-45b3-91d9-dd32d643f0c8") 95 #if !defined(IMPLEMENT_MANAGER) 96 CORE3D_END_NAMESPACE() 97 #endif 98 99 #endif 100