mirror of
https://github.com/open-goal/jak-project
synced 2026-06-10 20:59:11 -04:00
attempt 2
This commit is contained in:
@@ -853,6 +853,8 @@ void SpriteRenderer::do_3d_block_cpu(u32 count,
|
||||
m_frame_data.fog_min);
|
||||
glUniform1f(glGetUniformLocation(render_state->shaders[ShaderId::SPRITE_CPU].id(), "fog_max"),
|
||||
m_frame_data.fog_max);
|
||||
glUniform1f(glGetUniformLocation(render_state->shaders[ShaderId::SPRITE_CPU].id(), "min_scale"),
|
||||
m_frame_data.min_scale);
|
||||
glUniform1f(glGetUniformLocation(render_state->shaders[ShaderId::SPRITE_CPU].id(), "max_scale"),
|
||||
m_frame_data.max_scale);
|
||||
glUniform1f(glGetUniformLocation(render_state->shaders[ShaderId::SPRITE_CPU].id(), "bonus"),
|
||||
|
||||
@@ -11,6 +11,7 @@ uniform mat4 camera;
|
||||
uniform float pfog0;
|
||||
uniform float fog_min;
|
||||
uniform float fog_max;
|
||||
uniform float min_scale;
|
||||
uniform float max_scale;
|
||||
uniform float bonus;
|
||||
uniform float deg_to_rad;
|
||||
@@ -86,27 +87,15 @@ void main() {
|
||||
fragment_color = rgba;
|
||||
|
||||
|
||||
// STEP 2: TRANSFORM TRANS
|
||||
|
||||
// lqi.xyzw vf01, vi02 | nop
|
||||
// vec4 pos_vf01 = xyz_sx;
|
||||
// lqi.xyzw vf05, vi02 | nop
|
||||
// vec4 flags_vf05 = flag_rot_sy;
|
||||
// lqi.xyzw vf11, vi02 | nop
|
||||
// vec4 color_vf11 = rgba;
|
||||
// STEP 2
|
||||
|
||||
// multiplications from the right column
|
||||
position = matrix_transform(camera, position);
|
||||
float Q = pfog0 / position.w;
|
||||
vec4 transformed_pos_vf02 = matrix_transform(camera, xyz_sx);
|
||||
|
||||
|
||||
// STEP 3: SET UP SCALES AND AREA
|
||||
// This is used at the end for alpha mod?
|
||||
|
||||
// vec4 scales_vf01 = pos_vf01; // now used for something else.
|
||||
vec4 scales_vf01 = xyz_sx; // now used for something else.
|
||||
// lq.xyzw vf12, 1020(vi00) | mulaw.xyzw ACC, vf28, vf00
|
||||
// vf12 is fog consts
|
||||
// vec4 fog_consts_vf12 = vec4(fog_min, fog_max, max_scale, bonus);
|
||||
vec4 fog_consts_vf12 = vec4(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
|
||||
@@ -114,25 +103,15 @@ void main() {
|
||||
|
||||
// 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??
|
||||
|
||||
// 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 = min(sx * sy * inv_area, 1.0);
|
||||
|
||||
|
||||
// STEP 4
|
||||
scales_vf01.z = sy; // start building the scale vector
|
||||
// flags_vf05.w = 1.0; // what are we building in flags right now??
|
||||
|
||||
// nop | nop
|
||||
// div Q, vf31.x, vf02.w | muly.z vf05, vf05, vf31
|
||||
// float Q = pfog0 / position.w;
|
||||
quat.z *= deg_to_rad; // ?
|
||||
float Q = pfog0 / transformed_pos_vf02.w;
|
||||
quat.z *= deg_to_rad;
|
||||
// nop | mul.xyzw vf03, vf02, vf29
|
||||
// vec4 scaled_pos_vf03 = position * hmge_scale;
|
||||
// vec4 scaled_pos_vf03 = transformed_pos_vf02 * (hmge_scale);
|
||||
// nop | nop
|
||||
// nop | nop
|
||||
// nop | mulz.z vf04, vf05, vf05 (ts)
|
||||
@@ -142,22 +121,25 @@ void main() {
|
||||
// iaddi vi06, vi00, 0x1 | adda.xyzw ACC, vf11, vf11 (used for fmand)
|
||||
|
||||
// upcoming fcand with 0x3f, that checks all of them.
|
||||
// int fcand_result = clip_xyz_plus_minus(position * hmge_scale);
|
||||
// bool fcand_result = clip_xyz_plus_minus(scaled_pos_vf03);
|
||||
// bool fmand_result = color_vf11.w == 0; // (really w+w, but I don't think it matters?)
|
||||
|
||||
// L8:
|
||||
// xgkick double buffer setup
|
||||
// ior vi05, vi15, vi00 | mul.zw vf01, vf01, Q
|
||||
// scales_vf01.z *= Q; // sy
|
||||
scales_vf01.zw *= Q; // sy
|
||||
// scales_vf01.w *= Q; // sx
|
||||
|
||||
// lq.xyzw vf06, 998(vi00) | mulz.xyzw vf15, vf05, vf04 (ts)
|
||||
// auto adgif_vf06 = adgif_giftag;
|
||||
|
||||
// lq.xyzw vf14, 1002(vi00) ts| mula.xyzw ACC, vf05, vf14 (ts)
|
||||
|
||||
// fmand vi01, vi06 | mul.xyz vf02, vf02, Q
|
||||
position.xyz *= Q;
|
||||
transformed_pos_vf02.xyz *= Q;
|
||||
|
||||
// ibne vi00, vi01, L10 | addz.x vf01, vf00, vf01
|
||||
// scales_vf01.x = scales_vf01.z; // = sy
|
||||
scales_vf01.x = scales_vf01.z; // = sy
|
||||
// if (fmand_result) {
|
||||
// continue; // reject!
|
||||
// }
|
||||
@@ -169,11 +151,11 @@ void main() {
|
||||
|
||||
// lqi.xyzw vf08, vi03 | add.xyzw vf10, vf02, vf30
|
||||
// vf08 is second user adgif
|
||||
vec4 offset = position + hvdf_offset;
|
||||
vec4 offset_pos_vf10 = transformed_pos_vf02 + 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
|
||||
scales_vf01.x *= scales_vf01.w; // x = sx * sy
|
||||
|
||||
// sqi.xyzw vf06, vi05 | mulz.xyzw vf15, vf16, vf04 (ts)
|
||||
// FIRST ADGIF IS adgif_vf06
|
||||
@@ -182,34 +164,34 @@ void main() {
|
||||
// just do all 5 now.
|
||||
// packet.user_adgif = m_adgif[sprite_idx];
|
||||
|
||||
offset.w = max(offset.w, fog_max);
|
||||
offset_pos_vf10.w = max(offset_pos_vf10.w, 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.z = max(scales_vf01.z, min_scale);
|
||||
scales_vf01.w = max(scales_vf01.w, min_scale);
|
||||
|
||||
// scales_vf01.x *= m_frame_data.inv_area; // x = sx * sy * inv_area (area ratio)
|
||||
scales_vf01.x *= inv_area; // x = sx * sy * inv_area (area ratio)
|
||||
|
||||
offset.w = min(offset.w, fog_min);
|
||||
offset_pos_vf10.w = min(offset_pos_vf10.w, fog_min);
|
||||
|
||||
// scales_vf01.z = min(scales_vf01.z, max_scale);
|
||||
// scales_vf01.w = min(scales_vf01.w, max_scale);
|
||||
scales_vf01.z = min(scales_vf01.z, fog_consts_vf12.z);
|
||||
scales_vf01.w = min(scales_vf01.w, fog_consts_vf12.z);
|
||||
// bool use_first_giftag = offset_selector == 0;
|
||||
|
||||
// auto flag_vi07 = flags;
|
||||
|
||||
// scales_vf01.x = min(scales_vf01.x, 1.f);
|
||||
// auto flag_vi07 = m_vec_data_2d[sprite_idx].flag;
|
||||
|
||||
position.w = offset.w - fog_max;
|
||||
scales_vf01.x = min(scales_vf01.x, 1.0);
|
||||
|
||||
fragment_color.a *= final_area; // is this right? doesn't this stall??
|
||||
transformed_pos_vf02.w = offset_pos_vf10.w - fog_consts_vf12.y;
|
||||
|
||||
fragment_color.w *= scales_vf01.x; // is this right? doesn't this stall??
|
||||
|
||||
// ibne vi00, vi09, L6 | nop
|
||||
// if (position.w != 0) {
|
||||
// use_first_giftag = false;
|
||||
// if (transformed_pos_vf02.w != 0) {
|
||||
// use_first_giftag = false;
|
||||
// }
|
||||
|
||||
// flag_vi07 = 0; // todo hack
|
||||
// vec4* xy_array = m_frame_data.xyz_array + flag_vi07;
|
||||
// vec4* xy_array = xyz_array + flag_vi07;
|
||||
// math::Vector<s32, 4> color_integer_vf11 = color_vf11.cast<s32>();
|
||||
|
||||
// packet.color = color_integer_vf11;
|
||||
@@ -218,9 +200,10 @@ void main() {
|
||||
// continue; // reject (could move earlier)
|
||||
// }
|
||||
|
||||
vec4 transformed = sprite_transform2(position, xyz_array[vert_id], camera, sprite_quat_to_rot(quat.x, quat.y, quat.z), sx, sy, hvdf_offset, pfog0, fog_min, fog_max);
|
||||
mat3 rot = sprite_quat_to_rot(quat.x, quat.y, quat.z);
|
||||
vec4 transformed = sprite_transform2(position, xyz_array[vert_id], camera, rot, sx, sy, hvdf_offset, pfog0, fog_min, fog_max);
|
||||
|
||||
// packet.sprite_giftag = use_first_giftag ? m_frame_data.sprite_2d_giftag : m_frame_data.sprite_2d_giftag2;
|
||||
// packet.sprite_giftag = use_first_giftag ? sprite_2d_giftag : sprite_2d_giftag2;
|
||||
|
||||
tex_coord = st_array[vert_id].xyz;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user