2023-08-14 19:22:04 +02:00
|
|
|
function __3dLightDirectional() : __3dLight() constructor {
|
2023-08-29 14:33:44 +02:00
|
|
|
vertex = [[ new __vertex(1, 0, 0, c_yellow, 0.8), new __vertex(3, 0, 0, c_yellow, 0.8) ]];
|
2023-08-16 20:16:31 +02:00
|
|
|
VF = global.VF_POS_COL;
|
2023-08-14 19:22:04 +02:00
|
|
|
render_type = pr_linelist;
|
2023-08-16 20:16:31 +02:00
|
|
|
VB = build();
|
2023-08-14 19:22:04 +02:00
|
|
|
|
2023-08-16 20:16:31 +02:00
|
|
|
color = c_white;
|
2023-08-14 19:22:04 +02:00
|
|
|
intensity = 1;
|
2023-08-30 16:40:45 +02:00
|
|
|
transform.position.set(4, 0, 0);
|
|
|
|
transform.scale.set(0.6);
|
2023-08-14 19:22:04 +02:00
|
|
|
|
2023-08-22 11:51:45 +02:00
|
|
|
shadow_mapper = sh_d3d_shadow_depth;
|
|
|
|
|
|
|
|
static submitSel = function(params = {}) { #region
|
2023-08-14 19:22:04 +02:00
|
|
|
shader_set(sh_d3d_wireframe);
|
2023-08-16 20:16:31 +02:00
|
|
|
preSubmitVertex(params);
|
2023-08-14 19:22:04 +02:00
|
|
|
shader_reset();
|
2023-08-22 11:51:45 +02:00
|
|
|
} #endregion
|
2023-08-14 19:22:04 +02:00
|
|
|
|
2023-08-16 20:16:31 +02:00
|
|
|
static submitShader = function(params = {}) { params.addLightDirectional(self); }
|
|
|
|
|
2023-08-22 11:51:45 +02:00
|
|
|
static preSubmitVertex = function(params = {}) { #region
|
2023-08-30 16:40:45 +02:00
|
|
|
var _rot = new __rot3(0, 0, 0).lookAt(transform.position, params.camera.position);
|
2023-08-14 19:22:04 +02:00
|
|
|
|
2023-08-16 20:16:31 +02:00
|
|
|
var rot = matrix_build(0, 0, 0,
|
|
|
|
_rot.x, _rot.y, _rot.z,
|
|
|
|
1, 1, 1);
|
|
|
|
var sca = matrix_build(0, 0, 0,
|
|
|
|
0, 0, 0,
|
2023-08-30 16:40:45 +02:00
|
|
|
transform.scale.x, transform.scale.y, transform.scale.z);
|
|
|
|
var pos = matrix_build(transform.position.x, transform.position.y, transform.position.z,
|
2023-08-16 20:16:31 +02:00
|
|
|
0, 0, 0,
|
|
|
|
1, 1, 1);
|
2023-08-14 19:22:04 +02:00
|
|
|
|
2023-08-16 20:16:31 +02:00
|
|
|
matrix_stack_push(pos);
|
|
|
|
matrix_stack_push(rot);
|
|
|
|
|
|
|
|
matrix_set(matrix_world, matrix_stack_top());
|
2023-08-23 20:01:09 +02:00
|
|
|
vertex_submit(VB_UI[0], pr_linestrip, -1);
|
2023-08-16 20:16:31 +02:00
|
|
|
|
|
|
|
matrix_stack_push(sca);
|
|
|
|
matrix_set(matrix_world, matrix_stack_top());
|
2023-08-23 20:01:09 +02:00
|
|
|
vertex_submit(VB_UI[0], pr_linestrip, -1);
|
2023-08-16 20:16:31 +02:00
|
|
|
|
2023-08-30 16:40:45 +02:00
|
|
|
matrix_stack_pop();
|
|
|
|
matrix_stack_pop();
|
|
|
|
matrix_stack_pop();
|
|
|
|
|
2023-08-16 20:16:31 +02:00
|
|
|
matrix_set(matrix_world, matrix_build_identity());
|
2023-08-22 11:51:45 +02:00
|
|
|
} #endregion
|
|
|
|
|
|
|
|
static shadowProjectBegin = function() { #region
|
|
|
|
shadow_map = surface_verify(shadow_map, shadow_map_size, shadow_map_size, surface_r32float);
|
|
|
|
|
2023-08-30 16:40:45 +02:00
|
|
|
shadow_map_view = matrix_build_lookat(transform.position.x, transform.position.y, transform.position.z, 0, 0, 0, 0, 0, -1);
|
2023-08-23 20:01:09 +02:00
|
|
|
shadow_map_proj = matrix_build_projection_ortho(shadow_map_scale, shadow_map_scale, .01, 100);
|
2023-08-22 11:51:45 +02:00
|
|
|
|
|
|
|
surface_set_target(shadow_map);
|
|
|
|
draw_clear(c_black);
|
|
|
|
shader_set(shadow_mapper);
|
|
|
|
gpu_set_ztestenable(true);
|
|
|
|
|
|
|
|
camera_set_view_mat(shadow_map_camera, shadow_map_view);
|
|
|
|
camera_set_proj_mat(shadow_map_camera, shadow_map_proj);
|
|
|
|
camera_apply(shadow_map_camera);
|
|
|
|
} #endregion
|
|
|
|
|
|
|
|
static shadowProjectEnd = function() { #region
|
|
|
|
shader_reset();
|
|
|
|
surface_reset_target();
|
|
|
|
camera_apply(0);
|
|
|
|
gpu_set_ztestenable(false);
|
|
|
|
} #endregion
|
2023-08-14 19:22:04 +02:00
|
|
|
}
|