mirror of
https://github.com/open-goal/jak-project
synced 2026-08-14 12:34:36 -04:00
works-ish
This commit is contained in:
@@ -918,145 +918,58 @@ void SpriteRenderer::do_3d_block_cpu(u32 count,
|
||||
|
||||
Vector4f position = Vector4f(vert1.xyz_sx.x(), vert1.xyz_sx.y(), vert1.xyz_sx.z(), 1.0f);
|
||||
float sx = vert1.xyz_sx.w();
|
||||
float sy = vert1.quat_sy.y();
|
||||
float sy = vert1.quat_sy.w();
|
||||
Vector4f quat = Vector4f(vert1.quat_sy.x(), vert1.quat_sy.y(), vert1.quat_sy.z(), 1.0f);
|
||||
Vector4f fragment_color = vert1.rgba;
|
||||
|
||||
// STEP 2: TRANSFORM TRANS
|
||||
|
||||
// lqi.xyzw vf01, vi02 | nop
|
||||
// Vector4f pos_vf01 = xyz_sx;
|
||||
// lqi.xyzw vf05, vi02 | nop
|
||||
// Vector4f flags_vf05 = flag_rot_sy;
|
||||
// lqi.xyzw vf11, vi02 | nop
|
||||
// Vector4f color_vf11 = rgba;
|
||||
Vector4f transformed_pos_vf02 =
|
||||
matrix_transform(camera_matrix, m_vec_data_2d[sprite_idx] .xyz_sx);
|
||||
|
||||
// multiplications from the right column
|
||||
position = matrix_transform(camera_matrix, position);
|
||||
float Q = m_frame_data.pfog0 / position.w();
|
||||
Vector4f scales_vf01 = m_vec_data_2d[sprite_idx] .xyz_sx; // now used for something else.
|
||||
Vector4f fog_consts_vf12 = Vector4f(m_frame_data.fog_min, m_frame_data.fog_max,
|
||||
m_frame_data.max_scale, m_frame_data.bonus);
|
||||
|
||||
// STEP 3: SET UP SCALES AND AREA
|
||||
// This is used at the end for alpha mod?
|
||||
scales_vf01.z() = sy; // start building the scale vector
|
||||
|
||||
// Vector4f scales_vf01 = pos_vf01; // now used for something else.
|
||||
// lq.xyzw vf12, 1020(vi00) | mulaw.xyzw ACC, vf28, vf00
|
||||
// vf12 is fog consts
|
||||
// Vector4f fog_consts_vf12 = Vector4f(fog_min, fog_max, max_scale, bonus);
|
||||
// ilw.y vi08, 1(vi02) | maddax.xyzw ACC, vf25, vf01
|
||||
// load offset selector for the next round.
|
||||
// nop | madday.xyzw ACC, vf26, vf01
|
||||
// nop | maddz.xyzw vf02, vf27, vf01
|
||||
float Q = m_frame_data.pfog0 / transformed_pos_vf02.w();
|
||||
// quat.z() *= m_frame_data.deg_to_rad;
|
||||
scales_vf01.z() *= Q; // sy
|
||||
scales_vf01.w() *= Q; // sx
|
||||
|
||||
// move.w vf05, vf00 | addw.z vf01, vf00, vf05
|
||||
// scales_vf01.z = sy
|
||||
// scales_vf01.z = rot_sy.y; // start building the scale vector
|
||||
// rot_sy.y = 1.f; // what are we building in flags right now??
|
||||
transformed_pos_vf02.x() *= Q;
|
||||
transformed_pos_vf02.y() *= Q;
|
||||
transformed_pos_vf02.z() *= Q;
|
||||
|
||||
// scales_vf01.x = scales_vf01.z; // = sy
|
||||
// scales_vf01.x *= scales_vf01.w; // x = sx * sy
|
||||
// scales_vf01.x *= m_frame_data.inv_area; // x = sx * sy * inv_area (area ratio)
|
||||
sx *= Q;
|
||||
sy *= Q;
|
||||
float final_area = std::min(sx * sy * m_frame_data.inv_area, 1.0f);
|
||||
scales_vf01.x() = scales_vf01.z(); // = sy
|
||||
|
||||
// STEP 4
|
||||
Vector4f offset_pos_vf10 = transformed_pos_vf02 + hvdf_offset;
|
||||
|
||||
// nop | nop
|
||||
// div Q, vf31.x, vf02.w | muly.z vf05, vf05, vf31
|
||||
// float Q = pfog0 / position.w;
|
||||
quat.z() *= m_frame_data.deg_to_rad; // ?
|
||||
// nop | mul.xyzw vf03, vf02, vf29
|
||||
// Vector4f scaled_pos_vf03 = position * hmge_scale;
|
||||
// nop | nop
|
||||
// nop | nop
|
||||
// nop | mulz.z vf04, vf05, vf05 (ts)
|
||||
scales_vf01.x() *= scales_vf01.w(); // x = sx * sy
|
||||
|
||||
// the load is for rotation stuff,
|
||||
// lq.xyzw vf14, 1001(vi00) | clipw.xyz vf03, vf03 (used for fcand)
|
||||
// iaddi vi06, vi00, 0x1 | adda.xyzw ACC, vf11, vf11 (used for fmand)
|
||||
offset_pos_vf10.w() = std::max(offset_pos_vf10.w(), m_frame_data.fog_max);
|
||||
|
||||
// upcoming fcand with 0x3f, that checks all of them.
|
||||
// int fcand_result = clip_xyz_plus_minus(position * hmge_scale);
|
||||
// bool fmand_result = color_vf11.w == 0; // (really w+w, but I don't think it matters?)
|
||||
scales_vf01.z() = std::max(scales_vf01.z(), m_frame_data.min_scale);
|
||||
scales_vf01.w() = std::max(scales_vf01.w(), m_frame_data.min_scale);
|
||||
|
||||
// L8:
|
||||
// xgkick double buffer setup
|
||||
// ior vi05, vi15, vi00 | mul.zw vf01, vf01, Q
|
||||
// scales_vf01.z *= Q; // sy
|
||||
// scales_vf01.w *= Q; // sx
|
||||
scales_vf01.x() *= m_frame_data.inv_area; // x = sx * sy * inv_area (area ratio)
|
||||
|
||||
// lq.xyzw vf14, 1002(vi00) ts| mula.xyzw ACC, vf05, vf14 (ts)
|
||||
offset_pos_vf10.w() = std::min(offset_pos_vf10.w(), m_frame_data.fog_min);
|
||||
|
||||
// fmand vi01, vi06 | mul.xyz vf02, vf02, Q
|
||||
position.xyz() *= Q;
|
||||
scales_vf01.z() = std::min(scales_vf01.z(), fog_consts_vf12.z());
|
||||
scales_vf01.w() = std::min(scales_vf01.w(), fog_consts_vf12.z());
|
||||
|
||||
// ibne vi00, vi01, L10 | addz.x vf01, vf00, vf01
|
||||
// scales_vf01.x = scales_vf01.z; // = sy
|
||||
// if (fmand_result) {
|
||||
// continue; // reject!
|
||||
// }
|
||||
scales_vf01.x() = std::min(scales_vf01.x(), 1.0f);
|
||||
|
||||
// lqi.xyzw vf07, vi03 | mulz.xyzw vf16, vf15, vf04 (ts)
|
||||
// vf07 is first use adgif
|
||||
transformed_pos_vf02.w() = offset_pos_vf10.w() - fog_consts_vf12.y();
|
||||
|
||||
// lq.xyzw vf14, 1003(vi00) | madda.xyzw ACC, vf15, vf14 (ts both)
|
||||
fragment_color.w() *= scales_vf01.x(); // is this right? doesn't this stall??
|
||||
|
||||
// lqi.xyzw vf08, vi03 | add.xyzw vf10, vf02, vf30
|
||||
// vf08 is second user adgif
|
||||
Vector4f offset = position + hvdf_offset;
|
||||
|
||||
// lqi.xyzw vf09, vi03 | mulw.x vf01, vf01, vf01
|
||||
// vf09 is third user adgif
|
||||
// scales_vf01.x *= scales_vf01.w; // x = sx * sy
|
||||
|
||||
// sqi.xyzw vf06, vi05 | mulz.xyzw vf15, vf16, vf04 (ts)
|
||||
// FIRST ADGIF IS adgif_vf06
|
||||
// packet.adgif_giftag = adgif_vf06;
|
||||
|
||||
// just do all 5 now.
|
||||
// packet.user_adgif = m_adgif[sprite_idx];
|
||||
|
||||
offset.w() = std::max(offset.w(), m_frame_data.fog_max);
|
||||
|
||||
// scales_vf01.z = max(scales_vf01.z, m_frame_data.min_scale);
|
||||
// scales_vf01.w = max(scales_vf01.w, m_frame_data.min_scale);
|
||||
|
||||
// scales_vf01.x *= m_frame_data.inv_area; // x = sx * sy * inv_area (area ratio)
|
||||
|
||||
offset.w() = std::min(offset.w(), m_frame_data.fog_min);
|
||||
|
||||
// scales_vf01.z = min(scales_vf01.z, max_scale);
|
||||
// scales_vf01.w = min(scales_vf01.w, max_scale);
|
||||
// bool use_first_giftag = offset_selector == 0;
|
||||
|
||||
// auto flag_vi07 = flags;
|
||||
|
||||
// scales_vf01.x = min(scales_vf01.x, 1.f);
|
||||
|
||||
position.w() = offset.w() - m_frame_data.fog_max;
|
||||
|
||||
fragment_color.w() *= final_area; // is this right? doesn't this stall??
|
||||
|
||||
// ibne vi00, vi09, L6 | nop
|
||||
// if (position.w != 0) {
|
||||
// use_first_giftag = false;
|
||||
// }
|
||||
|
||||
// flag_vi07 = 0; // todo hack
|
||||
// Vector4f* xy_array = m_frame_data.xyz_array + flag_vi07;
|
||||
// math::Vector<s32, 4> color_integer_vf11 = color_vf11.cast<s32>();
|
||||
fragment_color /= 255.0f;
|
||||
|
||||
// packet.color = color_integer_vf11;
|
||||
|
||||
// if (fcand_result) {
|
||||
// continue; // reject (could move earlier)
|
||||
// }
|
||||
|
||||
Vector4f transf = sprite_transform2(position, m_frame_data.xyz_array[0], camera_matrix,
|
||||
sprite_quat_to_rot(quat.x(), quat.y(), quat.z()),
|
||||
sx, sy,
|
||||
hvdf_offset, m_frame_data.pfog0, m_frame_data.fog_min, m_frame_data.fog_max);
|
||||
std::array<math::Vector3f, 3> rot = sprite_quat_to_rot(quat.x(), quat.y(), quat.z());
|
||||
Vector4f transf = sprite_transform2(position, m_frame_data.xyz_array[0], camera_matrix, rot,
|
||||
sx, sy, hvdf_offset,
|
||||
m_frame_data.pfog0, m_frame_data.fog_min, m_frame_data.fog_max);
|
||||
|
||||
// packet.sprite_giftag = use_first_giftag ? m_frame_data.sprite_2d_giftag :
|
||||
// m_frame_data.sprite_2d_giftag2;
|
||||
@@ -1097,12 +1010,12 @@ void SpriteRenderer::do_3d_block_cpu(u32 count,
|
||||
Vector4f color_vf11 = m_vec_data_2d[sprite_idx].rgba;
|
||||
|
||||
// multiplications from the right column
|
||||
Vector4f transformed_pos_vf02 = matrix_transform(camera_matrix, pos_vf01);
|
||||
transformed_pos_vf02 = matrix_transform(camera_matrix, pos_vf01);
|
||||
|
||||
Vector4f scales_vf01 = pos_vf01; // now used for something else.
|
||||
scales_vf01 = pos_vf01; // now used for something else.
|
||||
// lq.xyzw vf12, 1020(vi00) | mulaw.xyzw ACC, vf28, vf00
|
||||
// vf12 is fog consts
|
||||
Vector4f fog_consts_vf12(m_frame_data.fog_min, m_frame_data.fog_max, m_frame_data.max_scale,
|
||||
fog_consts_vf12 = Vector4f(m_frame_data.fog_min, m_frame_data.fog_max, m_frame_data.max_scale,
|
||||
m_frame_data.bonus);
|
||||
// ilw.y vi08, 1(vi02) | maddax.xyzw ACC, vf25, vf01
|
||||
// load offset selector for the next round.
|
||||
@@ -1162,7 +1075,7 @@ void SpriteRenderer::do_3d_block_cpu(u32 count,
|
||||
|
||||
// lqi.xyzw vf08, vi03 | add.xyzw vf10, vf02, vf30
|
||||
// vf08 is second user adgif
|
||||
Vector4f offset_pos_vf10 = transformed_pos_vf02 + hvdf_offset;
|
||||
offset_pos_vf10 = transformed_pos_vf02 + hvdf_offset;
|
||||
// if (m_extra_debug) {
|
||||
// ImGui::Text("sel %d", offset_selector);
|
||||
// //ImGui::Text("hvdf off z: %f tf/w z: %f", hvdf_offset.z(), transformed_pos_vf02.z());
|
||||
@@ -1221,7 +1134,7 @@ void SpriteRenderer::do_3d_block_cpu(u32 count,
|
||||
|
||||
flags_vf05 = m_vec_data_2d[sprite_idx].flag_rot_sy;
|
||||
// do rot
|
||||
auto rot = sprite_quat_to_rot(flags_vf05.x(), flags_vf05.y(), flags_vf05.z());
|
||||
rot = sprite_quat_to_rot(flags_vf05.x(), flags_vf05.y(), flags_vf05.z());
|
||||
// fmt::print("root: {}\n", offset_pos_vf10.to_string_aligned());
|
||||
|
||||
// for (int i = 0; i < 3; i++) {
|
||||
|
||||
@@ -40,9 +40,9 @@ void main() {
|
||||
// T0.w = 1.0;
|
||||
// }
|
||||
// vec4 tex_color = fragment_color * T0 * 2.0;
|
||||
vec4 tex_color = fragment_color * 1.0;
|
||||
vec4 tex_color = fragment_color;
|
||||
if (tex_color.a < 0.016) {
|
||||
// discard;
|
||||
}
|
||||
color = vec4(1.0, 0, 1.0, 1.0);
|
||||
color = fragment_color;
|
||||
}
|
||||
|
||||
@@ -35,16 +35,6 @@ vec4 matrix_transform(mat4 mtx, vec4 pt) {
|
||||
+ mtx[2] * pt.z;
|
||||
}
|
||||
|
||||
int clip_xyz_plus_minus(vec4 pt) {
|
||||
float pw = abs(pt.w);
|
||||
float mw = -pw;
|
||||
if (pt.x > pw || pt.x < mw) return 1;
|
||||
if (pt.y > pw || pt.y < mw) return 1;
|
||||
if (pt.z > pw || pt.z < mw) return 1;
|
||||
if (pt.w > pw || pt.w < mw) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
mat3 sprite_quat_to_rot(float qi, float qj, float qk) {
|
||||
mat3 result;
|
||||
float qr = sqrt(abs(1.0 - (qi * qi + qj * qj + qk * qk)));
|
||||
@@ -82,7 +72,7 @@ void main() {
|
||||
|
||||
vec4 position = vec4(xyz_sx.xyz, 1.0);
|
||||
float sx = xyz_sx.w;
|
||||
float sy = quat_sy.y;
|
||||
float sy = quat_sy.w;
|
||||
vec4 quat = vec4(quat_sy.xyz, 1.0);
|
||||
fragment_color = rgba;
|
||||
|
||||
@@ -97,11 +87,13 @@ void main() {
|
||||
scales_vf01.z = sy; // start building the scale vector
|
||||
|
||||
float Q = pfog0 / transformed_pos_vf02.w;
|
||||
quat.z *= deg_to_rad;
|
||||
// quat.z *= deg_to_rad;
|
||||
scales_vf01.z *= Q; // sy
|
||||
scales_vf01.w *= Q; // sx
|
||||
|
||||
transformed_pos_vf02.xyz *= Q;
|
||||
transformed_pos_vf02.x *= Q;
|
||||
transformed_pos_vf02.y *= Q;
|
||||
transformed_pos_vf02.z *= Q;
|
||||
|
||||
scales_vf01.x = scales_vf01.z; // = sy
|
||||
|
||||
|
||||
Reference in New Issue
Block a user