diff --git a/example/bloom.cpp b/example/bloom.cpp index 96a6fde..9fde573 100644 --- a/example/bloom.cpp +++ b/example/bloom.cpp @@ -194,7 +194,7 @@ constexpr struct opb_size opb_size[ta_cont_count] = { { .opaque = 32 * 4, .opaque_modifier = 0, - .translucent = 8 * 4, + .translucent = 8 * 4, .translucent_modifier = 0, .punch_through = 0 } diff --git a/example/bloom_lightmap.cpp b/example/bloom_lightmap.cpp new file mode 100644 index 0000000..8ecf6a8 --- /dev/null +++ b/example/bloom_lightmap.cpp @@ -0,0 +1,1367 @@ +#include + +#include "holly/background.hpp" +#include "holly/core.hpp" +#include "holly/core_bits.hpp" +#include "holly/holly.hpp" +#include "holly/isp_tsp.hpp" +#include "holly/region_array.hpp" +#include "holly/ta_bits.hpp" +#include "holly/ta_fifo_polygon_converter.hpp" +#include "holly/ta_global_parameter.hpp" +#include "holly/ta_parameter.hpp" +#include "holly/ta_vertex_parameter.hpp" +#include "holly/texture_memory_alloc5.hpp" +#include "holly/video_output.hpp" + +#include "systembus.hpp" +#include "systembus_bits.hpp" + +#include "maple/maple.hpp" +#include "maple/maple_host_command_writer.hpp" +#include "maple/maple_bus_bits.hpp" +#include "maple/maple_bus_commands.hpp" +#include "maple/maple_bus_ft0.hpp" + +#include "memorymap.hpp" + +#include "sh7091/sh7091.hpp" +#include "sh7091/sh7091_bits.hpp" +#include "sh7091/serial.hpp" +#include "printf/printf.h" + +#include "interrupt.hpp" +#include "assert.h" + +#include "math/vec2.hpp" +#include "math/vec3.hpp" +#include "math/vec4.hpp" +#include "math/mat2x2.hpp" +#include "math/mat3x3.hpp" +#include "math/mat4x4.hpp" +#include "math/geometry.hpp" +#include "math/transform.hpp" + +using vec2 = vec<2, float>; +using vec3 = vec<3, float>; +using vec4 = vec<4, float>; +using mat4x4 = mat<4, 4, float>; + +#include "model/blender_export.h" +#include "model/bloom_lightmap/scene.h" + +#include "model/bloom_lightmap/container2.vq.h" +#include "model/bloom_lightmap/container_lightmap.vq.h" +#include "model/bloom_lightmap/floor_lightmap.vq.h" +#include "model/bloom_lightmap/wood.vq.h" + +constexpr int bloom_width = 128; +constexpr int bloom_height = 96; +constexpr float bloom_u_size = 128; +constexpr float bloom_v_size = 128; + +struct texture { + const void * start; + const int size; + const int offset; + const int width; + const int height; +}; + +enum texture_e { + TEX_WOOD, + TEX_CONTAINER2, + TEX_FLOOR_LIGHTMAP, + TEX_CONTAINER_LIGHTMAP, +}; + +const int bloom_size = bloom_width * bloom_height * 2; +const int wood_size = (int)&_binary_model_bloom_lightmap_wood_vq_size; +const int container2_size = (int)&_binary_model_bloom_lightmap_container2_vq_size; +const int floor_lightmap_size = (int)&_binary_model_bloom_lightmap_floor_lightmap_vq_size; +const int container_lightmap_size = (int)&_binary_model_bloom_lightmap_container_lightmap_vq_size; + +const struct texture textures[] = { + [TEX_WOOD] = { + .start = (void *)&_binary_model_bloom_lightmap_wood_vq_start, + .size = wood_size, + .offset = bloom_size, + .width = 1024, + .height = 1024, + }, + [TEX_CONTAINER2] = { + .start = (void *)&_binary_model_bloom_lightmap_container2_vq_start, + .size = container2_size, + .offset = bloom_size + wood_size, + .width = 512, + .height = 512, + }, + [TEX_FLOOR_LIGHTMAP] = { + .start = (void *)&_binary_model_bloom_lightmap_floor_lightmap_vq_start, + .size = floor_lightmap_size, + .offset = bloom_size + wood_size + container2_size, + .width = 1024, + .height = 1024, + }, + [TEX_CONTAINER_LIGHTMAP] = { + .start = (void *)&_binary_model_bloom_lightmap_container_lightmap_vq_start, + .size = container_lightmap_size, + .offset = bloom_size + wood_size + container2_size + floor_lightmap_size, + .width = 1024, + .height = 1024, + }, +}; + +static ft0::data_transfer::data_format data[4]; + +uint8_t send_buf[1024] __attribute__((aligned(32))); +uint8_t recv_buf[1024] __attribute__((aligned(32))); + +void do_get_condition() +{ + auto writer = maple::host_command_writer(send_buf, recv_buf); + + using command_type = maple::get_condition; + using response_type = maple::data_transfer; + + auto [host_command, host_response] + = writer.append_command_all_ports(); + + for (int port = 0; port < 4; port++) { + auto& data_fields = host_command[port].bus_data.data_fields; + data_fields.function_type = std::byteswap(function_type::controller); + } + maple::dma_start(send_buf, writer.send_offset, + recv_buf, writer.recv_offset); + + for (uint8_t port = 0; port < 4; port++) { + auto& bus_data = host_response[port].bus_data; + if (bus_data.command_code != response_type::command_code) { + return; + } + auto& data_fields = bus_data.data_fields; + if ((std::byteswap(data_fields.function_type) & function_type::controller) == 0) { + return; + } + + data[port].digital_button = data_fields.data.digital_button; + for (int i = 0; i < 6; i++) { + data[port].analog_coordinate_axis[i] + = data_fields.data.analog_coordinate_axis[i]; + } + } +} + +void vbr100() +{ + serial::string("vbr100\n"); + interrupt_exception(); +} + +void vbr400() +{ + serial::string("vbr400\n"); + interrupt_exception(); +} + +struct tile_param { + int framebuffer_width; + int framebuffer_height; + int region_array_offset; + consteval int tile_width() const { + return ((uint32_t)framebuffer_width) >> 5; + } + consteval int tile_height() const { + return ((uint32_t)framebuffer_height) >> 5; + } +}; + +constexpr tile_param tile_param[2] = { + { + .framebuffer_width = bloom_width, + .framebuffer_height = bloom_height, + .region_array_offset = 0, + }, + { + .framebuffer_width = 640, + .framebuffer_height = 480, + .region_array_offset = (bloom_width / 32) * (bloom_height / 32) * (sizeof (struct region_array_entry)), + } +}; + +constexpr int ta_cont_count = 2; + +constexpr uint32_t ta_alloc[ta_cont_count] = { + { + ta_alloc_ctrl::pt_opb::no_list + | ta_alloc_ctrl::tm_opb::no_list + | ta_alloc_ctrl::t_opb::no_list + | ta_alloc_ctrl::om_opb::no_list + | ta_alloc_ctrl::o_opb::_32x4byte, + }, + { + ta_alloc_ctrl::pt_opb::_32x4byte + | ta_alloc_ctrl::tm_opb::no_list + | ta_alloc_ctrl::t_opb::_8x4byte + | ta_alloc_ctrl::om_opb::_8x4byte + | ta_alloc_ctrl::o_opb::_32x4byte, + }, +}; + +constexpr struct opb_size opb_size[ta_cont_count] = { + { + .opaque = 32 * 4, + .opaque_modifier = 0, + .translucent = 0, + .translucent_modifier = 0, + .punch_through = 0 + }, + { + .opaque = 32 * 4, + .opaque_modifier = 8 * 4, + .translucent = 8 * 4, + .translucent_modifier = 0, + .punch_through = 32 * 4, + } +}; + +static volatile int ta_in_use = 0; +static volatile int core_in_use = 0; +static volatile int next_frame = 0; +static volatile int framebuffer_ix = 0; +static volatile int next_frame_ix = 0; + +static volatile int render_step = 0; + +static inline void pump_events(uint32_t istnrm) +{ + if (istnrm & istnrm::v_blank_in) { + system.ISTNRM = istnrm::v_blank_in; + + next_frame = 1; + holly.FB_R_SOF1 = texture_memory_alloc.framebuffer[next_frame_ix].start; + } + + if (istnrm & istnrm::end_of_render_tsp) { + system.ISTNRM = istnrm::end_of_render_tsp + | istnrm::end_of_render_isp + | istnrm::end_of_render_video; + + core_in_use = 0; + } + + if (istnrm & istnrm::end_of_transferring_opaque_list) { + system.ISTNRM = istnrm::end_of_transferring_opaque_list; + + ta_in_use = 0; + } +} + +void vbr600() +{ + uint32_t sr; + asm volatile ("stc sr,%0" : "=r" (sr)); + sr |= sh::sr::imask(15); + asm volatile ("ldc %0,sr" : : "r" (sr)); + //serial::string("imask\n"); + + //check_pipeline(); + + if (sh7091.CCN.EXPEVT == 0 && sh7091.CCN.INTEVT == 0x320) { + uint32_t istnrm = system.ISTNRM; + uint32_t isterr = system.ISTERR; + + if (isterr) { + serial::string("isterr: "); + serial::integer(system.ISTERR); + } + + pump_events(istnrm); + + sr &= ~sh::sr::imask(15); + asm volatile ("ldc %0,sr" : : "r" (sr)); + + return; + } + + serial::string("vbr600\n"); + interrupt_exception(); +} + +void global_polygon_type_0(ta_parameter_writer& writer, + uint32_t para_control_obj_control, + uint32_t tsp_instruction_word, + uint32_t texture_control_word, + uint32_t depth_compare_mode = isp_tsp_instruction_word::depth_compare_mode::greater + ) +{ + const uint32_t parameter_control_word = para_control::para_type::polygon_or_modifier_volume + | obj_control::col_type::floating_color + | obj_control::gouraud + | para_control_obj_control + ; + + const uint32_t isp_tsp_instruction_word = depth_compare_mode + | isp_tsp_instruction_word::culling_mode::no_culling + ; + + writer.append() = + ta_global_parameter::polygon_type_0(parameter_control_word, + isp_tsp_instruction_word, + tsp_instruction_word, + texture_control_word, + 0, + 0 + ); +} + +void global_polygon_type_3(ta_parameter_writer& writer, + uint32_t tsp_instruction_word_0, + uint32_t texture_control_word_0, + uint32_t tsp_instruction_word_1, + uint32_t texture_control_word_1) +{ + const uint32_t parameter_control_word = para_control::para_type::polygon_or_modifier_volume + | para_control::list_type::punch_through + | obj_control::col_type::packed_color + | obj_control::gouraud + | obj_control::shadow + | obj_control::volume::polygon::with_two_volumes + | obj_control::texture + ; + + const uint32_t isp_tsp_instruction_word = isp_tsp_instruction_word::depth_compare_mode::greater + | isp_tsp_instruction_word::culling_mode::no_culling // cull_if_negative + ; + + writer.append() = + ta_global_parameter::polygon_type_3(parameter_control_word, + isp_tsp_instruction_word, + tsp_instruction_word_0, + texture_control_word_0, + tsp_instruction_word_1, + texture_control_word_1, + 0, // data_size_for_sort_dma + 0 // next_address_for_sort_dma + ); +} + +static inline float clamp(float f) +{ + if (f > 1.0) + return 1.0; + if (f < 0.0) + return 0.0; + return f; +} + +void transfer_quad(ta_parameter_writer& writer, + vec3 ap, + vec3 bp, + vec3 cp, + vec3 dp, + vec3 ac, + vec3 bc, + vec3 cc, + vec3 dc + ) +{ + if (ap.z < 0 || bp.z < 0 || cp.z < 0 || dp.z < 0) + return; + + const float a = 1.0; + + writer.append() = + ta_vertex_parameter::polygon_type_1(polygon_vertex_parameter_control_word(false), + ap.x, ap.y, ap.z, + a, ac.x, ac.y, ac.z); + + writer.append() = + ta_vertex_parameter::polygon_type_1(polygon_vertex_parameter_control_word(false), + bp.x, bp.y, bp.z, + a, bc.x, bc.y, bc.z); + + writer.append() = + ta_vertex_parameter::polygon_type_1(polygon_vertex_parameter_control_word(false), + dp.x, dp.y, dp.z, + a, dc.x, dc.y, dc.z); + + writer.append() = + ta_vertex_parameter::polygon_type_1(polygon_vertex_parameter_control_word(true), + cp.x, cp.y, cp.z, + a, cc.x, cc.y, cc.z); +} + +void transfer_quad_type_11(ta_parameter_writer& writer, + vec3 ap, + vec3 bp, + vec3 cp, + vec3 dp, + vec2 at0, + vec2 bt0, + vec2 ct0, + vec2 dt0, + vec2 at1, + vec2 bt1, + vec2 ct1, + vec2 dt1, + uint32_t ac, + uint32_t bc, + uint32_t cc, + uint32_t dc + ) +{ + writer.append() = + ta_vertex_parameter::polygon_type_11(polygon_vertex_parameter_control_word(false), + ap.x, ap.y, ap.z, + at0.x, at0.y, + ac, 0, + at1.x, at1.y, + ac, 0); + + writer.append() = + ta_vertex_parameter::polygon_type_11(polygon_vertex_parameter_control_word(false), + bp.x, bp.y, bp.z, + bt0.x, bt0.y, + bc, 0, + bt1.x, bt1.y, + bc, 0); + + writer.append() = + ta_vertex_parameter::polygon_type_11(polygon_vertex_parameter_control_word(false), + dp.x, dp.y, dp.z, + dt0.x, dt0.y, + dc, 0, + dt1.x, dt1.y, + dc, 0); + + writer.append() = + ta_vertex_parameter::polygon_type_11(polygon_vertex_parameter_control_word(true), + cp.x, cp.y, cp.z, + ct0.x, ct0.y, + cc, 0, + ct1.x, ct1.y, + cc, 0); +} + +void transfer_tri_type_11(ta_parameter_writer& writer, + vec3 ap, + vec3 bp, + vec3 cp, + vec2 at0, + vec2 bt0, + vec2 ct0, + vec2 at1, + vec2 bt1, + vec2 ct1, + uint32_t ac, + uint32_t bc, + uint32_t cc + ) +{ + writer.append() = + ta_vertex_parameter::polygon_type_11(polygon_vertex_parameter_control_word(false), + ap.x, ap.y, ap.z, + at0.x, at0.y, + ac, 0, + at1.x, at1.y, + ac, 0); + + writer.append() = + ta_vertex_parameter::polygon_type_11(polygon_vertex_parameter_control_word(false), + bp.x, bp.y, bp.z, + bt0.x, bt0.y, + bc, 0, + bt1.x, bt1.y, + bc, 0); + + writer.append() = + ta_vertex_parameter::polygon_type_11(polygon_vertex_parameter_control_word(true), + cp.x, cp.y, cp.z, + ct0.x, ct0.y, + cc, 0, + ct1.x, ct1.y, + cc, 0); +} + +template +static inline void transfer_tri_textured_clipped(ta_parameter_writer& writer, + vec3 ap, + vec3 bp, + vec3 cp, + vec2 at0, + vec2 bt0, + vec2 ct0, + vec2 at1, + vec2 bt1, + vec2 ct1, + uint32_t c) +{ + const vec3 plane_point = {0.f, 0.f, 0.1f}; + const vec3 plane_normal = {0.f, 0.f, 1.f}; + + vec3 preclip_position[] = {ap, bp, cp}; + vec2 preclip_texture0[] = {at0, bt0, ct0}; + vec2 preclip_texture1[] = {at1, bt1, ct1}; + + vec3 clip_position[4]; + vec2 clip_texture0[4]; + vec2 clip_texture1[4]; + int output_length = geometry::clip_polygon_3<3>(clip_position, + clip_texture0, + clip_texture1, + plane_point, + plane_normal, + preclip_position, + preclip_texture0, + preclip_texture1); + + { + vec3 ap; + vec3 bp; + vec3 cp; + vec3 dp; + + const vec2& at0 = clip_texture0[0]; + const vec2& bt0 = clip_texture0[1]; + const vec2& ct0 = clip_texture0[2]; + const vec2& dt0 = clip_texture0[3]; + + const vec2& at1 = clip_texture1[0]; + const vec2& bt1 = clip_texture1[1]; + const vec2& ct1 = clip_texture1[2]; + const vec2& dt1 = clip_texture1[3]; + + if (output_length >= 3) { + ap = FS(clip_position[0]); + bp = FS(clip_position[1]); + cp = FS(clip_position[2]); + + transfer_tri_type_11(writer, + ap, bp, cp, + at0, bt0, ct0, + at1, bt1, ct1, + c, c, c); + } + if (output_length >= 4) { + dp = FS(clip_position[3]); + + transfer_tri_type_11(writer, + ap, cp, dp, + at0, ct0, dt0, + at1, ct1, dt1, + c, c, c); + } + } +} + +vec3 screen_transform1(const vec3& v) +{ + float w2 = bloom_width / 2.0; + float h2 = bloom_height / 2.0; + float dim = w2; + float iz = 1.0 / v.z; + + return { + v.x * iz * dim + w2, + v.y * iz * dim + h2, + iz, + }; +} + +vec3 screen_transform2(const vec3& v) +{ + float w2 = 640 / 2.0; + float h2 = 480 / 2.0; + float dim = w2; + float iz = 1.0 / v.z; + + return { + v.x * iz * dim + w2, + v.y * iz * dim + h2, + iz, + }; +} + +template +void transfer_mesh(ta_parameter_writer& writer, + const mat4x4& trans, + const object * object, + vec3 base_color) +{ + uint32_t control = para_control::list_type::opaque; + uint32_t tsp_instruction_word = tsp_instruction_word::src_alpha_instr::one + | tsp_instruction_word::dst_alpha_instr::zero + | tsp_instruction_word::texture_shading_instruction::decal + | tsp_instruction_word::fog_control::no_fog + ; + uint32_t texture_control_word = 0; + + global_polygon_type_0(writer, + control, + tsp_instruction_word, + texture_control_word); + + const mesh * mesh = object->mesh; + + vec3 position_cache[mesh->position_length]; + vec3 color_cache[mesh->position_length]; + + mat4x4 trans_p = trans + * translate(object->location) + * rotate_quaternion(object->rotation) + * scale(object->scale); + + for (int i = 0; i < mesh->position_length; i++) { + vec3 p = trans_p * mesh->position[i]; + position_cache[i] = p; + color_cache[i] = FC(trans, base_color, p); + } + + for (int i = 0; i < mesh->polygons_length; i++) { + const polygon * p = &mesh->polygons[i]; + + vec3 ap = FS(position_cache[p->a]); + vec3 bp = FS(position_cache[p->b]); + vec3 cp = FS(position_cache[p->c]); + vec3 dp = FS(position_cache[p->d]); + + vec3 ac = color_cache[p->a]; + vec3 bc = color_cache[p->b]; + vec3 cc = color_cache[p->c]; + vec3 dc = color_cache[p->d]; + + transfer_quad(writer, ap, bp, cp, dp, ac, bc, cc, dc); + } +} + +vec3 color_diffuse(const mat4x4& trans, const vec3& base_color, const vec3& normal, const vec3& vertex_position); +vec3 color_specular(const mat4x4& trans, const vec3& base_color, const vec3& normal, const vec3& vertex_position); + +template +void transfer_mesh_textured(ta_parameter_writer& writer, + const mat4x4& trans, + const object * object, + const texture * texture0, + float uv_mul, + const texture * texture1) +{ + uint32_t tsp_instruction_word = tsp_instruction_word::fog_control::no_fog + | tsp_instruction_word::texture_shading_instruction::modulate + | tsp_instruction_word::filter_mode::bilinear_filter; + + uint32_t texture_control_word = texture_control_word::pixel_format::_565 + | texture_control_word::scan_order::twiddled + | texture_control_word::vq_compressed; + + uint32_t tsp_instruction_word_0 = tsp_instruction_word + | tsp_instruction_word::src_alpha_instr::one + | tsp_instruction_word::dst_alpha_instr::zero + | tsp_instruction_word::texture_u_size::from_int(texture0->width) + | tsp_instruction_word::texture_v_size::from_int(texture0->height); + + uint32_t texture_address_0 = texture_memory_alloc.texture.start + texture0->offset; + uint32_t texture_control_word_0 = texture_control_word + | texture_control_word::texture_address(texture_address_0 / 8); + + uint32_t tsp_instruction_word_1 = tsp_instruction_word + | tsp_instruction_word::src_alpha_instr::other_color + | tsp_instruction_word::dst_alpha_instr::zero + | tsp_instruction_word::texture_u_size::from_int(texture1->width) + | tsp_instruction_word::texture_v_size::from_int(texture1->height); + + uint32_t texture_address_1 = texture_memory_alloc.texture.start + texture1->offset; + uint32_t texture_control_word_1 = texture_control_word + | texture_control_word::texture_address(texture_address_1 / 8); + + global_polygon_type_3(writer, + tsp_instruction_word_0, + texture_control_word_0, + tsp_instruction_word_1, + texture_control_word_1); + + const mesh * mesh = object->mesh; + + vec3 position_cache[mesh->position_length]; + + mat4x4 trans_p = trans + * translate(object->location) + * rotate_quaternion(object->rotation) + * scale(object->scale); + + //mat4x4 trans_n = trans + //* rotate_quaternion(object->rotation); + + for (int i = 0; i < mesh->position_length; i++) { + vec3 p = trans_p * mesh->position[i]; + position_cache[i] = p; + } + + for (int i = 0; i < mesh->polygons_length; i++) { + const polygon * p = &mesh->polygons[i]; + + //vec3 normal = normalize(normal_multiply(trans_n, mesh->polygon_normal[i])); + + vec3 ap = position_cache[p->a]; + vec3 bp = position_cache[p->b]; + vec3 cp = position_cache[p->c]; + vec3 dp = position_cache[p->d]; + + if (ap.z < 0 && bp.z < 0 && cp.z < 0 && dp.z < 0) + continue; + + //vec3 ac = color_cache[p->a];// * color_diffuse(trans_p, base_color, normal, ap); + //vec3 bc = color_cache[p->b];// * color_diffuse(trans_p, base_color, normal, bp); + //vec3 cc = color_cache[p->c];// * color_diffuse(trans_p, base_color, normal, cp); + //vec3 dc = color_cache[p->d];// * color_diffuse(trans_p, base_color, normal, dp); + + vec2 at0 = mesh->uv_layers[0][i * 4 + 0] * uv_mul; + vec2 bt0 = mesh->uv_layers[0][i * 4 + 1] * uv_mul; + vec2 ct0 = mesh->uv_layers[0][i * 4 + 2] * uv_mul; + vec2 dt0 = mesh->uv_layers[0][i * 4 + 3] * uv_mul; + + vec2 at1 = mesh->uv_layers[1][i * 4 + 0]; + vec2 bt1 = mesh->uv_layers[1][i * 4 + 1]; + vec2 ct1 = mesh->uv_layers[1][i * 4 + 2]; + vec2 dt1 = mesh->uv_layers[1][i * 4 + 3]; + + at1.y = 1.0 - at1.y; + bt1.y = 1.0 - bt1.y; + ct1.y = 1.0 - ct1.y; + dt1.y = 1.0 - dt1.y; + + uint32_t c = 0xffffffff; + + if (ap.z < 0 || bp.z < 0 || cp.z < 0 || dp.z < 0) { + transfer_tri_textured_clipped(writer, + ap, bp, dp, + at0, bt0, dt0, + at1, bt1, dt1, + c); + + transfer_tri_textured_clipped(writer, + bp, cp, dp, + bt0, ct0, dt0, + bt1, ct1, dt1, + c); + } + else { + transfer_quad_type_11(writer, + FS(ap), FS(bp), FS(cp), FS(dp), + at0, bt0, ct0, dt0, + at1, bt1, ct1, dt1, + c, c, c, c); + } + } +} + +constexpr vec2 plane[] = { + { 0, 0}, + { 1, 0}, + { 1, 1}, + { 0, 1}, +}; + +const vec3 colors[] = { + {0, 0, 1}, + {0, 1, 0}, + {1, 0, 0}, + {1, 1, 1}, +}; + +vec3 color_identity(const mat4x4& trans, const vec3& base_color, const vec3& position) +{ + return base_color; +} + +vec3 color_diffuse(const mat4x4& trans, const vec3& base_color, const vec3& normal, const vec3& vertex_position) +{ + vec3 attenuation = {0, 0, 0}; + + for (int i = 0; i < 4; i++) { + const object * object = &objects[6 + i]; + vec3 light_position = trans * object->location; + + vec3 light_dir = normalize(light_position - vertex_position); + + float diffuse = max(dot(normal, light_dir), 0.0f); + attenuation += colors[i] * diffuse; + } + + return base_color * attenuation; +} + +vec3 color_specular(const mat4x4& trans, const vec3& base_color, const vec3& normal, const vec3& vertex_position) +{ + vec3 attenuation = {0.1, 0.1, 0.1}; + + for (int i = 0; i < 4; i++) { + const object * object = &objects[6 + i]; + vec3 light_position = trans * object->location; + + vec3 light_dir = normalize(light_position - vertex_position); + vec3 view_position = {0, 0, 0}; + vec3 view_dir = normalize(view_position - vertex_position); + vec3 reflect_dir = reflect(-light_dir, normal); + float specular = __builtin_powf(max(dot(view_dir, reflect_dir), 0.0f), 64.0f); + + attenuation += colors[i] * specular; + } + + return base_color * attenuation; +} + +vec3 color_point(const mat4x4& trans, const vec3& base_color, const vec3& position) +{ + float constant = 1.0; + float linear = 0.7; + float quadratic = 1.8; + + vec3 attenuation = {0, 0, 0}; + + for (int i = 0; i < 4; i++) { + const object * object = &objects[6 + i]; + vec3 light_position = trans * object->location; + + float distance = magnitude(light_position - position); + float intensity = 1.0 / (constant + + linear * distance + + quadratic * (distance * distance)); + attenuation += colors[i] * intensity; + } + + return base_color * attenuation; +} + +void transfer_modifier_volume(ta_parameter_writer& writer) +{ + const uint32_t parameter_control_word = para_control::para_type::polygon_or_modifier_volume + | para_control::list_type::opaque_modifier_volume; + + const uint32_t isp_tsp_instruction_word = isp_tsp_instruction_word::volume_instruction::normal_polygon + | isp_tsp_instruction_word::culling_mode::no_culling; + + writer.append() = + ta_global_parameter::modifier_volume(parameter_control_word, + isp_tsp_instruction_word + ); + + writer.append() = + ta_vertex_parameter::modifier_volume(modifier_volume_vertex_parameter_control_word(), + 0, 0, 1000, + 640, 0, 1000, + 640, 480, 1000); + + const uint32_t last_parameter_control_word = para_control::para_type::polygon_or_modifier_volume + | para_control::list_type::opaque_modifier_volume + | obj_control::volume::modifier_volume::last_in_volume; + + const uint32_t last_isp_tsp_instruction_word = isp_tsp_instruction_word::volume_instruction::inside_last_polygon + | isp_tsp_instruction_word::culling_mode::no_culling; + + writer.append() = + ta_global_parameter::modifier_volume(last_parameter_control_word, + last_isp_tsp_instruction_word); + + writer.append() = + ta_vertex_parameter::modifier_volume(modifier_volume_vertex_parameter_control_word(), + 0, 0, 1000, + 640, 480, 1000, + 0, 480, 1000); +} + +void transfer_scene1(ta_parameter_writer& writer, const mat4x4& trans) +{ + vec3 zero = {0, 0, 0}; + + { // opaque + transfer_mesh(writer, trans, &objects[0], zero); + for (int i = 1; i < 6; i++) { + transfer_mesh(writer, trans, &objects[i], zero); + } + + for (int i = 0; i < 4; i++) { + transfer_mesh(writer, trans, &objects[6 + i], colors[i]); + } + + writer.append() = + ta_global_parameter::end_of_list(para_control::para_type::end_of_list); + } +} + +void transfer_quad_textured(ta_parameter_writer& writer, + vec3 ap, + vec3 bp, + vec3 cp, + vec3 dp, + vec2 at, + vec2 bt, + vec2 ct, + vec2 dt, + vec3 ac, + vec3 bc, + vec3 cc, + vec3 dc + ) +{ + if (ap.z < 0 || bp.z < 0 || cp.z < 0 || dp.z < 0) + return; + + const float a = 1.0; + + writer.append() = + ta_vertex_parameter::polygon_type_5(polygon_vertex_parameter_control_word(false), + ap.x, ap.y, ap.z, + at.x, at.y, + a, ac.x, ac.y, ac.z, + 0, 0, 0, 0); + + writer.append() = + ta_vertex_parameter::polygon_type_5(polygon_vertex_parameter_control_word(false), + bp.x, bp.y, bp.z, + bt.x, bt.y, + a, bc.x, bc.y, bc.z, + 0, 0, 0, 0); + + writer.append() = + ta_vertex_parameter::polygon_type_5(polygon_vertex_parameter_control_word(false), + dp.x, dp.y, dp.z, + dt.x, dt.y, + a, dc.x, dc.y, dc.z, + 0, 0, 0, 0); + + writer.append() = + ta_vertex_parameter::polygon_type_5(polygon_vertex_parameter_control_word(true), + cp.x, cp.y, cp.z, + ct.x, ct.y, + a, cc.x, cc.y, cc.z, + 0, 0, 0, 0); +} + +void transfer_ss_plane(ta_parameter_writer& writer, vec3 c) +{ + uint32_t control = para_control::list_type::translucent + | obj_control::texture; + uint32_t tsp_instruction_word = tsp_instruction_word::src_alpha_instr::one + | tsp_instruction_word::dst_alpha_instr::one + | tsp_instruction_word::texture_shading_instruction::decal + | tsp_instruction_word::fog_control::no_fog + | tsp_instruction_word::texture_u_size::from_int(bloom_u_size) + | tsp_instruction_word::texture_v_size::from_int(bloom_v_size) + | tsp_instruction_word::filter_mode::bilinear_filter + | tsp_instruction_word::clamp_uv::uv; + + const uint32_t texture_address = texture_memory_alloc.texture.start; + const uint32_t texture_control_word = texture_control_word::pixel_format::_565 + | texture_control_word::scan_order::non_twiddled + | texture_control_word::texture_address(texture_address / 8); + + global_polygon_type_0(writer, + control, + tsp_instruction_word, + texture_control_word, + isp_tsp_instruction_word::depth_compare_mode::always); + + constexpr vec3 size = {640, 480, 1}; + + constexpr vec3 ap = (vec3){plane[0].x, plane[0].y, 0.1} * size; + constexpr vec3 bp = (vec3){plane[1].x, plane[1].y, 0.1} * size; + constexpr vec3 cp = (vec3){plane[2].x, plane[2].y, 0.1} * size; + constexpr vec3 dp = (vec3){plane[3].x, plane[3].y, 0.1} * size; + + constexpr vec2 tscale = { + (float)bloom_width / bloom_u_size, + (float)bloom_height / bloom_v_size + }; + + constexpr vec2 at = plane[0] * tscale; + constexpr vec2 bt = plane[1] * tscale; + constexpr vec2 ct = plane[2] * tscale; + constexpr vec2 dt = plane[3] * tscale; + + transfer_quad_textured(writer, + ap, bp, cp, dp, + at, bt, ct, dt, + c, c, c, c); +} + +void transfer_scene2(ta_parameter_writer& writer, const mat4x4& trans) +{ + { // modifier volume + transfer_modifier_volume(writer); + + writer.append() = + ta_global_parameter::end_of_list(para_control::para_type::end_of_list); + } + + { // punch through + transfer_mesh_textured(writer, trans, &objects[0], + &textures[TEX_WOOD], + 2, + &textures[TEX_FLOOR_LIGHTMAP] + ); + for (int i = 1; i < 6; i++) { + transfer_mesh_textured(writer, trans, &objects[i], + &textures[TEX_CONTAINER2], + 1, + &textures[TEX_CONTAINER_LIGHTMAP] + ); + } + + writer.append() = + ta_global_parameter::end_of_list(para_control::para_type::end_of_list); + } + + { // translucent + transfer_ss_plane(writer, colors[3]); + + writer.append() = + ta_global_parameter::end_of_list(para_control::para_type::end_of_list); + } + + { // opaque + for (int i = 0; i < 4; i++) { + transfer_mesh(writer, trans, &objects[6 + i], colors[i]); + } + + writer.append() = + ta_global_parameter::end_of_list(para_control::para_type::end_of_list); + } +} + +void update_analog(mat4x4& screen) +{ + const float l_ = static_cast(data[0].analog_coordinate_axis[0]) * (1.f / 255.f); + const float r_ = static_cast(data[0].analog_coordinate_axis[1]) * (1.f / 255.f); + + const float x_ = static_cast(data[0].analog_coordinate_axis[2] - 0x80) / 127.f; + const float y_ = static_cast(data[0].analog_coordinate_axis[3] - 0x80) / 127.f; + + float yt = -0.05f * x_; + float xt = 0.05f * y_; + + mat4x4 ry = rotate_z(yt); + mat4x4 rx = rotate_x(xt); + + screen = screen * ry * rx; +} + +void ch1_dma_transfer(void * source, void * destination, uint32_t transfers) +{ + using namespace dmac; + + volatile uint32_t _dummy = sh7091.DMAC.CHCR1; + (void)_dummy; + + sh7091.DMAC.CHCR1 = 0; + + assert((((uint32_t)source) & 0b11111) == 0); + assert((((uint32_t)destination) & 0b11111) == 0); + sh7091.DMAC.SAR1 = (uint32_t)source; + sh7091.DMAC.DAR1 = (uint32_t)destination; + sh7091.DMAC.DMATCR1 = transfers & 0x00ff'ffff; + + sh7091.DMAC.CHCR1 = chcr::dm::destination_address_incremented + | chcr::sm::source_address_incremented + | chcr::rs::resource_select(0b0100) /* auto request, external address space → external address space */ + | chcr::tm::cycle_burst_mode /* transmit mode */ + //| chcr::tm::cycle_steal_mode /* transmit mode */ + | chcr::ts::_32_byte /* transfer size */ + //| chcr::ie::interrupt_request_generated + | chcr::de::channel_operation_enabled; + + for (uint32_t i = 0; i < transfers; i++) { + asm volatile ("ocbp @%0" + : // output + : "r" (((uint32_t)destination) + (32 * i)) // input + ); + } + + // wait for DMA completion + while ((sh7091.DMAC.CHCR1 & dmac::chcr::te::transfers_completed) == 0); +} + +void ch2_dma_transfer(void * source, void * destination, uint32_t transfers) +{ + using namespace dmac; + + assert((((uint32_t)source) & 0b11111) == 0); + assert((((uint32_t)destination) & 0b11111) == 0); + + for (uint32_t i = 0; i < transfers; i++) { + asm volatile ("ocbwb @%0" + : // output + : "r" (((uint32_t)source) + (32 * i)) // input + ); + } + + // this dummy read appears to be required on real hardware. + volatile uint32_t _dummy = sh7091.DMAC.CHCR2; + (void)_dummy; + + /* start a new CH2-DMA transfer from "system memory" to "TA FIFO polygon converter" */ + sh7091.DMAC.CHCR2 = 0; /* disable DMA channel */ + + sh7091.DMAC.SAR2 = (uint32_t)source; /* start address, must be aligned to a CHCHR__TS-sized (32-byte) boundary */ + sh7091.DMAC.DMATCR2 = dmatcr::transfer_count(transfers); /* transfer count, in CHCHR__TS-sized (32-byte) units */ + sh7091.DMAC.CHCR2 = chcr::dm::destination_address_incremented + | chcr::sm::source_address_incremented + | chcr::rs::resource_select(0b0010) /* external request, single address mode; + external address space → external device */ + | chcr::tm::cycle_burst_mode /* transmit mode */ + | chcr::ts::_32_byte /* transfer size */ + | chcr::de::channel_operation_enabled; + + system.C2DSTAT = c2dstat::texture_memory_start_address((uint32_t)destination); /* CH2-DMA destination address */ + system.C2DLEN = c2dlen::transfer_length(transfers * 32); /* CH2-DMA length (must be a multiple of 32) */ + system.C2DST = 1; /* CH2-DMA start (an 'external' request from SH7091's perspective) */ + + // wait for ch2-dma completion + while ((system.ISTNRM & istnrm::end_of_dma_ch2_dma) == 0); + // reset ch2-dma interrupt status + system.ISTNRM = istnrm::end_of_dma_ch2_dma; +} + +static void dma_init() +{ + using namespace dmac; + + sh7091.DMAC.CHCR0 = 0; + sh7091.DMAC.CHCR1 = 0; + sh7091.DMAC.CHCR2 = 0; + sh7091.DMAC.CHCR3 = 0; + sh7091.DMAC.DMAOR = dmaor::ddt::on_demand_data_transfer_mode /* on-demand data transfer mode */ + | dmaor::pr::ch2_ch0_ch1_ch3 /* priority mode; CH2 > CH0 > CH1 > CH3 */ + | dmaor::dme::operation_enabled_on_all_channels; /* DMAC master enable */ + +} + +void gauss_rgb565(uint16_t const * const src, uint16_t * const dst); + +void transfer_ta_fifo_texture_memory_32byte(void * dst, const void * src, int length) +{ + assert((((int)dst) & 31) == 0); + assert((((int)length) & 31) == 0); + + uint32_t out_addr = (uint32_t)dst; + sh7091.CCN.QACR0 = ((reinterpret_cast(out_addr) >> 24) & 0b11100); + sh7091.CCN.QACR1 = ((reinterpret_cast(out_addr) >> 24) & 0b11100); + + volatile uint32_t * base = &store_queue[(out_addr & 0x03ffffe0) / 4]; + const uint32_t * src32 = reinterpret_cast(src); + + length = (length + 31) & ~31; // round up to nearest multiple of 32 + while (length > 0) { + base[0] = src32[0]; + base[1] = src32[1]; + base[2] = src32[2]; + base[3] = src32[3]; + base[4] = src32[4]; + base[5] = src32[5]; + base[6] = src32[6]; + base[7] = src32[7]; + asm volatile ("pref @%0" + : // output + : "r" (&base[0]) // input + : "memory"); + length -= 32; + base += 8; + src32 += 8; + } +} + +void transfer_bloom_scene_textures() +{ + uint32_t last_end = 0; + + for (uint32_t i = 0; i < (sizeof (textures)) / (sizeof (textures[0])); i++) { + uint32_t offset = texture_memory_alloc.texture.start + textures[i].offset; + void * dst = reinterpret_cast(&ta_fifo_texture_memory[offset / 4]); + + assert(offset >= last_end); + last_end = offset + textures[i].size; + assert(last_end < 0x800000); + + transfer_ta_fifo_texture_memory_32byte(dst, textures[i].start, textures[i].size); + } +} + +void transfer_textures() +{ + system.LMMODE0 = 0; + system.LMMODE1 = 0; // 64-bit + + transfer_bloom_scene_textures(); +} + +uint8_t __attribute__((aligned(32))) ta_parameter_buf1[1024 * 1024]; +uint8_t __attribute__((aligned(32))) ta_parameter_buf2[1024 * 1024]; + +int main() +{ + serial::init(0); + + interrupt_init(); + dma_init(); + transfer_textures(); + + holly.SOFTRESET = softreset::pipeline_soft_reset + | softreset::ta_soft_reset; + holly.SOFTRESET = 0; + + core_init(); + + holly.FPU_SHAD_SCALE = fpu_shad_scale::simple_shadow_enable::parameter_selection_volume_mode; + holly.TEXT_CONTROL = text_control::stride(5); + + system.IML6NRM = istnrm::end_of_render_tsp + | istnrm::v_blank_in + | istnrm::end_of_transferring_opaque_list; + + region_array_multipass(tile_param[0].tile_width(), + tile_param[0].tile_height(), + &opb_size[0], + 1, + texture_memory_alloc.region_array.start + tile_param[0].region_array_offset, + texture_memory_alloc.object_list.start); + + region_array_multipass(tile_param[1].tile_width(), + tile_param[1].tile_height(), + &opb_size[1], + 1, + texture_memory_alloc.region_array.start + tile_param[1].region_array_offset, + texture_memory_alloc.object_list.start, + REGION_ARRAY__PRE_SORT); + + background_parameter2(texture_memory_alloc.background[0].start, + 0xff000000); + background_parameter2(texture_memory_alloc.background[1].start, + 0xff000000); + + ta_parameter_writer writer1 = ta_parameter_writer(ta_parameter_buf1, (sizeof (ta_parameter_buf1))); + ta_parameter_writer writer2 = ta_parameter_writer(ta_parameter_buf2, (sizeof (ta_parameter_buf2))); + + video_output::set_mode_vga(); + + mat4x4 screen_trans = { + 1, 0, 0, 0, + 0, 0, -1, 0, + 0, 1, 0, 3, + 0, 0, 0, 1, + }; + + do_get_condition(); + while (1) { + maple::dma_wait_complete(); + do_get_condition(); + + update_analog(screen_trans); + + writer1.offset = 0; + transfer_scene1(writer1, screen_trans); + writer2.offset = 0; + transfer_scene2(writer2, screen_trans); + + if (1) { // ta 0 + assert(!ta_in_use); ta_in_use = 1; + ta_polygon_converter_init2(texture_memory_alloc.isp_tsp_parameters.start, + texture_memory_alloc.isp_tsp_parameters.end, + texture_memory_alloc.object_list.start, + texture_memory_alloc.object_list.end, + opb_size[0].total(), + ta_alloc[0], + tile_param[0].tile_width(), + tile_param[0].tile_height()); + ta_polygon_converter_writeback(writer1.buf, writer1.offset); + ta_polygon_converter_transfer(writer1.buf, writer1.offset); + + while (ta_in_use); + } + + if (1) { // core 0 + assert(!core_in_use); core_in_use = 1; + + uint32_t region_array_start = texture_memory_alloc.region_array.start + + tile_param[0].region_array_offset; + uint32_t framebuffer_start = 0x100'0000 | texture_memory_alloc.texture.start; + core_start_render2(region_array_start, + texture_memory_alloc.isp_tsp_parameters.start, + texture_memory_alloc.background[0].start, + framebuffer_start, + tile_param[0].framebuffer_width + ); + + while (core_in_use); + } + + { // gauss + static uint16_t input[bloom_width * bloom_height] __attribute__((aligned(32))); + static uint16_t output[bloom_width * bloom_height] __attribute__((aligned(32))); + static_assert((sizeof (input)) == (sizeof (output))); + + uint32_t transfers = (sizeof (input)) / 32; + void * texture = (void *)&texture_memory64[texture_memory_alloc.texture.start / 4]; + ch1_dma_transfer(texture, input, transfers); + + gauss_rgb565(input, output); + + ch1_dma_transfer(output, texture, transfers); + } + + { // ta 1 + assert(!ta_in_use); ta_in_use = 1; + + ta_polygon_converter_init2(texture_memory_alloc.isp_tsp_parameters.start, + texture_memory_alloc.isp_tsp_parameters.end, + texture_memory_alloc.object_list.start, + texture_memory_alloc.object_list.end, + opb_size[1].total(), + ta_alloc[1], + tile_param[1].tile_width(), + tile_param[1].tile_height()); + ta_polygon_converter_writeback(writer2.buf, writer2.offset); + ta_polygon_converter_transfer(writer2.buf, writer2.offset); + + while (ta_in_use); + } + + { // core 1 + assert(!core_in_use); core_in_use = 1; + + uint32_t region_array_start = texture_memory_alloc.region_array.start + + tile_param[1].region_array_offset; + uint32_t framebuffer_start = texture_memory_alloc.framebuffer[framebuffer_ix].start; + + system.ISTERR = 0xffffffff; + + core_start_render2(region_array_start, + texture_memory_alloc.isp_tsp_parameters.start, + texture_memory_alloc.background[1].start, + framebuffer_start, + tile_param[1].framebuffer_width); + + int count = 0; + while (core_in_use) { + if (count++ > 300000) { + printf("isterr %08x istnrm %08x\n", system.ISTERR, system.ISTNRM); + holly.SOFTRESET = softreset::pipeline_soft_reset + | softreset::ta_soft_reset; + holly.SOFTRESET = 0; + core_in_use = 0; + break; + } + } + } + + { + next_frame_ix = framebuffer_ix; + framebuffer_ix += 1; + if (framebuffer_ix >= 3) framebuffer_ix = 0; + } + + while (next_frame == 0); + next_frame = 0; + } +} diff --git a/example/example.mk b/example/example.mk index 4179f89..0ae62d8 100644 --- a/example/example.mk +++ b/example/example.mk @@ -1106,3 +1106,26 @@ BLOOM_OBJ = \ example/bloom.elf: LDSCRIPT = $(LIB)/main.lds example/bloom.elf: $(START_OBJ) $(BLOOM_OBJ) + +BLOOM_LIGHTMAP_OBJ = \ + example/bloom_lightmap.o \ + holly/core.o \ + holly/region_array.o \ + holly/background.o \ + holly/ta_fifo_polygon_converter.o \ + holly/video_output.o \ + sh7091/serial.o \ + maple/maple.o \ + sh7091/c_serial.o \ + printf/printf.o \ + printf/unparse.o \ + printf/parse.o \ + gauss.o \ + model/bloom_lightmap/container2.vq.o \ + model/bloom_lightmap/container_lightmap.vq.o \ + model/bloom_lightmap/floor_lightmap.vq.o \ + model/bloom_lightmap/wood.vq.o \ + $(LIBGCC) + +example/bloom_lightmap.elf: LDSCRIPT = $(LIB)/main.lds +example/bloom_lightmap.elf: $(START_OBJ) $(BLOOM_LIGHTMAP_OBJ) diff --git a/model/bloom_lightmap/container2.png b/model/bloom_lightmap/container2.png new file mode 100644 index 0000000..800c63e Binary files /dev/null and b/model/bloom_lightmap/container2.png differ diff --git a/model/bloom_lightmap/container2.vq b/model/bloom_lightmap/container2.vq new file mode 100644 index 0000000..e64af59 Binary files /dev/null and b/model/bloom_lightmap/container2.vq differ diff --git a/model/bloom_lightmap/container2.vq.h b/model/bloom_lightmap/container2.vq.h new file mode 100644 index 0000000..e95520a --- /dev/null +++ b/model/bloom_lightmap/container2.vq.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern uint32_t _binary_model_bloom_lightmap_container2_vq_start __asm("_binary_model_bloom_lightmap_container2_vq_start"); +extern uint32_t _binary_model_bloom_lightmap_container2_vq_end __asm("_binary_model_bloom_lightmap_container2_vq_end"); +extern uint32_t _binary_model_bloom_lightmap_container2_vq_size __asm("_binary_model_bloom_lightmap_container2_vq_size"); + +#ifdef __cplusplus +} +#endif diff --git a/model/bloom_lightmap/container_lightmap.png b/model/bloom_lightmap/container_lightmap.png new file mode 100644 index 0000000..49997aa Binary files /dev/null and b/model/bloom_lightmap/container_lightmap.png differ diff --git a/model/bloom_lightmap/container_lightmap.vq b/model/bloom_lightmap/container_lightmap.vq new file mode 100644 index 0000000..7df9edd Binary files /dev/null and b/model/bloom_lightmap/container_lightmap.vq differ diff --git a/model/bloom_lightmap/container_lightmap.vq.h b/model/bloom_lightmap/container_lightmap.vq.h new file mode 100644 index 0000000..632752d --- /dev/null +++ b/model/bloom_lightmap/container_lightmap.vq.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern uint32_t _binary_model_bloom_lightmap_container_lightmap_vq_start __asm("_binary_model_bloom_lightmap_container_lightmap_vq_start"); +extern uint32_t _binary_model_bloom_lightmap_container_lightmap_vq_end __asm("_binary_model_bloom_lightmap_container_lightmap_vq_end"); +extern uint32_t _binary_model_bloom_lightmap_container_lightmap_vq_size __asm("_binary_model_bloom_lightmap_container_lightmap_vq_size"); + +#ifdef __cplusplus +} +#endif diff --git a/model/bloom_lightmap/cubes.blend b/model/bloom_lightmap/cubes.blend new file mode 100644 index 0000000..d62f61d Binary files /dev/null and b/model/bloom_lightmap/cubes.blend differ diff --git a/model/bloom_lightmap/floor_lightmap.png b/model/bloom_lightmap/floor_lightmap.png new file mode 100644 index 0000000..e567099 Binary files /dev/null and b/model/bloom_lightmap/floor_lightmap.png differ diff --git a/model/bloom_lightmap/floor_lightmap.vq b/model/bloom_lightmap/floor_lightmap.vq new file mode 100644 index 0000000..00990a2 Binary files /dev/null and b/model/bloom_lightmap/floor_lightmap.vq differ diff --git a/model/bloom_lightmap/floor_lightmap.vq.h b/model/bloom_lightmap/floor_lightmap.vq.h new file mode 100644 index 0000000..7aef360 --- /dev/null +++ b/model/bloom_lightmap/floor_lightmap.vq.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern uint32_t _binary_model_bloom_lightmap_floor_lightmap_vq_start __asm("_binary_model_bloom_lightmap_floor_lightmap_vq_start"); +extern uint32_t _binary_model_bloom_lightmap_floor_lightmap_vq_end __asm("_binary_model_bloom_lightmap_floor_lightmap_vq_end"); +extern uint32_t _binary_model_bloom_lightmap_floor_lightmap_vq_size __asm("_binary_model_bloom_lightmap_floor_lightmap_vq_size"); + +#ifdef __cplusplus +} +#endif diff --git a/model/bloom_lightmap/scene.h b/model/bloom_lightmap/scene.h new file mode 100644 index 0000000..4b9df47 --- /dev/null +++ b/model/bloom_lightmap/scene.h @@ -0,0 +1,761 @@ +const vec3 mesh_Plane_position[] = { + {-1.000000, -1.000000, 0.000000}, + {1.000000, -1.000000, 0.000000}, + {-1.000000, 1.000000, 0.000000}, + {1.000000, 1.000000, 0.000000}, +}; + +const vec2 mesh_Plane_UVMap_uvmap[] = { + {0.000000, 0.000000}, + {1.000000, 0.000000}, + {1.000000, 1.000000}, + {0.000000, 1.000000}, +}; + +const vec2 mesh_Plane_lightmap_uvmap[] = { + {0.997996, 0.002004}, + {0.002004, 0.002004}, + {0.002004, 0.997996}, + {0.997996, 0.997996}, +}; + +const vec3 mesh_Plane_normal[] = { + {0.000000, 0.000000, 1.000000}, + {0.000000, 0.000000, 1.000000}, + {0.000000, 0.000000, 1.000000}, + {0.000000, 0.000000, 1.000000}, +}; + +const vec3 mesh_Plane_polygon_normal[] = { + {0.000000, 0.000000, 1.000000}, +}; + +const polygon mesh_Plane_polygons[] = { + {0, 1, 3, 2}, +}; + +const vec2 * mesh_Plane_uv_layers[] = { + mesh_Plane_UVMap_uvmap, + mesh_Plane_lightmap_uvmap, +}; + +const mesh mesh_Plane = { + .position = mesh_Plane_position, + .position_length = (sizeof (mesh_Plane_position)) / (sizeof (mesh_Plane_position[0])), + .normal = mesh_Plane_normal, + .normal_length = (sizeof (mesh_Plane_normal)) / (sizeof (mesh_Plane_normal[0])), + .polygon_normal = mesh_Plane_polygon_normal, + .polygon_normal_length = (sizeof (mesh_Plane_polygon_normal)) / (sizeof (mesh_Plane_polygon_normal[0])), + .polygons = mesh_Plane_polygons, + .polygons_length = (sizeof (mesh_Plane_polygons)) / (sizeof (mesh_Plane_polygons[0])), + .uv_layers = mesh_Plane_uv_layers, + .uv_layers_length = (sizeof (mesh_Plane_uv_layers)) / (sizeof (mesh_Plane_uv_layers[0])), +}; + +const vec3 mesh_containercubemesh1_position[] = { + {-1.000000, -1.000000, -1.000000}, + {-1.000000, -1.000000, 1.000000}, + {-1.000000, 1.000000, -1.000000}, + {-1.000000, 1.000000, 1.000000}, + {1.000000, -1.000000, -1.000000}, + {1.000000, -1.000000, 1.000000}, + {1.000000, 1.000000, -1.000000}, + {1.000000, 1.000000, 1.000000}, +}; + +const vec2 mesh_containercubemesh1_UVMap_uvmap[] = { + {0.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, + {1.000000, 1.000000}, + {1.000000, 1.000000}, + {0.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, + {0.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, + {1.000000, 1.000000}, + {0.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, + {1.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, + {1.000000, 1.000000}, + {0.000000, 1.000000}, + {1.000000, 1.000000}, + {0.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, +}; + +const vec2 mesh_containercubemesh1_lightmap_uvmap[] = { + {0.831329, 0.668671}, + {0.668671, 0.668671}, + {0.668671, 0.831329}, + {0.831329, 0.831329}, + {0.997996, 0.002004}, + {0.835337, 0.002004}, + {0.835337, 0.164663}, + {0.997996, 0.164663}, + {0.164663, 0.835337}, + {0.002004, 0.835337}, + {0.002004, 0.997996}, + {0.164663, 0.997996}, + {0.997996, 0.168671}, + {0.835337, 0.168671}, + {0.835337, 0.331329}, + {0.997996, 0.331329}, + {0.331329, 0.835337}, + {0.168671, 0.835337}, + {0.168671, 0.997996}, + {0.331329, 0.997996}, + {0.497996, 0.835337}, + {0.335337, 0.835337}, + {0.335337, 0.997996}, + {0.497996, 0.997996}, +}; + +const vec3 mesh_containercubemesh1_normal[] = { + {-0.577350, -0.577350, -0.577350}, + {-0.577350, -0.577350, 0.577350}, + {-0.577350, 0.577350, -0.577350}, + {-0.577350, 0.577350, 0.577350}, + {0.577350, -0.577350, -0.577350}, + {0.577350, -0.577350, 0.577350}, + {0.577350, 0.577350, -0.577350}, + {0.577350, 0.577350, 0.577350}, +}; + +const vec3 mesh_containercubemesh1_polygon_normal[] = { + {0.000000, 1.000000, 0.000000}, + {-1.000000, 0.000000, 0.000000}, + {1.000000, 0.000000, 0.000000}, + {0.000000, -1.000000, 0.000000}, + {0.000000, 0.000000, -1.000000}, + {0.000000, 0.000000, 1.000000}, +}; + +const polygon mesh_containercubemesh1_polygons[] = { + {7, 6, 2, 3}, + {1, 3, 2, 0}, + {5, 4, 6, 7}, + {1, 0, 4, 5}, + {0, 2, 6, 4}, + {3, 1, 5, 7}, +}; + +const vec2 * mesh_containercubemesh1_uv_layers[] = { + mesh_containercubemesh1_UVMap_uvmap, + mesh_containercubemesh1_lightmap_uvmap, +}; + +const mesh mesh_containercubemesh1 = { + .position = mesh_containercubemesh1_position, + .position_length = (sizeof (mesh_containercubemesh1_position)) / (sizeof (mesh_containercubemesh1_position[0])), + .normal = mesh_containercubemesh1_normal, + .normal_length = (sizeof (mesh_containercubemesh1_normal)) / (sizeof (mesh_containercubemesh1_normal[0])), + .polygon_normal = mesh_containercubemesh1_polygon_normal, + .polygon_normal_length = (sizeof (mesh_containercubemesh1_polygon_normal)) / (sizeof (mesh_containercubemesh1_polygon_normal[0])), + .polygons = mesh_containercubemesh1_polygons, + .polygons_length = (sizeof (mesh_containercubemesh1_polygons)) / (sizeof (mesh_containercubemesh1_polygons[0])), + .uv_layers = mesh_containercubemesh1_uv_layers, + .uv_layers_length = (sizeof (mesh_containercubemesh1_uv_layers)) / (sizeof (mesh_containercubemesh1_uv_layers[0])), +}; + +const vec3 mesh_lightcubemesh_position[] = { + {-1.000000, -1.000000, -1.000000}, + {-1.000000, -1.000000, 1.000000}, + {-1.000000, 1.000000, -1.000000}, + {-1.000000, 1.000000, 1.000000}, + {1.000000, -1.000000, -1.000000}, + {1.000000, -1.000000, 1.000000}, + {1.000000, 1.000000, -1.000000}, + {1.000000, 1.000000, 1.000000}, +}; + +const vec2 mesh_lightcubemesh_UVMap_uvmap[] = { + {0.000000, 0.000000}, + {1.000000, 0.000000}, + {1.000000, 1.000000}, + {0.000000, 1.000000}, + {0.000000, 0.000000}, + {1.000000, 0.000000}, + {1.000000, 1.000000}, + {0.000000, 1.000000}, + {0.000000, 0.000000}, + {1.000000, 0.000000}, + {1.000000, 1.000000}, + {0.000000, 1.000000}, + {0.000000, 0.000000}, + {1.000000, 0.000000}, + {1.000000, 1.000000}, + {0.000000, 1.000000}, + {0.000000, 0.000000}, + {1.000000, 0.000000}, + {1.000000, 1.000000}, + {0.000000, 1.000000}, + {0.000000, 0.000000}, + {1.000000, 0.000000}, + {1.000000, 1.000000}, + {0.000000, 1.000000}, +}; + +const vec3 mesh_lightcubemesh_normal[] = { + {-0.577350, -0.577350, -0.577350}, + {-0.577350, -0.577350, 0.577350}, + {-0.577350, 0.577350, -0.577350}, + {-0.577350, 0.577350, 0.577350}, + {0.577350, -0.577350, -0.577350}, + {0.577350, -0.577350, 0.577350}, + {0.577350, 0.577350, -0.577350}, + {0.577350, 0.577350, 0.577350}, +}; + +const vec3 mesh_lightcubemesh_polygon_normal[] = { + {-1.000000, 0.000000, 0.000000}, + {0.000000, 1.000000, 0.000000}, + {1.000000, 0.000000, 0.000000}, + {0.000000, -1.000000, 0.000000}, + {0.000000, 0.000000, -1.000000}, + {0.000000, 0.000000, 1.000000}, +}; + +const polygon mesh_lightcubemesh_polygons[] = { + {0, 1, 3, 2}, + {2, 3, 7, 6}, + {6, 7, 5, 4}, + {4, 5, 1, 0}, + {2, 6, 4, 0}, + {7, 3, 1, 5}, +}; + +const vec2 * mesh_lightcubemesh_uv_layers[] = { + mesh_lightcubemesh_UVMap_uvmap, +}; + +const mesh mesh_lightcubemesh = { + .position = mesh_lightcubemesh_position, + .position_length = (sizeof (mesh_lightcubemesh_position)) / (sizeof (mesh_lightcubemesh_position[0])), + .normal = mesh_lightcubemesh_normal, + .normal_length = (sizeof (mesh_lightcubemesh_normal)) / (sizeof (mesh_lightcubemesh_normal[0])), + .polygon_normal = mesh_lightcubemesh_polygon_normal, + .polygon_normal_length = (sizeof (mesh_lightcubemesh_polygon_normal)) / (sizeof (mesh_lightcubemesh_polygon_normal[0])), + .polygons = mesh_lightcubemesh_polygons, + .polygons_length = (sizeof (mesh_lightcubemesh_polygons)) / (sizeof (mesh_lightcubemesh_polygons[0])), + .uv_layers = mesh_lightcubemesh_uv_layers, + .uv_layers_length = (sizeof (mesh_lightcubemesh_uv_layers)) / (sizeof (mesh_lightcubemesh_uv_layers[0])), +}; + +const vec3 mesh_containercubemesh2_position[] = { + {-1.000000, -1.000000, -1.000000}, + {-1.000000, -1.000000, 1.000000}, + {-1.000000, 1.000000, -1.000000}, + {-1.000000, 1.000000, 1.000000}, + {1.000000, -1.000000, -1.000000}, + {1.000000, -1.000000, 1.000000}, + {1.000000, 1.000000, -1.000000}, + {1.000000, 1.000000, 1.000000}, +}; + +const vec2 mesh_containercubemesh2_UVMap_uvmap[] = { + {0.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, + {1.000000, 1.000000}, + {1.000000, 1.000000}, + {0.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, + {0.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, + {1.000000, 1.000000}, + {0.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, + {1.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, + {1.000000, 1.000000}, + {0.000000, 1.000000}, + {1.000000, 1.000000}, + {0.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, +}; + +const vec2 mesh_containercubemesh2_lightmap_uvmap[] = { + {0.164663, 0.002004}, + {0.002004, 0.002004}, + {0.002004, 0.164663}, + {0.164663, 0.164663}, + {0.164663, 0.168671}, + {0.002004, 0.168671}, + {0.002004, 0.331329}, + {0.164663, 0.331329}, + {0.331329, 0.002004}, + {0.168671, 0.002004}, + {0.168671, 0.164663}, + {0.331329, 0.164663}, + {0.331329, 0.168671}, + {0.168671, 0.168671}, + {0.168671, 0.331329}, + {0.331329, 0.331329}, + {0.164663, 0.335337}, + {0.002004, 0.335337}, + {0.002004, 0.497996}, + {0.164663, 0.497996}, + {0.497996, 0.002004}, + {0.335337, 0.002004}, + {0.335337, 0.164663}, + {0.497996, 0.164663}, +}; + +const vec3 mesh_containercubemesh2_normal[] = { + {-0.577350, -0.577350, -0.577350}, + {-0.577350, -0.577350, 0.577350}, + {-0.577350, 0.577350, -0.577350}, + {-0.577350, 0.577350, 0.577350}, + {0.577350, -0.577350, -0.577350}, + {0.577350, -0.577350, 0.577350}, + {0.577350, 0.577350, -0.577350}, + {0.577350, 0.577350, 0.577350}, +}; + +const vec3 mesh_containercubemesh2_polygon_normal[] = { + {0.000000, 1.000000, 0.000000}, + {-1.000000, 0.000000, 0.000000}, + {1.000000, 0.000000, 0.000000}, + {0.000000, -1.000000, 0.000000}, + {0.000000, 0.000000, -1.000000}, + {0.000000, 0.000000, 1.000000}, +}; + +const polygon mesh_containercubemesh2_polygons[] = { + {7, 6, 2, 3}, + {1, 3, 2, 0}, + {5, 4, 6, 7}, + {1, 0, 4, 5}, + {0, 2, 6, 4}, + {3, 1, 5, 7}, +}; + +const vec2 * mesh_containercubemesh2_uv_layers[] = { + mesh_containercubemesh2_UVMap_uvmap, + mesh_containercubemesh2_lightmap_uvmap, +}; + +const mesh mesh_containercubemesh2 = { + .position = mesh_containercubemesh2_position, + .position_length = (sizeof (mesh_containercubemesh2_position)) / (sizeof (mesh_containercubemesh2_position[0])), + .normal = mesh_containercubemesh2_normal, + .normal_length = (sizeof (mesh_containercubemesh2_normal)) / (sizeof (mesh_containercubemesh2_normal[0])), + .polygon_normal = mesh_containercubemesh2_polygon_normal, + .polygon_normal_length = (sizeof (mesh_containercubemesh2_polygon_normal)) / (sizeof (mesh_containercubemesh2_polygon_normal[0])), + .polygons = mesh_containercubemesh2_polygons, + .polygons_length = (sizeof (mesh_containercubemesh2_polygons)) / (sizeof (mesh_containercubemesh2_polygons[0])), + .uv_layers = mesh_containercubemesh2_uv_layers, + .uv_layers_length = (sizeof (mesh_containercubemesh2_uv_layers)) / (sizeof (mesh_containercubemesh2_uv_layers[0])), +}; + +const vec3 mesh_containercubemesh3_position[] = { + {-1.000000, -1.000000, -1.000000}, + {-1.000000, -1.000000, 1.000000}, + {-1.000000, 1.000000, -1.000000}, + {-1.000000, 1.000000, 1.000000}, + {1.000000, -1.000000, -1.000000}, + {1.000000, -1.000000, 1.000000}, + {1.000000, 1.000000, -1.000000}, + {1.000000, 1.000000, 1.000000}, +}; + +const vec2 mesh_containercubemesh3_UVMap_uvmap[] = { + {0.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, + {1.000000, 1.000000}, + {1.000000, 1.000000}, + {0.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, + {0.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, + {1.000000, 1.000000}, + {0.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, + {1.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, + {1.000000, 1.000000}, + {0.000000, 1.000000}, + {1.000000, 1.000000}, + {0.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, +}; + +const vec2 mesh_containercubemesh3_lightmap_uvmap[] = { + {0.831329, 0.168671}, + {0.668671, 0.168671}, + {0.668671, 0.331329}, + {0.831329, 0.331329}, + {0.331329, 0.668671}, + {0.168671, 0.668671}, + {0.168671, 0.831329}, + {0.331329, 0.831329}, + {0.497996, 0.668671}, + {0.335337, 0.668671}, + {0.335337, 0.831329}, + {0.497996, 0.831329}, + {0.831329, 0.335337}, + {0.668671, 0.335337}, + {0.668671, 0.497996}, + {0.831329, 0.497996}, + {0.831329, 0.502004}, + {0.668671, 0.502004}, + {0.668671, 0.664663}, + {0.831329, 0.664663}, + {0.664663, 0.668671}, + {0.502004, 0.668671}, + {0.502004, 0.831329}, + {0.664663, 0.831329}, +}; + +const vec3 mesh_containercubemesh3_normal[] = { + {-0.577350, -0.577350, -0.577350}, + {-0.577350, -0.577350, 0.577350}, + {-0.577350, 0.577350, -0.577350}, + {-0.577350, 0.577350, 0.577350}, + {0.577350, -0.577350, -0.577350}, + {0.577350, -0.577350, 0.577350}, + {0.577350, 0.577350, -0.577350}, + {0.577350, 0.577350, 0.577350}, +}; + +const vec3 mesh_containercubemesh3_polygon_normal[] = { + {0.000000, 1.000000, 0.000000}, + {-1.000000, 0.000000, 0.000000}, + {1.000000, 0.000000, 0.000000}, + {0.000000, -1.000000, 0.000000}, + {0.000000, 0.000000, -1.000000}, + {0.000000, 0.000000, 1.000000}, +}; + +const polygon mesh_containercubemesh3_polygons[] = { + {7, 6, 2, 3}, + {1, 3, 2, 0}, + {5, 4, 6, 7}, + {1, 0, 4, 5}, + {0, 2, 6, 4}, + {3, 1, 5, 7}, +}; + +const vec2 * mesh_containercubemesh3_uv_layers[] = { + mesh_containercubemesh3_UVMap_uvmap, + mesh_containercubemesh3_lightmap_uvmap, +}; + +const mesh mesh_containercubemesh3 = { + .position = mesh_containercubemesh3_position, + .position_length = (sizeof (mesh_containercubemesh3_position)) / (sizeof (mesh_containercubemesh3_position[0])), + .normal = mesh_containercubemesh3_normal, + .normal_length = (sizeof (mesh_containercubemesh3_normal)) / (sizeof (mesh_containercubemesh3_normal[0])), + .polygon_normal = mesh_containercubemesh3_polygon_normal, + .polygon_normal_length = (sizeof (mesh_containercubemesh3_polygon_normal)) / (sizeof (mesh_containercubemesh3_polygon_normal[0])), + .polygons = mesh_containercubemesh3_polygons, + .polygons_length = (sizeof (mesh_containercubemesh3_polygons)) / (sizeof (mesh_containercubemesh3_polygons[0])), + .uv_layers = mesh_containercubemesh3_uv_layers, + .uv_layers_length = (sizeof (mesh_containercubemesh3_uv_layers)) / (sizeof (mesh_containercubemesh3_uv_layers[0])), +}; + +const vec3 mesh_containercubemesh4_position[] = { + {-1.000000, -1.000000, -1.000000}, + {-1.000000, -1.000000, 1.000000}, + {-1.000000, 1.000000, -1.000000}, + {-1.000000, 1.000000, 1.000000}, + {1.000000, -1.000000, -1.000000}, + {1.000000, -1.000000, 1.000000}, + {1.000000, 1.000000, -1.000000}, + {1.000000, 1.000000, 1.000000}, +}; + +const vec2 mesh_containercubemesh4_UVMap_uvmap[] = { + {0.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, + {1.000000, 1.000000}, + {1.000000, 1.000000}, + {0.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, + {0.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, + {1.000000, 1.000000}, + {0.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, + {1.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, + {1.000000, 1.000000}, + {0.000000, 1.000000}, + {1.000000, 1.000000}, + {0.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, +}; + +const vec2 mesh_containercubemesh4_lightmap_uvmap[] = { + {0.497996, 0.168671}, + {0.335337, 0.168671}, + {0.335337, 0.331329}, + {0.497996, 0.331329}, + {0.331329, 0.335337}, + {0.168671, 0.335337}, + {0.168671, 0.497996}, + {0.331329, 0.497996}, + {0.497996, 0.335337}, + {0.335337, 0.335337}, + {0.335337, 0.497996}, + {0.497996, 0.497996}, + {0.164663, 0.502004}, + {0.002004, 0.502004}, + {0.002004, 0.664663}, + {0.164663, 0.664663}, + {0.664663, 0.002004}, + {0.502004, 0.002004}, + {0.502004, 0.164663}, + {0.664663, 0.164663}, + {0.331329, 0.502004}, + {0.168671, 0.502004}, + {0.168671, 0.664663}, + {0.331329, 0.664663}, +}; + +const vec3 mesh_containercubemesh4_normal[] = { + {-0.577350, -0.577350, -0.577350}, + {-0.577350, -0.577350, 0.577350}, + {-0.577350, 0.577350, -0.577350}, + {-0.577350, 0.577350, 0.577350}, + {0.577350, -0.577350, -0.577350}, + {0.577350, -0.577350, 0.577350}, + {0.577350, 0.577350, -0.577350}, + {0.577350, 0.577350, 0.577350}, +}; + +const vec3 mesh_containercubemesh4_polygon_normal[] = { + {0.000000, 1.000000, 0.000000}, + {-1.000000, 0.000000, 0.000000}, + {1.000000, 0.000000, 0.000000}, + {0.000000, -1.000000, 0.000000}, + {0.000000, 0.000000, -1.000000}, + {0.000000, 0.000000, 1.000000}, +}; + +const polygon mesh_containercubemesh4_polygons[] = { + {7, 6, 2, 3}, + {1, 3, 2, 0}, + {5, 4, 6, 7}, + {1, 0, 4, 5}, + {0, 2, 6, 4}, + {3, 1, 5, 7}, +}; + +const vec2 * mesh_containercubemesh4_uv_layers[] = { + mesh_containercubemesh4_UVMap_uvmap, + mesh_containercubemesh4_lightmap_uvmap, +}; + +const mesh mesh_containercubemesh4 = { + .position = mesh_containercubemesh4_position, + .position_length = (sizeof (mesh_containercubemesh4_position)) / (sizeof (mesh_containercubemesh4_position[0])), + .normal = mesh_containercubemesh4_normal, + .normal_length = (sizeof (mesh_containercubemesh4_normal)) / (sizeof (mesh_containercubemesh4_normal[0])), + .polygon_normal = mesh_containercubemesh4_polygon_normal, + .polygon_normal_length = (sizeof (mesh_containercubemesh4_polygon_normal)) / (sizeof (mesh_containercubemesh4_polygon_normal[0])), + .polygons = mesh_containercubemesh4_polygons, + .polygons_length = (sizeof (mesh_containercubemesh4_polygons)) / (sizeof (mesh_containercubemesh4_polygons[0])), + .uv_layers = mesh_containercubemesh4_uv_layers, + .uv_layers_length = (sizeof (mesh_containercubemesh4_uv_layers)) / (sizeof (mesh_containercubemesh4_uv_layers[0])), +}; + +const vec3 mesh_containercubemesh5_position[] = { + {-1.000000, -1.000000, -1.000000}, + {-1.000000, -1.000000, 1.000000}, + {-1.000000, 1.000000, -1.000000}, + {-1.000000, 1.000000, 1.000000}, + {1.000000, -1.000000, -1.000000}, + {1.000000, -1.000000, 1.000000}, + {1.000000, 1.000000, -1.000000}, + {1.000000, 1.000000, 1.000000}, +}; + +const vec2 mesh_containercubemesh5_UVMap_uvmap[] = { + {0.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, + {1.000000, 1.000000}, + {1.000000, 1.000000}, + {0.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, + {0.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, + {1.000000, 1.000000}, + {0.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, + {1.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, + {1.000000, 1.000000}, + {0.000000, 1.000000}, + {1.000000, 1.000000}, + {0.000000, 1.000000}, + {-0.000000, 0.000000}, + {1.000000, -0.000000}, +}; + +const vec2 mesh_containercubemesh5_lightmap_uvmap[] = { + {0.664663, 0.168671}, + {0.502004, 0.168671}, + {0.502004, 0.331329}, + {0.664663, 0.331329}, + {0.497996, 0.502004}, + {0.335337, 0.502004}, + {0.335337, 0.664663}, + {0.497996, 0.664663}, + {0.664663, 0.335337}, + {0.502004, 0.335337}, + {0.502004, 0.497996}, + {0.664663, 0.497996}, + {0.664663, 0.502004}, + {0.502004, 0.502004}, + {0.502004, 0.664663}, + {0.664663, 0.664663}, + {0.164663, 0.668671}, + {0.002004, 0.668671}, + {0.002004, 0.831329}, + {0.164663, 0.831329}, + {0.831329, 0.002004}, + {0.668671, 0.002004}, + {0.668671, 0.164663}, + {0.831329, 0.164663}, +}; + +const vec3 mesh_containercubemesh5_normal[] = { + {-0.577350, -0.577350, -0.577350}, + {-0.577350, -0.577350, 0.577350}, + {-0.577350, 0.577350, -0.577350}, + {-0.577350, 0.577350, 0.577350}, + {0.577350, -0.577350, -0.577350}, + {0.577350, -0.577350, 0.577350}, + {0.577350, 0.577350, -0.577350}, + {0.577350, 0.577350, 0.577350}, +}; + +const vec3 mesh_containercubemesh5_polygon_normal[] = { + {0.000000, 1.000000, 0.000000}, + {-1.000000, 0.000000, 0.000000}, + {1.000000, 0.000000, 0.000000}, + {0.000000, -1.000000, 0.000000}, + {0.000000, 0.000000, -1.000000}, + {0.000000, 0.000000, 1.000000}, +}; + +const polygon mesh_containercubemesh5_polygons[] = { + {7, 6, 2, 3}, + {1, 3, 2, 0}, + {5, 4, 6, 7}, + {1, 0, 4, 5}, + {0, 2, 6, 4}, + {3, 1, 5, 7}, +}; + +const vec2 * mesh_containercubemesh5_uv_layers[] = { + mesh_containercubemesh5_UVMap_uvmap, + mesh_containercubemesh5_lightmap_uvmap, +}; + +const mesh mesh_containercubemesh5 = { + .position = mesh_containercubemesh5_position, + .position_length = (sizeof (mesh_containercubemesh5_position)) / (sizeof (mesh_containercubemesh5_position[0])), + .normal = mesh_containercubemesh5_normal, + .normal_length = (sizeof (mesh_containercubemesh5_normal)) / (sizeof (mesh_containercubemesh5_normal[0])), + .polygon_normal = mesh_containercubemesh5_polygon_normal, + .polygon_normal_length = (sizeof (mesh_containercubemesh5_polygon_normal)) / (sizeof (mesh_containercubemesh5_polygon_normal[0])), + .polygons = mesh_containercubemesh5_polygons, + .polygons_length = (sizeof (mesh_containercubemesh5_polygons)) / (sizeof (mesh_containercubemesh5_polygons[0])), + .uv_layers = mesh_containercubemesh5_uv_layers, + .uv_layers_length = (sizeof (mesh_containercubemesh5_uv_layers)) / (sizeof (mesh_containercubemesh5_uv_layers[0])), +}; + +const struct object objects[] = { + { // object_Plane + .mesh = &mesh_Plane, + .scale = {5.000000, 5.000000, 1.000000}, + .rotation = {0.000000, 0.000000, 0.000000, 1.000000}, // quaternion (XYZW) + .location = {0.000000, 0.000000, 0.000000}, + }, + { // object_containercube1 + .mesh = &mesh_containercubemesh1, + .scale = {0.500000, 0.500000, 0.500000}, + .rotation = {-0.029408, 0.323142, -0.128470, 0.937129}, // quaternion (XYZW) + .location = {-0.913651, 0.474673, 0.796012}, + }, + { // object_containercube2 + .mesh = &mesh_containercubemesh2, + .scale = {0.433165, 0.433164, 0.433165}, + .rotation = {0.167269, 0.020963, -0.062335, 0.983715}, // quaternion (XYZW) + .location = {1.959044, 0.268435, 0.403276}, + }, + { // object_containercube3 + .mesh = &mesh_containercubemesh3, + .scale = {0.433165, 0.433165, 0.433165}, + .rotation = {0.043599, 0.204523, -0.282546, 0.936182}, // quaternion (XYZW) + .location = {0.979381, -0.585301, -0.197909}, + }, + { // object_containercube4 + .mesh = &mesh_containercubemesh4, + .scale = {0.201927, 0.201927, 0.201927}, + .rotation = {0.076094, 0.080903, -0.107096, 0.988026}, // quaternion (XYZW) + .location = {0.851650, 0.413418, 1.370947}, + }, + { // object_containercube5 + .mesh = &mesh_containercubemesh5, + .scale = {0.201927, 0.201927, 0.201927}, + .rotation = {0.073075, -0.010083, -0.084328, 0.993704}, // quaternion (XYZW) + .location = {0.242747, 0.769229, 0.513025}, + }, + { // object_bluecube + .mesh = &mesh_lightcubemesh, + .scale = {0.200000, 0.200000, 0.200000}, + .rotation = {-0.131058, 0.376347, -0.164256, 0.902334}, // quaternion (XYZW) + .location = {-0.388222, 0.468224, 1.569220}, + }, + { // object_greencube + .mesh = &mesh_lightcubemesh, + .scale = {0.150812, 0.150812, 0.150812}, + .rotation = {0.000000, 0.000000, 0.000000, 1.000000}, // quaternion (XYZW) + .location = {0.448543, 2.267525, 0.599414}, + }, + { // object_redcube + .mesh = &mesh_lightcubemesh, + .scale = {0.100338, 0.100338, 0.100338}, + .rotation = {0.080010, -0.229758, 0.100278, 0.964756}, // quaternion (XYZW) + .location = {0.606424, 0.150943, 1.609826}, + }, + { // object_whitecube + .mesh = &mesh_lightcubemesh, + .scale = {0.150812, 0.150812, 0.150812}, + .rotation = {0.000000, 0.000000, 0.000000, 1.000000}, // quaternion (XYZW) + .location = {1.715308, 0.016594, 1.375648}, + }, +}; + diff --git a/model/bloom_lightmap/wood.png b/model/bloom_lightmap/wood.png new file mode 100644 index 0000000..afc6e9c Binary files /dev/null and b/model/bloom_lightmap/wood.png differ diff --git a/model/bloom_lightmap/wood.vq b/model/bloom_lightmap/wood.vq new file mode 100644 index 0000000..65f5f8a Binary files /dev/null and b/model/bloom_lightmap/wood.vq differ diff --git a/model/bloom_lightmap/wood.vq.h b/model/bloom_lightmap/wood.vq.h new file mode 100644 index 0000000..bf60e10 --- /dev/null +++ b/model/bloom_lightmap/wood.vq.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern uint32_t _binary_model_bloom_lightmap_wood_vq_start __asm("_binary_model_bloom_lightmap_wood_vq_start"); +extern uint32_t _binary_model_bloom_lightmap_wood_vq_end __asm("_binary_model_bloom_lightmap_wood_vq_end"); +extern uint32_t _binary_model_bloom_lightmap_wood_vq_size __asm("_binary_model_bloom_lightmap_wood_vq_size"); + +#ifdef __cplusplus +} +#endif