• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef SCENE_INTERFACE_ILIGHT_H
17 #define SCENE_INTERFACE_ILIGHT_H
18 
19 #include <scene/base/namespace.h>
20 
21 #include <base/util/color.h>
22 
23 #include <meta/base/interface_macros.h>
24 #include <meta/interface/interface_macros.h>
25 
26 SCENE_BEGIN_NAMESPACE()
27 
28 /**
29  * @brief LightType enum defines the light type. Different types of lights use
30  *        different properties
31  */
32 enum class LightType : uint8_t { DIRECTIONAL = 0, POINT = 1, SPOT = 2 };
33 
34 class ILight : public CORE_NS::IInterface {
35     META_INTERFACE(CORE_NS::IInterface, ILight, "cbf423b5-e12d-4433-8967-2e4e8c38e5a6")
36 public:
37     /**
38      * @brief Diffuse color of the light. Values from 0.0 to 1.0.
39      */
40     META_PROPERTY(BASE_NS::Color, Color)
41     /**
42      * @brief Intensity of the light.
43      */
44     META_PROPERTY(float, Intensity)
45     /**
46      * @brief Near plane distance from the light source.
47      */
48     META_PROPERTY(float, NearPlane)
49     /**
50      * @brief Shadow enabled.
51      */
52     META_PROPERTY(bool, ShadowEnabled)
53     /**
54      * @brief Shadow strength.
55      */
56     META_PROPERTY(float, ShadowStrength)
57     /**
58      * @brief Shadow depth bias.
59      */
60     META_PROPERTY(float, ShadowDepthBias)
61     /**
62      * @brief Shadow normal bias.
63      */
64     META_PROPERTY(float, ShadowNormalBias)
65     /**
66      * @brief Spotlight inner angle.
67      */
68     META_PROPERTY(float, SpotInnerAngle)
69     /**
70      * @brief Spotlight outer angle.
71      */
72     META_PROPERTY(float, SpotOuterAngle)
73     /**
74      * @brief Type of the light. Defaults to DIRECTIONAL.
75      */
76     META_PROPERTY(LightType, Type)
77     /**
78      * @brief Additional factor for e.g. shader customization.
79      */
80     META_PROPERTY(BASE_NS::Math::Vec4, AdditionalFactor)
81     /**
82      * @brief 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      */
85     META_PROPERTY(uint64_t, LightLayerMask)
86     /**
87      * @brief Defines a layer mask which affects lighting of layer objects. Default is all layer mask, and then the
88      * light affects objects on all layers.
89      */
90     META_PROPERTY(uint64_t, ShadowLayerMask)
91 };
92 
93 META_REGISTER_CLASS(LightNode, "416287c6-c7f2-4047-ad32-d247db42aef0", META_NS::ObjectCategoryBits::NO_CATEGORY)
94 
95 SCENE_END_NAMESPACE()
96 
97 META_INTERFACE_TYPE(SCENE_NS::ILight)
98 META_TYPE(SCENE_NS::LightType)
99 
100 #endif
101