Renamed variables in Shadow

This commit is contained in:
korenkonder
2025-04-29 21:00:08 +03:00
parent d5d3595cc5
commit 29a4a0e682
5 changed files with 59 additions and 58 deletions
+4 -3
View File
@@ -176,9 +176,10 @@ HOOK(void, FASTCALL, auth_3d_m_object_hrc_disp, 0x00000001401D0760, auth_3d_m_ob
mat4_mul(m, &mat, &mat);
mat4_transpose(&mat, &mat);
vec3 pos = *(vec3*)&mat.row3;
vec3 pos;
mat4_get_translation(&mat, &pos);
pos.y -= 0.2f;
shad->field_1D0[shadow_type].push_back(pos);
shad->positions[shadow_type].push_back(pos);
}
if (i.mats.size())
@@ -238,7 +239,7 @@ HOOK(void, FASTCALL, auth_3d_object_hrc_disp, 0x00000001401D04A0, auth_3d_object
vec3 pos;
mat4_get_translation(&mat, &pos);
pos.y -= 0.2f;
shad->field_1D0[SHADOW_STAGE].push_back(pos);
shad->positions[SHADOW_STAGE].push_back(pos);
}
}
+9 -9
View File
@@ -420,9 +420,9 @@ namespace rndr {
Shadow* shad = shadow_ptr;
if (shadow && v3) {
int32_t v11[2];
v11[0] = shad->field_200[0];
v11[1] = shad->field_200[1];
int32_t index[2];
index[0] = shad->index[0];
index[1] = shad->index[1];
shad->curr_render_textures[0] = &shad->render_textures[0];
shad->curr_render_textures[1] = &shad->render_textures[1];
shad->curr_render_textures[2] = &shad->render_textures[2];
@@ -431,15 +431,15 @@ namespace rndr {
if (!v10[i])
continue;
draw_pass_shadow_begin_make_shadowmap(shad, v11[i], j);
disp_manager->draw((mdl::ObjType)(mdl::OBJ_TYPE_SHADOW_CHARA + v11[i]));
if (disp_manager->get_obj_count((mdl::ObjType)(mdl::OBJ_TYPE_SHADOW_OBJECT_CHARA + v11[i])) > 0) {
draw_pass_shadow_begin_make_shadowmap(shad, index[i], j);
disp_manager->draw((mdl::ObjType)(mdl::OBJ_TYPE_SHADOW_CHARA + index[i]));
if (disp_manager->get_obj_count((mdl::ObjType)(mdl::OBJ_TYPE_SHADOW_OBJECT_CHARA + index[i])) > 0) {
gl_rend_state.set_color_mask(show_stage_shadow
? GL_TRUE : GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
disp_manager->draw((mdl::ObjType)(mdl::OBJ_TYPE_SHADOW_OBJECT_CHARA + i));
gl_rend_state.set_color_mask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
}
draw_pass_shadow_end_make_shadowmap(shad, v11[i], j);
draw_pass_shadow_end_make_shadowmap(shad, index[i], j);
j++;
}
}
@@ -1435,7 +1435,7 @@ static void draw_pass_shadow_end_make_shadowmap(Shadow* shad, int32_t index, int
if (a3 == shad->num_shadow - 1) {
draw_pass_shadow_filter(&shad->render_textures[3],
&shad->render_textures[4], shad->curr_render_textures[0],
shad->field_2DC, shad->field_2E0 / (shad->field_208 * 2.0f), false);
shad->field_2DC, shad->field_2E0 / (shad->z_half_range * 2.0f), false);
draw_pass_shadow_esm_filter(&shad->render_textures[5],
&shad->render_textures[6], &shad->render_textures[3]);
}
@@ -1897,7 +1897,7 @@ static void draw_pass_3d_shadow_set(Shadow* shad) {
gl_rend_state.active_bind_texture_2d(19, shad->render_textures[3].GetColorTex());
gl_rend_state.active_bind_texture_2d(20, shad->render_textures[5].GetColorTex());
gl_rend_state.active_texture(0);
esm_param = (shad->field_2D8 * shad->field_208 * 2.0f) * 1.442695f;
esm_param = (shad->field_2D8 * shad->z_half_range * 2.0f) * 1.442695f;
draw_state.self_shadow = true;
}
else {
+1 -1
View File
@@ -455,7 +455,7 @@ HOOK(void, FASTCALL, rob_chara_item_equip_disp, 0x0000000140512950,
if (rob_item_equip->field_A0 & 0x04) {
vec3 pos = rob_item_equip->position;
pos.y -= 0.2f;
shadow_ptr_get()->field_1D0[rob_item_equip->shadow_type].push_back(pos);
shadow_ptr_get()->positions[rob_item_equip->shadow_type].push_back(pos);
float_t v9;
if (sub_140512F60(rob_item_equip) <= -0.2f)
+41 -41
View File
@@ -98,7 +98,7 @@ void Shadow::reset() {
view_point[i] = 1.0f;
field_1C0[i] = 0.0f;
field_1C8[i] = 0.0f;
field_200[i] = i;
index[i] = i;
}
for (RenderTexture*& i : curr_render_textures)
@@ -125,7 +125,7 @@ void Shadow::reset() {
show_texture = false;
self_shadow = true;
separate = false;
field_208 = (z_far - z_near) * 0.5f;
z_half_range = (z_far - z_near) * 0.5f;
}
Shadow* shadow_ptr_get() {
@@ -147,33 +147,33 @@ void shadow_patch() {
static void sub_1405E60E0(Shadow* shad) {
for (int32_t i = 0; i < 2; i++) {
shad->field_1A8[i] = 0.0f;
shad->position[i] = 0.0f;
shad->field_1C8[i] = 0.0f;
if (!shad->shadow_enable[i] || !shad->field_1D0[i].size())
if (!shad->shadow_enable[i] || !shad->positions[i].size())
continue;
vec3 v7 = 0.0f;
for (vec3& j : shad->field_1D0[i])
v7 += j;
vec3 position = 0.0f;
for (vec3& j : shad->positions[i])
position += j;
float_t v14 = (float_t)(int64_t)shad->field_1D0[i].size();
float_t v14 = (float_t)(int64_t)shad->positions[i].size();
if (v14 < 0.0f)
v14 += (float_t)UINT64_MAX;
v7 *= 1.0f / v14;
position *= 1.0f / v14;
float_t v15 = 0.0f;
for (vec3& j : shad->field_1D0[i]) {
vec3 v22 = v7 - j;
for (vec3& j : shad->positions[i]) {
vec3 v22 = position - j;
vec3 v23 = vec3::dot(v22, shad->direction);
float_t v24 = vec3::distance(shad->direction * v23, v22);
v15 = max_def(v15, max_def(v24 - 0.25f, 0.0f));
}
shad->field_1A8[i] = v7;
shad->position[i] = position;
shad->field_1C8[i] = v15;
}
for (prj::vector<vec3>& i : shad->field_1D0)
for (prj::vector<vec3>& i : shad->positions)
i.clear();
}
@@ -187,12 +187,12 @@ static void sub_1405E63D0(Shadow* shad) {
if (!shad->shadow_enable[i])
continue;
const vec3 v11 = shad->field_1A8[i] - shad->direction * shad->field_208;
const vec3 v11 = shad->position[i] - shad->direction * shad->z_half_range;
const float_t v9 = vec3::distance(shad->view_point[i], v11);
const float_t v12 = vec3::distance(shad->interest[i], shad->field_1A8[i]);
const float_t v12 = vec3::distance(shad->interest[i], shad->position[i]);
if (v9 > 0.1f || v12 > 0.1f) {
shad->view_point[i] = v11;
shad->interest[i] = shad->field_1A8[i];
shad->interest[i] = shad->position[i];
}
view_point += shad->view_point[i];
@@ -207,9 +207,9 @@ static void sub_1405E6840(Shadow* shad) {
int32_t count = 0;
shad->num_shadow = 0;
for (int32_t i = 0; i < 2; i++) {
if (shad->shadow_enable[i] && shad->field_1D0[i].size()) {
if (shad->shadow_enable[i] && shad->positions[i].size()) {
++shad->num_shadow;
count += (int32_t)shad->field_1D0->size();
count += (int32_t)shad->positions->size();
}
else
shad->shadow_enable[i] = false;
@@ -228,14 +228,14 @@ static void sub_1405E6910(Shadow* shad) {
const float_t v2 = max_def(shad->field_1C8[0], shad->field_1C8[1]);
shad->separate = false;
shad->shadow_range = v2 + MIN_SHADOW_RANGE;
shad->field_200[0] = 0;
shad->field_200[1] = 1;
shad->index[0] = 0;
shad->index[1] = 1;
if (shad->num_shadow < 2)
return;
const vec3 v12 = shad->field_1A8[0] - shad->interest_shared;
const vec3 v14 = shad->field_1A8[1] - shad->interest_shared;
const vec3 v12 = shad->position[0] - shad->interest_shared;
const vec3 v14 = shad->position[1] - shad->interest_shared;
float_t v16 = vec3::distance((shad->direction * vec3::dot(v12, shad->direction)), v12);
v16 = max_def(v16 - 0.25f, 0.0f);
@@ -247,8 +247,8 @@ static void sub_1405E6910(Shadow* shad) {
shad->shadow_range = v2 + MIN_SHADOW_RANGE + v16;
if (vec3::dot(v12, shad->direction) < vec3::dot(v14, shad->direction)) {
shad->field_200[0] = 1;
shad->field_200[1] = 0;
shad->index[0] = 1;
shad->index[1] = 0;
}
}
@@ -267,29 +267,29 @@ static void sub_1405E6B70(Shadow* shad) {
}
for (int32_t i = 0; i < 2; i++) {
shad->field_1A8[i] = 0.0f;
shad->position[i] = 0.0f;
shad->field_1C8[i] = 0.0f;
if (!shad->shadow_enable[i] || !shad->field_1D0[i].size())
if (!shad->shadow_enable[i] || !shad->positions[i].size())
continue;
vec3 v22 = 0.0f;
for (vec3& j : shad->field_1D0[i])
for (vec3& j : shad->positions[i])
v22 += j;
float_t v29 = (float_t)(int64_t)shad->field_1D0[i].size();
float_t v29 = (float_t)(int64_t)shad->positions[i].size();
if (v29 < 0.0f)
v29 += (float_t)UINT64_MAX;
v22 *= 1.0f / v29;
float_t v30 = 0.0f;
for (vec3& j : shad->field_1D0[i]) {
for (vec3& j : shad->positions[i]) {
const vec3 v35 = v22 - j;
const float_t v39 = fabsf(vec3::dot(v35, v86));
const float_t v38 = fabsf(vec3::dot(v35, v3));
v30 = max_def(v30, max_def(v38, v39));
}
shad->field_1A8[i] = v22;
shad->position[i] = v22;
shad->field_1C8[i] = v30;
}
@@ -300,12 +300,12 @@ static void sub_1405E6B70(Shadow* shad) {
if (!shad->shadow_enable[i])
continue;
const vec3 v41 = shad->field_1A8[0] - shad->direction * shad->field_208;
const vec3 v41 = shad->position[0] - shad->direction * shad->z_half_range;
const float_t v42 = vec3::distance(shad->view_point[0], v41);
const float_t v45 = vec3::distance(shad->interest[0], shad->field_1A8[0]);
const float_t v45 = vec3::distance(shad->interest[0], shad->position[0]);
if (v42 > 0.1f || v45 > 0.1f) {
shad->view_point[0] = v41;
shad->interest[0] = shad->field_1A8[0];
shad->interest[0] = shad->position[0];
}
view_point += shad->view_point[i];
@@ -319,8 +319,8 @@ static void sub_1405E6B70(Shadow* shad) {
const float_t v67 = max_def(shad->field_1C8[0], shad->field_1C8[1]);
shad->separate = 0;
shad->shadow_range = v67 + MIN_SHADOW_RANGE;
shad->field_200[0] = 0;
shad->field_200[1] = 1;
shad->index[0] = 0;
shad->index[1] = 1;
if (shad->num_shadow >= 2) {
float_t v2 = 0.0f;
@@ -331,7 +331,7 @@ static void sub_1405E6B70(Shadow* shad) {
if (!shad->shadow_enable[i])
continue;
for (vec3& j : shad->field_1D0[i]) {
for (vec3& j : shad->positions[i]) {
const vec3 v74 = j - shad->interest_shared;
const float_t v77 = vec3::dot(v86, v74);
@@ -357,13 +357,13 @@ static void sub_1405E6B70(Shadow* shad) {
else
shad->shadow_range = v79 + MIN_SHADOW_RANGE;
if (vec3::dot(shad->field_1A8[0] - shad->interest_shared, shad->direction)
< vec3::dot(shad->field_1A8[1] - shad->interest_shared, shad->direction)) {
shad->field_200[1] = 0;
shad->field_200[0] = 1;
if (vec3::dot(shad->position[0] - shad->interest_shared, shad->direction)
< vec3::dot(shad->position[1] - shad->interest_shared, shad->direction)) {
shad->index[1] = 0;
shad->index[0] = 1;
}
}
for (prj::vector<vec3>& i : shad->field_1D0)
for (prj::vector<vec3>& i : shad->positions)
i.clear();
}
+4 -4
View File
@@ -22,12 +22,12 @@ struct Shadow {
float_t shadow_range_factor;
vec3 view_point[2];
vec3 interest[2];
vec3 field_1A8[2];
vec3 position[2];
float_t field_1C0[2];
float_t field_1C8[2];
prj::vector<vec3> field_1D0[2];
int32_t field_200[2];
float_t field_208;
prj::vector<vec3> positions[2];
int32_t index[2];
float_t z_half_range;
vec3 direction;
vec3 view_point_shared;
vec3 interest_shared;