Class Info |
|---|
class Light : public IComponent 灯光类。主要提供灯光颜色,类型,强度,光源位置,光照方向、聚光灯内外切角、冯氏光照模型参数的设置及获取等功能。 |
Qualifier and Type |
Method Name and Description |
|---|---|
virtual void |
Start() override 创建灯光信息,初始化灯光的颜色、位置、照射方向、类型。 |
virtual void |
Update(f32 deltaTime) override 更新灯光的位置(点光源、聚光灯)或方向(平行光)。 |
void |
SetLightType(LightType type) 设置灯光类型。 |
void |
SetColor(const Vector3& color) 设置灯光颜色。 |
void |
SetIntensity(f32 intensity) 设置灯光强度。 |
void |
SetPosition(const Vector3& position) 设置光源位置。 |
void |
SetDirection(const Vector3& direction) 设置灯光照射方向。 |
void |
SetCutoff(const Vector2& cutoff) 设置聚光灯的内外切角信息。 |
void |
SetAmbient(const Vector3& ambient) 设置光源的ambient分量。 |
void |
SetDiffuse(const Vector3& diffuse) 设置光源的diffuse分量。 |
void |
SetSpecular(const Vector3& specular) 设置光源的specular分量。 |
void |
SetAttenuation(const Vector3& attenuation) 设置光源的衰减项。 |
void |
设置从光源中心发射的光的传播距离(仅限点光源)。 |
GetLightType() const 获取灯光类型,如平行光、点光源。 |
|
GetColor() const 获取灯光颜色。 |
|
GetIntensity() const 获取灯光强度。 |
|
GetPosition() const 获取光源位置。 |
|
GetDirection() const 获取灯光照射方向。 |
|
GetCutoff() const 获取聚光灯的内外切角信息。 |
|
GetAmbient() const 获取光源的ambient分量。 |
|
GetDiffuse() const 获取光源的diffuse分量。 |
|
GetSpecular() const 获取光源的specular分量。 |
|
GetAttenuation() const 获取光源的衰减项。 |
|
GetRange() const 获取从光源中心发射的光的传播距离(仅限点光源)。 |
|
bool |
SetShadowParam(bool shadowEnable, u32 cascadeCount = 2) 设置阴影参数(仅限方向光)。 |
bool |
IsShadowEnable() const 判断阴影功能是否开启(仅限方向光)。 |
const Texture* |
GetShadowTexture() const 获取阴影贴图纹理。 |
void |
SetShadowVisable(bool isShadowVisable) 设置阴影的显示和隐藏。 |
bool |
IsShadowVisable() const 查询阴影是否显示。 |
GetShadowCascadeCount() const 获取阴影级联拆分的值。 |
|
void |
SetShadowInfoCascadeViewProjMatrixUniformBuffer(UniformBuffer& uniformBuffer) 更新一致性变量级联拆分的值。 |
Constructor |
|---|
Light(SceneObject* sceneObject = nullptr) 构造函数。 |
Parameters
Name |
Description |
|---|---|
sceneObject |
指定初始化的场景对象。 |
Method |
|---|
virtual void Update(f32 deltaTime) override 更新灯光的位置(点光源、聚光灯)或方向(平行光)。 |
Parameters
Name |
Description |
|---|---|
deltaTime |
帧间隔时间,单位为秒。 |
Method |
|---|
void SetLightType(LightType type) 设置灯光类型。 |
Parameters
Name |
Description |
|---|---|
type |
LightType类型的灯光类型,如平行光、点光源。 |
Method |
|---|
void SetColor(const Vector3& color) 设置灯光颜色。 |
Parameters
Name |
Description |
|---|---|
color |
Vector3类型的灯光颜色,取值范围为(0.0, 1.0)。 |
Method |
|---|
void SetIntensity(f32 intensity) 设置灯光强度。 |
Parameters
Name |
Description |
|---|---|
intensity |
浮点类型的灯光强度。可以是任意大于0的值,默认为1.0。 |
Method |
|---|
void SetPosition(const Vector3& position) 设置光源位置。 |
Parameters
Name |
Description |
|---|---|
position |
Vector3类型的光源位置。 |
Method |
|---|
void SetDirection(const Vector3& direction) 设置灯光照射方向。 |
Parameters
Name |
Description |
|---|---|
direction |
Vector3类型的灯光照射方向。 |
Method |
|---|
void SetCutoff(const Vector2& cutoff) 设置聚光灯的内外切角信息。 |
Parameters
Name |
Description |
|---|---|
cutoff |
Vector2类型的内外切角值。 |
Method |
|---|
void SetAmbient(const Vector3& ambient) 设置光源的ambient分量。 |
Parameters
Name |
Description |
|---|---|
ambient |
Vector3类型的颜色值。 |
Method |
|---|
void SetDiffuse(const Vector3& diffuse) 设置光源的diffuse分量。 |
Parameters
Name |
Description |
|---|---|
diffuse |
Vector3类型的颜色值。 |
Method |
|---|
SetSpecular(const Vector3& specular) 设置光源的specular分量。 |
Parameters
Name |
Description |
|---|---|
specular |
Vector3类型的颜色值。 |
Method |
|---|
void SetAttenuation(const Vector3& attenuation) 设置光源的衰减项。 |
Parameters
Name |
Description |
|---|---|
attenuation |
Vector3类型的常数衰减项,一次衰减项,二次衰减项。 |
Method |
|---|
void SetRange(f32 range) 设置从光源中心发射的光的传播距离(仅限点光源)。 |
Parameters
Name |
Description |
|---|---|
range |
f32类型的传播距离。取值为任意大于0的值,默认为1.0。 |
Method |
|---|
bool SetShadowParam(bool shadowEnable, u32 cascadeCount = 2) 设置阴影参数。 |
Parameters
Name |
Description |
|---|---|
shadowEnable |
是否开启阴影功能。
|
cascadeCount |
级联阴影贴图数量(仅限方向光)。取值范围为:2,3,4。 |
Returns
Type |
Description |
|---|---|
bool |
设置阴影参数是否成功(仅限方向光)。
|
Method |
|---|
bool IsShadowEnable() const 查询阴影功能是否开启(仅限方向光)。 |
Returns
Type |
Description |
|---|---|
bool |
查询阴影功能是否开启(仅限方向光)。
|
Method |
|---|
const Texture* GetShadowTexture() const 获取阴影贴图的纹理。 |
Returns
Type |
Description |
|---|---|
const Texture* |
阴影贴图的纹理指针。 |
Method |
|---|
void SetShadowVisable(bool isShadowVisable) 设置阴影的显示和隐藏。 |
Parameters
Name |
Description |
|---|---|
isShadowVisable |
阴影的显示和隐藏。
|
Method |
|---|
bool IsShadowVisable() const 查询阴影功能是否显示。 |
Returns
Type |
Description |
|---|---|
bool |
查询阴影功能是否显示。
|
Method |
|---|
u32 GetShadowCascadeCount() const 获取阴影级联拆分的值。 |
Returns
Type |
Description |
|---|---|
级联拆分的值。 |
Method |
|---|
void SetShadowInfoCascadeViewProjMatrixUniformBuffer(UniformBuffer& uniformBuffer) 更新一致性变量级联拆分的值。 |
Parameters
Name |
Description |
|---|---|
uniformBuffer |
一致性变量缓存。 |