use new nice rendering architecture to easily add shadowmap pass
This commit is contained in:
parent
4cc52535fc
commit
f86026b588
@ -36,10 +36,7 @@ Iprof :: #import "Iprof"(IMPORT_MODE = .METAPROGRAM);
|
|||||||
set_build_options_dc(.{do_output = false});
|
set_build_options_dc(.{do_output = false});
|
||||||
|
|
||||||
make_directory_if_it_does_not_exist("dist", recursive = true);
|
make_directory_if_it_does_not_exist("dist", recursive = true);
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
process_result, output, error := run_command("cp", "-r", "./resources", "./dist/", working_directory=tprint("%", #filepath));
|
process_result, output, error := run_command("cp", "-r", "./resources", "./dist/", working_directory=tprint("%", #filepath));
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -160,7 +160,14 @@ backend_process_command_buckets :: () {
|
|||||||
backend_handle_command(it);
|
backend_handle_command(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 2. Shadow pass
|
||||||
|
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = g_shadowmap_attachments}));
|
||||||
|
for render_command_buckets.shadow {
|
||||||
|
backend_handle_command(it);
|
||||||
|
}
|
||||||
|
sg_end_pass();
|
||||||
current_trile_offset_index = 0; // This is not optimal, but it is nice and simple.
|
current_trile_offset_index = 0; // This is not optimal, but it is nice and simple.
|
||||||
|
|
||||||
// 2. Reflection pass
|
// 2. Reflection pass
|
||||||
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = gPipelines.plane.attachments}));
|
sg_begin_pass(*(sg_pass.{ action = state.pass_action_clear, attachments = gPipelines.plane.attachments}));
|
||||||
for render_command_buckets.reflection {
|
for render_command_buckets.reflection {
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
SHADOWMAP_SIZE :: 2000;
|
||||||
|
|
||||||
Pipeline_Binding :: struct {
|
Pipeline_Binding :: struct {
|
||||||
pipeline : sg_pipeline;
|
pipeline : sg_pipeline;
|
||||||
bind : sg_bindings;
|
bind : sg_bindings;
|
||||||
@ -5,7 +7,10 @@ Pipeline_Binding :: struct {
|
|||||||
pass_action : sg_pass_action;
|
pass_action : sg_pass_action;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_specular_lut : sg_image;
|
g_specular_lut : sg_image;
|
||||||
|
g_shadowmap : sg_image;
|
||||||
|
g_shadowmap_img : sg_image; // Apparently we are requried to have one of these, sigh... we don't use this.
|
||||||
|
g_shadowmap_attachments : sg_attachments;
|
||||||
|
|
||||||
gPipelines : struct {
|
gPipelines : struct {
|
||||||
|
|
||||||
@ -28,12 +33,42 @@ gPipelines : struct {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
create_shadowmap_image :: () {
|
||||||
|
w : s32 = SHADOWMAP_SIZE;
|
||||||
|
h : s32 = SHADOWMAP_SIZE;
|
||||||
|
|
||||||
|
if g_shadowmap.id != INVALID_ID then sg_destroy_image(g_shadowmap);
|
||||||
|
|
||||||
|
depth_desc := sg_image_desc.{
|
||||||
|
width = w,
|
||||||
|
height = h,
|
||||||
|
pixel_format = .DEPTH_STENCIL,
|
||||||
|
render_target = true,
|
||||||
|
};
|
||||||
|
img_desc := sg_image_desc.{
|
||||||
|
width = w,
|
||||||
|
height = h,
|
||||||
|
pixel_format = .RGBA8,
|
||||||
|
render_target = true,
|
||||||
|
};
|
||||||
|
g_shadowmap = sg_make_image(*depth_desc);
|
||||||
|
g_shadowmap_img = sg_make_image(*img_desc);
|
||||||
|
attachmentsDesc : sg_attachments_desc;
|
||||||
|
attachmentsDesc = .{
|
||||||
|
colors[0].image = g_shadowmap_img,
|
||||||
|
depth_stencil.image = g_shadowmap,
|
||||||
|
};
|
||||||
|
sg_destroy_attachments(g_shadowmap_attachments);
|
||||||
|
g_shadowmap_attachments = sg_make_attachments(*attachmentsDesc);
|
||||||
|
}
|
||||||
|
|
||||||
create_pipelines :: () {
|
create_pipelines :: () {
|
||||||
create_arbtri_pipeline();
|
create_arbtri_pipeline();
|
||||||
create_trixel_pipeline();
|
create_trixel_pipeline();
|
||||||
create_trile_pipeline();
|
create_trile_pipeline();
|
||||||
create_sky_pipeline();
|
create_sky_pipeline();
|
||||||
create_plane_pipeline();
|
create_plane_pipeline();
|
||||||
|
create_shadowmap_image();
|
||||||
}
|
}
|
||||||
|
|
||||||
TRIXEL_SIZE_HALF : float : 1.0/32.0;
|
TRIXEL_SIZE_HALF : float : 1.0/32.0;
|
||||||
|
|||||||
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#load "groundplane.jai";
|
|
||||||
#load "tasks.jai";
|
#load "tasks.jai";
|
||||||
#load "sky.jai";
|
#load "sky.jai";
|
||||||
#load "core.jai";
|
#load "core.jai";
|
||||||
|
|||||||
@ -76,6 +76,7 @@ tasks_to_commands :: () {
|
|||||||
// Currently no need to draw trixels anywhere but the editor so no
|
// Currently no need to draw trixels anywhere but the editor so no
|
||||||
// need for drawing them in the planar reflection pass...
|
// need for drawing them in the planar reflection pass...
|
||||||
// array_add(*render_command_buckets.reflection, drawCommand);
|
// array_add(*render_command_buckets.reflection, drawCommand);
|
||||||
|
|
||||||
case .TRILE;
|
case .TRILE;
|
||||||
trileTask := (cast(*Rendering_Task_Trile)it);
|
trileTask := (cast(*Rendering_Task_Trile)it);
|
||||||
addPositionsCmd := New(Render_Command_Add_Trile_Positions,, temp);
|
addPositionsCmd := New(Render_Command_Add_Trile_Positions,, temp);
|
||||||
@ -87,6 +88,7 @@ tasks_to_commands :: () {
|
|||||||
drawPositionsCmd.conf = trileTask.worldConf;
|
drawPositionsCmd.conf = trileTask.worldConf;
|
||||||
array_add(*render_command_buckets.reflection, drawPositionsCmd);
|
array_add(*render_command_buckets.reflection, drawPositionsCmd);
|
||||||
array_add(*render_command_buckets.main, drawPositionsCmd);
|
array_add(*render_command_buckets.main, drawPositionsCmd);
|
||||||
|
array_add(*render_command_buckets.shadow, drawPositionsCmd);
|
||||||
case .SKY;
|
case .SKY;
|
||||||
command := New(Render_Command_Sky,, temp);
|
command := New(Render_Command_Sky,, temp);
|
||||||
command.worldConfig = (cast(*Rendering_Task_Sky)it).worldConfig;
|
command.worldConfig = (cast(*Rendering_Task_Sky)it).worldConfig;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user