add shadow volume (last commit prior to game jam deadline)
This commit is contained in:
parent
4071c1f405
commit
9bf58636f1
@ -78,7 +78,7 @@ namespace demo {
|
||||
//lizard_position = {81, 100, 212};
|
||||
lizard_velocity = {0, 0, 0};
|
||||
|
||||
if (1 || !emulator_detected) {
|
||||
if (!emulator_detected) {
|
||||
emulator_detected_hud_frames = 60 * 30;
|
||||
playlist::next();
|
||||
} else {
|
||||
@ -409,6 +409,20 @@ namespace demo {
|
||||
draw_hud(writer);
|
||||
draw_lizard(writer, trans);
|
||||
|
||||
writer.append<ta_global_parameter::end_of_list>() =
|
||||
ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
|
||||
|
||||
// opaque modifier
|
||||
|
||||
mat4x4 t
|
||||
= trans
|
||||
* translate(lizard_position)
|
||||
* rotate_y(lizard_heading)
|
||||
* scale(vec3(1.0, 1.0, 1.0));
|
||||
|
||||
draw_lizard_mv(writer,
|
||||
t);
|
||||
|
||||
writer.append<ta_global_parameter::end_of_list>() =
|
||||
ta_global_parameter::end_of_list(para_control::para_type::end_of_list);
|
||||
|
||||
|
@ -49,12 +49,12 @@ namespace graphics {
|
||||
= ta_alloc_ctrl::pt_opb::_32x4byte
|
||||
| ta_alloc_ctrl::tm_opb::no_list
|
||||
| ta_alloc_ctrl::t_opb::_32x4byte
|
||||
| ta_alloc_ctrl::om_opb::no_list
|
||||
| ta_alloc_ctrl::om_opb::_32x4byte
|
||||
| ta_alloc_ctrl::o_opb::_32x4byte;
|
||||
|
||||
const opb_size opb_size = {
|
||||
.opaque = 32 * 4,
|
||||
.opaque_modifier = 0,
|
||||
.opaque_modifier = 32 * 4,
|
||||
.translucent = 32 * 4,
|
||||
.translucent_modifier = 0,
|
||||
.punch_through = 32 * 4
|
||||
|
@ -338,7 +338,7 @@ void draw_textured_cube(ta_parameter_writer& writer,
|
||||
|
||||
global_polygon_textured_intensity(writer,
|
||||
color,
|
||||
para_control::list_type::opaque,
|
||||
para_control::list_type::opaque,// | obj_control::shadow,
|
||||
offsets.side,
|
||||
texture_uv_size,
|
||||
pixel_format);
|
||||
@ -347,14 +347,14 @@ void draw_textured_cube(ta_parameter_writer& writer,
|
||||
if (i == 4)
|
||||
global_polygon_textured_intensity(writer,
|
||||
color,
|
||||
para_control::list_type::opaque,
|
||||
para_control::list_type::opaque,// | obj_control::shadow,
|
||||
offsets.bottom,
|
||||
texture_uv_size,
|
||||
pixel_format);
|
||||
if (i == 5)
|
||||
global_polygon_textured_intensity(writer,
|
||||
color,
|
||||
para_control::list_type::opaque,
|
||||
para_control::list_type::opaque | obj_control::shadow,
|
||||
offsets.top,
|
||||
texture_uv_size,
|
||||
pixel_format);
|
||||
@ -667,3 +667,235 @@ void draw_textured_voxel(ta_parameter_writer& writer,
|
||||
base_intensity);
|
||||
}
|
||||
}
|
||||
|
||||
void draw_lizard_mv(ta_parameter_writer& writer,
|
||||
const mat4x4& trans)
|
||||
{
|
||||
const vec3 position[] = {
|
||||
{0.024607, -19.000000, -0.547183},
|
||||
{0.024607, 1.000000, -0.547183},
|
||||
{0.581259, -19.000000, -0.638034},
|
||||
{0.581259, 1.000000, -0.638034},
|
||||
{1.140180, -19.000000, -0.601015},
|
||||
{1.140180, 1.000000, -0.601015},
|
||||
{1.655285, -19.000000, -0.540899},
|
||||
{1.655285, 1.000000, -0.540899},
|
||||
{2.106778, -19.000000, -0.218025},
|
||||
{2.106778, 1.000000, -0.218025},
|
||||
{2.469107, -19.000000, -0.230178},
|
||||
{2.469107, 1.000000, -0.230178},
|
||||
{2.748537, -19.000000, -0.269455},
|
||||
{2.748537, 1.000000, -0.269455},
|
||||
{2.918084, -19.000000, -0.147419},
|
||||
{2.918084, 1.000000, -0.147419},
|
||||
{2.979434, -19.000000, 0.000000},
|
||||
{2.979434, 1.000000, 0.000000},
|
||||
{2.950894, -19.000000, 0.249949},
|
||||
{2.950894, 1.000000, 0.249949},
|
||||
{2.871574, -19.000000, 0.371985},
|
||||
{2.871574, 1.000000, 0.371985},
|
||||
{2.280451, -19.000000, 0.295798},
|
||||
{2.280451, 1.000000, 0.295798},
|
||||
{2.123183, -19.000000, 0.349264},
|
||||
{2.123183, 1.000000, 0.349264},
|
||||
{1.757816, -19.000000, 0.590114},
|
||||
{1.757816, 1.000000, 0.590114},
|
||||
{1.242711, -19.000000, 0.650229},
|
||||
{1.242711, 1.000000, 0.650229},
|
||||
{0.571416, -19.000000, 0.652798},
|
||||
{0.571416, 1.000000, 0.652798},
|
||||
{0.009843, -19.000000, 0.596398},
|
||||
{0.009843, 1.000000, 0.596398},
|
||||
{-0.650159, -19.000000, 0.623270},
|
||||
{-0.650159, 1.000000, 0.623270},
|
||||
{-1.661035, -19.000000, 0.654331},
|
||||
{-1.661035, 1.000000, 0.654331},
|
||||
{-2.176140, -19.000000, 0.594215},
|
||||
{-2.176140, 1.000000, 0.594215},
|
||||
{-2.455382, -19.000000, 0.455896},
|
||||
{-2.455382, 1.000000, 0.455896},
|
||||
{-2.612649, -19.000000, 0.623895},
|
||||
{-2.612649, 1.000000, 0.623895},
|
||||
{-2.887979, -19.000000, 0.511426},
|
||||
{-2.887979, 1.000000, 0.511426},
|
||||
{-2.922185, -19.000000, 0.126913},
|
||||
{-2.922185, 1.000000, 0.126913},
|
||||
{-2.979434, -19.000000, 0.000000},
|
||||
{-2.979434, 1.000000, 0.000000},
|
||||
{-2.922185, -19.000000, -0.126913},
|
||||
{-2.922185, 1.000000, -0.126913},
|
||||
{-2.879776, -19.000000, -0.482718},
|
||||
{-2.879776, 1.000000, -0.482718},
|
||||
{-2.604447, -19.000000, -0.595187},
|
||||
{-2.604447, 1.000000, -0.595187},
|
||||
{-2.397965, -19.000000, -0.443592},
|
||||
{-2.397965, 1.000000, -0.443592},
|
||||
{-2.061306, -19.000000, -0.586012},
|
||||
{-2.061306, 1.000000, -0.586012},
|
||||
{-1.359185, -19.000000, -0.621521},
|
||||
{-1.359185, 1.000000, -0.621521},
|
||||
{-0.576337, -19.000000, -0.574055},
|
||||
{-0.576337, 1.000000, -0.574055},
|
||||
};
|
||||
const int position_length = (sizeof (position)) / (sizeof (position[0]));
|
||||
|
||||
struct tri {
|
||||
int a;
|
||||
int b;
|
||||
int c;
|
||||
};
|
||||
|
||||
const tri tris[] = {
|
||||
{1, 2, 0},
|
||||
{3, 4, 2},
|
||||
{5, 6, 4},
|
||||
{7, 8, 6},
|
||||
{9, 10, 8},
|
||||
{11, 12, 10},
|
||||
{13, 14, 12},
|
||||
{15, 16, 14},
|
||||
{17, 18, 16},
|
||||
{19, 20, 18},
|
||||
{21, 22, 20},
|
||||
{23, 24, 22},
|
||||
{25, 26, 24},
|
||||
{27, 28, 26},
|
||||
{29, 30, 28},
|
||||
{31, 32, 30},
|
||||
{33, 34, 32},
|
||||
{35, 36, 34},
|
||||
{37, 38, 36},
|
||||
{39, 40, 38},
|
||||
{41, 42, 40},
|
||||
{43, 44, 42},
|
||||
{45, 46, 44},
|
||||
{47, 48, 46},
|
||||
{49, 50, 48},
|
||||
{51, 52, 50},
|
||||
{53, 54, 52},
|
||||
{55, 56, 54},
|
||||
{57, 58, 56},
|
||||
{59, 60, 58},
|
||||
{47, 37, 25},
|
||||
{61, 62, 60},
|
||||
{63, 0, 62},
|
||||
{32, 46, 56},
|
||||
{1, 3, 2},
|
||||
{3, 5, 4},
|
||||
{5, 7, 6},
|
||||
{7, 9, 8},
|
||||
{9, 11, 10},
|
||||
{11, 13, 12},
|
||||
{13, 15, 14},
|
||||
{15, 17, 16},
|
||||
{17, 19, 18},
|
||||
{19, 21, 20},
|
||||
{21, 23, 22},
|
||||
{23, 25, 24},
|
||||
{25, 27, 26},
|
||||
{27, 29, 28},
|
||||
{29, 31, 30},
|
||||
{31, 33, 32},
|
||||
{33, 35, 34},
|
||||
{35, 37, 36},
|
||||
{37, 39, 38},
|
||||
{39, 41, 40},
|
||||
{41, 43, 42},
|
||||
{43, 45, 44},
|
||||
{45, 47, 46},
|
||||
{47, 49, 48},
|
||||
{49, 51, 50},
|
||||
{51, 53, 52},
|
||||
{53, 55, 54},
|
||||
{55, 57, 56},
|
||||
{57, 59, 58},
|
||||
{59, 61, 60},
|
||||
{5, 3, 1},
|
||||
{63, 61, 59},
|
||||
{7, 5, 1},
|
||||
{1, 63, 59},
|
||||
{57, 55, 53},
|
||||
{1, 59, 57},
|
||||
{9, 7, 1},
|
||||
{15, 13, 11},
|
||||
{9, 1, 57},
|
||||
{15, 11, 9},
|
||||
{19, 17, 15},
|
||||
{23, 21, 19},
|
||||
{29, 27, 25},
|
||||
{23, 19, 15},
|
||||
{31, 29, 25},
|
||||
{25, 23, 15},
|
||||
{15, 9, 57},
|
||||
{57, 53, 51},
|
||||
{51, 49, 47},
|
||||
{47, 45, 43},
|
||||
{41, 39, 37},
|
||||
{47, 43, 41},
|
||||
{57, 51, 47},
|
||||
{25, 15, 57},
|
||||
{33, 31, 25},
|
||||
{37, 35, 33},
|
||||
{47, 41, 37},
|
||||
{25, 57, 47},
|
||||
{37, 33, 25},
|
||||
{61, 63, 62},
|
||||
{63, 1, 0},
|
||||
{0, 2, 4},
|
||||
{4, 6, 8},
|
||||
{10, 12, 14},
|
||||
{0, 4, 8},
|
||||
{8, 10, 14},
|
||||
{14, 16, 18},
|
||||
{18, 20, 22},
|
||||
{24, 26, 28},
|
||||
{14, 18, 22},
|
||||
{24, 28, 30},
|
||||
{14, 22, 24},
|
||||
{62, 0, 8},
|
||||
{8, 14, 24},
|
||||
{24, 30, 32},
|
||||
{32, 34, 36},
|
||||
{36, 38, 40},
|
||||
{40, 42, 44},
|
||||
{46, 48, 50},
|
||||
{40, 44, 46},
|
||||
{32, 36, 40},
|
||||
{8, 24, 32},
|
||||
{60, 62, 8},
|
||||
{56, 58, 60},
|
||||
{52, 54, 56},
|
||||
{46, 50, 52},
|
||||
{32, 40, 46},
|
||||
{60, 8, 32},
|
||||
{46, 52, 56},
|
||||
{56, 60, 32}
|
||||
};
|
||||
|
||||
const int tris_length = (sizeof (tris)) / (sizeof (tris[0]));
|
||||
|
||||
static vec3 position_cache[position_length];
|
||||
for (int i = 0; i < position_length; i++) {
|
||||
position_cache[i] = screen_transform(trans * (position[i] * vec3(-0.5, 1, 0.7)));
|
||||
}
|
||||
|
||||
global_polygon_modifier_volume(writer);
|
||||
|
||||
for (int i = 0; i < tris_length; i++) {
|
||||
|
||||
const vec3& ap = position_cache[tris[i].a];
|
||||
const vec3& bp = position_cache[tris[i].b];
|
||||
const vec3& cp = position_cache[tris[i].c];
|
||||
|
||||
bool last_in_volume = i == (tris_length - 1);
|
||||
if (last_in_volume) {
|
||||
global_polygon_modifier_volume_last_in_volume(writer);
|
||||
}
|
||||
|
||||
writer.append<ta_vertex_parameter::modifier_volume>() =
|
||||
ta_vertex_parameter::modifier_volume(modifier_volume_vertex_parameter_control_word(),
|
||||
ap.x, ap.y, ap.z,
|
||||
bp.x, bp.y, bp.z,
|
||||
cp.x, cp.y, cp.z);
|
||||
}
|
||||
}
|
||||
|
@ -112,3 +112,6 @@ void draw_halfspace(ta_parameter_writer& writer,
|
||||
void draw_textured_voxel(ta_parameter_writer& writer,
|
||||
const mat4x4& trans,
|
||||
int texture_offset);
|
||||
|
||||
void draw_lizard_mv(ta_parameter_writer& writer,
|
||||
const mat4x4& trans);
|
||||
|
@ -10,6 +10,34 @@
|
||||
#include "math/geometry.hpp"
|
||||
#include "math/float_types.hpp"
|
||||
|
||||
static inline void global_polygon_modifier_volume(ta_parameter_writer& writer)
|
||||
{
|
||||
uint32_t parameter_control_word = para_control::para_type::polygon_or_modifier_volume
|
||||
| para_control::list_type::opaque_modifier_volume
|
||||
;
|
||||
|
||||
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>() =
|
||||
ta_global_parameter::modifier_volume(parameter_control_word,
|
||||
isp_tsp_instruction_word);
|
||||
}
|
||||
|
||||
static inline void global_polygon_modifier_volume_last_in_volume(ta_parameter_writer& writer)
|
||||
{
|
||||
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>() =
|
||||
ta_global_parameter::modifier_volume(last_parameter_control_word,
|
||||
last_isp_tsp_instruction_word);
|
||||
}
|
||||
|
||||
static inline void global_polygon_intensity(ta_parameter_writer& writer,
|
||||
const vec3& color,
|
||||
uint32_t culling_mode = isp_tsp_instruction_word::culling_mode::no_culling)
|
||||
|
@ -71,7 +71,7 @@ namespace playlist {
|
||||
|
||||
bool next(bool stop_sound)
|
||||
{
|
||||
if (state.loops < 0 || state.loops >= 3) {
|
||||
if (state.loops < 0 || state.loops >= 1) {
|
||||
state.playlist_ix += 1;
|
||||
state.loops = 0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user