一.Direct3D光照类型
? ? ?Direct3D将光源分为3种类型,点光源,方向光源,聚光灯源.Direct3D内部会根据光源类型进行2D渲染管线实时计算.
? ? ?Direct3D将光照参数封装在D3DLight9结构体中,重要参数有光源类型,漫反射参数,高光参数等.
typedef struct D3DLIGHT9 {
D3DLIGHTTYPE Type;
D3DCOLORVALUE Diffuse;
D3DCOLORVALUE Specular;
D3DCOLORVALUE Ambient;
D3DVECTOR Position;
D3DVECTOR Direction;
} D3DLIGHT9, *LPD3DLIGHT;
Diffuse-光源发出的漫反射光颜色。
Specular-光源发出的镜面光颜色。
Ambient-光源发出的环境光颜色。
Position-用向量表示的光源世界坐标位置(对方向光无效)。
二.骑砍引擎光照类型
? ? ?骑砍通过将Direct3D中光照类型进行封装后,将灯光分为点光源和日光源.室内场景通过添加场景物spr_light实现点光源,室外场景通过设置日光源参数实现白天和黑夜的光照效果.
? ? 室内场景(sf_indoor)灯光场景物:
#室内场景点光源,可以理解为电灯泡
("light_sun",sokf_invisible,"light_sphere","0", []),
("light",sokf_invisible,"light_sphere","0", []),
("light_red",sokf_invisible,"light_sphere","0", []),
("light_night",sokf_invisible,"light_sphere","0", []),
#设置点光源光照强度,颜色API
set_current_color = 1950 # (set_current_color, <red_value>, <green_value>, <blue_value>),
set_position_delta = 1955 # (set_position_delta, <value>, <value>, <value>),
add_point_light = 1960 # (add_point_light, [flicker_magnitude], [flicker_interval]),
add_point_light_to_entity = 1961 # (add_point_light_to_entity, [flicker_magnitude], [flicker_interval]),
? ? ?室外场景(野外战斗)灯光控制:
set_skybox = 2389 # (set_skybox, <non_hdr_skybox_index>, <hdr_skybox_index>),
#太阳光强度
set_startup_sun_light = 2390 # (set_startup_sun_light, <r>, <g>, <b>),
#漫反射强度
set_startup_ambient_light = 2391 # (set_startup_ambient_light, <r>, <g>, <b>),
#地面漫反射强度
set_startup_ground_ambient_light = 2392 # (set_startup_ground_ambient_light, <r>, <g>, <b>),