Scene / Lighting
Lighting Class
illumination
Illumination refers to simulating the illumination and influence of light sources on objects in the real world.
In 3D rendering, lighting is used to calculate the shading, shadow, reflection and other effects of objects to increase the realism and stereoscopic sense of the scene.
The lighting model usually includes such factors as the type, color, intensity of the light source, and the material property of the surface of the object. Common lighting models include parallel light, point light, etc.
It includes a series of adjust property. You can use these static property and methods to change the way lighting is displayed and interacts with other objects, as outlined in Lighting property.
Usage example: You can control the real-time effects of post-processing in the editor as follows. Create a script named "LightingExample", place it in the object bar, open the script, enter the following code, run the game, and you can control the lighting brightness through the+and - keys
@Component
export default class LightingExample extends mw.Script {
// When the script is instantiated, this function will be called before the first frame update
protected async onStart(): Promise<void> {
if(SystemUtil.isClient())
{
mw.InputUtil.onKeyDown(Keys.Add,()=>{
// Keypad+Jian, increase lighting brightness by 1 unit
Lighting.skyLightIntensity = Lighting.skyLightIntensity + 1;
Lighting.directionalLightIntensity = Lighting.directionalLightIntensity + 1;
Console.log ("brightness of current light source:"+Lighting. brightness);
// At the same time, change the angle of the directional light, increasing by 5 (angle)
Lighting.pitchAngle = Lighting.pitchAngle + 5;
Console.log ("Current parallel light angle:"+Lighting.pitchAngle);
});
mw.InputUtil.onKeyDown(Keys.Subtract,()=>{
// Keypad - Jian, reduce lighting brightness by 1 unit
Lighting.skyLightIntensity = Lighting.skyLightIntensity - 1;
Lighting.directionalLightIntensity = Lighting.directionalLightIntensity - 1;
// At the same time, change the angle of the directional light, and decrease by 5 (angle)
Lighting.pitchAngle = Lighting.pitchAngle - 5;
Console.log ("Current parallel light angle:"+Lighting.pitchAngle);
});
}
}
}
@Component
export default class LightingExample extends mw.Script {
// When the script is instantiated, this function will be called before the first frame update
protected async onStart(): Promise<void> {
if(SystemUtil.isClient())
{
mw.InputUtil.onKeyDown(Keys.Add,()=>{
// Keypad+Jian, increase lighting brightness by 1 unit
Lighting.skyLightIntensity = Lighting.skyLightIntensity + 1;
Lighting.directionalLightIntensity = Lighting.directionalLightIntensity + 1;
Console.log ("brightness of current light source:"+Lighting. brightness);
// At the same time, change the angle of the directional light, increasing by 5 (angle)
Lighting.pitchAngle = Lighting.pitchAngle + 5;
Console.log ("Current parallel light angle:"+Lighting.pitchAngle);
});
mw.InputUtil.onKeyDown(Keys.Subtract,()=>{
// Keypad - Jian, reduce lighting brightness by 1 unit
Lighting.skyLightIntensity = Lighting.skyLightIntensity - 1;
Lighting.directionalLightIntensity = Lighting.directionalLightIntensity - 1;
// At the same time, change the angle of the directional light, and decrease by 5 (angle)
Lighting.pitchAngle = Lighting.pitchAngle - 5;
Console.log ("Current parallel light angle:"+Lighting.pitchAngle);
});
}
}
}
Table of contents
Accessors
castShadowsEnabled(): boolean other |
---|
Get whether to enable shadows |
directionalLightColor(): LinearColor other |
Obtain parallel light color |
directionalLightIntensity(): number other |
Obtain parallel light intensity |
ev100(): number other |
Obtain exposure value |
lightColor(): LinearColor other |
Obtain color cast value |
pitchAngle(): number other |
Get pitch angle |
shadowsDistance(): number other |
Obtain shadow distance |
skyLightColor(): LinearColor other |
Obtain the color of the sky light |
skyLightIntensity(): number other |
Obtain the intensity of daylight |
skyLightTextureId(): string other |
Obtain the color of the sky light |
temperature(): number other |
Obtain color temperature |
temperatureEnabled(): boolean other |
Obtain whether to enable color temperature |
yawAngle(): number other |
Obtain orientation angle |
Accessors
castShadowsEnabled
• | • | ||||
---|---|---|---|---|---|
Get whether to enable shadows Returns
| Set whether to enable shadows Parameters
|
directionalLightColor
• | • | ||||
---|---|---|---|---|---|
Obtain parallel light color Returns
| Set parallel light color Parameters
|
directionalLightIntensity
• | • | ||||
---|---|---|---|---|---|
Obtain parallel light intensity Returns
| Set parallel light intensity Parameters
|
ev100
• | • | ||||
---|---|---|---|---|---|
Obtain exposure value Returns
| Set exposure value Parameters
|
lightColor
• | • | ||||
---|---|---|---|---|---|
Obtain color cast value Returns
| Set color deviation value Parameters
|
pitchAngle
• | • | ||||
---|---|---|---|---|---|
Get pitch angle Returns
| Set pitch angle (-90~90) Parameters
|
shadowsDistance
• | • | ||||
---|---|---|---|---|---|
Obtain shadow distance Returns
| Set shadow distance Parameters
|
skyLightColor
• | • | ||||
---|---|---|---|---|---|
Obtain the color of the sky light Returns
| Set sky color Parameters
|
skyLightIntensity
• | • | ||||
---|---|---|---|---|---|
Obtain the intensity of daylight Returns
| Set daylight intensity Parameters
|
skyLightTextureId
• | • | ||||
---|---|---|---|---|---|
Obtain the color of the sky light Returns
| Set lighting texture Parameters
|
temperature
• | • | ||||
---|---|---|---|---|---|
Obtain color temperature Returns
| Set color temperature (1000~14000) Parameters
|
temperatureEnabled
• | • | ||||
---|---|---|---|---|---|
Obtain whether to enable color temperature Returns
| Set whether to enable color temperature Parameters
|
yawAngle
• | • | ||||
---|---|---|---|---|---|
Obtain orientation angle Returns
| Set orientation angle (-180~180) Parameters
|