Temp commit. Need to store all sh... Changes

This commit is contained in:
korenkonder
2022-06-13 02:18:05 +03:00
parent 913c874c01
commit 82da8a484d
261 changed files with 23706 additions and 17661 deletions
+30 -28
View File
@@ -9,37 +9,39 @@ bool data_test_shared_lock;
extern bool input_locked;
static void TaskWindow_do_disp(TaskWindow* t);
namespace app {
static void TaskWindow_do_disp(TaskWindow* t);
TaskWindow::TaskWindow() : show_window(), window_focus() {
TaskWindow::TaskWindow() : show_window(), window_focus() {
}
}
TaskWindow::~TaskWindow() {
TaskWindow::~TaskWindow() {
}
}
void TaskWindow::Window() {
if (!show_window)
return;
}
void TaskWindow::Window() {
if (!show_window)
return;
}
void TaskWork_Window() {
task_work->disp = true;
for (int32_t i = 0; i < 3; i++)
for (Task*& j : task_work->tasks) {
Task* tsk = j;
TaskWindow* tsk_w = dynamic_cast<TaskWindow*>(tsk);
if (tsk_w && tsk_w->priority == i)
TaskWindow_do_disp(tsk_w);
}
task_work->disp = false;
}
void TaskWork_Window() {
task_work->disp = true;
for (int32_t i = 0; i < 3; i++)
for (Task*& j : task_work->tasks) {
Task* tsk = j;
TaskWindow* tsk_w = dynamic_cast<TaskWindow*>(tsk);
if (tsk_w && tsk_w->priority == i)
TaskWindow_do_disp(tsk_w);
}
task_work->disp = false;
}
static void TaskWindow_do_disp(TaskWindow* t) {
if ((t->field_1C == 1 || t->field_1C == 2)
&& t->field_18 != TASK_INIT && t->field_18 != TASK_DEST)
t->Window();
static void TaskWindow_do_disp(TaskWindow* t) {
if ((t->field_1C == 1 || t->field_1C == 2)
&& t->field_18 != Task::Enum::Init && t->field_18 != Task::Enum::Dest)
t->Window();
}
}
void classes_process_init(classes_data* classes, const size_t classes_count, render_context* rctx) {
@@ -202,11 +204,11 @@ void classes_process_input(classes_data* classes, const size_t classes_count) {
classes_process_input(c->sub_classes, c->sub_classes_count);
}
if (task_work)
if (app::task_work)
for (int32_t i = 0; i < 3; i++)
for (Task*& j : task_work->tasks) {
Task* tsk = j;
TaskWindow* tsk_w = dynamic_cast<TaskWindow*>(tsk);
for (app::Task*& j : app::task_work->tasks) {
app::Task* tsk = j;
app::TaskWindow* tsk_w = dynamic_cast<app::TaskWindow*>(tsk);
if (tsk_w && tsk_w->priority == i)
input_locked |= tsk_w->window_focus;
}
+12 -10
View File
@@ -5,7 +5,7 @@
#pragma once
#include "../KKdLib/default.h"
#include "../KKdLib/default.hpp"
#include "../CRE/lock.h"
#include "../CRE/render_context.hpp"
#include "../CRE/task.hpp"
@@ -13,17 +13,19 @@
#define CLASS_DATA_NO_DATA (0)
#define CLASSES_DATA_NO_FUNC (0)
class TaskWindow : public Task {
public:
bool show_window;
bool window_focus;
namespace app {
class TaskWindow : public Task {
public:
bool show_window;
bool window_focus;
TaskWindow();
~TaskWindow();
virtual void Window() = 0;
};
TaskWindow();
~TaskWindow();
virtual void Window() = 0;
};
extern void TaskWork_Window();
extern void TaskWork_Window();
}
enum class_flags {
CLASS_INIT = 0x01,
+3 -3
View File
@@ -4,9 +4,9 @@
*/
#include "data_test.h"
#include "data_test/auth_3d_test.h"
#include "data_test/glitter_test.h"
#include "data_test/stage_test.h"
#include "data_test/auth_3d_test.hpp"
#include "data_test/glitter_test.hpp"
#include "data_test/stage_test.hpp"
classes_data data_test_classes[] = {
{
-671
View File
@@ -1,671 +0,0 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#include "auth_3d_test.h"
#include "../../../KKdLib/io/path.h"
#include "../../../KKdLib/hash.hpp"
#include "../../../KKdLib/sort.hpp"
#include "../../../KKdLib/str_utils.h"
#include "../../../KKdLib/vector.h"
#include "../../../CRE/data.hpp"
#include "../../../CRE/render_context.hpp"
#include "../../../CRE/stage.hpp"
#include "../../input.hpp"
#include "../imgui_helper.h"
struct data_test_auth_3d_test_uid {
const char* name;
uint32_t uid;
};
vector_old(data_test_auth_3d_test_uid)
struct data_test_auth_3d_test_category {
const char* name;
int32_t index;
vector_old_data_test_auth_3d_test_uid uid;
};
vector_old(data_test_auth_3d_test_category)
struct data_test_auth_3d_test {
int32_t auth_3d_category_index;
int32_t auth_3d_category_index_prev;
int32_t auth_3d_index;
int32_t stage_index;
int32_t auth_3d_id;
int32_t auth_3d_uid;
bool auth_3d_load;
bool auth_3d_load_wait;
bool auth_3d_uid_load;
bool stage_load;
vec2 a3d_stage_window_pos;
render_context* rctx;
bool enable;
bool repeat;
bool left_right_reverse;
float_t frame;
bool frame_changed;
float_t last_frame;
bool paused;
float_t trans_x;
float_t trans_z;
float_t rot_y;
vector_old_uint32_t obj_set_id;
vector_old_ptr_char stage;
vector_old_data_test_auth_3d_test_category category;
};
vector_old_func(data_test_auth_3d_test_category)
vector_old_func(data_test_auth_3d_test_uid)
extern int32_t width;
extern int32_t height;
extern float_t frame_speed;
static const char* data_test_auth_3d_test_window_title = "Auth 3D Test##Data Test";
static void data_test_auth_3d_test_category_free(data_test_auth_3d_test_category* cat);
static void data_test_auth_3d_test_load_auth_file(data_test_auth_3d_test* auth_3d_test);
static int data_test_auth_3d_test_uid_quicksort_compare_func(void const* src1, void const* src2);
bool data_test_auth_3d_test_init(class_data* data, render_context* rctx) {
data->data = force_malloc_s(data_test_auth_3d_test, 1);
data_test_auth_3d_test* auth_3d_test = (data_test_auth_3d_test*)data->data;
if (auth_3d_test) {
auth_3d_database* auth_3d_db = &rctx->data->data_ft.auth_3d_db;
std::vector<auth_3d_database_category>& auth_3d_db_cat = auth_3d_db->category;
auth_3d_database_uid* uids = auth_3d_db->uid.data();
auth_3d_test->category = vector_old_empty(data_test_auth_3d_test_category);
vector_old_data_test_auth_3d_test_category_reserve(&auth_3d_test->category, auth_3d_db_cat.size());
for (auth_3d_database_category& i : auth_3d_db_cat) {
data_test_auth_3d_test_category* cat
= vector_old_data_test_auth_3d_test_category_reserve_back(&auth_3d_test->category);
cat->name = i.name.c_str();
cat->index = -1;
cat->uid = vector_old_empty(data_test_auth_3d_test_uid);
vector_old_data_test_auth_3d_test_uid_reserve(&cat->uid, i.uid.size());
for (int32_t& j : i.uid) {
if (!uids[j].enabled)
continue;
data_test_auth_3d_test_uid uid;
uid.name = uids[j].name.c_str();
uid.uid = uids[j].org_uid;
vector_old_data_test_auth_3d_test_uid_push_back(&cat->uid, &uid);
}
if (vector_old_length(cat->uid)) {
quicksort_custom(cat->uid.begin, vector_old_length(cat->uid),
sizeof(data_test_auth_3d_test_uid),
data_test_auth_3d_test_uid_quicksort_compare_func);
cat->index = 0;
}
}
auth_3d_test->rctx = rctx;
auth_3d_test->auth_3d_category_index = -1;
auth_3d_test->auth_3d_category_index_prev = -1;
auth_3d_test->auth_3d_index = -1;
auth_3d_test->stage_index = 0;
auth_3d_test->auth_3d_id = -1;
auth_3d_test->auth_3d_uid = -1;
auth_3d_test->auth_3d_load = false;
auth_3d_test->auth_3d_load_wait = false;
auth_3d_test->auth_3d_uid_load = false;
if (vector_old_length(auth_3d_test->category) > 0) {
data_test_auth_3d_test_category* cat = &auth_3d_test->category.begin[0];
if (vector_old_length(cat->uid)) {
auth_3d_test->auth_3d_load = true;
auth_3d_test->auth_3d_load_wait = true;
auth_3d_test->auth_3d_uid_load = true;
auth_3d_test->auth_3d_uid = cat->uid.begin[0].uid;
}
auth_3d_test->auth_3d_category_index = 0;
auth_3d_test->auth_3d_category_index_prev = 0;
auth_3d_test->auth_3d_index = cat->index;
}
stage_database* aft_stage_data = &rctx->data->data_ft.stage_data;
auth_3d_test->stage = vector_old_ptr_empty(char);
vector_old_ptr_char_reserve(&auth_3d_test->stage, aft_stage_data->stage_data.size());
for (stage_data& i : aft_stage_data->stage_data)
*vector_old_ptr_char_reserve_back(&auth_3d_test->stage) = (char*)i.name.c_str();
auth_3d_test->a3d_stage_window_pos = { 200.0f, 100.0f };
auth_3d_test->enable = true;
auth_3d_test->repeat = true;
auth_3d_test->left_right_reverse = false;
auth_3d_test->frame = 0.0f;
auth_3d_test->frame_changed = false;
auth_3d_test->last_frame = 0.0f;
auth_3d_test->paused = false;
auth_3d_test->trans_x = 0.0f;
auth_3d_test->trans_z = 0.0f;
auth_3d_test->rot_y = 0.0f;
auth_3d_test->obj_set_id = vector_old_empty(uint32_t);
}
return true;
}
void data_test_auth_3d_test_ctrl(class_data* data) {
data_test_auth_3d_test* auth_3d_test = (data_test_auth_3d_test*)data->data;
if (!auth_3d_test)
return;
if (auth_3d_test->auth_3d_uid_load && auth_3d_test->auth_3d_id != -1) {
render_context* rctx = auth_3d_test->rctx;
data_struct* aft_data = rctx->data;
stage_database* aft_stage_data = &aft_data->data_ft.stage_data;
auth_3d_database* aft_auth_3d_db = &aft_data->data_ft.auth_3d_db;
auth_3d_database_uid* uids = aft_auth_3d_db->uid.data();
const char* uid_name = uids[auth_3d_test->auth_3d_uid].name.c_str();
uint32_t name_hash;
const char* s = 0;
if (s = strchr(uid_name, '_'))
name_hash = hash_murmurhash(uid_name, s - uid_name);
else
name_hash = hash_utf8_murmurhash(uid_name);
for (stage_data& i : aft_stage_data->stage_data) {
if (name_hash != i.name_hash)
continue;
int32_t stage_index = (int32_t)(&i - aft_stage_data->stage_data.data());
if (stage_index != auth_3d_test->stage_index)
auth_3d_test->stage_load = true;
auth_3d_test->stage_index = stage_index;
break;
}
auth_3d_data_unload_id(auth_3d_test->auth_3d_id, auth_3d_test->rctx);
auth_3d_test->auth_3d_id = -1;
}
if (auth_3d_test->auth_3d_load) {
render_context* rctx = auth_3d_test->rctx;
if (auth_3d_test->auth_3d_category_index_prev != auth_3d_test->auth_3d_category_index) {
data_test_auth_3d_test_category* cat_prev
= &auth_3d_test->category.begin[auth_3d_test->auth_3d_category_index_prev];
auth_3d_data_unload_category(cat_prev->name);
}
for (uint32_t* i = auth_3d_test->obj_set_id.begin; i != auth_3d_test->obj_set_id.end; i++)
object_storage_unload_set(*i);
vector_old_uint32_t_clear(&auth_3d_test->obj_set_id, 0);
data_test_auth_3d_test_category* cat
= &auth_3d_test->category.begin[auth_3d_test->auth_3d_category_index];
{
data_struct* aft_data = rctx->data;
object_database* obj_db = &aft_data->data_ft.obj_db;
const char* name_str = cat->name;
size_t name_len = utf8_length(cat->name);
if (!memcmp(name_str, "ITMPV", 5)) {
uint32_t set_id = obj_db->get_object_set_id(name_str);
if (set_id != (uint32_t)-1) {
object_storage_load_set(aft_data, obj_db, set_id);
vector_old_uint32_t_push_back(&auth_3d_test->obj_set_id, &set_id);
}
}
if (!memcmp(name_str, "EFFCHRPV", 8)) {
uint32_t set_id = obj_db->get_object_set_id(name_str);
if (set_id != (uint32_t)-1) {
object_storage_load_set(aft_data, obj_db, set_id);
vector_old_uint32_t_push_back(&auth_3d_test->obj_set_id, &set_id);
}
}
std::string obj;
for (size_t i = 0; i < name_len && name_len - i >= 8; i++)
if (!memcmp(&name_str[i], "STGPV", 5)) {
obj = std::string(&name_str[i], 8);
break;
}
for (size_t i = 0; i < name_len && name_len - i >= 10; i++)
if (!memcmp(&name_str[i], "STGD2PV", 7)) {
obj = std::string(&name_str[i], 10);
break;
}
uint32_t set_id = obj_db->get_object_set_id(obj.c_str());
if (set_id != (uint32_t)-1) {
object_storage_load_set(aft_data, obj_db, set_id);
vector_old_uint32_t_push_back(&auth_3d_test->obj_set_id, &set_id);
}
obj += "HRC";
uint32_t hrc_set_id = obj_db->get_object_set_id(obj.c_str());
if (hrc_set_id != (uint32_t)-1) {
object_storage_load_set(aft_data, obj_db, hrc_set_id);
vector_old_uint32_t_push_back(&auth_3d_test->obj_set_id, &hrc_set_id);
}
}
auth_3d_data_load_category(cat->name);
auth_3d_test->auth_3d_category_index_prev = auth_3d_test->auth_3d_category_index;
auth_3d_test->auth_3d_load = false;
auth_3d_test->auth_3d_load_wait = true;
}
if (auth_3d_test->auth_3d_load_wait) {
bool wait = false;
for (uint32_t* i = auth_3d_test->obj_set_id.begin; i != auth_3d_test->obj_set_id.end; i++)
wait |= object_storage_load_obj_set_check_not_read(*i);
if (wait)
return;
auth_3d_test->auth_3d_load_wait = false;
}
if (auth_3d_test->auth_3d_uid_load) {
data_test_auth_3d_test_load_auth_file(auth_3d_test);
auth_3d_test->auth_3d_uid_load = false;
}
if (auth_3d_test->stage_load) {
task_stage_set_stage_index(auth_3d_test->stage_index);
auth_3d_test->stage_load = false;
}
}
bool data_test_auth_3d_test_hide(class_data* data) {
data_test_auth_3d_test* auth_3d_test = (data_test_auth_3d_test*)data->data;
if (!auth_3d_test)
return true;
task_stage_unload();
for (uint32_t* i = auth_3d_test->obj_set_id.begin;
i != auth_3d_test->obj_set_id.end; i++)
object_storage_unload_set(*i);
vector_old_uint32_t_free(&auth_3d_test->obj_set_id, 0);
auth_3d_data_unload_id(auth_3d_test->auth_3d_id, auth_3d_test->rctx);
auth_3d_test->auth_3d_category_index = -1;
auth_3d_test->auth_3d_category_index_prev = -1;
auth_3d_test->auth_3d_index = -1;
auth_3d_test->auth_3d_uid = -1;
enum_and(data->flags, ~CLASS_HIDE);
enum_or(data->flags, CLASS_HIDDEN);
return true;
}
void data_test_auth_3d_test_imgui(class_data* data) {
ImGuiIO& io = ImGui::GetIO();
ImGuiStyle& style = ImGui::GetStyle();
ImFont* font = ImGui::GetFont();
float_t w = min((float_t)width, 280.0f);
float_t h = min((float_t)height, 316.0f);
ImGui::SetNextWindowPos({ 0, 0 }, ImGuiCond_Appearing);
ImGui::SetNextWindowSize({ w, h }, ImGuiCond_Always);
ImGuiWindowFlags window_flags = 0;
window_flags |= ImGuiWindowFlags_NoResize;
data->imgui_focus = false;
bool open = data->flags & CLASS_HIDDEN ? false : true;
bool collapsed = !ImGui::Begin(data_test_auth_3d_test_window_title, &open, window_flags);
if (!open) {
enum_or(data->flags, CLASS_HIDE);
ImGui::End();
return;
}
else if (collapsed) {
ImGui::End();
return;
}
data_test_auth_3d_test* auth_3d_test = (data_test_auth_3d_test*)data->data;
if (!auth_3d_test) {
ImGui::End();
return;
}
auth_3d* auth = auth_3d_data_get_auth_3d(auth_3d_test->auth_3d_id);
if (auth)
auth_3d_test->last_frame = auth->play_control.size;
if (auth_3d_data_check_id_not_empty(&auth_3d_test->auth_3d_id)) {
auth_3d_test->enable = auth_3d_data_get_enable(&auth_3d_test->auth_3d_id);
auth_3d_test->repeat = auth_3d_data_get_repeat(&auth_3d_test->auth_3d_id);
auth_3d_test->left_right_reverse = auth_3d_data_get_left_right_reverse(&auth_3d_test->auth_3d_id);
auth_3d_test->frame = auth_3d_data_get_frame(&auth_3d_test->auth_3d_id);
auth_3d_test->frame_changed = false;
auth_3d_test->paused = auth_3d_data_get_paused(&auth_3d_test->auth_3d_id);
}
vector_old_data_test_auth_3d_test_category* auth_3d_db_cat = &auth_3d_test->category;
render_context* rctx = auth_3d_test->rctx;
data_struct* aft_data = rctx->data;
auth_3d_database* aft_auth_3d_db = &aft_data->data_ft.auth_3d_db;
auth_3d_database_uid* uids = aft_auth_3d_db->uid.data();
int32_t auth_3d_category_index = auth_3d_test->auth_3d_category_index;
imguiGetContentRegionAvailSetNextItemWidth();
if (ImGui::BeginCombo("##Auth 3D Category Index", auth_3d_category_index > -1
? auth_3d_db_cat->begin[auth_3d_category_index].name : "", 0)) {
for (data_test_auth_3d_test_category* i = auth_3d_db_cat->begin; i != auth_3d_db_cat->end; i++) {
int32_t auth_3d_category_idx = (int32_t)(i - auth_3d_db_cat->begin);
ImGui::PushID(i);
if (ImGui::Selectable(i->name, auth_3d_category_index == auth_3d_category_idx)
|| imguiItemKeyPressed(GLFW_KEY_ENTER, true)
|| (ImGui::IsItemFocused() && auth_3d_category_index != auth_3d_category_idx)) {
auth_3d_test->auth_3d_category_index = -1;
auth_3d_category_index = auth_3d_category_idx;
}
ImGui::PopID();
if (auth_3d_category_index == auth_3d_category_idx)
ImGui::SetItemDefaultFocus();
}
data->imgui_focus |= true;
ImGui::EndCombo();
}
if (auth_3d_category_index != auth_3d_test->auth_3d_category_index) {
data_test_auth_3d_test_category* cat = &auth_3d_db_cat->begin[auth_3d_category_index];
if (vector_old_length(cat->uid) > 0) {
auth_3d_test->auth_3d_load = true;
auth_3d_test->auth_3d_uid_load = true;
auth_3d_test->auth_3d_uid = cat->uid.begin[cat->index].uid;
}
else {
auth_3d_test->auth_3d_load = false;
auth_3d_test->auth_3d_uid_load = false;
auth_3d_test->auth_3d_uid = -1;
}
auth_3d_test->auth_3d_category_index = auth_3d_category_index;
auth_3d_test->auth_3d_index = cat->index;
}
int32_t auth_3d_index = auth_3d_test->auth_3d_index;
ImGui::Text(" ID ");
imguiGetContentRegionAvailSetNextItemWidth();
bool auth_3d_category_found = false;
for (data_test_auth_3d_test_category* i = auth_3d_db_cat->begin; i != auth_3d_db_cat->end; i++) {
if (auth_3d_category_index != i - auth_3d_db_cat->begin)
continue;
if (ImGui::BeginCombo("##Auth 3D Index", auth_3d_index > -1
? i->uid.begin[auth_3d_index].name : "", 0)) {
for (data_test_auth_3d_test_uid* j = i->uid.begin; j != i->uid.end; j++) {
int32_t auth_3d_idx = (int32_t)(j - i->uid.begin);
ImGui::PushID(j);
if (ImGui::Selectable(j->name, auth_3d_index == auth_3d_idx)
|| imguiItemKeyPressed(GLFW_KEY_ENTER, true)
|| (ImGui::IsItemFocused() && auth_3d_index != auth_3d_idx)) {
auth_3d_test->auth_3d_index = -1;
auth_3d_index = auth_3d_idx;
}
ImGui::PopID();
if (auth_3d_index == auth_3d_idx)
ImGui::SetItemDefaultFocus();
}
data->imgui_focus |= true;
ImGui::EndCombo();
}
if (auth_3d_index != auth_3d_test->auth_3d_index) {
i->index = auth_3d_index;
auth_3d_test->auth_3d_uid_load = true;
auth_3d_test->auth_3d_uid = i->uid.begin[auth_3d_index].uid;
auth_3d_test->auth_3d_index = auth_3d_index;
}
auth_3d_category_found = true;
break;
}
if (!auth_3d_category_found && ImGui::BeginCombo("##Auth 3D Index", "", 0)) {
data->imgui_focus |= true;
ImGui::EndCombo();
}
float_t frame = auth_3d_test->frame;
ImGui::Text("frame[ 0,%4.0f)", auth_3d_test->last_frame);
imguiGetContentRegionAvailSetNextItemWidth();
igSliderFloatButton("##frame slider", &frame, 1.0f,
0.0f, auth_3d_test->last_frame, "%5.0f", 0);
if (ImGui::IsItemActivated())
auth_3d_test->paused = true;
if (ImGui::Button("|<<", { 32.0, 0.0f }))
frame = 0.0f;
ImGui::SameLine();
if (ImGui::Button(auth_3d_test->paused ? " > " : "||", { 32.0, 0.0f }))
auth_3d_test->paused = auth_3d_test->paused ? false : true;
ImGui::SameLine();
if (ImGui::Button(">>|", { 32.0, 0.0f }))
frame = auth_3d_test->last_frame;
ImGui::SameLine();
if (ImGui::Checkbox("repeat", &auth_3d_test->repeat) && auth_3d_test->repeat && auth_3d_test->paused)
auth_3d_test->paused = false;
if (ImGui::Checkbox("Left Right Reverse", &auth_3d_test->left_right_reverse))
frame = 0.0f;
if (frame != auth_3d_test->frame) {
auth_3d_test->frame_changed = true;
auth_3d_test->frame = frame;
}
imguiColumnSliderFloat("transX", &auth_3d_test->trans_x, 0.1f, -5.0f, 5.0f, "%.2f", 0, true);
imguiColumnSliderFloat("transZ", &auth_3d_test->trans_z, 0.1f, -5.0f, 5.0f, "%.2f", 0, true);
imguiColumnSliderFloat("rotY", &auth_3d_test->rot_y, 1.0f, -360.0f, 360.0f, "%.0f", 0, true);
if (ImGui::Button("cam reset", { 72.0f, 0.0f })
&& auth_3d_test->rctx && auth_3d_test->rctx->camera) {
camera* cam = auth_3d_test->rctx->camera;
camera_set_fov(cam, 32.2673416137695);
camera_set_roll(cam, 0.0);
vec3 view_point = { 0.0f, 1.0f, 6.0f };
camera_set_view_point(cam, &view_point);
vec3 interest = { 0.0f, 1.0f, 0.0f };
camera_set_interest(cam, &interest);
}
ImGui::Separator();
imguiColumnSliderFloat("Frame Speed", &frame_speed, 0.01f, 0.0f, 3.0f, "%.2f", 0, true);
data->imgui_focus |= ImGui::IsWindowFocused();
ImGui::End();
float_t x = w;
float_t y = 0.0f;
w = min((float_t)width, auth_3d_test->a3d_stage_window_pos.x);
h = min((float_t)height, auth_3d_test->a3d_stage_window_pos.y);
ImGui::SetNextWindowPos({ x, y }, ImGuiCond_Appearing);
ImGui::SetNextWindowSize({ w, h }, ImGuiCond_Always);
window_flags = 0;
window_flags |= ImGuiWindowFlags_NoResize;
window_flags |= ImGuiWindowFlags_NoCollapse;
if (ImGui::Begin("A3D STAGE", 0, window_flags)) {
stage* stg = task_stage_get_current_stage();
if (stg){
ImGui::Checkbox("stage", &stg->stage_display);
ImGui::Checkbox("stg auth display", &stg->effect_display);
}
else {
bool stage = true;
ImGui::Checkbox("stage", &stage);
bool effects = true;
ImGui::Checkbox("stg auth display", &effects);
}
int32_t stage_index = auth_3d_test->stage_index;
imguiGetContentRegionAvailSetNextItemWidth();
if (ImGui::BeginCombo("##Stage Index", stage_index > -1
? auth_3d_test->stage.begin[stage_index] : "", 0)) {
for (char** i = auth_3d_test->stage.begin; i != auth_3d_test->stage.end; i++) {
int32_t stage_idx = (int32_t)(i - auth_3d_test->stage.begin);
ImGui::PushID(i);
if (ImGui::Selectable(*i, stage_index == stage_idx)
|| imguiItemKeyPressed(GLFW_KEY_ENTER, true)
|| (ImGui::IsItemFocused() && stage_index != stage_idx)) {
auth_3d_test->stage_index = -1;
stage_index = stage_idx;
}
ImGui::PopID();
if (stage_index == stage_idx)
ImGui::SetItemDefaultFocus();
}
data->imgui_focus |= ImGui::IsWindowFocused();
ImGui::EndCombo();
}
if (stage_index != auth_3d_test->stage_index) {
auth_3d_test->stage_load = true;
auth_3d_test->stage_index = stage_index;
}
data->imgui_focus |= ImGui::IsWindowFocused();
}
if (auth_3d_data_check_id_not_empty(&auth_3d_test->auth_3d_id)) {
auth_3d_data_set_enable(&auth_3d_test->auth_3d_id, auth_3d_test->enable);
auth_3d_data_set_repeat(&auth_3d_test->auth_3d_id, auth_3d_test->repeat);
auth_3d_data_set_left_right_reverse(&auth_3d_test->auth_3d_id, auth_3d_test->left_right_reverse);
if (auth_3d_test->frame_changed) {
auth_3d_data_set_req_frame(&auth_3d_test->auth_3d_id, auth_3d_test->frame);
auth_3d_test->frame_changed = false;
}
auth_3d_data_set_paused(&auth_3d_test->auth_3d_id, auth_3d_test->paused);
auth_3d_data_set_frame_rate(&auth_3d_test->auth_3d_id, 0);
mat4 mat;
mat4_translate(auth_3d_test->trans_x, 0.0f, auth_3d_test->trans_z, &mat);
mat4_rotate_y_mult(&mat, auth_3d_test->rot_y * DEG_TO_RAD_FLOAT, &mat);
auth_3d_data_set_mat(&auth_3d_test->auth_3d_id, &mat);
}
ImGui::End();
}
bool data_test_auth_3d_test_show(class_data* data) {
data_test_auth_3d_test* auth_3d_test = (data_test_auth_3d_test*)data->data;
if (!auth_3d_test)
return false;
auth_3d_test->enable = true;
auth_3d_test->repeat = true;
auth_3d_test->left_right_reverse = false;
auth_3d_test->frame = 0.0f;
auth_3d_test->frame_changed = false;
auth_3d_test->last_frame = 0.0f;
auth_3d_test->paused = false;
auth_3d_test->trans_x = 0.0f;
auth_3d_test->trans_z = 0.0f;
auth_3d_test->rot_y = 0.0f;
task_stage_load("A3D_STAGE");
task_stage_set_stage_index(auth_3d_test->stage_index);
return true;
}
bool data_test_auth_3d_test_dispose(class_data* data) {
data_test_auth_3d_test* auth_3d_test = (data_test_auth_3d_test*)data->data;
if (auth_3d_test) {
memset(auth_3d_test->stage.begin, 0, sizeof(char*) * vector_old_length(auth_3d_test->stage));
for (uint32_t* i = auth_3d_test->obj_set_id.begin;
i != auth_3d_test->obj_set_id.end; i++)
object_storage_unload_set(*i);
vector_old_uint32_t_free(&auth_3d_test->obj_set_id, 0);
auth_3d_data_unload_id(auth_3d_test->auth_3d_id, auth_3d_test->rctx);
vector_old_data_test_auth_3d_test_category_free(&auth_3d_test->category,
data_test_auth_3d_test_category_free);
vector_old_ptr_char_free(&auth_3d_test->stage, 0);
}
free(data->data);
return true;
}
static void data_test_auth_3d_test_category_free(data_test_auth_3d_test_category* cat) {
vector_old_data_test_auth_3d_test_uid_free(&cat->uid, 0);
}
static void data_test_auth_3d_test_load_auth_file(data_test_auth_3d_test* auth_3d_test) {
render_context* rctx = auth_3d_test->rctx;
data_struct* aft_data = rctx->data;
auth_3d_database* aft_auth_3d_db = &aft_data->data_ft.auth_3d_db;
object_database* aft_obj_db = &aft_data->data_ft.obj_db;
texture_database* aft_tex_db = &aft_data->data_ft.tex_db;
auth_3d_database_uid* uids = aft_auth_3d_db->uid.data();
const char* uid_name = uids[auth_3d_test->auth_3d_uid].name.c_str();
auth_3d_test->auth_3d_id = auth_3d_data_load_uid(auth_3d_test->auth_3d_uid, aft_auth_3d_db);
if (auth_3d_test->auth_3d_id == -1)
return;
auth_3d_data_read_file(&auth_3d_test->auth_3d_id, aft_auth_3d_db);
auth_3d_data_set_enable(&auth_3d_test->auth_3d_id, true);
auth_3d_data_set_paused(&auth_3d_test->auth_3d_id, false);
auth_3d_data_set_repeat(&auth_3d_test->auth_3d_id, auth_3d_test->repeat);
auth_3d_data_set_left_right_reverse(&auth_3d_test->auth_3d_id, auth_3d_test->left_right_reverse);
auth_3d_data_set_camera_root_update(&auth_3d_test->auth_3d_id, true);
auth_3d_data_set_req_frame(&auth_3d_test->auth_3d_id, 0.0f);
auth_3d_data_set_max_frame(&auth_3d_test->auth_3d_id, -1.0f);
auth_3d_data_set_visibility(&auth_3d_test->auth_3d_id, true);
auth_3d_test->enable = true;
auth_3d_test->frame = 0.0f;
auth_3d_test->frame_changed = false;
auth_3d_test->last_frame = auth_3d_data_get_play_control_size(&auth_3d_test->auth_3d_id);
auth_3d_test->paused = false;
auth_3d_test->trans_x = 0.0f;
auth_3d_test->trans_z = 0.0f;
auth_3d_test->rot_y = 0.0f;
}
static int data_test_auth_3d_test_uid_quicksort_compare_func(void const* src1, void const* src2) {
const char* str1 = ((data_test_auth_3d_test_uid*)src1)->name;
const char* str2 = ((data_test_auth_3d_test_uid*)src2)->name;
return str_utils_compare(str1, str2);
}
@@ -0,0 +1,491 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#include "auth_3d_test.hpp"
#include "../../../KKdLib/io/path.hpp"
#include "../../../KKdLib/hash.hpp"
#include "../../../KKdLib/sort.hpp"
#include "../../../KKdLib/str_utils.hpp"
#include "../../../CRE/data.hpp"
#include "../../../CRE/render_context.hpp"
#include "../../../CRE/stage.hpp"
#include "../../input.hpp"
#include "../data_test.h"
#include "../imgui_helper.h"
struct data_test_auth_3d_test_uid {
const char* name;
int32_t uid;
data_test_auth_3d_test_uid(const char* name, int32_t uid);
};
struct data_test_auth_3d_test_category {
const char* name;
int32_t index;
std::vector<data_test_auth_3d_test_uid> uid;
data_test_auth_3d_test_category();
~data_test_auth_3d_test_category();
};
class Auth3dTestWindow : public app::TaskWindow {
public:
int32_t auth_3d_category_index;
int32_t auth_3d_category_index_prev;
int32_t auth_3d_index;
int32_t auth_3d_uid;
bool auth_3d_load;
bool auth_3d_uid_load;
bool enable;
float_t frame;
bool frame_changed;
float_t last_frame;
bool paused;
std::vector<const char*> stage;
std::vector<data_test_auth_3d_test_category> category;
Auth3dTestWindow();
virtual ~Auth3dTestWindow() override;
virtual void Window() override;
};
extern int32_t width;
extern int32_t height;
extern float_t frame_speed;
extern render_context* rctx_ptr;
extern vec4u8 clear_color;
static const char* data_test_auth_3d_test_window_title = "Auth 3D Test##Data Test";
static Auth3dTestWindow* auth_3d_test_window;
static bool auth_3d_load();
static bool auth_3d_unload();
static int data_test_auth_3d_test_uid_quicksort_compare_func(void const* src1, void const* src2);
bool data_test_auth_3d_test_init(class_data* data, render_context* rctx) {
return true;
}
void data_test_auth_3d_test_ctrl(class_data* data) {
if (app::TaskWork::HasTaskCtrl(&auth_3d_test_task)) {
if (auth_3d_test_window->auth_3d_load) {
std::vector<data_test_auth_3d_test_category>& auth_3d_db_cat = auth_3d_test_window->category;
int32_t auth_3d_category_index = auth_3d_test_window->auth_3d_category_index;
auth_3d_test_task.load_category = auth_3d_db_cat[auth_3d_category_index].name;
auth_3d_test_window->auth_3d_load = false;
}
if (auth_3d_test_window->auth_3d_uid_load) {
auth_3d_test_task.auth_3d_uid = auth_3d_test_window->auth_3d_uid;
auth_3d_test_window->auth_3d_uid_load = false;
}
}
}
bool data_test_auth_3d_test_hide(class_data* data) {
auth_3d_test_task.SetDest();
enum_and(data->flags, ~CLASS_HIDE);
enum_or(data->flags, CLASS_HIDDEN);
return true;
}
void data_test_auth_3d_test_imgui(class_data* data) {
ImGuiIO& io = ImGui::GetIO();
ImGuiStyle& style = ImGui::GetStyle();
ImFont* font = ImGui::GetFont();
float_t w = min((float_t)width, 280.0f);
float_t h = min((float_t)height, 324.0f);
ImGui::SetNextWindowPos({ 0, 0 }, ImGuiCond_Appearing);
ImGui::SetNextWindowSize({ w, h }, ImGuiCond_Always);
ImGuiWindowFlags window_flags = 0;
window_flags |= ImGuiWindowFlags_NoResize;
data->imgui_focus = false;
bool open = data->flags & CLASS_HIDDEN ? false : true;
bool collapsed = !ImGui::Begin(data_test_auth_3d_test_window_title, &open, window_flags);
if (!open) {
enum_or(data->flags, CLASS_HIDE);
ImGui::End();
return;
}
else if (collapsed) {
ImGui::End();
return;
}
if (!auth_3d_test_window) {
ImGui::End();
return;
}
auth_3d* auth = auth_3d_data_get_auth_3d(auth_3d_test_task.auth_3d_id);
if (auth)
auth_3d_test_window->last_frame = auth->play_control.size;
if (auth_3d_data_check_id_not_empty(&auth_3d_test_task.auth_3d_id)) {
auth_3d_test_window->enable = auth_3d_data_get_enable(&auth_3d_test_task.auth_3d_id);
auth_3d_test_window->frame = auth_3d_data_get_frame(&auth_3d_test_task.auth_3d_id);
auth_3d_test_window->frame_changed = false;
}
std::vector<data_test_auth_3d_test_category>& auth_3d_db_cat = auth_3d_test_window->category;
data_struct* aft_data = rctx_ptr->data;
auth_3d_database* aft_auth_3d_db = &aft_data->data_ft.auth_3d_db;
auth_3d_database_uid* uids = aft_auth_3d_db->uid.data();
int32_t auth_3d_category_index = auth_3d_test_window->auth_3d_category_index;
imguiGetContentRegionAvailSetNextItemWidth();
if (ImGui::BeginCombo("##Auth 3D Category Index", auth_3d_category_index > -1
? auth_3d_db_cat[auth_3d_category_index].name : "", 0)) {
for (data_test_auth_3d_test_category& i : auth_3d_db_cat) {
int32_t auth_3d_category_idx = (int32_t)(&i - auth_3d_db_cat.data());
ImGui::PushID(&i);
if (ImGui::Selectable(i.name, auth_3d_category_index == auth_3d_category_idx)
|| imguiItemKeyPressed(GLFW_KEY_ENTER, true)
|| (ImGui::IsItemFocused() && auth_3d_category_index != auth_3d_category_idx)) {
auth_3d_category_index = auth_3d_category_idx;
}
ImGui::PopID();
if (auth_3d_category_index == auth_3d_category_idx)
ImGui::SetItemDefaultFocus();
}
data->imgui_focus |= true;
ImGui::EndCombo();
}
if (auth_3d_category_index != auth_3d_test_window->auth_3d_category_index) {
data_test_auth_3d_test_category* cat = &auth_3d_db_cat[auth_3d_category_index];
if (cat->uid.size() > 0) {
auth_3d_test_window->auth_3d_load = true;
auth_3d_test_window->auth_3d_uid_load = true;
auth_3d_test_window->auth_3d_uid = cat->uid[cat->index].uid;
}
else {
auth_3d_test_window->auth_3d_load = false;
auth_3d_test_window->auth_3d_uid_load = false;
auth_3d_test_window->auth_3d_uid = -1;
}
auth_3d_test_window->auth_3d_category_index = auth_3d_category_index;
auth_3d_test_window->auth_3d_index = cat->index;
}
int32_t auth_3d_index = auth_3d_test_window->auth_3d_index;
ImGui::Text(" ID ");
ImGui::SameLine();
ImGui::Checkbox("OBJ Link", &auth_3d_test_task.window.obj_link);
imguiGetContentRegionAvailSetNextItemWidth();
bool auth_3d_category_found = false;
for (data_test_auth_3d_test_category& i : auth_3d_db_cat) {
if (auth_3d_category_index != &i - auth_3d_db_cat.data())
continue;
if (ImGui::BeginCombo("##Auth 3D Index", auth_3d_index > -1
? i.uid[auth_3d_index].name : "", 0)) {
for (data_test_auth_3d_test_uid& j : i.uid) {
int32_t auth_3d_idx = (int32_t)(&j - i.uid.data());
ImGui::PushID(&j);
if (ImGui::Selectable(j.name, auth_3d_index == auth_3d_idx)
|| imguiItemKeyPressed(GLFW_KEY_ENTER, true)
|| (ImGui::IsItemFocused() && auth_3d_index != auth_3d_idx)) {
auth_3d_test_window->auth_3d_index = -1;
auth_3d_index = auth_3d_idx;
}
ImGui::PopID();
if (auth_3d_index == auth_3d_idx)
ImGui::SetItemDefaultFocus();
}
data->imgui_focus |= true;
ImGui::EndCombo();
}
if (auth_3d_index != auth_3d_test_window->auth_3d_index) {
i.index = auth_3d_index;
auth_3d_test_window->auth_3d_uid_load = true;
auth_3d_test_window->auth_3d_uid = i.uid[auth_3d_index].uid;
auth_3d_test_window->auth_3d_index = auth_3d_index;
}
auth_3d_category_found = true;
break;
}
if (!auth_3d_category_found && ImGui::BeginCombo("##Auth 3D Index", "", 0)) {
data->imgui_focus |= true;
ImGui::EndCombo();
}
float_t frame = auth_3d_test_window->frame;
ImGui::Text("frame[ 0,%4.0f)", auth_3d_test_window->last_frame);
imguiGetContentRegionAvailSetNextItemWidth();
igSliderFloatButton("##frame slider", &frame, 1.0f,
0.0f, auth_3d_test_window->last_frame, "%5.0f", 0);
if (ImGui::IsItemActivated())
auth_3d_test_window->paused = true;
if (ImGui::Button("|<<", { 32.0, 0.0f }))
frame = 0.0f;
ImGui::SameLine();
if (ImGui::Button( auth_3d_test_window->paused ? " > " : "||", { 32.0, 0.0f }))
auth_3d_test_window->paused = auth_3d_test_window->paused ? false : true;
ImGui::SameLine();
if (ImGui::Button(">>|", { 32.0, 0.0f }))
frame = auth_3d_test_window->last_frame;
ImGui::SameLine();
if (ImGui::Checkbox("repeat", &auth_3d_test_task.repeat)
&& auth_3d_test_task.repeat && auth_3d_test_window->paused)
auth_3d_test_window->paused = false;
if (ImGui::Checkbox("Left Right Reverse", &auth_3d_test_task.left_right_reverse))
frame = 0.0f;
if (frame != auth_3d_test_window->frame) {
auth_3d_test_window->frame_changed = true;
auth_3d_test_window->frame = frame;
}
imguiColumnSliderFloat("transX", &auth_3d_test_task.trans_value.x, 0.1f, -5.0f, 5.0f, "%.2f", 0, true);
imguiColumnSliderFloat("transZ", &auth_3d_test_task.trans_value.z, 0.1f, -5.0f, 5.0f, "%.2f", 0, true);
imguiColumnSliderFloat("rotY", &auth_3d_test_task.rot_y_value, 1.0f, -360.0f, 360.0f, "%.0f", 0, true);
if (ImGui::Button("cam reset", { 72.0f, 0.0f }) && rctx_ptr && rctx_ptr->camera) {
camera* cam = rctx_ptr->camera;
camera_set_fov(cam, 32.2673416137695);
camera_set_roll(cam, 0.0);
vec3 view_point = { 0.0f, 1.0f, 6.0f };
camera_set_view_point(cam, &view_point);
vec3 interest = { 0.0f, 1.0f, 0.0f };
camera_set_interest(cam, &interest);
}
ImGui::Separator();
imguiColumnSliderFloat("Frame Speed", &frame_speed, 0.01f, 0.0f, 3.0f, "%.2f", 0, true);
data->imgui_focus |= ImGui::IsWindowFocused();
ImGui::End();
float_t x = w;
float_t y = 0.0f;
w = min((float_t)width, 200.0f);
h = min((float_t)height, 124.0f);
ImGui::SetNextWindowPos({ x, y }, ImGuiCond_Appearing);
ImGui::SetNextWindowSize({ w, h }, ImGuiCond_Always);
window_flags = 0;
window_flags |= ImGuiWindowFlags_NoResize;
window_flags |= ImGuiWindowFlags_NoCollapse;
if (ImGui::Begin("A3D STAGE", 0, window_flags)) {
stage* stg = task_stage_get_current_stage();
if (stg) {
ImGui::Checkbox("stage", &stg->stage_display);
ImGui::Checkbox("stg auth display", &stg->effect_display);
}
else {
bool stage = true;
ImGui::Checkbox("stage", &stage);
bool effects = true;
ImGui::Checkbox("stg auth display", &effects);
}
int32_t stage_index = auth_3d_test_task.stage_index;
imguiGetContentRegionAvailSetNextItemWidth();
if (ImGui::BeginCombo("##Stage Index", stage_index > -1
? auth_3d_test_window->stage[stage_index] : "", 0)) {
for (const char*& i : auth_3d_test_window->stage) {
int32_t stage_idx = (int32_t)(&i - auth_3d_test_window->stage.data());
ImGui::PushID(i);
if (ImGui::Selectable(i, stage_index == stage_idx)
|| imguiItemKeyPressed(GLFW_KEY_ENTER, true)
|| (ImGui::IsItemFocused() && stage_index != stage_idx))
stage_index = stage_idx;
ImGui::PopID();
if (stage_index == stage_idx)
ImGui::SetItemDefaultFocus();
}
data->imgui_focus |= ImGui::IsWindowFocused();
ImGui::EndCombo();
}
if (stage_index != auth_3d_test_task.stage_index)
auth_3d_test_task.load_stage_index = stage_index;
data->imgui_focus |= ImGui::IsWindowFocused();
}
ImGui::Checkbox("Stage Link Change", &auth_3d_test_task.window.stage_link_change);
if (auth_3d_data_check_id_not_empty(&auth_3d_test_task.auth_3d_id)) {
auth_3d_data_set_enable(&auth_3d_test_task.auth_3d_id, auth_3d_test_window->enable);
auth_3d_data_set_repeat(&auth_3d_test_task.auth_3d_id, auth_3d_test_task.repeat);
auth_3d_data_set_left_right_reverse(&auth_3d_test_task.auth_3d_id, auth_3d_test_task.left_right_reverse);
if (auth_3d_test_window->frame_changed) {
auth_3d_data_set_req_frame(&auth_3d_test_task.auth_3d_id, auth_3d_test_window->frame);
auth_3d_test_window->frame_changed = false;
}
auth_3d_data_set_paused(&auth_3d_test_task.auth_3d_id, auth_3d_test_window->paused);
auth_3d_data_set_frame_rate(&auth_3d_test_task.auth_3d_id, 0);
}
ImGui::End();
}
bool data_test_auth_3d_test_show(class_data* data) {
auth_3d_load();
if (!auth_3d_test_window)
auth_3d_test_window = new Auth3dTestWindow;
else {
auth_3d_test_window->auth_3d_category_index = -1;
auth_3d_test_window->auth_3d_category_index_prev = -1;
auth_3d_test_window->auth_3d_index = -1;
auth_3d_test_window->auth_3d_uid = -1;
}
auth_3d_test_window->enable = true;
auth_3d_test_window->frame = 0.0f;
auth_3d_test_window->frame_changed = false;
auth_3d_test_window->last_frame = 0.0f;
auth_3d_test_window->paused = false;
return true;
}
bool data_test_auth_3d_test_dispose(class_data* data) {
delete auth_3d_test_window;
data->flags = (class_flags)(CLASS_HIDDEN | CLASS_DISPOSED);
data->imgui_focus = false;
return true;
}
static bool auth_3d_load() {
app::TaskWork::AppendTask(&auth_3d_test_task, "AUTH3DTEST");
return true;
}
static bool auth_3d_unload() {
auth_3d_test_task.SetDest();
classes_data* c = &data_test_classes[DATA_TEST_AUTH_3D_TEST];
enum_or(c->data.flags, CLASS_HIDE);
return true;
}
static int data_test_auth_3d_test_uid_quicksort_compare_func(void const* src1, void const* src2) {
const char* str1 = ((data_test_auth_3d_test_uid*)src1)->name;
const char* str2 = ((data_test_auth_3d_test_uid*)src2)->name;
return str_utils_compare(str1, str2);
}
data_test_auth_3d_test_uid::data_test_auth_3d_test_uid(
const char* name, int32_t uid) : name(name), uid(uid) {
}
data_test_auth_3d_test_category::data_test_auth_3d_test_category() : name(), index() {
}
data_test_auth_3d_test_category::~data_test_auth_3d_test_category() {
}
Auth3dTestWindow::Auth3dTestWindow() {
data_struct* aft_data = rctx_ptr->data;
auth_3d_database* aft_auth_3d_db = &aft_data->data_ft.auth_3d_db;
object_database* aft_obj_db = &aft_data->data_ft.obj_db;
stage_database* aft_stage_data = &rctx_ptr->data->data_ft.stage_data;
std::vector<auth_3d_database_category>& auth_3d_db_cat = aft_auth_3d_db->category;
auth_3d_database_uid* uids = aft_auth_3d_db->uid.data();
category.resize(auth_3d_db_cat.size());
for (auth_3d_database_category& i : auth_3d_db_cat) {
data_test_auth_3d_test_category* cat = &category[&i - auth_3d_db_cat.data()];
cat->name = i.name.c_str();
cat->index = -1;
cat->uid.reserve(i.uid.size());
for (int32_t& j : i.uid)
if (uids[j].enabled)
cat->uid.push_back({ uids[j].name.c_str(), uids[j].org_uid });
if (cat->uid.size()) {
quicksort_custom(cat->uid.data(), cat->uid.size(),
sizeof(data_test_auth_3d_test_uid),
data_test_auth_3d_test_uid_quicksort_compare_func);
cat->index = 0;
}
}
auth_3d_category_index = -1;
auth_3d_category_index_prev = -1;
auth_3d_index = -1;
auth_3d_uid = -1;
auth_3d_load = false;
auth_3d_uid_load = false;
if (category.size() > 0) {
data_test_auth_3d_test_category* cat = &category.front();
if (cat->uid.size()) {
auth_3d_load = true;
auth_3d_uid_load = true;
auth_3d_uid = cat->uid.front().uid;
}
auth_3d_category_index = 0;
auth_3d_category_index_prev = 0;
auth_3d_index = cat->index;
}
stage.reserve(aft_stage_data->stage_data.size());
for (stage_data& i : aft_stage_data->stage_data)
stage.push_back(i.name.c_str());
enable = true;
frame = 0.0f;
frame_changed = false;
last_frame = 0.0f;
paused = false;
}
Auth3dTestWindow::~Auth3dTestWindow() {
}
void Auth3dTestWindow::Window() {
}
@@ -5,7 +5,7 @@
#pragma once
#include "../../../KKdLib/default.h"
#include "../../../KKdLib/default.hpp"
#include "../../classes.h"
extern bool data_test_auth_3d_test_init(class_data* data, render_context* rctx);
@@ -3,9 +3,9 @@
GitHub/GitLab: korenkonder
*/
#include "glitter_test.h"
#include "../../../KKdLib/io/path.h"
#include "../../../KKdLib/str_utils.h"
#include "glitter_test.hpp"
#include "../../../KKdLib/io/path.hpp"
#include "../../../KKdLib/str_utils.hpp"
#include "../../../CRE/Glitter/glitter.hpp"
#include "../../../CRE/data.hpp"
#include "../../../CRE/render_context.hpp"
@@ -13,9 +13,9 @@
#include "../../input.hpp"
#include "../data_test.h"
#include "../imgui_helper.h"
#include "stage_test.h"
#include "stage_test.hpp"
class TaskDataTestGlitterParticle : public TaskWindow {
class TaskDataTestGlitterParticle : public app::TaskWindow {
public:
uint64_t hash;
Glitter::SceneCounter scene_counter;
@@ -54,13 +54,13 @@ TaskDataTestGlitterParticle task_data_test_glitter_particle;
extern int32_t width;
extern int32_t height;
extern render_context* rctx_ptr;
extern vec3 clear_color;
extern vec4u8 clear_color;
extern bool input_reset;
extern bool input_locked;
extern bool draw_grid_3d;
bool task_data_test_glitter_particle_load() {
TaskWork::AppendTask(&task_data_test_glitter_particle, "DATA_TEST_PARTICLE");
app::TaskWork::AppendTask(&task_data_test_glitter_particle, "DATA_TEST_PARTICLE");
dtm_stg_load(0);
//dtw_stg_load(1);
return true;
@@ -90,11 +90,11 @@ bool TaskDataTestGlitterParticle::Init() {
QueryPerformanceCounter(&time);
Glitter::glt_particle_manager.counter = (uint32_t)(time.LowPart * 0x0CAD3078ULL);
data_list[DATA_AFT].get_directory_files("rom/particle/", &files);
data_list[DATA_AFT].get_directory_files("rom/particle/", files);
for (std::vector<data_struct_file>::iterator i = files.begin(); i != files.end();)
if (str_utils_check_ends_with(i->name.c_str(), ".farc")) {
char* temp = str_utils_get_without_extension(i->name.c_str());
i->name = temp ? temp : 0;
i->name = temp ? std::string(temp) : std::string();
free(temp);
i++;
}
@@ -106,7 +106,7 @@ bool TaskDataTestGlitterParticle::Init() {
Glitter::glt_particle_manager.draw_all_mesh = false;
dtm_stg_load(0);
clear_color = { (float_t)(96.0 / 255.0), (float_t)(96.0 / 255.0), (float_t)(96.0 / 255.0) };
clear_color = { 0x60, 0x60, 0x60, 0xFF };
camera* cam = rctx_ptr->camera;
camera_reset(cam);
@@ -5,7 +5,7 @@
#pragma once
#include "../../../KKdLib/default.h"
#include "../../../KKdLib/default.hpp"
#include "../../classes.h"
extern bool data_test_glitter_test_init(class_data* data, render_context* rctx);
@@ -3,10 +3,10 @@
GitHub/GitLab: korenkonder
*/
#include "stage_test.h"
#include "../../../KKdLib/io/path.h"
#include "stage_test.hpp"
#include "../../../KKdLib/io/path.hpp"
#include "../../../KKdLib/sort.hpp"
#include "../../../KKdLib/str_utils.h"
#include "../../../KKdLib/str_utils.hpp"
#include "../../../CRE/data.hpp"
#include "../../../CRE/render_context.hpp"
#include "../../../CRE/stage.hpp"
@@ -22,7 +22,7 @@ struct data_test_stage_test_stage_pv {
~data_test_stage_test_stage_pv();
};
class DtwStg : public TaskWindow {
class DtwStg : public app::TaskWindow {
public:
int32_t pv_id;
int32_t pv_index;
@@ -39,13 +39,14 @@ public:
DtwStg();
virtual ~DtwStg() override;
virtual void Window() override;
};
extern int32_t width;
extern int32_t height;
extern render_context* rctx_ptr;
extern vec3 clear_color;
extern vec4u8 clear_color;
static const char* data_test_stage_test_window_title = "Stage Test##Data Test";
@@ -325,7 +326,7 @@ static int data_test_stage_test_stage_pv_quicksort_compare_func(void const* src1
}
static bool stage_test_load() {
clear_color = { (float_t)(96.0 / 255.0), (float_t)(96.0 / 255.0), (float_t)(96.0 / 255.0) };
clear_color = { 96, 96, 96, 255 };
camera* cam = rctx_ptr->camera;
camera_reset(cam);
@@ -333,7 +334,7 @@ static bool stage_test_load() {
camera_set_view_point(cam, &view_point);
vec3 interest = { 0.0f, 1.0f, 0.0f };
camera_set_interest(cam, &interest);
TaskWork::AppendTask(&dtm_stg, "DATA_TEST_STAGE");
app::TaskWork::AppendTask(&dtm_stg, "DATA_TEST_STAGE");
if (!dtw_stg)
dtw_stg = new DtwStg();
@@ -349,6 +350,7 @@ static bool stage_test_unload() {
enum_or(c->data.flags, CLASS_HIDE);
return true;
}
data_test_stage_test_stage_pv::data_test_stage_test_stage_pv(int32_t pv_id) {
this->pv_id = pv_id;
}
@@ -5,7 +5,7 @@
#pragma once
#include "../../../KKdLib/default.h"
#include "../../../KKdLib/default.hpp"
#include "../../classes.h"
extern bool data_test_stage_test_init(class_data* data, render_context* rctx);
+1 -1
View File
@@ -5,7 +5,7 @@
#pragma once
#include "../../../KKdLib/default.h"
#include "../../../KKdLib/default.hpp"
#include "../../classes.h"
extern bool data_view_auth_3d_init(class_data* data, render_context* rctx);
+1 -1
View File
@@ -5,7 +5,7 @@
#pragma once
#include "../../../KKdLib/default.h"
#include "../../../KKdLib/default.hpp"
#include "../../classes.h"
extern bool data_view_draw_task_init(class_data* data, render_context* rctx);
+1 -1
View File
@@ -5,7 +5,7 @@
#pragma once
#include "../../../KKdLib/default.h"
#include "../../../KKdLib/default.hpp"
#include "../../classes.h"
extern bool data_view_glitter_init(class_data* data, render_context* rctx);
+1 -1
View File
@@ -5,7 +5,7 @@
#pragma once
#include "../../../KKdLib/default.h"
#include "../../../KKdLib/default.hpp"
#include "../../classes.h"
extern bool data_view_object_init(class_data* data, render_context* rctx);
+1 -1
View File
@@ -5,7 +5,7 @@
#pragma once
#include "../../../KKdLib/default.h"
#include "../../../KKdLib/default.hpp"
#include "../../classes.h"
extern bool data_view_texture_init(class_data* data, render_context* rctx);
+69 -74
View File
@@ -7,20 +7,20 @@
#if defined(CLOUD_DEV)
#include "glitter_editor.h"
#include "../../KKdLib/io/path.h"
#include "../../KKdLib/io/stream.h"
#include "../../KKdLib/dds.h"
#include "../../KKdLib/io/path.hpp"
#include "../../KKdLib/io/stream.hpp"
#include "../../KKdLib/dds.hpp"
#include "../../KKdLib/interpolation.h"
#include "../../KKdLib/str_utils.h"
#include "../../KKdLib/str_utils.hpp"
#include "../../KKdLib/txp.hpp"
#include "../../KKdLib/vec.h"
#include "../../KKdLib/vec.hpp"
#include "../../CRE/Glitter/glitter.hpp"
#include "../../CRE/camera.h"
#include "../../CRE/data.hpp"
#include "../../CRE/draw_task.h"
#include "../../CRE/gl_state.h"
#include "../../CRE/render_context.hpp"
#include "../../CRE/shader_glsl.h"
#include "../../CRE/shader_glsl.hpp"
#include "../../CRE/stage.hpp"
#include "../../CRE/static_var.h"
#include "../input.hpp"
@@ -322,11 +322,11 @@ bool glitter_editor_init(class_data* data, render_context* rctx) {
GlitterFileReader* fr = 0;
if (files_x.begin) {
stream s;
io_open(&s, L"name_VRFL.glitter.txt", L"rb");
s.open(L"name_VRFL.glitter.txt", L"rb");
size_t length = s.length;
uint8_t* data = force_malloc(length);
io_read(&s, data, length);
io_free(&s);
s.read(data, length);
s.close();
char* buf;
char** lines;
@@ -470,11 +470,11 @@ bool glitter_editor_init(class_data* data, render_context* rctx) {
}
stream s;
io_open(&s, L"name_F2.glitter.txt", L"rb");
s.open(L"name_F2.glitter.txt", L"rb");
size_t length = s.length;
uint8_t* data = force_malloc(length);
io_read(&s, data, length);
io_free(&s);
s.read(data, length);
s.close();
char* buf;
char** lines;
@@ -1725,16 +1725,15 @@ static void glitter_editor_save_file(glitter_editor_struct* glt_edt, const char*
if (glt_type != Glitter::FT) {
char* list_temp = str_utils_add(temp, ".glitter.txt");
stream s;
io_open(&s, list_temp, "wb");
s.open(list_temp, "wb");
if (s.io.stream) {
Glitter::EffectGroup* eg = glt_edt->effect_group;
for (Glitter::Effect*& i : eg->effects)
if (i) {
io_write_string(&s, &i->name);
io_write_char(&s, '\n');
s.write_string(i->name);
s.write_char('\n');
}
}
io_free(&s);
free(list_temp);
}
f.write(temp, mode, false);
@@ -1759,11 +1758,11 @@ static bool glitter_editor_list_open_window(Glitter::EffectGroup* eg) {
ofn.lpstrTitle = L"File to Open";
if (GetOpenFileNameW(&ofn)) {
stream s;
io_open(&s, file, L"rb");
s.open(file, L"rb");
size_t length = s.length;
uint8_t* data = force_malloc_s(uint8_t, length);
io_read(&s, data, length);
io_free(&s);
s.read(data, length);
s.close();
char* buf;
char** lines;
@@ -1841,7 +1840,6 @@ static bool glitter_editor_resource_import(glitter_editor_struct* glt_edt) {
if (GetOpenFileNameW(&ofn)) {
wchar_t* f = str_utils_get_without_extension(file);
wchar_t* p = str_utils_split_right_get_left(file, L'.');
dds* d = dds_init();
uint64_t hash_ft = hash_utf16_fnv1a64m(f);
uint64_t hash_f2 = hash_utf16_murmurhash(f);
@@ -1855,44 +1853,45 @@ static bool glitter_editor_resource_import(glitter_editor_struct* glt_edt) {
for (int32_t i = 0; i < rc; i++)
if (rh[i] == hash_ft || rh[i] == hash_f2)
goto DDSEnd;
{
dds d;
d.read(p);
if (d.width == 0 || d.height == 0 || d.mipmaps_count == 0 || d.data.size() < 1)
goto DDSEnd;
dds_read(d, p);
if (d->width == 0 || d->height == 0 || d->mipmaps_count == 0 || vector_old_length(d->data) < 1)
goto DDSEnd;
eg->resources_tex.textures.push_back({});
tex = &eg->resources_tex.textures.back();
tex->array_size = d.has_cube_map ? 6 : 1;
tex->has_cube_map = d.has_cube_map;
tex->mipmaps_count = d.mipmaps_count;
eg->resources_tex.textures.push_back({});
tex = &eg->resources_tex.textures.back();
tex->array_size = d->has_cube_map ? 6 : 1;
tex->has_cube_map = d->has_cube_map;
tex->mipmaps_count = d->mipmaps_count;
tex->mipmaps.reserve((tex->has_cube_map ? 6LL : 1LL) * tex->mipmaps_count);
index = 0;
do
for (uint32_t i = 0; i < tex->mipmaps_count; i++) {
txp_mipmap tex_mip;
memset(&tex_mip, 0, sizeof(txp_mipmap));
tex_mip.width = max(d.width >> i, 1);
tex_mip.height = max(d.height >> i, 1);
tex_mip.format = d.format;
tex->mipmaps.reserve((tex->has_cube_map ? 6LL : 1LL) * tex->mipmaps_count);
index = 0;
do
for (uint32_t i = 0; i < tex->mipmaps_count; i++) {
txp_mipmap tex_mip;
memset(&tex_mip, 0, sizeof(txp_mipmap));
tex_mip.width = max(d->width >> i, 1);
tex_mip.height = max(d->height >> i, 1);
tex_mip.format = d->format;
uint32_t size = txp::get_size(tex_mip.format, tex_mip.width, tex_mip.height);
tex_mip.size = size;
tex_mip.data.resize(size);
memcpy(tex_mip.data.data(), d.data[index], size);
tex->mipmaps.push_back(tex_mip);
index++;
}
while (index / tex->mipmaps_count < tex->array_size);
uint32_t size = txp::get_size(tex_mip.format, tex_mip.width, tex_mip.height);
tex_mip.size = size;
tex_mip.data.resize(size);
memcpy(tex_mip.data.data(), d->data.begin[index], size);
tex->mipmaps.push_back(tex_mip);
index++;
}
while (index / tex->mipmaps_count < tex->array_size);
eg->resources_count++;
if (eg->type == Glitter::FT)
eg->resource_hashes.push_back(hash_ft);
else
eg->resource_hashes.push_back(hash_f2);
ret = true;
eg->resources_count++;
if (eg->type == Glitter::FT)
eg->resource_hashes.push_back(hash_ft);
else
eg->resource_hashes.push_back(hash_f2);
ret = true;
}
DDSEnd:
dds_dispose(d);
free(f);
free(p);
}
@@ -1921,7 +1920,6 @@ static bool glitter_editor_resource_export(glitter_editor_struct* glt_edt) {
ofn.Flags = OFN_NONETWORKBUTTON;
if (GetSaveFileNameW(&ofn)) {
wchar_t* p = str_utils_split_right_get_left(file, L'.');
dds* d = dds_init();
Glitter::EffectGroup* eg = glt_edt->effect_group;
txp& tex = eg->resources_tex.textures[sel_rsrc];
@@ -1930,27 +1928,25 @@ static bool glitter_editor_resource_export(glitter_editor_struct* glt_edt) {
uint32_t width = tex.mipmaps[0].width;
uint32_t height = tex.mipmaps[0].height;
d->format = format;
d->width = width;
d->height = height;
d->mipmaps_count = tex.mipmaps_count;
d->has_cube_map = tex.has_cube_map;
d->data = vector_old_ptr_empty(void);
vector_old_ptr_void_reserve(&d->data, (tex.has_cube_map ? 6LL : 1LL) * tex.mipmaps_count);
dds d;
d.format = format;
d.width = width;
d.height = height;
d.mipmaps_count = tex.mipmaps_count;
d.has_cube_map = tex.has_cube_map;
d.data.reserve((tex.has_cube_map ? 6LL : 1LL) * tex.mipmaps_count);
uint32_t index = 0;
do
for (uint32_t i = 0; i < tex.mipmaps_count; i++) {
uint32_t size = txp::get_size(format, max(width >> i, 1), max(height >> i, 1));
void* data = force_malloc(size);
memcpy(data, tex.mipmaps[index].data.data(), size);
vector_old_ptr_void_push_back(&d->data, &data);
d.data.push_back(data);
index++;
}
while (index / tex.mipmaps_count < tex.array_size);
dds_write(d, p);
d.write(p);
ret = true;
dds_dispose(d);
free(p);
}
CoUninitialize();
@@ -4054,7 +4050,7 @@ static void glitter_editor_property_particle(glitter_editor_struct* glt_edt, cla
}
imguiStartPropertyColumn("Object");
if (ImGui::BeginCombo("##Object", obj ? string_data(&obj->name) : "None", 0)) {
if (ImGui::BeginCombo("##Object", obj ? obj->name : "None", 0)) {
if (set_id != -1 && handler && handler->set_id == set_id && handler->obj_set) {
obj_set* set = handler->obj_set;
ssize_t obj_index = -1;
@@ -4074,7 +4070,7 @@ static void glitter_editor_property_particle(glitter_editor_struct* glt_edt, cla
for (uint32_t i = 0; i < set->obj_num; i++) {
ImGui::PushID(i);
::obj* obj = &set->obj_data[i];
if (ImGui::Selectable(string_data(&obj->name), obj->id == obj_id)
if (ImGui::Selectable(obj->name, obj->id == obj_id)
|| imguiItemKeyPressed(GLFW_KEY_ENTER, true)
|| (ImGui::IsItemFocused() && obj->id != obj_id))
obj_index = i;
@@ -6529,8 +6525,7 @@ static void glitter_editor_gl_load(glitter_editor_struct* glt_edt) {
" result = color;\n"
"}\n";
shader_glsl_param param;
memset(&param, 0, sizeof(shader_glsl_param));
shader_glsl_param param = {};
param.name = "Glitter Editor Wireframe";
glt_edt->gl_data.wireframe.shader.load(glitter_editor_wireframe_vert,
glitter_editor_wireframe_frag, 0, &param);
@@ -6716,7 +6711,7 @@ static void glitter_editor_gl_draw_wireframe_draw(glitter_editor_struct* glt_edt
gl_state_bind_vertex_array(glt_edt->vao);
glt_edt->gl_data.wireframe.shader.use();
shader_glsl_set_vec4_value(&glt_edt->gl_data.wireframe.shader, "color", 1.0f, 1.0f, 0.0f, 1.0f);
glt_edt->gl_data.wireframe.shader.set("color", 1.0f, 1.0f, 0.0f, 1.0f);
for (Glitter::F2RenderGroup*& i : eff->render_scene.groups) {
if (!i)
continue;
@@ -6727,7 +6722,7 @@ static void glitter_editor_gl_draw_wireframe_draw(glitter_editor_struct* glt_edt
else if (rg->disp < 1)
continue;
shader_glsl_set_mat4(&glt_edt->gl_data.wireframe.shader, "model", false, rg->mat_draw);
glt_edt->gl_data.wireframe.shader.set("model", false, rg->mat_draw);
switch (rg->type) {
case Glitter::PARTICLE_QUAD: {
@@ -6778,7 +6773,7 @@ static void glitter_editor_gl_draw_wireframe_draw(glitter_editor_struct* glt_edt
gl_state_bind_vertex_array(glt_edt->vao);
glt_edt->gl_data.wireframe.shader.use();
shader_glsl_set_vec4_value(&glt_edt->gl_data.wireframe.shader, "color", 1.0f, 1.0f, 0.0f, 1.0f);
glt_edt->gl_data.wireframe.shader.set("color", 1.0f, 1.0f, 0.0f, 1.0f);
for (Glitter::XRenderGroup*& i : eff->render_scene.groups) {
if (!i)
continue;
@@ -6789,7 +6784,7 @@ static void glitter_editor_gl_draw_wireframe_draw(glitter_editor_struct* glt_edt
else if (rg->disp < 1)
continue;
shader_glsl_set_mat4(&glt_edt->gl_data.wireframe.shader, "model", false, rg->mat_draw);
glt_edt->gl_data.wireframe.shader.set("model", false, rg->mat_draw);
switch (rg->type) {
case Glitter::PARTICLE_QUAD: {
@@ -6865,7 +6860,7 @@ static void glitter_editor_gl_draw_wireframe_draw_mesh(glitter_editor_struct* gl
object_data, rctx->camera, &mat)))
continue;
shader_glsl_set_mat4(&glt_edt->gl_data.wireframe.shader, "model", false, mat);
glt_edt->gl_data.wireframe.shader.set("model", false, mat);
int32_t ttc = 0;
texture_transform_struct* tt = object_data->texture_transform_array;
+1 -1
View File
@@ -6,7 +6,7 @@
#pragma once
#if defined(CLOUD_DEV)
#include "../../KKdLib/default.h"
#include "../../KKdLib/default.hpp"
#include "../classes.h"
extern bool glitter_editor_init(class_data* data, render_context* rctx);
+11 -4
View File
@@ -4,12 +4,12 @@
*/
#include "background_color.h"
#include "../../../KKdLib/vec.h"
#include "../../../KKdLib/vec.hpp"
#include "../imgui_helper.h"
extern int32_t width;
extern int32_t height;
extern vec3 clear_color;
extern vec4u8 clear_color;
extern bool set_clear_color;
static const char* graphics_background_color_window_title = "Background Color##Graphics";
@@ -52,11 +52,18 @@ void graphics_background_color_imgui(class_data* data) {
color_edit_flags |= ImGuiColorEditFlags_NoDragDrop;
imguiGetContentRegionAvailSetNextItemWidth();
ImGui::ColorEdit3("##Background Color", (float_t*)&clear_color, color_edit_flags);
vec4 _clear_color;
vec4u8_to_vec4(clear_color, _clear_color);
vec4_mult_scalar(_clear_color, (float_t)(1.0 / 255.0), _clear_color);
if (ImGui::ColorEdit4("##Background Color", (float_t*)&_clear_color, color_edit_flags)) {
vec4_clamp_scalar(_clear_color, 0.0f, 1.0f, _clear_color);
vec4_mult_scalar(_clear_color, 255.0f, _clear_color);
vec4_to_vec4u8(_clear_color, clear_color);
}
ImGui::Checkbox("Set Clear Color", &set_clear_color);
if (imguiButton("Reset Color")) {
clear_color = { (float_t)(96.0 / 255.0), (float_t)(96.0 / 255.0), (float_t)(96.0 / 255.0) };
clear_color = { 0x60, 0x60, 0x60, 0xFF };
set_clear_color = true;
}
@@ -5,7 +5,7 @@
#pragma once
#include "../../../KKdLib/default.h"
#include "../../../KKdLib/default.hpp"
#include "../../classes.h"
extern bool graphics_background_color_init(class_data* data, render_context* rctx);
+1 -1
View File
@@ -5,7 +5,7 @@
#pragma once
#include "../../../KKdLib/default.h"
#include "../../../KKdLib/default.hpp"
#include "../../classes.h"
extern bool graphics_glitter_init(class_data* data, render_context* rctx);
+26 -31
View File
@@ -69,27 +69,24 @@ void graphics_post_process_imgui(class_data* data) {
imguiSetColumnSpace(1.0f / 4.0f);
if (ImGui::TreeNode("Tone Trans")) {
vec3 tone_trans_start;
post_process_tone_map_get_tone_trans_start(tone_map, &tone_trans_start);
vec3 tone_trans_start = tone_map->get_tone_trans_start();
imguiColumnSliderVec3("Start", &tone_trans_start, 0.01f, 0.0f, 1.0f, "%.2f", 0, true);
post_process_tone_map_set_tone_trans_start(tone_map, &tone_trans_start);
tone_map->set_tone_trans_start(tone_trans_start);
vec3 tone_trans_end;
post_process_tone_map_get_tone_trans_end(tone_map, &tone_trans_end);
vec3 tone_trans_end = tone_map->get_tone_trans_end();
imguiColumnSliderVec3("End", &tone_trans_end, 0.01f, 0.0f, 1.0f, "%.2f", 0, true);
post_process_tone_map_set_tone_trans_end(tone_map, &tone_trans_end);
tone_map->set_tone_trans_end(tone_trans_end);
ImGui::TreePop();
}
if (ImGui::TreeNode("Scene Fade")) {
float_t scene_fade_alpha = post_process_tone_map_get_scene_fade_alpha(tone_map);
float_t scene_fade_alpha = tone_map->get_scene_fade_alpha();
imguiColumnSliderFloat("Alpha", &scene_fade_alpha, 0.01f, 0.0f, 1.0f, "%.2f", 0, true);
post_process_tone_map_set_scene_fade_alpha(tone_map, scene_fade_alpha);
tone_map->set_scene_fade_alpha(scene_fade_alpha);
vec3 scene_fade_color;
post_process_tone_map_get_scene_fade_color(tone_map, &scene_fade_color);
vec3 scene_fade_color = tone_map->get_scene_fade_color();
imguiColumnSliderVec3("Color", &scene_fade_color, 0.01f, 0.0f, 1.0f, "%.2f", 0, true);
post_process_tone_map_set_scene_fade_color(tone_map, &scene_fade_color);
tone_map->set_scene_fade_color(scene_fade_color);
const char* scene_fade_blend_func_labels[] = {
"0: OVER",
@@ -97,10 +94,10 @@ void graphics_post_process_imgui(class_data* data) {
"2: PLUS",
};
int32_t scene_fade_blend_func = post_process_tone_map_get_scene_fade_blend_func(tone_map);
int32_t scene_fade_blend_func = tone_map->get_scene_fade_blend_func();
imguiColumnComboBox("Blend Func", scene_fade_blend_func_labels, 3,
&scene_fade_blend_func, 0, false, &data->imgui_focus);
post_process_tone_map_set_scene_fade_blend_func(tone_map, scene_fade_blend_func);
tone_map->set_scene_fade_blend_func(scene_fade_blend_func);
ImGui::TreePop();
}
@@ -111,48 +108,46 @@ void graphics_post_process_imgui(class_data* data) {
"RGB LINEAR2",
};
int32_t _tone_map_method = post_process_tone_map_get_tone_map_method(tone_map);
int32_t _tone_map_method = tone_map->get_tone_map_method();
imguiColumnComboBox("Tone Map", tone_map_method_labels, 3,
&_tone_map_method, 0, false, &data->imgui_focus);
post_process_tone_map_set_tone_map_method(tone_map, (tone_map_method)_tone_map_method);
tone_map->set_tone_map_method((tone_map_method)_tone_map_method);
float_t exposure = post_process_tone_map_get_exposure(tone_map);
float_t exposure = tone_map->get_exposure();
imguiColumnSliderFloat("Exposure", &exposure, 0.02f, 0.0f, 4.0f, "%.2f", 0, true);
exposure = roundf(exposure / 0.02f) * 0.02f;
post_process_tone_map_set_exposure(tone_map, exposure);
tone_map->set_exposure(exposure);
bool auto_exposure = post_process_tone_map_get_auto_exposure(tone_map);
bool auto_exposure = tone_map->get_auto_exposure();
imguiCheckbox("Auto Exposure", &auto_exposure);
post_process_tone_map_set_auto_exposure(tone_map, auto_exposure);
tone_map->set_auto_exposure(auto_exposure);
float_t gamma = post_process_tone_map_get_gamma(tone_map);
float_t gamma = tone_map->get_gamma();
imguiColumnSliderFloat("Gamma", &gamma, 0.01f, 0.2f, 2.2f, "%.2f", 0, true);
post_process_tone_map_set_gamma(tone_map, gamma);
tone_map->set_gamma(gamma);
int32_t saturate1 = post_process_tone_map_get_saturate_power(tone_map);
int32_t saturate1 = tone_map->get_saturate_power();
imguiColumnSliderInt("Saturate 1", &saturate1, 1, 6, "%d", 0, true);
post_process_tone_map_set_saturate_power(tone_map, saturate1);
tone_map->set_saturate_power(saturate1);
float_t saturate2 = post_process_tone_map_get_saturate_coeff(tone_map);
float_t saturate2 = tone_map->get_saturate_coeff();
imguiColumnSliderFloat("Saturate 2", &saturate2, 0.01f, 0.0f, 1.0f, "%.2f", 0, true);
post_process_tone_map_set_saturate_coeff(tone_map, saturate2);
tone_map->set_saturate_coeff(saturate2);
ImGui::TreePop();
}
if (ImGui::TreeNodeEx("Glare", ImGuiTreeNodeFlags_DefaultOpen)) {
vec3 radius;
post_process_blur_get_radius(blur, &radius);
vec3 radius = blur->get_radius();
imguiColumnSliderFloat("Radius R", &radius.x, 0.1f, 1.0f, 3.0f, "%.2f", 0, true);
imguiColumnSliderFloat("Radius G", &radius.y, 0.1f, 1.0f, 3.0f, "%.2f", 0, true);
imguiColumnSliderFloat("Radius B", &radius.z, 0.1f, 1.0f, 3.0f, "%.2f", 0, true);
post_process_blur_set_radius(blur, &radius);
blur->set_radius(radius);
vec3 intensity;
post_process_blur_get_intensity(blur, &intensity);
vec3 intensity = blur->get_intensity();
imguiColumnSliderFloat("Inten R", &intensity.x, 0.05f, 0.0f, 2.0f, "%.2f", 0, true);
imguiColumnSliderFloat("Inten G", &intensity.y, 0.05f, 0.0f, 2.0f, "%.2f", 0, true);
imguiColumnSliderFloat("Inten B", &intensity.z, 0.05f, 0.0f, 2.0f, "%.2f", 0, true);
post_process_blur_set_intensity(blur, &intensity);
blur->set_intensity(intensity);
ImGui::TreePop();
}
imguiSetDefaultColumnSpace();
+1 -1
View File
@@ -5,7 +5,7 @@
#pragma once
#include "../../../KKdLib/default.h"
#include "../../../KKdLib/default.hpp"
#include "../../classes.h"
extern bool graphics_post_process_init(class_data* data, render_context* rctx);
+1 -1
View File
@@ -5,7 +5,7 @@
#pragma once
#include "../../../KKdLib/default.h"
#include "../../../KKdLib/default.hpp"
#include "../../classes.h"
extern bool graphics_render_settings_init(class_data* data, render_context* rctx);
+11 -11
View File
@@ -4,7 +4,7 @@
*/
#include "imgui_helper.h"
#include "../../KKdLib/str_utils.h"
#include "../../KKdLib/str_utils.hpp"
#include "../../CRE/data.hpp"
const float_t imgui_alpha_disabled_scale = 0.5f;
@@ -463,7 +463,7 @@ bool imguiComboBox(const char* label, const char** items, const size_t size,
return prev_selected_idx != *selected_idx;
}
bool imguiComboBoxString(const char* label, string* items, const size_t size,
bool imguiComboBoxString(const char* label, std::string* items, const size_t size,
int32_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus) {
int32_t prev_selected_idx = *selected_idx;
@@ -478,11 +478,11 @@ bool imguiComboBoxString(const char* label, string* items, const size_t size,
return false;
}
if (ImGui::BeginCombo(label, *selected_idx != -1 ? string_data(&items[*selected_idx]) : 0, flags)) {
if (ImGui::BeginCombo(label, *selected_idx != -1 ? items[*selected_idx].c_str() : 0, flags)) {
if (include_last)
for (size_t n = 0; n <= size; n++) {
ImGui::PushID((int32_t)n);
if (ImGui::Selectable(string_data(&items[n]), *selected_idx == n)
if (ImGui::Selectable(items[n].c_str(), *selected_idx == n)
|| imguiItemKeyPressed(GLFW_KEY_ENTER, true)
|| (ImGui::IsItemFocused() && *selected_idx != n))
*selected_idx = (int32_t)n;
@@ -494,7 +494,7 @@ bool imguiComboBoxString(const char* label, string* items, const size_t size,
else
for (size_t n = 0; n < size; n++) {
ImGui::PushID((int32_t)n);
if (ImGui::Selectable(string_data(&items[n]), *selected_idx == n)
if (ImGui::Selectable(items[n].c_str(), *selected_idx == n)
|| imguiItemKeyPressed(GLFW_KEY_ENTER, true)
|| (ImGui::IsItemFocused() && *selected_idx != n))
*selected_idx = (int32_t)n;
@@ -511,7 +511,7 @@ bool imguiComboBoxString(const char* label, string* items, const size_t size,
return prev_selected_idx != *selected_idx;
}
bool imguiComboBoxString(const char* label, string* items, const size_t size,
bool imguiComboBoxString(const char* label, std::string* items, const size_t size,
size_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus) {
size_t prev_selected_idx = *selected_idx;
@@ -526,11 +526,11 @@ bool imguiComboBoxString(const char* label, string* items, const size_t size,
return false;
}
if (ImGui::BeginCombo(label, *selected_idx != -1 ? string_data(&items[*selected_idx]) : 0, flags)) {
if (ImGui::BeginCombo(label, *selected_idx != -1 ? items[*selected_idx].c_str() : 0, flags)) {
if (include_last)
for (size_t n = 0; n <= size; n++) {
ImGui::PushID((void*)n);
if (ImGui::Selectable(string_data(&items[n]), *selected_idx == n)
if (ImGui::Selectable(items[n].c_str(), *selected_idx == n)
|| imguiItemKeyPressed(GLFW_KEY_ENTER, true)
|| (ImGui::IsItemFocused() && *selected_idx != n))
*selected_idx = n;
@@ -542,7 +542,7 @@ bool imguiComboBoxString(const char* label, string* items, const size_t size,
else
for (size_t n = 0; n < size; n++) {
ImGui::PushID((void*)n);
if (ImGui::Selectable(string_data(&items[n]), *selected_idx == n)
if (ImGui::Selectable(items[n].c_str(), *selected_idx == n)
|| imguiItemKeyPressed(GLFW_KEY_ENTER, true)
|| (ImGui::IsItemFocused() && *selected_idx != n))
*selected_idx = n;
@@ -695,7 +695,7 @@ bool imguiColumnComboBox(const char* label, const char** items, const size_t siz
return res;
}
bool imguiColumnComboBoxString(const char* label, string* items, const size_t size,
bool imguiColumnComboBoxString(const char* label, std::string* items, const size_t size,
int32_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus) {
imguiStartPropertyColumn(label);
bool res = imguiComboBoxString("", items, size, selected_idx, flags, include_last, focus);
@@ -703,7 +703,7 @@ bool imguiColumnComboBoxString(const char* label, string* items, const size_t si
return res;
}
bool imguiColumnComboBoxString(const char* label, string* items, const size_t size,
bool imguiColumnComboBoxString(const char* label, std::string* items, const size_t size,
size_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus) {
imguiStartPropertyColumn(label);
bool res = imguiComboBoxString("", items, size, selected_idx, flags, include_last, focus);
+7 -7
View File
@@ -5,9 +5,9 @@
#pragma once
#include "../../KKdLib/default.h"
#include "../../KKdLib/string.h"
#include "../../KKdLib/vec.h"
#include <string>
#include "../../KKdLib/default.hpp"
#include "../../KKdLib/vec.hpp"
#define CIMGUI_DEFINE_ENUMS_AND_STRUCTS
#include <imgui/imgui.h>
#include <imgui/imgui_internal.h>
@@ -54,9 +54,9 @@ extern bool imguiComboBox(const char* label, const char** items, const size_t si
int32_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
extern bool imguiComboBox(const char* label, const char** items, const size_t size,
size_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
extern bool imguiComboBoxString(const char* label, string* items, const size_t size,
extern bool imguiComboBoxString(const char* label, std::string* items, const size_t size,
int32_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
extern bool imguiComboBoxString(const char* label, string* items, const size_t size,
extern bool imguiComboBoxString(const char* label, std::string* items, const size_t size,
size_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
extern bool imguiComboBoxConfigFile(const char* label, void* items, const size_t size,
int32_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
@@ -68,9 +68,9 @@ extern bool imguiColumnComboBox(const char* label, const char** items, const siz
int32_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
extern bool imguiColumnComboBox(const char* label, const char** items, const size_t size,
size_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
extern bool imguiColumnComboBoxString(const char* label, string* items, const size_t size,
extern bool imguiColumnComboBoxString(const char* label, std::string* items, const size_t size,
int32_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
extern bool imguiColumnComboBoxString(const char* label, string* items, const size_t size,
extern bool imguiColumnComboBoxString(const char* label, std::string* items, const size_t size,
size_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
extern bool imguiColumnComboBoxConfigFile(const char* label, void* items, const size_t size,
int32_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
+1 -1
View File
@@ -5,7 +5,7 @@
#pragma once
#include "../../../KKdLib/default.h"
#include "../../../KKdLib/default.hpp"
#include "../../classes.h"
extern bool information_frame_speed_init(class_data* data, render_context* rctx);
+14 -14
View File
@@ -5,7 +5,7 @@
#include "task.h"
#include "../../../KKdLib/sort.hpp"
#include "../../../KKdLib/str_utils.h"
#include "../../../KKdLib/str_utils.hpp"
#include "../../../CRE/task.hpp"
#include "../imgui_helper.h"
@@ -58,9 +58,9 @@ void information_task_imgui(class_data* data) {
return;
}
std::vector<Task*> vec;
std::vector<app::Task*> vec;
for (int32_t i = 0; ; i++) {
Task* t = TaskWork::GetTaskByIndex(i);
app::Task* t = app::TaskWork::GetTaskByIndex(i);
if (!t)
break;
@@ -69,13 +69,13 @@ void information_task_imgui(class_data* data) {
switch (task_sort) {
case 2:
quicksort_custom(vec.data(), vec.size(), sizeof(Task*), task_sort_by_name);
quicksort_custom(vec.data(), vec.size(), sizeof(app::Task*), task_sort_by_name);
break;
case 3:
quicksort_custom(vec.data(), vec.size(), sizeof(Task*), task_sort_by_calc);
quicksort_custom(vec.data(), vec.size(), sizeof(app::Task*), task_sort_by_calc);
break;
case 4:
quicksort_custom(vec.data(), vec.size(), sizeof(Task*), task_sort_by_disp);
quicksort_custom(vec.data(), vec.size(), sizeof(app::Task*), task_sort_by_disp);
break;
}
@@ -84,13 +84,13 @@ void information_task_imgui(class_data* data) {
ImGui::BeginListBox("#Tasks", size);
char buf[0x100];
if (show_priority)
for (Task*& i : vec) {
for (app::Task*& i : vec) {
sprintf_s(buf, sizeof(buf), "%1d %-30s % 7d(% 7d) % 7d(% 7d)", i->priority,
i->GetName(), i->GetCalcTime(), i->GetCalcTimeMax(), i->GetDispTime(), i->GetDispTimeMax());
ImGui::Selectable(buf);
}
else
for (Task*& i : vec) {
for (app::Task*& i : vec) {
sprintf_s(buf, sizeof(buf), "%-32s % 7d(% 7d) % 7d(% 7d)",
i->GetName(), i->GetCalcTime(), i->GetCalcTimeMax(), i->GetDispTime(), i->GetDispTimeMax());
ImGui::Selectable(buf);
@@ -149,19 +149,19 @@ bool information_task_dispose(class_data* data) {
}
static int32_t task_sort_by_calc(void const* src1, void const* src2) {
Task* t1 = *(Task**)src1;
Task* t2 = *(Task**)src2;
app::Task* t1 = *(app::Task**)src1;
app::Task* t2 = *(app::Task**)src2;
return t2->calc_time - t1->calc_time;
}
static int32_t task_sort_by_disp(void const* src1, void const* src2) {
Task* t1 = *(Task**)src1;
Task* t2 = *(Task**)src2;
app::Task* t1 = *(app::Task**)src1;
app::Task* t2 = *(app::Task**)src2;
return t2->disp_time - t1->disp_time;
}
static int32_t task_sort_by_name(void const* src1, void const* src2) {
Task* t1 = *(Task**)src1;
Task* t2 = *(Task**)src2;
app::Task* t1 = *(app::Task**)src1;
app::Task* t2 = *(app::Task**)src2;
return str_utils_compare(t1->name, t2->name);
}
+1 -1
View File
@@ -5,7 +5,7 @@
#pragma once
#include "../../../KKdLib/default.h"
#include "../../../KKdLib/default.hpp"
#include "../../classes.h"
extern bool information_task_init(class_data* data, render_context* rctx);
+1 -1
View File
@@ -7,7 +7,7 @@
#include "input.hpp"
#include <map>
#include "../KKdLib/vec.h"
#include "../KKdLib/vec.hpp"
#include "../CRE/timer.h"
#define CIMGUI_DEFINE_ENUMS_AND_STRUCTS
#include <timeapi.h>
+18 -20
View File
@@ -37,12 +37,10 @@ static void decrypt_edat() {
stream f0;
stream f1;
io_open(&f0, "misc\\shader_ps3.edat", "rb");
io_open(&f1, "misc\\shader_ps3.dat", "wb");
f0.open("misc\\shader_ps3.edat", "rb");
f1.open("misc\\shader_ps3.dat", "wb");
if (f0.io.stream && f1.io.stream)
DecryptEDAT(&f0, &f1, 8, "misc\\EP0177-NPEB02013_00-PJDF2MOMJTNSDAYO.rap", klic);
io_free(&f0);
io_free(&f1);
DecryptEDAT(f0, f1, 8, "misc\\EP0177-NPEB02013_00-PJDF2MOMJTNSDAYO.rap", klic);
}
struct dof_data {
@@ -133,12 +131,12 @@ static void a3da_to_dft_dsc(int32_t pv_id) {
sprintf_s(buf, sizeof(buf), "DOF\\script\\pv_%03d_hard.dsc", pv_id);
stream s_src_dsc;
io_open(&s_src_dsc, buf, "rb");
s_src_dsc.open(buf, "rb");
size_t src_dsc_length = io_get_length(&s_src_dsc);
size_t src_dsc_length = s_src_dsc.get_length();
void* src_dsc_data = force_malloc(src_dsc_length);
io_read(&s_src_dsc, src_dsc_data, src_dsc_length);
io_free(&s_src_dsc);
s_src_dsc.read(src_dsc_data, src_dsc_length);
s_src_dsc.close();
dsc d_src = dsc();
d_src.parse(src_dsc_data, src_dsc_length, DSC_FT);
@@ -268,14 +266,14 @@ static void a3da_to_dft_dsc(int32_t pv_id) {
sprintf_s(buf, sizeof(buf), "DOF\\pv_script\\pv_%03d_dof.dsc", pv_id);
stream s_dsc;
io_open(&s_dsc, buf, "wb");
io_write(&s_dsc, dsc_data, dsc_length);
io_free(&s_dsc);
s_dsc.open(buf, "wb");
s_dsc.write(dsc_data, dsc_length);
s_dsc.close();
free(dsc_data);
stream s_dft;
io_open(&s_dft);
s_dft.open();
uint32_t off;
enrs e;
enrs_entry ee;
@@ -293,15 +291,15 @@ static void a3da_to_dft_dsc(int32_t pv_id) {
off = (uint32_t)(dft_data.dof.size() * 24ULL);
off = align_val(off, 0x10);
io_write_uint32_t(&s_dft, (int32_t)dft_data.dof.size());
io_write_offset_f2_pof_add(&s_dft, 0x10, 0x40, &pof);
io_align_write(&s_dft, 0x10);
io_write(&s_dft, dft_data.dof.data(), sizeof(dof_data) * dft_data.dof.size());
s_dft.write_uint32_t((int32_t)dft_data.dof.size());
io_write_offset_f2_pof_add(s_dft, 0x10, 0x40, &pof);
s_dft.align_write(0x10);
s_dft.write(dft_data.dof.data(), sizeof(dof_data) * dft_data.dof.size());
f2_struct st;
io_align_write(&s_dft, 0x10);
io_copy(&s_dft, &st.data);
io_free(&s_dft);
s_dft.align_write(0x10);
s_dft.copy(st.data);
s_dft.close();
st.enrs = e;
st.pof = pof;
+1 -1
View File
@@ -5,7 +5,7 @@
#pragma once
#include "../KKdLib/default.h"
#include "../KKdLib/default.hpp"
#include "input.hpp"
#include "render.h"
#include "sound.h"
File diff suppressed because it is too large Load Diff
+351
View File
@@ -0,0 +1,351 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#if defined(CLOUD_DEV)
#pragma once
#include <list>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
#include "../KKdLib/dsc.hpp"
#include "../CRE/auth_3d.hpp"
#include "../CRE/pv_db.hpp"
#include "../CRE/rob.hpp"
#include "../CRE/stage.hpp"
#include "../CRE/task.hpp"
#include "classes.h"
struct pv_play_data_set_motion {
float_t frame_speed;
int32_t motion_id;
float_t frame;
float_t duration;
bool field_10;
MotionBlendType blend_type;
bool disable_eye_motion;
int32_t motion_index;
int64_t dsc_time;
float_t dsc_frame;
};
struct pv_play_data_motion {
bool enable;
int32_t motion_index;
int64_t time;
};
struct dsc_set_item {
int32_t time;
int32_t item_index;
int32_t pv_branch_mode;
};
struct dsc_set_motion {
int32_t time;
int32_t motion_index;
int32_t pv_branch_mode;
};
struct struc_104 {
rob_chara* rob_chr;
float_t current_time;
float_t duration;
vec3 start_pos;
vec3 end_pos;
float_t start_rot;
float_t end_rot;
float_t mot_smooth_len;
std::vector<dsc_set_motion> set_motion;
std::vector<dsc_set_item> set_item;
struc_104();
~struc_104();
void reset();
};
struct pv_play_data {
std::vector<pv_play_data_motion> motion;
rob_chara* rob_chr;
std::list<pv_play_data_set_motion> set_motion;
bool disp;
struc_104 field_38;
pv_play_data();
~pv_play_data();
void reset();
};
struct pv_disp2d {
int32_t pv_id;
int32_t title_start_2d_field;
int32_t title_end_2d_field;
int32_t title_start_2d_low_field;
int32_t title_end_2d_low_field;
int32_t title_start_3d_field;
int32_t title_end_3d_field;
bool target_shadow_type;
int32_t pv_spr_set_id;
int32_t pv_aet_set_id;
int32_t pv_main_aet_id;
std::string title_2d_layer;
pv_disp2d();
virtual ~pv_disp2d();
};
struct pv_game_data {
//struc_490 field_0;
//struc_155 field_2C838;
int field_2CE98;
char field_2CE9C[128];
int field_2CF1C;
char field_2CF20;
int field_2CF24;
float_t field_2CF28;
float_t field_2CF2C;
int field_2CF30;
int field_2CF34;
int field_2CF38;
int32_t life_gauge;
int32_t score_final;
int32_t challenge_time_total_bonus;
int32_t combo;
int32_t challenge_time_combo_count;
int32_t max_combo;
int32_t total_hit_count[5];
int32_t hit_count[5];
int32_t current_reference_score;
int32_t target_count;
int field_2CF84;
int field_2CF88;
float_t field_2CF8C;
int32_t score_slide_chain_bonus;
int32_t slide_chain_length;
int field_2CF98;
int field_2CF9C;
__int16 field_2CFA0;
int field_2CFA4;
pv_db_pv* pv;
int field_2CFB0;
int field_2CFB4;
int32_t reference_score;
int field_2CFBC;
int field_2CFC0;
int field_2CFC4;
std::vector<int32_t> field_2CFC8;
int field_2CFE0;
int field_2CFE4;
size_t notes_passed;
int field_2CFF0;
float_t score_percentage;
float_t score_percentage_clear;
float_t score_percentage_border;
int32_t life_gauge_safety_time;
int32_t life_gauge_border;
int field_2D008;
char field_2D00C;
bool no_fail;
char field_2D00E;
bool field_2D00F;
int64_t challenge_time_start;
int64_t challenge_time_end;
uint64_t max_time;
float_t max_time_float;
float_t current_time_float;
uint64_t current_time;
float_t current_time_float_dup;
float_t field_2D03C;
int32_t score_hold_multi;
uint32_t score_hold;
int32_t score_slide;
uint8_t field_2D04C;
uint8_t chance_time_endede;
pv_disp2d* pv_disp2d;
int32_t life_gauge_final;
bool hit_border;
char field_2D05D;
char field_2D05E;
char field_2D05F;
char field_2D060;
char field_2D061;
char field_2D062;
char field_2D063;
bool field_2D064;
char field_2D065;
char field_2D066[2];
char field_2D068;
char field_2D069;
char field_2D06A[2];
int field_2D06C;
uint32_t field_2D070;
int field_2D074;
int field_2D078;
int field_2D07C;
int field_2D080;
int field_2D084;
int32_t life_gauge_bonus;
int32_t life_gauge_total_bonus;
char field_2D090;
char field_2D091;
char field_2D092;
char field_2D093;
uint8_t field_2D094;
char field_2D095;
char field_2D096;
bool success;
int field_2D098;
int field_2D09C;
char field_2D0A0;
bool pv_end_fadeout;
float_t rival_percentage;
int field_2D0A8;
int field_2D0AC;
int field_2D0B0[3];
bool field_2D0BC;
char field_2D0BD;
char field_2D0BE;
char field_2D0BF;
int field_2D0C0;
int field_2D0C4;
//struc_154 chrcam_chrmot[6];
std::vector<uint32_t> motion_set_ids;
std::vector<uint32_t> motion_set_face_ids;
std::vector<int32_t> obj_set_itmpv;
std::vector<int32_t> obj_set_handitem;
std::vector<int32_t> chreff_auth_3d_obj_set_ids;
std::vector<int32_t> field_2D770;
std::vector<int32_t> stgpvhrc_obj_set_ids;
std::vector<int32_t> ex_song_ex_auth_obj_set_ids;
std::vector<int32_t> stage_indices;
std::vector<task_stage_info> stage_infos;
char field_2D7E8;
int field_2D7EC;
std::vector<int32_t> field_2D7F0;
int field_2D808;
int field_2D80C;
std::vector<int32_t> field_2D810;
std::vector<int32_t> field_2D828;
std::vector<int32_t> field_2D840;
int field_2D858;
float_t field_2D85C;
float_t field_2D860;
float_t field_2D864;
float_t field_2D868;
char field_2D86C;
int camera_auth_3d_uid;
int field_2D874;
bool field_2D878;
int field_2D87C;
size_t current_field;
//std::vector<pv_game_data_field_data> field_data;
char field_2D8A0;
int field_2D8A4;
__int64 field_2D8A8;
int field_2D8B0;
int field_2D8B4;
__int64 field_2D8B8;
__int64 field_2D8C0;
int field_2D8C8;
int field_2D8CC;
int field_2D8D0;
int field_2D8D4;
int field_2D8D8;
int field_2D8DC;
int field_2D8E0;
int field_2D8E4;
int field_2D8E8;
int field_2D8EC;
int field_2D8F0;
int field_2D8F4;
int field_2D8F8;
int field_2D8FC;
int field_2D900;
int field_2D904;
std::string campv_string;
std::vector<int32_t> campv_auth_3d_uids;
std::map<int32_t, int32_t> campv;
int data_camera_id;
int field_2D954;
std::string itmpv_string;
std::vector<int32_t> itmpv_auth_3d_uids;
//std::map<int32_t, struc_644> itmpv[6];
std::vector<std::string> field_2D9F0;
//struc_78 field_2DA08[3];
std::vector<int32_t> loaded_auth_3d_uids;
char field_2DAC8;
int field_2DACC;
std::vector<std::string> auth_3d_categories;
std::map<int32_t, int32_t> auth_3d;
//std::vector<pv_game_data_chreff> chreff_auth_3d;
//std::vector<pv_game_data_chreff> chreff_auth_3d_obj;
char field_2DB28;
vec2 field_2DB2C;
int field_2DB34;
time_struct field_2DB38;
std::vector<uint64_t> field_2DB48;
//std::vector<struc_12> field_2DB60;
};
class pv_game : public app::TaskWindow {
public:
int32_t pv_id;
std::vector<uint32_t> objset_load;
int32_t state;
int32_t frame;
double_t frame_float;
int64_t time;
int32_t rob_chara_ids[ROB_CHARA_COUNT];
std::string pv_category;
std::string stage_category;
std::string camera_category;
std::vector<std::string> category_load;
std::map<uint32_t, int32_t> pv_auth_3d_ids;
int32_t light_auth_3d_id;
int32_t camera_auth_3d_id;
dsc dsc_m;
dsc_data* dsc_data_ptr;
dsc_data* dsc_data_ptr_end;
bool play;
bool success;
int32_t chara_id;
float_t target_anim_fps;
float_t anim_frame_speed;
int64_t dsc_time;
bool pv_end;
pv_play_data playdata[ROB_CHARA_COUNT];
float_t scene_rot_y;
mat4u scene_rot_mat;
int32_t branch_mode;
bool pause;
bool step_frame;
pv_game();
virtual ~pv_game() override;
virtual bool Init() override;
virtual bool Ctrl() override;
virtual bool Dest() override;
virtual void Disp() override;
virtual void Window() override;
void Load(int32_t pv_id, chara_index charas[6], int32_t modules[6]);
void Unload();
};
extern pv_game pv_game_data;
#endif
+63 -41
View File
@@ -23,22 +23,24 @@
#include "../CRE/light_param.hpp"
#include "../CRE/lock.h"
#include "../CRE/object.hpp"
#include "../CRE/pv_db.hpp"
#include "../CRE/rob.hpp"
#include "../CRE/shader.h"
#include "../CRE/shader_ft.h"
#include "../CRE/shader_glsl.h"
#include "../CRE/shader_glsl.hpp"
#include "../CRE/stage.hpp"
#include "../CRE/static_var.h"
#include "../CRE/task.hpp"
#include "../CRE/texture.hpp"
#include "../CRE/timer.h"
#include "../CRE/post_process.hpp"
#include "../KKdLib/io/path.h"
#include "../KKdLib/io/path.hpp"
#include "../KKdLib/database/item_table.hpp"
#include "../KKdLib/sort.hpp"
#include "../KKdLib/str_utils.h"
#include "../KKdLib/str_utils.hpp"
#include "classes/imgui_helper.h"
#include "input.hpp"
#include "pv_game.hpp"
#include "x_pv_game.hpp"
#include <timeapi.h>
@@ -103,7 +105,7 @@ int32_t width;
int32_t height;
static const double_t aspect = 16.0 / 9.0;
vec3 clear_color;
vec4u8 clear_color;
bool set_clear_color;
bool light_chara_ambient;
@@ -407,7 +409,7 @@ static render_context* render_load() {
object_storage_init(aft_obj_db);
item_table_array_init();
task_work_init();
app::task_work_init();
rob_init();
auth_3d_data_init();
light_param_storage_data_init();
@@ -557,16 +559,15 @@ static render_context* render_load() {
" gl_FragDepth = texelFetch(g_depth, ivec2(gl_FragCoord.xy), 0).r;\n"
"}\n";
shader_glsl_param param;
memset(&param, 0, sizeof(shader_glsl_param));
shader_glsl_param param = {};
param.name = "Cube Line";
cube_line_shader.load(cube_line_vert_shader, cube_line_frag_shader, 0, &param);
memset(&param, 0, sizeof(shader_glsl_param));
param = {};
param.name = "Cube Line Point";
cube_line_point_shader.load(cube_line_point_vert_shader, cube_line_point_frag_shader, 0, &param);
memset(&param, 0, sizeof(shader_glsl_param));
param = {};
param.name = "Grid";
grid_shader.load(grid_vert_shader, grid_frag_shader, 0, &param);
@@ -577,9 +578,11 @@ static render_context* render_load() {
render_resize_fb(rctx, true);
task_pv_db_append_task();
task_auth_3d_append_task();
TaskWork::AppendTask(&Glitter::glt_particle_manager, "GLITTER_TASK", 2);
TaskWork::AppendTask(&x_pv_game_data, "X_PV_GAME", 0);
app::TaskWork::AppendTask(&Glitter::glt_particle_manager, "GLITTER_TASK", 2);
//app::TaskWork::AppendTask(&pv_game_data, "PV_GAME", 0);
app::TaskWork::AppendTask(&x_pv_game_data, "X_PV_GAME", 0);
task_rob_manager_append_task();
aft_data->load_file(aft_data, "rom/", "chritm_prop.farc", item_table_array_load_file);
@@ -603,7 +606,7 @@ static render_context* render_load() {
for (int32_t i = 0; i < 30; i++) {
timer_start_of_cycle(&render_timer);
lock_lock(&render_lock);
TaskWork::Ctrl();
app::TaskWork::Ctrl();
file_handler_storage_ctrl();
lock_unlock(&render_lock);
timer_end_of_cycle(&render_timer);
@@ -732,28 +735,45 @@ static render_context* render_load() {
ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL3_Init("#version 430");
clear_color = { (float_t)(96.0 / 255.0), (float_t)(96.0 / 255.0), (float_t)(96.0 / 255.0) };
clear_color = { 0x60, 0x60, 0x60, 0xFF };
set_clear_color = true;
chara_index charas[6];
charas[5] = CHARA_MIKU;
charas[1] = CHARA_RIN;
charas[2] = CHARA_LEN;
charas[3] = CHARA_LUKA;
charas[4] = CHARA_KAITO;
charas[0] = CHARA_MEIKO;
/*chara_index charas[6];
charas[0] = CHARA_MIKU;
charas[1] = CHARA_MIKU;//CHARA_RIN;
charas[2] = CHARA_MIKU;//CHARA_LEN;
charas[3] = CHARA_MIKU;//CHARA_LUKA;
charas[4] = CHARA_MIKU;//CHARA_KAITO;
charas[5] = CHARA_MIKU;//CHARA_MEIKO;
int32_t modules[6];
modules[5] = 168;
modules[0] = 0;//168;
modules[1] = 0;//46;
modules[2] = 0;//39;
modules[3] = 41;
modules[4] = 40;
modules[0] = 0;//31;
x_pv_game_data.Load(822, 22, charas, modules);
modules[3] = 0;//41;
modules[4] = 0;//40;
modules[5] = 0;//31;
pv_game_data.Load(739, charas, modules);*/
shader_env_vert_set_ptr(&shaders_ft, 3, &vec4_identity);
shader_env_vert_set_ptr(&shaders_ft, 4, &vec4_null);
chara_index charas[6];
charas[0] = CHARA_MIKU;
charas[1] = CHARA_MIKU;//CHARA_RIN;
charas[2] = CHARA_MIKU;//CHARA_LEN;
charas[3] = CHARA_MIKU;//CHARA_LUKA;
charas[4] = CHARA_MIKU;//CHARA_KAITO;
charas[5] = CHARA_MIKU;//CHARA_MEIKO;
int32_t modules[6];
modules[0] = 0;//168;
modules[1] = 0;//46;
modules[2] = 0;//39;
modules[3] = 0;//41;
modules[4] = 0;//40;
modules[5] = 0;//31;
x_pv_game_data.Load(826, 26, charas, modules);
shaders_ft.env_vert_set(3, vec4_identity);
shaders_ft.env_vert_set(4, vec4_null);
classes_process_init(classes, classes_count, rctx);
return rctx;
}
@@ -781,7 +801,7 @@ static void render_ctrl(render_context* rctx) {
global_context_menu = true;
lock_lock(&imgui_context_lock);
ImGui::SetCurrentContext(imgui_context);
TaskWork_Window();
app::TaskWork_Window();
classes_process_imgui(classes, classes_count);
lock_unlock(&imgui_context_lock);
@@ -862,8 +882,8 @@ static void render_ctrl(render_context* rctx) {
glBufferSubData(GL_UNIFORM_BUFFER, 0, COMMON_DATA_SIZE, &common_data);
gl_state_bind_uniform_buffer(0);
shader_glsl_set_mat4(&cube_line_shader, "vp", false, cam->view_projection);
shader_glsl_set_mat4(&cube_line_point_shader, "vp", false, cam->view_projection);
cube_line_shader.set("vp", false, cam->view_projection);
cube_line_point_shader.set("vp", false, cam->view_projection);
}
static void cube_line_draw(shader_glsl* shader, camera* cam, vec3* trans, float_t line_size, vec4* color) {
@@ -895,7 +915,7 @@ static void cube_line_draw(shader_glsl* shader, camera* cam, vec3* trans, float_
vec3_add(trans[1], norm[0], vert_trans[2]);
vec3_add(trans[1], norm[1], vert_trans[3]);
shader_glsl_set_vec4(shader, "color", *color);
shader->set("color", *color);
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vert_trans), vert_trans);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
@@ -943,10 +963,10 @@ static void render_draw(render_context* rctx) {
gl_state_set_depth_mask(GL_FALSE);
if (set_clear_color) {
vec4 color;
*(vec3*)&color = clear_color;
color.w = 1.0f;
glClearBufferfv(GL_COLOR, 0, (GLfloat*)&color);
vec4 _clear_color;
vec4u8_to_vec4(clear_color, _clear_color);
vec4_mult_scalar(_clear_color, (float_t)(1.0 / 255.0), _clear_color);
glClearBufferfv(GL_COLOR, 0, (GLfloat*)&_clear_color);
}
camera_update(cam);
@@ -1040,10 +1060,10 @@ static void render_draw(render_context* rctx) {
gl_state_bind_vertex_array(cube_line_point_vao);
cube_line_point_shader.use();
shader_glsl_set_vec3_array(&cube_line_point_shader, "trans", 4, trans);
shader_glsl_set_float(&cube_line_point_shader, "dark_border_end",
cube_line_point_shader.set("trans", 4, trans);
cube_line_point_shader.set("dark_border_end",
((CUBE_LINE_POINT_SIZE - (CUBE_LINE_SIZE * 1.125f)) / (2.0f * CUBE_LINE_POINT_SIZE)));
shader_glsl_set_float(&cube_line_point_shader, "dark_border_start",
cube_line_point_shader.set("dark_border_start",
(1.0f - ((CUBE_LINE_POINT_SIZE - (CUBE_LINE_SIZE * 1.125f)) / (2.0f * CUBE_LINE_POINT_SIZE))));
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, (GLsizei)cube_line_points.size());
cube_line_points.clear();
@@ -1071,16 +1091,18 @@ static void render_dispose(render_context* rctx) {
lock_free(&imgui_context_lock);
task_rob_manager_free_task();
//pv_game_data.SetDest();
x_pv_game_data.SetDest();
Glitter::glt_particle_manager.SetDest();
task_auth_3d_free_task();
task_pv_db_free_task();
//rob_chara_array_free_chara_id(0);
timer_reset(&render_timer);
for (int32_t i = 0; i < 30; i++) {
timer_start_of_cycle(&render_timer);
lock_lock(&render_lock);
TaskWork::Ctrl();
app::TaskWork::Ctrl();
file_handler_storage_ctrl();
lock_unlock(&render_lock);
timer_end_of_cycle(&render_timer);
@@ -1091,7 +1113,7 @@ static void render_dispose(render_context* rctx) {
light_param_storage_data_free();
auth_3d_data_free();
rob_free();
task_work_free();
app::task_work_free();
item_table_array_free();
object_storage_free();
data_struct_free();
@@ -1252,7 +1274,7 @@ inline static void render_shaders_load() {
}
inline static void render_shaders_free() {
shader_free(&shaders_ft);
shaders_ft.unload();
}
#if defined (DEBUG) && OPENGL_DEBUG
+1 -2
View File
@@ -6,8 +6,7 @@
#pragma once
#include "shared.h"
#include "../KKdLib/vec.h"
#include "../KKdLib/vector.h"
#include "../KKdLib/vec.hpp"
struct render_init_struct {
vec2i res;
+25 -26
View File
@@ -1,6 +1,6 @@
#include "unedat.h"
#define AES128
#include "../KKdLib/aes.h"
#include "../KKdLib/aes.hpp"
#include "lz.h"
#include <math.h>
@@ -150,7 +150,7 @@ void get_block_key(int block, NPD_HEADER* npd, uint8_t* dest_key) {
// Also, set 'in file' to the beginning of the encrypted data, which may be offset
// if inside another file, but normally just reset to beginning of file
// returns number of bytes written, -1 for error
int decrypt_block(stream* in, uint8_t* out, EDAT_HEADER* edat, NPD_HEADER* npd,
int decrypt_block(stream& in, uint8_t* out, EDAT_HEADER* edat, NPD_HEADER* npd,
uint8_t* crypt_key, uint32_t block_num, uint32_t total_blocks, int64_t size_left) {
// Get metadata info and setup buffers.
const int64_t metadata_section_size = edat->flags & (EDAT_COMPRESSED_FLAG | EDAT_FLAG_0x20) ? 0x20 : 0x10;
@@ -165,17 +165,17 @@ int decrypt_block(stream* in, uint8_t* out, EDAT_HEADER* edat, NPD_HEADER* npd,
uint8_t empty_iv[0x10];
memset(empty_iv, 0, 0x10);
size_t file_offset = io_get_position(in);
size_t file_offset = in.get_position();
// Decrypt the metadata.
if (edat->flags & EDAT_COMPRESSED_FLAG) {
metadata_sec_offset = metadata_offset + block_num * metadata_section_size;
io_set_position(in, file_offset + metadata_sec_offset, SEEK_SET);
in.set_position(file_offset + metadata_sec_offset, SEEK_SET);
uint8_t metadata[0x20];
memset(metadata, 0, 0x20);
io_read(in, metadata, 0x20);
in.read(metadata, 0x20);
// If the data is compressed, decrypt the metadata.
// NOTE: For NPD version 1 the metadata is not encrypted.
@@ -212,11 +212,11 @@ int decrypt_block(stream* in, uint8_t* out, EDAT_HEADER* edat, NPD_HEADER* npd,
// If FLAG 0x20, the metadata precedes each data block.
metadata_sec_offset = metadata_offset + block_num * (metadata_section_size + edat->block_size);
io_set_position(in, file_offset + metadata_sec_offset, SEEK_SET);
in.set_position(file_offset + metadata_sec_offset, SEEK_SET);
uint8_t metadata[0x20];
memset(metadata, 0, 0x20);
io_read(in, metadata, 0x20);
in.read(metadata, 0x20);
offset = metadata_sec_offset + 0x20;
length = edat->block_size;
@@ -226,7 +226,7 @@ int decrypt_block(stream* in, uint8_t* out, EDAT_HEADER* edat, NPD_HEADER* npd,
}
else {
metadata_sec_offset = metadata_offset + (uint64_t)block_num * metadata_section_size;
io_set_position(in, file_offset + metadata_sec_offset, SEEK_SET);
in.set_position(file_offset + metadata_sec_offset, SEEK_SET);
offset = metadata_offset + (uint64_t)block_num * edat->block_size + total_blocks * metadata_section_size;
length = edat->block_size;
@@ -243,8 +243,8 @@ int decrypt_block(stream* in, uint8_t* out, EDAT_HEADER* edat, NPD_HEADER* npd,
uint8_t* enc_data = force_malloc_s(uint8_t, length);
uint8_t* dec_data = force_malloc_s(uint8_t, length);
io_set_position(in, file_offset + offset, 0);
io_read(in, enc_data, length);
in.set_position(file_offset + offset, 0);
in.read(enc_data, length);
// Generate a key for the current block.
uint8_t b_key[16];
@@ -289,31 +289,31 @@ int decrypt_block(stream* in, uint8_t* out, EDAT_HEADER* edat, NPD_HEADER* npd,
// EDAT/SDAT decryption.
// reset file to beginning of data before calling
int decrypt_data(stream* in, stream* out, EDAT_HEADER* edat, NPD_HEADER* npd, unsigned char* crypt_key) {
int decrypt_data(stream& in, stream& out, EDAT_HEADER* edat, NPD_HEADER* npd, unsigned char* crypt_key) {
const int total_blocks = (int)((edat->file_size + edat->block_size - 1) / edat->block_size);
int64_t size_left = edat->file_size;
uint8_t* data = force_malloc_s(uint8_t, edat->block_size);
for (int i = 0; i < total_blocks; i++) {
io_set_position(in, 0, 0);
in.set_position(0, 0);
memset(data, 0, edat->block_size);
int res = decrypt_block(in, data, edat, npd, crypt_key, i, total_blocks, size_left);
if (res == -1)
return 1;
size_left -= res;
io_write(out, data, res);
out.write(data, res);
}
free(data);
return 0;
}
void read_npd_edat_header(stream* input, NPD_HEADER* NPD, EDAT_HEADER* EDAT) {
void read_npd_edat_header(stream& input, NPD_HEADER* NPD, EDAT_HEADER* EDAT) {
char npd_header[0x80];
char edat_header[0x10];
io_read(input, npd_header, sizeof(npd_header));
io_read(input, edat_header, sizeof(edat_header));
input.read(npd_header, sizeof(npd_header));
input.read(edat_header, sizeof(edat_header));
memcpy(&NPD->magic, npd_header, 0x04);
NPD->version = load_reverse_endianness_int32_t(&npd_header[0x04]);
@@ -331,7 +331,7 @@ void read_npd_edat_header(stream* input, NPD_HEADER* NPD, EDAT_HEADER* EDAT) {
EDAT->file_size = load_reverse_endianness_int64_t(&edat_header[0x08]);
}
bool extract_all_data(stream* input, stream* output, uint8_t* devKlic, uint8_t* rifKey) {
bool extract_all_data(stream& input, stream& output, uint8_t* devKlic, uint8_t* rifKey) {
// Setup NPD and EDAT/SDAT structs.
NPD_HEADER NPD;
EDAT_HEADER EDAT;
@@ -358,26 +358,26 @@ bool extract_all_data(stream* input, stream* output, uint8_t* devKlic, uint8_t*
else if (NPD.license == 0x1) // Type 1: Use network activation.
memcpy(key, rifKey, 0x10);
io_set_position(input, 0, 0);
input.set_position(0, 0);
if (decrypt_data(input, output, &EDAT, &NPD, key))
return 1;
return 0;
}
void GetEdatRifKeyFromRapFile(stream* rap_file, uint8_t* rifKey) {
void GetEdatRifKeyFromRapFile(stream& rap_file, uint8_t* rifKey) {
uint8_t rapKey[0x10];
io_read(rap_file, rapKey, 0x10);
rap_file.read(rapKey, 0x10);
rap_to_rif(rapKey, rifKey);
}
// Decrypts full file
void DecryptEDAT(stream* input, stream* output, int mode, const char* rap_file_name, uint8_t* custom_klic) {
if (!input || !output || !rap_file_name)
void DecryptEDAT(stream& input, stream& output, int mode, const char* rap_file_name, uint8_t* custom_klic) {
if (!rap_file_name)
return;
// Prepare the files.
io_set_position(input, 0, 0);
input.set_position(0, 0);
// Set keys (RIF and DEVKLIC).
uint8_t rifKey[16];
@@ -417,10 +417,9 @@ void DecryptEDAT(stream* input, stream* output, int mode, const char* rap_file_n
// Read the RAP file, if provided.
if (*rap_file_name) {
stream rap;
io_open(&rap, rap_file_name, "rb");
rap.open(rap_file_name, "rb");
if (rap.io.stream)
GetEdatRifKeyFromRapFile(&rap, rifKey);
io_free(&rap);
GetEdatRifKeyFromRapFile(rap, rifKey);
}
extract_all_data(input, output, devklic, rifKey);
+4 -4
View File
@@ -1,7 +1,7 @@
#pragma once
#include "../KKdLib/default.h"
#include "../KKdLib/io/stream.h"
#include "../KKdLib/default.hpp"
#include "../KKdLib/io/stream.hpp"
#define SDAT_FLAG 0x01000000
#define EDAT_COMPRESSED_FLAG 0x00000001
@@ -106,5 +106,5 @@ typedef struct EDAT_HEADER {
// Decrypts full file, or null/empty file
extern void rap_to_rif(uint8_t* rap, uint8_t* rif);
extern void DecryptEDAT(stream* input, stream* output, int mode, const char* rap_file_name, uint8_t* custom_klic);
extern void GetEdatRifKeyFromRapFile(stream* rap_file, uint8_t* rifKey);
extern void DecryptEDAT(stream& input, stream& output, int mode, const char* rap_file_name, uint8_t* custom_klic);
extern void GetEdatRifKeyFromRapFile(stream& rap_file, uint8_t* rifKey);
+555 -240
View File
File diff suppressed because it is too large Load Diff
+48 -17
View File
@@ -28,7 +28,7 @@ struct x_pv_game_glitter {
~x_pv_game_glitter();
};
struct pv_play_data_set_motion {
struct x_pv_play_data_set_motion {
float_t frame_speed;
int32_t motion_id;
float_t frame;
@@ -41,25 +41,25 @@ struct pv_play_data_set_motion {
float_t dsc_frame;
};
struct pv_play_data_motion {
struct x_pv_play_data_motion {
bool enable;
int32_t motion_index;
int64_t time;
};
struct dsc_set_item {
struct x_dsc_set_item {
int32_t time;
int32_t item_index;
int32_t pv_branch_mode;
};
struct dsc_set_motion {
struct x_dsc_set_motion {
int32_t time;
int32_t motion_index;
int32_t pv_branch_mode;
};
struct struc_104 {
struct x_struc_104 {
rob_chara* rob_chr;
float_t current_time;
float_t duration;
@@ -68,24 +68,24 @@ struct struc_104 {
float_t start_rot;
float_t end_rot;
float_t mot_smooth_len;
std::vector<dsc_set_motion> set_motion;
std::vector<dsc_set_item> set_item;
std::vector<x_dsc_set_motion> set_motion;
std::vector<x_dsc_set_item> set_item;
struc_104();
~struc_104();
x_struc_104();
~x_struc_104();
void reset();
};
struct pv_play_data {
std::vector<pv_play_data_motion> motion;
struct x_pv_play_data {
std::vector<x_pv_play_data_motion> motion;
rob_chara* rob_chr;
std::list<pv_play_data_set_motion> set_motion;
std::list<x_pv_play_data_set_motion> set_motion;
bool disp;
struc_104 field_38;
x_struc_104 field_38;
pv_play_data();
~pv_play_data();
x_pv_play_data();
~x_pv_play_data();
void reset();
};
@@ -105,6 +105,15 @@ struct x_pv_game_stage_effect_init {
int32_t bar;
};
struct x_pv_game_a3da_to_mot_keys {
std::vector<float_t> x;
std::vector<float_t> y;
std::vector<float_t> z;
x_pv_game_a3da_to_mot_keys();
~x_pv_game_a3da_to_mot_keys();
};
struct x_pv_game_a3da_to_mot {
int32_t auth_3d_id;
int32_t gblctr;
@@ -118,6 +127,15 @@ struct x_pv_game_a3da_to_mot {
int32_t j_kubi_wj;
int32_t n_kao;
int32_t j_kao_wj;
int32_t j_kao_normal_wj;
int32_t j_kao_close_wj;
int32_t j_kao_smile_wj;
int32_t j_kao_close_half_wj;
int32_t j_kao_smile_half_wj;
int32_t j_kuti_l_wj;
int32_t j_kuti_u_wj;
int32_t j_kuti_d_wj;
int32_t j_kuti_r_wj;
int32_t j_eye_r_wj;
int32_t j_eye_l_wj;
int32_t n_waki_l;
@@ -126,12 +144,19 @@ struct x_pv_game_a3da_to_mot {
int32_t j_kata_l_wj;
int32_t j_ude_l_wj;
int32_t j_te_l_wj;
int32_t j_te_sizen2_l_wj;
int32_t j_te_close_l_wj;
int32_t j_te_reset_l_wj;
int32_t n_waki_r;
int32_t j_waki_r_wj;
int32_t n_kata_r;
int32_t j_kata_r_wj;
int32_t j_ude_r_wj;
int32_t j_te_r_wj;
int32_t j_te_sizen2_r_wj;
int32_t j_te_close_r_wj;
int32_t j_te_reset_r_wj;
int32_t j_te_one_r_wj;
int32_t j_kosi_wj;
int32_t n_momo_l;
int32_t j_momo_l_wj;
@@ -141,11 +166,16 @@ struct x_pv_game_a3da_to_mot {
int32_t j_momo_r_wj;
int32_t j_sune_r_wj;
int32_t j_asi_r_wj;
std::map<motion_bone_index, x_pv_game_a3da_to_mot_keys> bone_keys;
std::map<motion_bone_index, x_pv_game_a3da_to_mot_keys> sec_bone_keys;
x_pv_game_a3da_to_mot(int32_t auth_3d_id);
~x_pv_game_a3da_to_mot();
void get_bone_indices(auth_3d_object_hrc* oh);
};
class x_pv_game : public TaskWindow {
class x_pv_game : public app::TaskWindow {
public:
int32_t pv_id;
int32_t stage_id;
@@ -184,6 +214,7 @@ public:
uint32_t camera_category_hash;
std::vector<std::pair<std::string, uint32_t>> category_load;
std::vector<std::pair<std::string, uint32_t>> effchrpv_category_load;
std::set<std::string> pv_auth_3d_names;
std::set<std::string> stage_auth_3d_names;
@@ -219,7 +250,7 @@ public:
float_t anim_frame_speed;
int64_t dsc_time;
bool pv_end;
pv_play_data playdata[ROB_CHARA_COUNT];
x_pv_play_data playdata[ROB_CHARA_COUNT];
float_t scene_rot_y;
mat4u scene_rot_mat;
int32_t branch_mode;
+257
View File
@@ -7,6 +7,13 @@
#include "../../KKdLib/interpolation.h"
namespace Glitter {
#if defined(CRE_DEV)
static float_t glitter_curve_add_key(bool has_error,
bool has_error_lerp, bool has_error_hermite, float_t* a, float_t* b, int32_t frame,
const uint8_t step, size_t i, float_t t1, float_t t2, float_t t2_old,
std::vector<Curve::Key>* keys_rev);
#endif
Curve::Key::Key() : type(), frame(), value(), tangent1(), tangent2(), random_range() {
}
@@ -198,6 +205,205 @@ namespace Glitter {
}
#if defined(CRE_DEV)
void Curve::FitKeysIntoCurve(GLT) {
size_t count = keys.size();
keys_rev = {};
if (~flags & CURVE_BAKED) {
keys_rev.insert(keys_rev.end(), keys.begin(), keys.end());
return;
}
else if (count == 1) {
keys.data()[0].frame = start_time;
keys_rev.push_back(keys.data()[0]);
return;
}
bool curve_baked_half = false;
if (type == Glitter::F2 || (type == Glitter::X && ~flags & CURVE_BAKED_FULL))
curve_baked_half = true;
const uint8_t step = curve_baked_half ? 2 : 1;
end_time = start_time + (int32_t)((count - 1) * step);
float_t* arr_a = force_malloc_s(float_t, count);
float_t* arr_b = force_malloc_s(float_t, count);
Curve::Key* keys_data = keys.data();
for (size_t i = 0; i < count; i++) {
keys_data[i].frame = start_time + (int32_t)(i * step);
arr_a[i] = keys_data[i].value;
arr_b[i] = keys_data[i].random_range;
}
static const float_t curve_baked_reverse_bias[] = {
0.00001f,
0.0001f,
0.001f,
};
static const float_t curve_baked_half_reverse_bias[] = {
0.000001f,
0.00001f,
0.0001f,
};
const float_t* reverse_bias = curve_baked_half
? curve_baked_half_reverse_bias : curve_baked_reverse_bias;
const size_t reverse_min_count = curve_baked_half ? 5 : 4;
keys_rev.clear();
float_t* a = arr_a;
float_t* b = arr_b;
size_t left_count = count;
int32_t frame = start_time;
int32_t prev_frame = start_time;
float_t t2_old = 0.0f;
while (left_count > 0) {
int32_t c = 0;
if (left_count < reverse_min_count) {
Curve::Key key;
if (left_count == 1) {
key.type = KEY_CONSTANT;
key.frame = frame;
key.value = a[0];
key.tangent1 = t2_old;
key.tangent2 = 0.0f;
key.random_range = b[0];
keys_rev.push_back(key);
t2_old = 0.0f;
}
else {
bool has_error = false;
bool has_error_lerp = false;
for (size_t j = 1; j < left_count; j++) {
float_t val = lerp(a[0], a[left_count - 1], (float_t)j / (float_t)left_count);
if (fabsf(val - a[0]) > reverse_bias[0]) {
has_error = true;
if (fabsf(val - a[j]) > reverse_bias[1]) {
has_error_lerp = true;
break;
}
}
}
t2_old = glitter_curve_add_key(has_error, has_error_lerp, true,
a, b, frame, step, left_count, 0.0f, 0.0f, t2_old, &keys_rev);
}
break;
}
float_t t1 = 0.0f;
float_t t2 = 0.0f;
float_t t1_prev = 0.0f;
float_t t2_prev = 0.0f;
bool has_prev_succeded = false;
bool constant = false;
bool prev_constant = false;
bool has_error = false;
bool has_error_lerp = false;
bool has_error_hermite = false;
bool has_prev_error = false;
bool has_prev_error_lerp = false;
bool has_prev_error_hermite = false;
size_t i;
for (i = reverse_min_count - 1; i < left_count; i++) {
double_t tt1 = 0.0;
double_t tt2 = 0.0;
for (size_t j = 1; j < i - 1; j++) {
float_t _t1 = 0.0f;
float_t _t2 = 0.0f;
interpolate_chs_reverse_step_value(a, left_count, &_t1, &_t2, 0, i, j, step);
tt1 += _t1;
tt2 += _t2;
}
t1 = (float_t)(tt1 / (double_t)(i - 2));
t2 = (float_t)(tt2 / (double_t)(i - 2));
constant = false;
has_error = false;
has_error_lerp = false;
has_error_hermite = false;
for (size_t j = 1; j < i; j++) {
float_t val = interpolate_chs_value(a[0], a[i], t1, t2, 0.0f,
(float_t)(i * step), (float_t)(j * step));
float_t val_lerp = lerp(a[0], a[i], (float_t)j / (float_t)i);
if (fabsf(val - a[0]) > reverse_bias[0]) {
has_error = true;
constant = false;
if (fabsf(val_lerp - a[j]) > reverse_bias[1]) {
has_error_lerp = true;
if (fabsf(val - a[j]) > reverse_bias[2]) {
has_error_hermite = true;
break;
}
}
}
else
constant = true;
}
if (!has_error_hermite) {
t1_prev = t1;
t2_prev = t2;
prev_constant = constant;
has_prev_succeded = true;
has_prev_error = has_error;
has_prev_error_lerp = has_error_lerp;
has_prev_error_hermite = has_error_hermite;
if (i < left_count)
continue;
}
if (has_prev_succeded) {
if (prev_constant && ((i < left_count - 1 && a[i] == a[i + 1]) || (frame + i == end_time)))
c = (int32_t)i;
else
c = (int32_t)(i - 1);
t1 = t1_prev;
t2 = t2_prev;
has_error = has_prev_error;
has_error_lerp = has_prev_error_lerp;
has_error_hermite = has_prev_error_hermite;
}
else
c = (int32_t)i;
if (has_error_hermite)
c = 1;
t2_old = glitter_curve_add_key(has_error, has_error_lerp, has_error_hermite,
a, b, frame, step, c, t1, t2, t2_old, &keys_rev);
prev_constant = false;
has_prev_succeded = false;
break;
}
if (has_prev_succeded) {
t2_old = glitter_curve_add_key(has_prev_error, has_prev_error_lerp, has_prev_error_hermite,
a, b, frame, step, i, t1_prev, t2_prev, t2_old, &keys_rev);
c = (int32_t)i;
}
prev_frame = frame;
frame += c * step;
a += c;
b += c;
left_count -= c;
}
Curve::Key key;
key.type = KEY_CONSTANT;
key.frame = (int32_t)(start_time + (count - 1) * step);
key.value = arr_a[count - 1];
key.tangent1 = t2_old;
key.tangent2 = 0.0f;
key.random_range = arr_b[count - 1];
keys_rev.push_back(key);
free(arr_a);
free(arr_b);
Recalculate(GLT_VAL);
}
void Curve::Recalculate(GLT) {
keys.clear();
if (keys_rev.size() == 1)
@@ -418,4 +624,55 @@ namespace Glitter {
? -key->random_range : 0.0f, key->random_range);
return rand + key->value;
}
#if defined(CRE_DEV)
static float_t glitter_curve_add_key(bool has_error,
bool has_error_lerp, bool has_error_hermite, float_t* a, float_t* b, int32_t frame,
const uint8_t step, size_t i, float_t t1, float_t t2, float_t t2_old,
std::vector<Curve::Key>* keys_rev) {
Curve::Key key;
if (has_error && has_error_lerp && has_error_hermite) {
float_t _t2 = t2_old;
for (size_t j = 0; j < i; j++) {
key.type = KEY_CONSTANT;
key.frame = (int32_t)(frame + j * step);
key.value = a[j];
key.tangent1 = _t2;
key.tangent2 = 0.0f;
key.random_range = b[j];
keys_rev->push_back(key);
_t2 = 0.0f;
}
}
else if (has_error && has_error_lerp) {
key.type = KEY_HERMITE;
key.frame = frame;
key.value = a[0];
key.tangent1 = t2_old;
key.tangent2 = t1;
key.random_range = b[0];
keys_rev->push_back(key);
return t2;
}
else if (has_error || (i > 1 && b[0] != b[1])) {
key.type = KEY_LINEAR;
key.frame = frame;
key.value = a[0];
key.tangent1 = 0.0f;
key.tangent2 = 0.0f;
key.random_range = b[0];
keys_rev->push_back(key);
}
else {
key.type = KEY_CONSTANT;
key.frame = frame;
key.value = a[0];
key.tangent1 = 0.0f;
key.tangent2 = 0.0f;
key.random_range = b[0];
keys_rev->push_back(key);
}
return 0.0f;
}
#endif
}
+2 -2
View File
@@ -126,11 +126,11 @@ namespace Glitter {
#include "effect_group.hpp"
#include "../../KKdLib/database/object.h"
#include "../../KKdLib/database/texture.h"
#include "../../KKdLib/io/path.h"
#include "../../KKdLib/io/path.hpp"
#include "../../KKdLib/obj.h"
#include "../../KKdLib/farc.h"
#include "../../KKdLib/obj.h"
#include "../../KKdLib/str_utils.h"
#include "../../KKdLib/str_utils.hpp"
#include "../data.h"
#include "../object.h"
#include "effect.hpp"
+17 -22
View File
@@ -4,7 +4,7 @@
*/
#include "glitter.hpp"
#include "../../KKdLib/str_utils.h"
#include "../../KKdLib/str_utils.hpp"
#include "../auth_3d.hpp"
#include "../rob.hpp"
@@ -329,27 +329,20 @@ namespace Glitter {
enum_or(flags, EFFECT_INST_HAS_EXT_ANIM_SCALE);
int32_t bone_index = ext_anim->bone_index;
if (bone_index == -1) {
if (flags & EFFECT_INST_EXT_ANIM_TRANS_ONLY) {
ext_anim->mat = mat4_identity;
mat4_get_translation(&mat, &ext_anim->translation);
}
else
ext_anim->mat = mat;
}
else {
if (bone_index != -1) {
mat4* bone_mat = rob_chr->get_bone_data_mat(bone_index);
if (!bone_mat)
return;
mat4_mult(bone_mat, &mat, &mat);
if (flags & EFFECT_INST_EXT_ANIM_TRANS_ONLY) {
ext_anim->mat = mat4_identity;
mat4_get_translation(&mat, &ext_anim->translation);
}
else
ext_anim->mat = mat;
}
if (flags & EFFECT_INST_EXT_ANIM_TRANS_ONLY) {
ext_anim->mat = mat4_identity;
mat4_get_translation(&mat, &ext_anim->translation);
}
else
ext_anim->mat = mat;
goto SetFlags;
}
@@ -395,8 +388,10 @@ namespace Glitter {
if (chara_id >= 0 && chara_id < ROB_CHARA_COUNT) {
rob_chara* rob_chr = rob_chara_array_get(chara_id);
if (rob_chr) {
mat = rob_chr->data.adjust_data.mat;
vec3 scale;
mat4_get_scale(&rob_chr->data.adjust_data.mat, &scale);
mat4_get_scale(&mat, &scale);
vec3_sub_scalar(scale, 1.0f, ext_anim_scale);
ext_anim_scale.z = 0.0f;
enum_or(flags, EFFECT_INST_HAS_EXT_ANIM_SCALE);
@@ -872,10 +867,10 @@ namespace Glitter {
if (!rob_chr)
return;
mat4 temp = rob_chr->data.adjust_data.mat;
mat4 mat = rob_chr->data.adjust_data.mat;
vec3 scale;
mat4_get_scale(&temp, &scale);
mat4_get_scale(&rob_chr->data.adjust_data.mat, &scale);
vec3_sub_scalar(scale, 1.0f, ext_anim_scale);
ext_anim_scale.z = 0.0f;
enum_or(flags, EFFECT_INST_HAS_EXT_ANIM_SCALE);
@@ -889,10 +884,10 @@ namespace Glitter {
if (bone_index != -1) {
mat4* bone_mat = rob_chr->get_bone_data_mat(bone_index);
if (bone_mat)
SetExtAnim(&temp, bone_mat, 0, set_flags);
SetExtAnim(&mat, bone_mat, 0, set_flags);
}
else
SetExtAnim(&temp, 0, 0, set_flags);
SetExtAnim(&mat, 0, 0, set_flags);
}
else if (flags & EFFECT_INST_GET_EXT_ANIM_MAT) {
mat4 m = mat4_identity;
@@ -1024,7 +1019,7 @@ namespace Glitter {
}
}
}
void XEffectInst::SetExtAnim(mat4* a2, mat4* a3, vec3* trans, bool set_flags) {
EffectInstFlag flags = this->flags;
if (a2) {
+27 -281
View File
@@ -4,20 +4,13 @@
*/
#include "glitter.hpp"
#include "../../KKdLib/io/path.h"
#include "../../KKdLib/io/path.hpp"
#include "../../KKdLib/interpolation.h"
#include "../../KKdLib/farc.hpp"
#include "../../KKdLib/str_utils.h"
#include "../../KKdLib/str_utils.hpp"
#include "../data.hpp"
namespace Glitter {
#if defined(CRE_DEV)
static float_t glitter_curve_key_add_key(bool has_error,
bool has_error_lerp, bool has_error_hermite, float_t* a, float_t* b, int32_t frame,
const uint8_t step, size_t i, float_t t1, float_t t2, float_t t2_old,
std::vector<Curve::Key>* keys_rev);
#endif
FileReader::FileReader(GLT) : file_handler(), farc(), effect_group(),
load_count(), type(), path(), file(), state(), init_scene(), obj_db() {
emission = -1.0f;
@@ -838,55 +831,56 @@ namespace Glitter {
}
if (c->flags & CURVE_KEY_RANDOM_RANGE && keys.size()) {
Curve::Key* keys_data = keys.data();
if (type == Glitter::X && c->flags & CURVE_BAKED)
if (c->flags & CURVE_RANDOM_RANGE_NEGATE)
for (size_t i = 0; i < count; i++) {
float_t max = keys.data()[i].value;
float_t min = keys.data()[i].random_range;
float_t max = keys_data[i].value;
float_t min = keys_data[i].random_range;
if (*(uint32_t*)&min != *(uint32_t*)&max) {
keys.data()[i].value = (float_t)(((double_t)min + (double_t)max) * 0.5);
keys.data()[i].random_range = (float_t)((double_t)max
keys_data[i].value = (float_t)(((double_t)min + (double_t)max) * 0.5);
keys_data[i].random_range = (float_t)((double_t)max
- ((double_t)min + (double_t)max) * 0.5);
}
else
keys.data()[i].random_range = 0.0f;
keys_data[i].random_range = 0.0f;
}
else
for (size_t i = 0; i < count; i++) {
float_t max = keys.data()[i].value;
float_t min = keys.data()[i].random_range;
float_t max = keys_data[i].value;
float_t min = keys_data[i].random_range;
if (*(uint32_t*)&min != *(uint32_t*)&max) {
keys.data()[i].value = min;
keys.data()[i].random_range = (float_t)((double_t)max - (double_t)min);
keys_data[i].value = min;
keys_data[i].random_range = (float_t)((double_t)max - (double_t)min);
}
else
keys.data()[i].random_range = 0.0f;
keys_data[i].random_range = 0.0f;
}
bool has_key_random_range = false;
if (type == Glitter::F2) {
if (count > 1 && keys.data()[0].random_range != 0.0f
&& keys.data()[1].random_range != 0.0f)
if (count > 1 && keys_data[0].random_range != 0.0f
&& keys_data[1].random_range != 0.0f)
has_key_random_range = true;
else if (count > 1 && keys.data()[0].random_range != 0.0f
&& keys.data()[1].random_range == 0.0f) {
keys.data()[0].value += keys.data()[0].random_range * 10.0f;
keys.data()[0].random_range = 0.0f;
else if (count > 1 && keys_data[0].random_range != 0.0f
&& keys_data[1].random_range == 0.0f) {
keys_data[0].value += keys_data[0].random_range * 10.0f;
keys_data[0].random_range = 0.0f;
}
if (count > 1 && keys.data()[count - 2].random_range != 0.0f
&& keys.data()[count - 1].random_range != 0.0f)
if (count > 1 && keys_data[count - 2].random_range != 0.0f
&& keys_data[count - 1].random_range != 0.0f)
has_key_random_range = true;
else if (count > 1 && keys.data()[count - 2].random_range == 0.0f
&& keys.data()[count - 1].random_range != 0.0f) {
keys.data()[count - 1].value += keys.data()[count - 1].random_range * 10.0f;
keys.data()[count - 1].random_range = 0.0f;
else if (count > 1 && keys_data[count - 2].random_range == 0.0f
&& keys_data[count - 1].random_range != 0.0f) {
keys_data[count - 1].value += keys_data[count - 1].random_range * 10.0f;
keys_data[count - 1].random_range = 0.0f;
}
}
if (!has_key_random_range)
for (size_t i = 0; i < count; i++)
if (keys.data()[i].random_range != 0.0f) {
if (keys_data[i].random_range != 0.0f) {
has_key_random_range = true;
break;
}
@@ -896,204 +890,7 @@ namespace Glitter {
}
#if defined(CRE_DEV)
c->keys_rev = vector_old_empty(Curve::Key);
if (~c->flags & CURVE_BAKED) {
c->keys_rev.insert(c->keys_rev.end(), keys.begin(), keys.end());
return;
}
else if (count == 1) {
keys.data()[0].frame = c->start_time;
c->keys_rev.push_back(keys.data()[0]);
return;
}
bool curve_baked_half = false;
if (type == Glitter::F2 || (type == Glitter::X && ~c->flags & CURVE_BAKED_FULL))
curve_baked_half = true;
const uint8_t step = curve_baked_half ? 2 : 1;
int32_t start_time = c->start_time;
int32_t end_time = c->start_time + (int32_t)((count - 1) * step);
c->end_time = end_time;
float_t* arr_a = force_malloc_s(float_t, count);
float_t* arr_b = force_malloc_s(float_t, count);
for (size_t i = 0; i < count; i++) {
keys.data()[i].frame = start_time + (int32_t)(i * step);
arr_a[i] = keys.data()[i].value;
arr_b[i] = keys.data()[i].random_range;
}
static const float_t curve_baked_reverse_bias[] = {
0.00001f,
0.0001f,
0.001f,
};
static const float_t curve_baked_half_reverse_bias[] = {
0.000001f,
0.00001f,
0.0001f,
};
const float_t* reverse_bias = curve_baked_half
? curve_baked_half_reverse_bias : curve_baked_reverse_bias;
const size_t reverse_min_count = curve_baked_half ? 5 : 4;
std::vector<Curve::Key> keys_rev = vector_old_empty(Curve::Key);
float_t* a = arr_a;
float_t* b = arr_b;
size_t left_count = count;
int32_t frame = start_time;
int32_t prev_frame = start_time;
float_t t2_old = 0.0f;
float_t* val_arr = force_malloc_s(float_t, count);
while (left_count > 0) {
int32_t c = 0;
if (left_count < reverse_min_count) {
Curve::Key key;
if (left_count == 1) {
key.type = KEY_CONSTANT;
key.frame = frame;
key.value = a[0];
key.tangent1 = t2_old;
key.tangent2 = 0.0f;
key.random_range = b[0];
keys_rev.push_back(key);
t2_old = 0.0f;
}
else {
bool has_error = false;
bool has_error_lerp = false;
for (size_t j = 1; j < left_count; j++) {
float_t val = lerp(a[0], a[left_count - 1], (float_t)j / (float_t)left_count);
if (fabsf(val - a[0]) > reverse_bias[0]) {
has_error = true;
if (fabsf(val - a[j]) > reverse_bias[1]) {
has_error_lerp = true;
break;
}
}
}
t2_old = glitter_curve_key_add_key(has_error, has_error_lerp, true,
a, b, frame, step, left_count, 0.0f, 0.0f, t2_old, &keys_rev);
}
break;
}
float_t t1 = 0.0f;
float_t t2 = 0.0f;
float_t t1_prev = 0.0f;
float_t t2_prev = 0.0f;
bool has_prev_succeded = false;
bool constant = false;
bool prev_constant = false;
bool has_error = false;
bool has_error_lerp = false;
bool has_error_hermite = false;
bool has_prev_error = false;
bool has_prev_error_lerp = false;
bool has_prev_error_hermite = false;
size_t i;
for (i = reverse_min_count - 1; i < left_count; i++) {
double_t tt1 = 0.0;
double_t tt2 = 0.0;
for (size_t j = 1; j < i - 1; j++) {
float_t _t1 = 0.0f;
float_t _t2 = 0.0f;
interpolate_chs_reverse_step_value(a, left_count, &_t1, &_t2, 0, i, j, step);
tt1 += _t1;
tt2 += _t2;
}
t1 = (float_t)(tt1 / (double_t)(i - 2));
t2 = (float_t)(tt2 / (double_t)(i - 2));
constant = false;
has_error = false;
has_error_lerp = false;
has_error_hermite = false;
for (size_t j = 1; j < i; j++) {
float_t val = interpolate_chs_value(a[0], a[i], t1, t2, 0.0f,
(float_t)(i * step), (float_t)(j * step));
float_t val_lerp = lerp(a[0], a[i], (float_t)j / (float_t)i);
if (fabsf(val - a[0]) > reverse_bias[0]) {
has_error = true;
constant = false;
if (fabsf(val_lerp - a[j]) > reverse_bias[1]) {
has_error_lerp = true;
if (fabsf(val - a[j]) > reverse_bias[2]) {
has_error_hermite = true;
break;
}
}
}
else
constant = true;
}
if (!has_error_hermite) {
t1_prev = t1;
t2_prev = t2;
prev_constant = constant;
has_prev_succeded = true;
has_prev_error = has_error;
has_prev_error_lerp = has_error_lerp;
has_prev_error_hermite = has_error_hermite;
if (i < left_count)
continue;
}
if (has_prev_succeded) {
if (prev_constant && ((i < left_count - 1 && a[i] == a[i + 1]) || (frame + i == end_time)))
c = (int32_t)i;
else
c = (int32_t)(i - 1);
t1 = t1_prev;
t2 = t2_prev;
has_error = has_prev_error;
has_error_lerp = has_prev_error_lerp;
has_error_hermite = has_prev_error_hermite;
}
else
c = (int32_t)i;
if (has_error_hermite)
c = 1;
t2_old = glitter_curve_key_add_key(has_error, has_error_lerp, has_error_hermite,
a, b, frame, step, c, t1, t2, t2_old, &keys_rev);
prev_constant = false;
has_prev_succeded = false;
break;
}
if (has_prev_succeded) {
t2_old = glitter_curve_key_add_key(has_prev_error, has_prev_error_lerp, has_prev_error_hermite,
a, b, frame, step, i, t1_prev, t2_prev, t2_old, &keys_rev);
c = (int32_t)i;
}
prev_frame = frame;
frame += c * step;
a += c;
b += c;
left_count -= c;
}
free(val_arr);
key.type = KEY_CONSTANT;
key.frame = start_time + (count - 1) * step;
key.value = arr_a[count - 1];
key.tangent1 = t2_old;
key.tangent2 = 0.0f;
key.random_range = arr_b[count - 1];
keys_rev.push_back(key);
free(arr_a);
free(arr_b);
c->keys_rev = keys_rev;
c->Recalculate(type);
c->FitKeysIntoCurve(type);
#endif
}
@@ -2606,55 +2403,4 @@ namespace Glitter {
ptcl->data.uv_index_count = 0;
return true;
}
#if defined(CRE_DEV)
static float_t glitter_curve_key_add_key(bool has_error,
bool has_error_lerp, bool has_error_hermite, float_t* a, float_t* b, int32_t frame,
const uint8_t step, size_t i, float_t t1, float_t t2, float_t t2_old,
std::vector<Curve::Key>* keys_rev) {
Curve::Key key;
if (has_error && has_error_lerp && has_error_hermite) {
float_t _t2 = t2_old;
for (size_t j = 0; j < i; j++) {
key.type = KEY_CONSTANT;
key.frame = (int32_t)(frame + j * step);
key.value = a[j];
key.tangent1 = _t2;
key.tangent2 = 0.0f;
key.random_range = b[j];
keys_rev->push_back(key);
_t2 = 0.0f;
}
}
else if (has_error && has_error_lerp) {
key.type = KEY_HERMITE;
key.frame = frame;
key.value = a[0];
key.tangent1 = t2_old;
key.tangent2 = t1;
key.random_range = b[0];
keys_rev->push_back(key);
return t2;
}
else if (has_error || (i > 1 && b[0] != b[1])) {
key.type = KEY_LINEAR;
key.frame = frame;
key.value = a[0];
key.tangent1 = 0.0f;
key.tangent2 = 0.0f;
key.random_range = b[0];
keys_rev->push_back(key);
}
else {
key.type = KEY_CONSTANT;
key.frame = frame;
key.value = a[0];
key.tangent1 = 0.0f;
key.tangent2 = 0.0f;
key.random_range = b[0];
keys_rev->push_back(key);
}
return 0.0f;
}
#endif
}
+6 -6
View File
@@ -9,15 +9,14 @@
#include <map>
#include <vector>
#include "../../KKdLib/database/object.hpp"
#include "../../KKdLib/f2/header.h"
#include "../../KKdLib/f2/header.hpp"
#include "../../KKdLib/f2/struct.hpp"
#include "../../KKdLib/default.h"
#include "../../KKdLib/default.hpp"
#include "../../KKdLib/farc.hpp"
#include "../../KKdLib/hash.hpp"
#include "../../KKdLib/mat.h"
#include "../../KKdLib/mat.hpp"
#include "../../KKdLib/txp.hpp"
#include "../../KKdLib/vec.h"
#include "../../KKdLib/vector.h"
#include "../../KKdLib/vec.hpp"
#include "../file_handler.hpp"
#include "../frame_rate_control.hpp"
#include "../static_var.h"
@@ -502,6 +501,7 @@ namespace Glitter {
float_t F2Randomize(GLT, float_t value, Random* random);
float_t F2RandomizeKey(GLT, Curve::Key* key, Random* random);
#if defined(CRE_DEV) || defined(CLOUD_DEV)
void FitKeysIntoCurve(GLT);
void Recalculate(GLT);
#endif
bool XGetValue(float_t frame,
@@ -1392,7 +1392,7 @@ namespace Glitter {
#endif
};
class GltParticleManager : public Task {
class GltParticleManager : public app::Task {
public:
std::vector<Scene*> scenes;
std::vector<FileReader*> file_readers;
+20 -21
View File
@@ -1009,15 +1009,15 @@ namespace Glitter {
|| rend_group->blend_mode == PARTICLE_BLEND_TYPICAL)
emission = rend_group->emission;
shader_state_material_set_emission(&shaders_ft, false, emission, emission, emission, 1.0f);
shader_state_matrix_set_mvp_separate(&shaders_ft,
&rend_group->mat_draw, &((render_context*)GPM_VAL->rctx)->camera->view,
&((render_context*)GPM_VAL->rctx)->camera->projection);
shader_state_matrix_set_texture(&shaders_ft, 0, &mat4_identity);
shader_state_matrix_set_texture(&shaders_ft, 1, &mat4_identity);
shader_env_vert_set_ptr(&shaders_ft, 3, &vec4_identity);
shaders_ft.state_material_set_emission(false, emission, emission, emission, 1.0f);
shaders_ft.state_matrix_set_mvp(rend_group->mat_draw,
((render_context*)GPM_VAL->rctx)->camera->view,
((render_context*)GPM_VAL->rctx)->camera->projection);
shaders_ft.state_matrix_set_texture(0, mat4_identity);
shaders_ft.state_matrix_set_texture(1, mat4_identity);
shaders_ft.env_vert_set(3, vec4_identity);
shader_set(&shaders_ft, SHADER_FT_GLITTER_PT);
shaders_ft.set(SHADER_FT_GLITTER_PT);
switch (rend_group->type) {
case PARTICLE_QUAD: {
static const GLsizei buffer_size = sizeof(Buffer);
@@ -1038,8 +1038,7 @@ namespace Glitter {
gl_state_bind_array_buffer(0);
gl_state_bind_element_array_buffer(rend_group->ebo);
shader_draw_elements(&shaders_ft,
GL_TRIANGLES, (GLsizei)(6 * rend_group->disp), GL_UNSIGNED_INT, 0);
shaders_ft.draw_elements(GL_TRIANGLES, (GLsizei)(6 * rend_group->disp), GL_UNSIGNED_INT, 0);
gl_state_bind_element_array_buffer(0);
glDisableVertexAttribArray(0);
@@ -1069,7 +1068,7 @@ namespace Glitter {
const GLenum mode = rend_group->type == PARTICLE_LINE ? GL_LINE_STRIP : GL_TRIANGLE_STRIP;
for (std::pair<GLint, GLsizei>& i : rend_group->draw_list)
shader_draw_arrays(&shaders_ft, mode, i.first, i.second);
shaders_ft.draw_arrays(mode, i.first, i.second);
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(3);
@@ -2167,14 +2166,15 @@ namespace Glitter {
if (rend_group->flags & PARTICLE_EMISSION || rend_group->blend_mode == PARTICLE_BLEND_TYPICAL)
emission = rend_group->emission;
shader_state_material_set_emission(&shaders_ft, false, emission, emission, emission, 1.0f);
shader_state_matrix_set_mvp_separate(&shaders_ft,
&rend_group->mat_draw, &((render_context*)GPM_VAL->rctx)->camera->view,
&((render_context*)GPM_VAL->rctx)->camera->projection);
shader_state_matrix_set_texture(&shaders_ft, 0, &mat4_identity);
shader_state_matrix_set_texture(&shaders_ft, 1, &mat4_identity);
shaders_ft.state_material_set_emission(false, emission, emission, emission, 1.0f);
shaders_ft.state_matrix_set_mvp(rend_group->mat_draw,
((render_context*)GPM_VAL->rctx)->camera->view,
((render_context*)GPM_VAL->rctx)->camera->projection);
shaders_ft.state_matrix_set_texture(0, mat4_identity);
shaders_ft.state_matrix_set_texture(1, mat4_identity);
shaders_ft.env_vert_set(3, vec4_identity);
shader_set(&shaders_ft, SHADER_FT_GLITTER_PT);
shaders_ft.set(SHADER_FT_GLITTER_PT);
switch (rend_group->type) {
case PARTICLE_QUAD: {
static const GLsizei buffer_size = sizeof(Buffer);
@@ -2195,8 +2195,7 @@ namespace Glitter {
gl_state_bind_array_buffer(0);
gl_state_bind_element_array_buffer(rend_group->ebo);
shader_draw_elements(&shaders_ft,
GL_TRIANGLES, (GLsizei)(6 * rend_group->disp), GL_UNSIGNED_INT, 0);
shaders_ft.draw_elements(GL_TRIANGLES, (GLsizei)(6 * rend_group->disp), GL_UNSIGNED_INT, 0);
gl_state_bind_element_array_buffer(0);
glDisableVertexAttribArray(0);
@@ -2225,7 +2224,7 @@ namespace Glitter {
const GLenum mode = rend_group->type == PARTICLE_LINE ? GL_LINE_STRIP : GL_TRIANGLE_STRIP;
for (std::pair<GLint, GLsizei>& i : rend_group->draw_list)
shader_draw_arrays(&shaders_ft, mode, i.first, i.second);
shaders_ft.draw_arrays(mode, i.first, i.second);
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(3);
+405 -82
View File
@@ -6,13 +6,14 @@
#include "auth_3d.hpp"
#include "../KKdLib/hash.hpp"
#include "../KKdLib/interpolation.h"
#include "../KKdLib/str_utils.h"
#include "../KKdLib/str_utils.hpp"
#include "draw_task.h"
#include "object.hpp"
#include "rob.hpp"
#include "stage.hpp"
namespace auth_3d_detail {
class TaskAuth3d : public Task {
class TaskAuth3d : public app::Task {
public:
TaskAuth3d();
virtual ~TaskAuth3d() override;
@@ -173,7 +174,7 @@ static void auth_3d_farc_load(auth_3d_farc* a3da_farc, const char* mdata_dir);
static void auth_3d_farc_load_modern(auth_3d_farc* a3da_farc, void* data);
static void auth_3d_farc_read_file(auth_3d_farc* a3da_farc, const char* mdata_dir);
static void auth_3d_farc_read_file_modern(auth_3d_farc* a3da_farc, void* data);
static bool auth_3d_farc_read_func(auth_3d_farc* a3da_farc, void* data, size_t size);
static bool auth_3d_farc_read_func(auth_3d_farc* a3da_farc, const void* data, size_t size);
static void auth_3d_farc_unload(auth_3d_farc* a3da_farc);
static void auth_3d_uid_file_load(auth_3d_uid_file* uid_file);
@@ -185,11 +186,17 @@ static void auth_3d_uid_file_modern_unload(auth_3d_uid_file_modern* uid_file);
static void auth_3d_uid_file_unload_file(auth_3d_uid_file* uid_file);
static void auth_3d_uid_file_modern_unload_file(auth_3d_uid_file_modern* uid_file);
static void Auth3dTestTask__SetAuth3dId(Auth3dTestTask* tt);
static void Auth3dTestTask__SetStage(Auth3dTestTask* tt);
auth_3d_data_struct* auth_3d_data;
auth_3d_detail::TaskAuth3d task_auth_3d;
Auth3dTestTask auth_3d_test_task;
static int16_t auth_3d_load_counter;
extern render_context* rctx_ptr;
extern vec4u8 clear_color;
auth_3d::auth_3d() : uid(), id(), mat(), enable(), camera_root_update(), visible(), repeat(),
ended(), left_right_reverse(), once(), alpha(), chara_id(), shadow(), frame_rate(), frame(),
@@ -1442,14 +1449,6 @@ void auth_3d_post_process::reset() {
scene_fade_init = vec4u_null;
}
auth_3d_data_struct::auth_3d_data_struct() {
}
auth_3d_data_struct::~auth_3d_data_struct() {
}
auth_3d_farc::auth_3d_farc() : load_count(), name(), state(), farc(), data(), size() {
}
@@ -1476,14 +1475,144 @@ auth_3d_uid_file_modern::~auth_3d_uid_file_modern() {
}
auth_3d_data_struct::auth_3d_data_struct() {
}
auth_3d_data_struct::~auth_3d_data_struct() {
}
Auth3dTestTask::Auth3dTestTask::Window::Window() {
stage_link_change = true;
obj_link = true;
}
Auth3dTestTask::Auth3dTestTask() {
field_1C0 = 10;
field_1C4 = 10;
field_1C8 = 10;
field_1CC = 10;
field_1D0 = false;
field_1D4 = 0;
auth_3d_id = -1;
auth_3d_uid = -1;
repeat = true;
left_right_reverse = false;
field_1E3 = false;
field_1E4 = 0;
field_1E8 = false;
field_1E9 = false;
black_mask_listener = false;
field_1EB = true;
field_1EC = 1;
effcmn_obj_set = -1;
field_210 = 1;
field_328 = false;
field_329 = true;
field_32A = true;
stage_index = -1;
load_stage_index = 0;
trans_value = vec3_null;
rot_y_value = 0.0f;
field_388 = false;
field_38C = 0;
field_390 = false;
field_394 = 0;
}
Auth3dTestTask:: ~Auth3dTestTask() {
}
bool Auth3dTestTask::Init() {
data_struct* data = rctx_ptr->data;
object_database* obj_db = &data->data_ft.obj_db;
field_1D0 = false;
field_1D4 = 0;
auth_3d_id = -1;
auth_3d_uid = -1;
repeat = true;
left_right_reverse = false;
field_1E3 = false;
field_1E4 = 0;
field_1E8 = false;
field_1E9 = false;
black_mask_listener = false;
field_1EC = 1;
effcmn_obj_set = obj_db->get_object_set_id("EFFCMN");
field_210 = 1;
field_328 = false;
field_329 = true;
field_32A = true;
stage_index = -1;
load_stage_index = 0;
trans_value = vec3_null;
rot_y_value = 0.0f;
field_390 = true;
field_394 = 0;
category = {};
load_category = {};
obj_sets = {};
rctx_ptr->draw_pass.shadow_ptr->self_shadow = true;
clear_color = { 0x99, 0x99, 0x99, 0x00 };
task_stage_load("A3D_STAGE");
object_storage_load_set(data, obj_db, effcmn_obj_set);
return true;
}
bool Auth3dTestTask::Ctrl() {
Auth3dTestTask__SetStage(this);
Auth3dTestTask__SetAuth3dId(this);
if (field_1EC == 1 && !object_storage_load_obj_set_check_not_read(effcmn_obj_set))
field_1EC = 4;
if (field_1D4 == 1 && auth_3d_data_check_id_loaded(&auth_3d_id))
field_1D4 = 2;
if (field_1D4 == 2) {
auth_3d_data_set_enable(&auth_3d_id, true);
auth_3d_data_set_paused(&auth_3d_id, false);
auth_3d_data_set_repeat(&auth_3d_id, repeat);
auth_3d_data_set_left_right_reverse(&auth_3d_id, left_right_reverse);
field_1D4 = 4;
}
if (auth_3d_data_check_id_not_empty(&auth_3d_id)) {
mat4 mat;
mat4_translate(trans_value.x, trans_value.y, trans_value.z, &mat);
mat4_rotate_y_mult(&mat, rot_y_value * DEG_TO_RAD_FLOAT, &mat);
auth_3d_data_set_mat(&auth_3d_id, &mat);
}
return false;
}
bool Auth3dTestTask::Dest() {
auth_3d_data_unload_id(auth_3d_id, rctx_ptr);
object_storage_unload_set(effcmn_obj_set);
task_stage_unload();
clear_color = { 0x00, 0x00, 0x00, 0xFF };
rctx_ptr->draw_pass.shadow_ptr->self_shadow = true;
if (category.size())
auth_3d_data_unload_category(category.c_str());
category = {};
load_category = {};
for (uint32_t& i : obj_sets)
object_storage_unload_set(i);
return true;
}
/*
void sub_140248480(string *auth_3d_data, list_int32_t *a2)
void __fastcall sub_140248480(string *a1, list_int32_t *a2)
{
list_int32_t_node *uid_file; // rcx
list_int32_t_node *v4; // rcx
list_int32_t_node *v5; // rbx
char *v6; // rcx
int32_t *i; // rbx
char *v8; // rax
const char *v8; // rax
size_t v9; // r8
size_t v10; // rsi
char *v11; // rdi
@@ -1501,7 +1630,7 @@ void sub_140248480(string *auth_3d_data, list_int32_t *a2)
pv_db_pv_difficulty *v23; // rcx
string_union v24; // kr00_16
pv_item *__shifted(pv_item,8) v25; // rbx
char *v26; // rcx
const char *v26; // rcx
object_info v27; // eax
list_int32_t_node *v28; // rdi
list_int32_t_node *v29; // rax
@@ -1528,31 +1657,31 @@ void sub_140248480(string *auth_3d_data, list_int32_t *a2)
string Dst; // [rsp+30h] [rbp-39h] BYREF
string v51; // [rsp+30h] [rbp-39h] FORCED BYREF
string Memory; // [rsp+50h] [rbp-19h] BYREF
vector_old_int32_t uids; // [rsp+70h] [rbp+7h] BYREF
vector_int32_t uids; // [rsp+70h] [rbp+7h] BYREF
v49 = -2i64;
uid_file = a2->head->next;
v4 = a2->head->next;
a2->head->next = a2->head;
a2->head->prev = a2->head;
a2->size = 0i64;
if ( uid_file != a2->head )
if ( v4 != a2->head )
{
do
{
v5 = uid_file->next;
operator delete(uid_file);
uid_file = v5;
v5 = v4->next;
operator delete(v4);
v4 = v5;
}
while ( v5 != a2->head );
}
uids.begin = 0i64;
uids.end = 0i64;
uids.capacity_end = 0i64;
if ( auth_3d_data->capacity < 0x10 )
v6 = (char *)auth_3d_data;
if ( a1->capacity < 0x10 )
v6 = (char *)a1;
else
v6 = auth_3d_data->data.ptr;
sub_1401CBC70(v6, &uids);
v6 = a1->data.ptr;
auth_3d_data_get_category_uids(v6, &uids);
for ( i = uids.begin; i != uids.end; ++i )
{
v8 = auth_3d_data_get_uid_name(*i);
@@ -1570,7 +1699,7 @@ void sub_140248480(string *auth_3d_data, list_int32_t *a2)
{
v9 = 0i64;
}
string_append_char_str(&Dst, v8, v9);
string_assign_char_str(&Dst, v8, v9);
v10 = Dst.length;
if ( Dst.length )
{
@@ -1623,9 +1752,9 @@ void sub_140248480(string *auth_3d_data, list_int32_t *a2)
if ( Dst.capacity >= 0x10 )
operator delete(Dst.data.ptr);
}
if ( !string_compare_ptr_char(auth_3d_data, "ITMPV", 0i64, 5ui64) )
if ( !string::find(a1, "ITMPV", 0i64, 5ui64) )
{
sub_1400215A0(auth_3d_data, &Memory, 5i64, -1i64);
sub_1400215A0(a1, &Memory, 5i64, -1i64);
v21 = sub_1400D29A0(&Memory, 0xAu);
v22 = task_pv_db_get_pv(v21);
if ( v22 )
@@ -1635,7 +1764,7 @@ void sub_140248480(string *auth_3d_data, list_int32_t *a2)
{
v51.data = 0ui64;
v51.length = 0i64;
sub_14023FDE0((vector_old_pv_item *)&v51, &v23->pv_item);
sub_14023FDE0((vector_pv_item *)&v51, &v23->pv_item);
v24 = v51.data;
if ( v51.data.ptr != *(char **)&v51.data.data[8] )
{
@@ -1644,7 +1773,10 @@ void sub_140248480(string *auth_3d_data, list_int32_t *a2)
{
if ( ADJ(v25)->index > 0 )
{
v26 = (char *)(ADJ(v25)->name.capacity < 0x10 ? v25 : ADJ(v25)->name.data.ptr);
if ( ADJ(v25)->name.capacity < 0x10 )
v26 = (const char *)v25;
else
v26 = ADJ(v25)->name.data.ptr;
v27 = obj_database_get_object_info(v26);
if ( v27 != -1 )
{
@@ -1685,9 +1817,12 @@ void sub_140248480(string *auth_3d_data, list_int32_t *a2)
if ( Memory.capacity >= 0x10 )
operator delete(Memory.data.ptr);
}
if ( !string_compare_ptr_char(auth_3d_data, "EFFCHRPV", 0i64, 8ui64) )
if ( !string::find(a1, "EFFCHRPV", 0i64, 8ui64) )
{
v32 = (char *)(auth_3d_data->capacity < 0x10 ? auth_3d_data : auth_3d_data->data.ptr);
if ( a1->capacity < 0x10 )
v32 = (char *)a1;
else
v32 = a1->data.ptr;
a4 = obj_database_get_object_set(v32);
if ( a4 != -1 )
{
@@ -1706,11 +1841,11 @@ void sub_140248480(string *auth_3d_data, list_int32_t *a2)
v51.capacity = 15i64;
v51.length = 0i64;
v51.data.data[0] = 0;
string_append_char_str(&v51, null_string, 0i64);
v36 = string_compare_ptr_char(auth_3d_data, "STGPV", 0i64, 5ui64);
string_assign_char_str(&v51, null_string, 0i64);
v36 = string::find(a1, "STGPV", 0i64, 5ui64);
if ( v36 != -1 )
{
v37 = sub_1400215A0(auth_3d_data, &Memory, v36, 8i64);
v37 = sub_1400215A0(a1, &Memory, v36, 8i64);
if ( &v51 != v37 )
{
if ( v51.capacity >= 0x10 )
@@ -1736,10 +1871,10 @@ void sub_140248480(string *auth_3d_data, list_int32_t *a2)
if ( Memory.capacity >= 0x10 )
operator delete(Memory.data.ptr);
}
v38 = string_compare_ptr_char(auth_3d_data, "STGD2PV", 0i64, 7ui64);
v38 = string::find(a1, "STGD2PV", 0i64, 7ui64);
if ( v38 != -1 )
{
v39 = sub_1400215A0(auth_3d_data, &Memory, v38, 10i64);
v39 = sub_1400215A0(a1, &Memory, v38, 10i64);
if ( &v51 != v39 )
{
if ( v51.capacity >= 0x10 )
@@ -1829,6 +1964,15 @@ bool auth_3d_data_check_category_loaded(uint32_t category_hash) {
return auth_3d_data_struct_check_category_loaded(auth_3d_data, category_hash);
}
bool auth_3d_data_check_id_loading(int32_t* id) {
if (*id >= 0 && ((*id & 0x7FFF) < AUTH_3D_DATA_COUNT)) {
auth_3d* auth = &auth_3d_data->data[*id & 0x7FFF];
if (auth->id == *id)
return auth->state == 1;
}
return false;
}
bool auth_3d_data_check_id_loaded(int32_t* id) {
if (*id >= 0 && ((*id & 0x7FFF) < AUTH_3D_DATA_COUNT)) {
auth_3d* auth = &auth_3d_data->data[*id & 0x7FFF];
@@ -2045,6 +2189,16 @@ int32_t auth_3d_data_get_uid(int32_t* id) {
return -1;
}
const char* auth_3d_data_get_uid_name(int32_t uid, auth_3d_database* auth_3d_db) {
if (uid < 0 || uid > auth_3d_db->uid.size())
return 0;
auth_3d_database_uid* db_uid = &auth_3d_db->uid[uid];
if (db_uid->enabled)
return db_uid->name.c_str();
return 0;
}
void auth_3d_data_load_category(const char* category_name, const char* mdata_dir) {
auth_3d_data_struct_load_category(auth_3d_data, category_name, mdata_dir);
}
@@ -2143,6 +2297,16 @@ void auth_3d_data_set_chara_id(int32_t* id, int32_t value) {
}
}
void auth_3d_data_set_draw_task_flags_alpha(int32_t* id, draw_task_flags draw_task_flags, float_t alpha) {
if (*id >= 0 && ((*id & 0x7FFF) < AUTH_3D_DATA_COUNT)) {
auth_3d* auth = &auth_3d_data->data[*id & 0x7FFF];
if (auth->id == *id) {
auth->draw_task_flags = draw_task_flags;
auth->alpha = alpha;
}
}
}
void auth_3d_data_set_enable(int32_t* id, bool value) {
if (*id >= 0 && ((*id & 0x7FFF) < AUTH_3D_DATA_COUNT)) {
auth_3d* auth = &auth_3d_data->data[*id & 0x7FFF];
@@ -2269,7 +2433,7 @@ void auth_3d_data_free() {
}
void task_auth_3d_append_task() {
TaskWork::AppendTask(&task_auth_3d, "AUTH_3D");
app::TaskWork::AppendTask(&task_auth_3d, "AUTH_3D");
}
void task_auth_3d_free_task() {
@@ -2731,30 +2895,30 @@ static void auth_3d_camera_auxiliary_restore_prev_value(auth_3d_camera_auxiliary
post_process_tone_map* tm = rctx->post_process.tone_map;
if (ca->flags & AUTH_3D_CAMERA_AUXILIARY_AUTO_EXPOSURE)
post_process_tone_map_set_auto_exposure(tm, true);
tm->set_auto_exposure(true);
if (ca->flags & AUTH_3D_CAMERA_AUXILIARY_EXPOSURE)
post_process_tone_map_set_exposure(tm, 1.0);
tm->set_exposure(1.0);
if (ca->flags & AUTH_3D_CAMERA_AUXILIARY_GAMMA)
post_process_tone_map_set_gamma(tm, 1.0);
tm->set_gamma(1.0);
if (ca->flags & AUTH_3D_CAMERA_AUXILIARY_GAMMA_RATE)
post_process_tone_map_set_gamma_rate(tm, 1.0);
tm->set_gamma_rate(1.0);
if (ca->flags & AUTH_3D_CAMERA_AUXILIARY_SATURATE)
post_process_tone_map_set_saturate_coeff(tm, 1.0);
tm->set_saturate_coeff(1.0);
}
static void auth_3d_camera_auxiliary_set(auth_3d_camera_auxiliary* ca, render_context* rctx) {
post_process_tone_map* tm = rctx->post_process.tone_map;
if (ca->flags & AUTH_3D_CAMERA_AUXILIARY_AUTO_EXPOSURE)
post_process_tone_map_set_auto_exposure(tm, ca->auto_exposure_value > 0.0);
tm->set_auto_exposure(ca->auto_exposure_value > 0.0f);
if (ca->flags & AUTH_3D_CAMERA_AUXILIARY_EXPOSURE)
post_process_tone_map_set_exposure(tm, ca->exposure_value);
tm->set_exposure(ca->exposure_value);
if (ca->flags & AUTH_3D_CAMERA_AUXILIARY_GAMMA)
post_process_tone_map_set_gamma(tm, ca->gamma_value);
tm->set_gamma(ca->gamma_value);
if (ca->flags & AUTH_3D_CAMERA_AUXILIARY_GAMMA_RATE)
post_process_tone_map_set_gamma_rate(tm, ca->gamma_rate_value);
tm->set_gamma_rate(ca->gamma_rate_value);
if (ca->flags & AUTH_3D_CAMERA_AUXILIARY_SATURATE)
post_process_tone_map_set_saturate_coeff(tm, ca->saturate_value);
tm->set_saturate_coeff(ca->saturate_value);
}
static void auth_3d_camera_root_ctrl(auth_3d_camera_root* cr,
@@ -3317,8 +3481,8 @@ static void auth_3d_m_object_hrc_disp(auth_3d_m_object_hrc* moh, auth_3d* auth,
}
static void auth_3d_m_object_hrc_list_ctrl(auth_3d_m_object_hrc* moh, mat4* parent_mat) {
if (!moh->model_transform.visible)
return;
//if (!moh->model_transform.visible)
// return;
auth_3d_object_node* node = moh->node.data();
size_t instance_count = moh->instance.size();
@@ -3330,8 +3494,8 @@ static void auth_3d_m_object_hrc_list_ctrl(auth_3d_m_object_hrc* moh, mat4* pare
mat4 mat = moh->model_transform.mat;
for (auth_3d_object_instance& i : moh->instance) {
if (!i.model_transform.visible)
continue;
//if (!i.model_transform.visible)
// continue;
auth_3d_object_model_transform_mat_mult(&i.model_transform, &mat);
int32_t* object_bone_indices = i.object_bone_indices.data();
@@ -3618,8 +3782,8 @@ static void auth_3d_object_disp(auth_3d_object* o, auth_3d* auth, render_context
}
static void auth_3d_object_list_ctrl(auth_3d_object* o, mat4* parent_mat) {
if (!o->model_transform.visible)
return;
//if (!o->model_transform.visible)
// return;
auth_3d_model_transform_set_mat(&o->model_transform, parent_mat);
@@ -3668,7 +3832,7 @@ static void auth_3d_object_hrc_load(auth_3d* auth, auth_3d_object_hrc* oh,
i.bone_id = -1;
uint64_t name_hash = hash_string_fnv1a64m(&i.name);
for (uint32_t j = 0; j < skin->bones_count; j++)
if (hash_utf8_fnv1a64m(string_data(&skin->bones[j].name)) == name_hash) {
if (hash_utf8_fnv1a64m(skin->bones[j].name) == name_hash) {
i.bone_id = skin->bones[j].id;
break;
}
@@ -3742,8 +3906,8 @@ static void auth_3d_object_hrc_disp(auth_3d_object_hrc* oh, auth_3d* auth, rende
}
static void auth_3d_object_hrc_list_ctrl(auth_3d_object_hrc* oh, mat4* mat) {
if (oh->node.size() < 1 || !oh->node[0].model_transform.visible)
return;
//if (oh->node.size() < 1 || !oh->node[0].model_transform.visible)
// return;
auth_3d_object_hrc_nodes_mat_mult(oh, mat);
@@ -3802,7 +3966,7 @@ static void auth_3d_object_instance_load(auth_3d* auth, auth_3d_object_instance*
mat4* mats = oi->mats.data();
for (uint32_t i = 0; i < skin->bones_count; i++) {
uint64_t name_hash = hash_utf8_fnv1a64m(string_data(&skin->bones[i].name));
uint64_t name_hash = hash_utf8_fnv1a64m(skin->bones[i].name);
for (auth_3d_object_node& j : moh->node)
if (hash_string_fnv1a64m(&j.name) == name_hash) {
int32_t bone_id = skin->bones[i].id;
@@ -4151,23 +4315,23 @@ static void auth_3d_post_process_restore_prev_value(auth_3d_post_process* pp, re
post_process_tone_map* tm = rctx->post_process.tone_map;
if (pp->flags_init & AUTH_3D_POST_PROCESS_INTENSITY)
post_process_blur_set_intensity(blur, &pp->intensity_init);
blur->set_intensity(pp->intensity_init);
if (pp->flags_init & AUTH_3D_POST_PROCESS_LENS_FLARE)
post_process_tone_map_set_lens_ghost(tm, pp->lens_flare_init);
tm->set_lens_flare(pp->lens_flare_init);
if (pp->flags_init & AUTH_3D_POST_PROCESS_LENS_GHOST)
post_process_tone_map_set_lens_ghost(tm, pp->lens_ghost_init);
tm->set_lens_ghost(pp->lens_ghost_init);
if (pp->flags_init & AUTH_3D_POST_PROCESS_LENS_SHAFT)
post_process_tone_map_set_lens_shaft(tm, pp->lens_shaft_init);
tm->set_lens_shaft(pp->lens_shaft_init);
if (pp->flags_init & AUTH_3D_POST_PROCESS_RADIUS)
post_process_blur_set_radius(blur, &pp->radius_init);
blur->set_radius(pp->radius_init);
if (pp->flags_init & AUTH_3D_POST_PROCESS_SCENE_FADE) {
vec4 scene_fade_init = pp->scene_fade_init;
post_process_tone_map_set_scene_fade(tm, &scene_fade_init);
tm->set_scene_fade(scene_fade_init);
}
}
@@ -4177,59 +4341,57 @@ static void auth_3d_post_process_set(auth_3d_post_process* pp, render_context* r
if (pp->flags & AUTH_3D_POST_PROCESS_INTENSITY) {
if (~pp->flags_init & AUTH_3D_POST_PROCESS_INTENSITY) {
post_process_blur_get_intensity(blur, &pp->intensity_init);
pp->intensity_init = blur->get_intensity();
enum_or(pp->flags_init, AUTH_3D_POST_PROCESS_INTENSITY);
}
post_process_blur_set_intensity(blur, (vec3*)&pp->intensity.value);
blur->set_intensity(*(vec3*)&pp->intensity.value);
}
if (pp->flags & AUTH_3D_POST_PROCESS_LENS_FLARE) {
if (~pp->flags_init & AUTH_3D_POST_PROCESS_LENS_FLARE) {
pp->lens_flare_init = post_process_tone_map_get_lens_flare(tm);
pp->lens_flare_init = tm->get_lens_flare();
enum_or(pp->flags_init, AUTH_3D_POST_PROCESS_LENS_FLARE);
}
post_process_tone_map_set_lens_ghost(tm, pp->lens_flare_value);
tm->set_lens_flare(pp->lens_flare_value);
}
if (pp->flags & AUTH_3D_POST_PROCESS_LENS_GHOST) {
if (~pp->flags_init & AUTH_3D_POST_PROCESS_LENS_GHOST) {
pp->lens_ghost_init = post_process_tone_map_get_lens_ghost(tm);
pp->lens_ghost_init = tm->get_lens_ghost();
enum_or(pp->flags_init, AUTH_3D_POST_PROCESS_LENS_GHOST);
}
post_process_tone_map_set_lens_ghost(tm, pp->lens_ghost_value);
tm->set_lens_ghost(pp->lens_ghost_value);
}
if (pp->flags & AUTH_3D_POST_PROCESS_LENS_SHAFT) {
if (~pp->flags_init & AUTH_3D_POST_PROCESS_LENS_SHAFT) {
pp->lens_shaft_init = post_process_tone_map_get_lens_shaft(tm);
pp->lens_shaft_init = tm->get_lens_shaft();
enum_or(pp->flags_init, AUTH_3D_POST_PROCESS_LENS_SHAFT);
}
post_process_tone_map_set_lens_shaft(tm, pp->lens_shaft_value);
tm->set_lens_shaft(pp->lens_shaft_value);
}
if (pp->flags & AUTH_3D_POST_PROCESS_RADIUS) {
if (~pp->flags_init & AUTH_3D_POST_PROCESS_RADIUS) {
post_process_blur_get_radius(blur, &pp->radius_init);
pp->radius_init = blur->get_radius();
enum_or(pp->flags_init, AUTH_3D_POST_PROCESS_RADIUS);
}
post_process_blur_set_radius(blur, (vec3*)&pp->radius.value);
blur->set_radius(*(vec3*)&pp->radius.value);
}
if (pp->flags & AUTH_3D_POST_PROCESS_SCENE_FADE) {
if (~pp->flags_init & AUTH_3D_POST_PROCESS_SCENE_FADE) {
vec4 scene_fade_init;
post_process_tone_map_get_scene_fade(tm, &scene_fade_init);
pp->scene_fade_init = scene_fade_init;
pp->scene_fade_init = tm->get_scene_fade();
enum_or(pp->flags_init, AUTH_3D_POST_PROCESS_SCENE_FADE);
}
vec4 scene_fade = pp->scene_fade.value;
post_process_tone_map_set_scene_fade(tm, &scene_fade);
tm->set_scene_fade(scene_fade);
}
}
@@ -4396,7 +4558,7 @@ static void auth_3d_farc_read_file(auth_3d_farc* a3da_farc, const char* mdata_di
if (a3da_farc->file_handler.read_file(rctx_ptr->data, a3da_farc->path.c_str(), a3da_farc->file.c_str()))
a3da_farc->file_handler.set_callback_data(0,
(void(*)(void*, void*, size_t))auth_3d_farc_read_func, a3da_farc);
(void(*)(void*, const void*, size_t))auth_3d_farc_read_func, a3da_farc);
else
a3da_farc->state = 2;
}
@@ -4413,19 +4575,20 @@ static void auth_3d_farc_read_file_modern(auth_3d_farc* a3da_farc, void* data) {
if (a3da_farc->file_handler.read_file(data, a3da_farc->path.c_str(), a3da_farc->file.c_str()))
a3da_farc->file_handler.set_callback_data(0,
(void(*)(void*, void*, size_t))auth_3d_farc_read_func, a3da_farc);
(void(*)(void*, const void*, size_t))auth_3d_farc_read_func, a3da_farc);
else
a3da_farc->state = 2;
}
static bool auth_3d_farc_read_func(auth_3d_farc* a3da_farc, void* data, size_t size) {
static bool auth_3d_farc_read_func(auth_3d_farc* a3da_farc, const void* data, size_t size) {
if (a3da_farc->state == 1) {
a3da_farc->state = 2;
a3da_farc->data = data;
a3da_farc->size = size;
}
a3da_farc->farc = new farc;
if (!a3da_farc->farc)
a3da_farc->farc = new farc;
if (!a3da_farc->farc)
return false;
@@ -4532,3 +4695,163 @@ static void auth_3d_uid_file_modern_unload_file(auth_3d_uid_file_modern* uid_fil
uid_file->state = 0;
auth_3d_data->uid_files_modern.erase(uid_file->hash);
}
static void Auth3dTestTask__SetAuth3dId(Auth3dTestTask* tt) {
if (task_stage_check_not_loaded() || tt->auth_3d_uid == -1
|| !tt->load_category.size() || tt->auth_3d_uid == auth_3d_data_get_uid(&tt->auth_3d_id))
return;
if (tt->load_category.compare(tt->category)) {
if (tt->category.size()) {
auth_3d_data_unload_category(tt->category.c_str());
for (uint32_t& i : tt->obj_sets)
object_storage_unload_set(i);
tt->obj_sets.clear();
}
auth_3d_data_load_category(tt->load_category.c_str());
tt->category = tt->load_category;
if (tt->window.obj_link)
tt->field_394 = 1;
}
if (!auth_3d_data_check_category_loaded(tt->category.c_str()))
return;
if (tt->field_394 == 1) {
data_struct* data = rctx_ptr->data;
object_database* obj_db = &data->data_ft.obj_db;
const char* cat_str = tt->category.c_str();
size_t cat_len = tt->category.size();
if (!memcmp(cat_str, "ITMPV", 5)) {
uint32_t set_id = obj_db->get_object_set_id(cat_str);
if (set_id != (uint32_t)-1) {
object_storage_load_set(data, obj_db, set_id);
tt->obj_sets.push_back(set_id);
}
}
if (!memcmp(cat_str, "EFFCHRPV", 8)) {
uint32_t set_id = obj_db->get_object_set_id(cat_str);
if (set_id != (uint32_t)-1) {
object_storage_load_set(data, obj_db, set_id);
tt->obj_sets.push_back(set_id);
}
}
size_t off;
std::string obj;
if ((off = tt->category.find("STGNS", 0)) != -1)
obj = std::string(&cat_str[off], 8);
if ((off = tt->category.find("STGD2NS", 0)) != -1)
obj = std::string(&cat_str[off], 10);
if ((off = tt->category.find("STGPV", 0)) != -1)
obj = std::string(&cat_str[off], 8);
if ((off = tt->category.find("STGD2PV", 0)) != -1)
obj = std::string(&cat_str[off], 10);
uint32_t set_id = obj_db->get_object_set_id(obj.c_str());
if (set_id != (uint32_t)-1) {
object_storage_load_set(data, obj_db, set_id);
tt->obj_sets.push_back(set_id);
}
obj += "HRC";
uint32_t hrc_set_id = obj_db->get_object_set_id(obj.c_str());
if (hrc_set_id != (uint32_t)-1) {
object_storage_load_set(data, obj_db, hrc_set_id);
tt->obj_sets.push_back(hrc_set_id);
}
for (uint32_t& i : tt->obj_sets)
object_storage_load_set(data, obj_db, i);
tt->field_394 = 2;
}
else if (tt->field_394 == 2) {
bool wait_load = false;
for (uint32_t& i : tt->obj_sets)
if (object_storage_load_obj_set_check_not_read(i))
wait_load = true;
if (!wait_load)
tt->field_394 = 0;
}
if (!tt->field_394) {
data_struct* data = rctx_ptr->data;
auth_3d_database* auth_3d_db = &data->data_ft.auth_3d_db;
auth_3d_data_unload_id(tt->auth_3d_id, rctx_ptr);
tt->auth_3d_id = auth_3d_data_load_uid(tt->auth_3d_uid, auth_3d_db);
if (auth_3d_data_check_id_not_empty(&tt->auth_3d_id)) {
auth_3d_data_set_enable(&tt->auth_3d_id, false);
auth_3d_data_read_file(&tt->auth_3d_id, auth_3d_db);
tt->field_1D4 = 1;
}
tt->auth_3d_uid = -1;
return;
}
}
static void Auth3dTestTask__SetStage(Auth3dTestTask* tt) {
if (tt->window.stage_link_change) {
data_struct* data = rctx_ptr->data;
auth_3d_database* auth_3d_db = &data->data_ft.auth_3d_db;
stage_database* stage_data = &data->data_ft.stage_data;
const char* name = auth_3d_data_get_uid_name(tt->auth_3d_uid, auth_3d_db);
size_t name_length = utf8_length(name);
if (name && name_length >= 3) {
size_t v5 = name_length - 2;
const char* v6 = name;
while (v5) {
const char* v7 = (const char*)memchr(v6, 'S', v5);
if (!v7)
break;
if (memcmp(v7, "STG", min(v5, 3))) {
v5 += v6 - v7 - 1;
v6 = v7 + 1;
continue;
}
size_t v16 = v7 - name;
if (v16 == -1 || v16 >= name_length || name_length == v16)
break;
size_t v17 = name_length - v16;
for (const char* i = name + v16; v17; ) {
const char* v20 = (const char*)memchr(i, '_', v17);
if (!v20)
break;
if (*v20 != '_') {
v17 += i - v20 - 1;
i = v20 + 1;
continue;
}
size_t v24 = v20 - name;
if (v24 != -1) {
std::string v30 = std::string(name + v16, v24 - v16);
int32_t stage_index = stage_data->get_stage_index(v30.c_str());
if (tt->stage_index != stage_index)
tt->load_stage_index = stage_index;
}
break;
}
break;
}
}
}
if (tt->load_stage_index != -1 && tt->load_stage_index != tt->stage_index) {
task_stage_set_stage_index(tt->load_stage_index);
tt->stage_index = tt->load_stage_index;
tt->load_stage_index = -1;
}
}
+59 -3
View File
@@ -7,11 +7,11 @@
#include <map>
#include <vector>
#include "../KKdLib/default.h"
#include "../KKdLib/default.hpp"
#include "../KKdLib/database/object.hpp"
#include "../KKdLib/database/texture.hpp"
#include "../KKdLib/a3da.hpp"
#include "../KKdLib/kf.h"
#include "../KKdLib/kf.hpp"
#include "frame_rate_control.hpp"
#include "render_context.hpp"
#include "task.hpp"
@@ -740,7 +740,7 @@ struct auth_3d_farc {
std::string file;
p_file_handler file_handler;
farc* farc;
void* data;
const void* data;
size_t size;
auth_3d_farc();
@@ -787,12 +787,66 @@ struct auth_3d_data_struct {
virtual ~auth_3d_data_struct();
};
class Auth3dTestTask : public app::Task {
public:
int32_t field_1C0;
int32_t field_1C4;
int32_t field_1C8;
int32_t field_1CC;
bool field_1D0;
int32_t field_1D4;
int32_t auth_3d_id;
int32_t auth_3d_uid;
bool repeat;
bool left_right_reverse;
bool field_1E3;
int32_t field_1E4;
bool field_1E8;
bool field_1E9;
bool black_mask_listener;
bool field_1EB;
int32_t field_1EC;
uint32_t effcmn_obj_set;
int32_t field_210;
bool field_328;
bool field_329;
bool field_32A;
int32_t stage_index;
int32_t load_stage_index;
vec3 trans_value;
float_t rot_y_value;
std::vector<std::pair<std::string, std::string>> field_348;
bool field_388;
int32_t field_38C;
bool field_390;
int32_t field_394;
std::string category;
std::string load_category;
std::vector<uint32_t> obj_sets;
struct Window {
bool stage_link_change;
bool obj_link;
Window();
} window;
Auth3dTestTask();
virtual ~Auth3dTestTask();
virtual bool Init();
virtual bool Ctrl();
virtual bool Dest();
};
extern auth_3d_data_struct* auth_3d_data;
extern Auth3dTestTask auth_3d_test_task;
extern void auth_3d_data_init();
extern bool auth_3d_data_check_id_not_empty(int32_t* id);
extern bool auth_3d_data_check_category_loaded(const char* category_name);
extern bool auth_3d_data_check_category_loaded(uint32_t category_hash);
extern bool auth_3d_data_check_id_loading(int32_t* id);
extern bool auth_3d_data_check_id_loaded(int32_t* id);
extern auth_3d* auth_3d_data_get_auth_3d(int32_t id);
extern int32_t auth_3d_data_get_auth_3d_id(object_info obj_info,
@@ -810,6 +864,7 @@ extern float_t auth_3d_data_get_play_control_begin(int32_t* id);
extern float_t auth_3d_data_get_play_control_size(int32_t* id);
extern bool auth_3d_data_get_repeat(int32_t* id);
extern int32_t auth_3d_data_get_uid(int32_t* id);
extern const char* auth_3d_data_get_uid_name(int32_t uid, auth_3d_database* auth_3d_db);
extern void auth_3d_data_load_auth_3d_db(auth_3d_database* auth_3d_db);
extern void auth_3d_data_load_category(const char* category_name, const char* mdata_dir = 0);
extern void auth_3d_data_load_category(void* data, const char* category_name, uint32_t category_hash);
@@ -820,6 +875,7 @@ extern void auth_3d_data_read_file(int32_t* id, auth_3d_database* auth_3d_db);
extern void auth_3d_data_read_file_modern(int32_t* id);
extern void auth_3d_data_set_camera_root_update(int32_t* id, bool value);
extern void auth_3d_data_set_chara_id(int32_t* id, int32_t value);
extern void auth_3d_data_set_draw_task_flags_alpha(int32_t* id, draw_task_flags draw_task_flags, float_t alpha);
extern void auth_3d_data_set_enable(int32_t* id, bool value);
extern void auth_3d_data_set_frame_rate(int32_t* id, FrameRateControl* value);
extern void auth_3d_data_set_last_frame(int32_t* id, float_t value);
+3 -3
View File
@@ -5,9 +5,9 @@
#pragma once
#include "../KKdLib/default.h"
#include "../KKdLib/mat.h"
#include "../KKdLib/vec.h"
#include "../KKdLib/default.hpp"
#include "../KKdLib/mat.hpp"
#include "../KKdLib/vec.hpp"
struct camera {
mat4 view;
+59 -30
View File
@@ -4,17 +4,17 @@
*/
#include "data.hpp"
#include "../KKdLib/io/path.h"
#include "../KKdLib/io/stream.h"
#include "../KKdLib/io/path.hpp"
#include "../KKdLib/io/stream.hpp"
#include "../KKdLib/hash.hpp"
#include "../KKdLib/str_utils.h"
#include "../KKdLib/str_utils.hpp"
data_struct* data_list;
static char default_config[] = "#AFT\n\n\n";
static void data_free_inner(data_struct* ds);
static void data_load_inner(stream* s);
static void data_load_inner(stream& s);
#if defined(CRE_DEV)
static void data_load_glitter_list(data_struct* ds, const char* path);
#endif
@@ -27,28 +27,26 @@ void data_struct_init() {
void data_struct_load(const char* path) {
stream s;
io_open(&s, path, "rb");
s.open(path, "rb");
if (s.io.stream)
data_load_inner(&s);
data_load_inner(s);
else {
io_free(&s);
io_open(&s, default_config, 7);
data_load_inner(&s);
s.close();
s.open(default_config, 7);
data_load_inner(s);
}
io_free(&s);
}
void data_struct_load(const wchar_t* path) {
stream s;
io_open(&s, path, L"rb");
s.open(path, L"rb");
if (s.io.stream)
data_load_inner(&s);
data_load_inner(s);
else {
io_free(&s);
io_open(&s, default_config, 7);
data_load_inner(&s);
s.close();
s.open(default_config, 7);
data_load_inner(s);
}
io_free(&s);
}
void data_struct_free() {
@@ -98,6 +96,21 @@ void data_struct_free() {
delete[] data_list;
}
bool data_struct::check_file_exists(const char* path) {
const char* t = strrchr(path, '/');
if (t) {
std::string dir = std::string(path, t - path + 1);
return check_file_exists(dir.c_str(), t + 1);
}
t = strrchr(path, '\\');
if (t) {
std::string dir = std::string(path, t - path + 1);
return check_file_exists(dir.c_str(), t + 1);
}
return false;
}
bool data_struct::check_file_exists(const char* dir, const char* file) {
if (path_check_directory_exists(dir)) {
const char* t = strrchr(file, '.');
@@ -259,9 +272,9 @@ bool data_struct::check_file_exists(const char* dir, uint32_t hash) {
return false;
}
void data_struct::get_directory_files(const char* dir, std::vector<data_struct_file>* data_files) {
data_files->clear();
data_files->shrink_to_fit();
void data_struct::get_directory_files(const char* dir, std::vector<data_struct_file>& data_files) {
data_files.clear();
data_files.shrink_to_fit();
size_t dir_len = utf8_length(dir);
if (dir_len >= 2 && !memcmp(dir, "./", 2)) {
@@ -318,7 +331,7 @@ void data_struct::get_directory_files(const char* dir, std::vector<data_struct_f
for (std::string& k : files) {
bool found = false;
for (data_struct_file& l : *data_files)
for (data_struct_file& l : data_files)
if (k == l.name) {
found = true;
break;
@@ -330,7 +343,7 @@ void data_struct::get_directory_files(const char* dir, std::vector<data_struct_f
data_struct_file f;
f.path = temp;
f.name = k;
data_files->push_back(f);
data_files.push_back(f);
}
}
@@ -338,7 +351,7 @@ void data_struct::get_directory_files(const char* dir, std::vector<data_struct_f
free(temp);
}
bool data_struct::get_file(const char* dir, uint32_t hash, const char* ext, std::string* file) {
bool data_struct::get_file(const char* dir, uint32_t hash, const char* ext, std::string& file) {
size_t dir_len = utf8_length(dir);
if (dir_len >= 2 && !memcmp(dir, "./", 2)) {
dir += 2;
@@ -403,7 +416,7 @@ bool data_struct::get_file(const char* dir, uint32_t hash, const char* ext, std:
t = l.c_str();
if (hash_murmurhash(t, t_len) == hash) {
*file = l;
file = l;
free(dir_temp);
free(temp);
return true;
@@ -419,6 +432,22 @@ bool data_struct::get_file(const char* dir, uint32_t hash, const char* ext, std:
return false;
}
bool data_struct::load_file(void* data, const char* path,
bool (*load_func)(void* data, const char* path, const char* file, uint32_t hash)) {
const char* t = strrchr(path, '/');
if (t) {
std::string dir = std::string(path, t - path + 1);
return load_file(data, dir.c_str(), t + 1, load_func);
}
t = strrchr(path, '\\');
if (t) {
std::string dir = std::string(path, t - path + 1);
return load_file(data, dir.c_str(), t + 1, load_func);
}
return false;
}
bool data_struct::load_file(void* data, const char* dir, const char* file,
bool (*load_func)(void* data, const char* path, const char* file, uint32_t hash)) {
if (path_check_directory_exists(dir)) {
@@ -680,10 +709,10 @@ static void data_free_inner(data_struct* ds) {
ds->ready = false;
}
static void data_load_inner(stream* s) {
size_t length = s->length;
static void data_load_inner(stream& s) {
size_t length = s.length;
void* data = force_malloc(length);
io_read(s, data, length);
s.read(data, length);
char* buf;
char** lines;
@@ -815,7 +844,7 @@ static void data_load_inner(stream* s) {
data_struct_path data_path;
t -= t_len[count - j - 1] + 1;
data_path.path = std::string(t, t_len[count - j - 1]);
data_path.data = vector_old_empty(data_struct_directory);
data_path.data = {};
ds->data_paths.push_back(data_path);
}
free(t_len);
@@ -1050,11 +1079,11 @@ static void data_load_inner(stream* s) {
#if defined(CRE_DEV)
static void data_load_glitter_list(data_struct* ds, const char* path) {
stream s;
io_open(&s, path, "rb");
s.open(path, "rb");
size_t length = s.length;
uint8_t* data = force_malloc_s(uint8_t, length);
io_read(&s, data, length);
io_free(&s);
s.read(data, length);
s.close();
char* buf;
char** lines;
+8 -5
View File
@@ -7,14 +7,14 @@
#include <string>
#include <vector>
#include "../KKdLib/default.h"
#include "../KKdLib/default.hpp"
#include "../KKdLib/database/auth_3d.hpp"
#include "../KKdLib/database/bone.hpp"
#include "../KKdLib/database/motion.hpp"
#include "../KKdLib/database/object.hpp"
#include "../KKdLib/database/stage.hpp"
#include "../KKdLib/database/texture.hpp"
#include "../KKdLib/vec.h"
#include "../KKdLib/vec.hpp"
enum data_type {
DATA_AFT = 0,
@@ -110,12 +110,15 @@ struct data_struct {
data_struct();
virtual ~data_struct();
bool check_file_exists(const char* path);
bool check_file_exists(const char* dir, const char* file);
bool check_file_exists(const char* dir, uint32_t hash);
void get_directory_files(const char* dir, std::vector<data_struct_file>* data_files);
bool get_file(const char* dir, uint32_t hash, const char* ext, std::string* file);
void get_directory_files(const char* dir, std::vector<data_struct_file>& data_files);
bool get_file(const char* dir, uint32_t hash, const char* ext, std::string& file);
bool load_file(void* data, const char* path,
bool (*load_func)(void* data, const char* path, const char* file, uint32_t hash));
bool load_file(void* data, const char* dir, const char* file,
bool (*load_func)(void* data, const char* path, const char* file, uint32_t hash));
bool (*load_func)(void* data, const char* path, const char* file, uint32_t hash));
bool load_file(void* data, const char* dir, uint32_t hash, const char* ext,
bool (*load_func)(void* data, const char* path, const char* file, uint32_t hash));
};
+72 -72
View File
@@ -4,7 +4,7 @@
*/
#include "draw_object.h"
#include "light_param/light.h"
#include "light_param/light.hpp"
#include "shader_ft.h"
#include "static_var.h"
#include "texture.hpp"
@@ -41,7 +41,7 @@ void draw_object_draw(render_context* rctx, draw_object* draw, mat4* model,
mat4u* mats = draw->mats;
if (draw->mat_count == 2) {
mat4 mat = *mats;
shader_state_matrix_set_program(&shaders_ft, 7, &mat);
shaders_ft.state_matrix_set_program(7, mat);
}
for (int32_t i = 0; i < draw->mat_count; i++, mats++) {
@@ -51,11 +51,11 @@ void draw_object_draw(render_context* rctx, draw_object* draw, mat4* model,
} mat;
mat4_transpose(mats, &mat.m);
shader_buffer_set_ptr_array(&shaders_ft, (size_t)i * 3, 3, mat.v);
shaders_ft.buffer_set((size_t)i * 3, 3, mat.v);
}
shader_state_matrix_set_modelview(&shaders_ft, 0, &rctx->view_mat, true);
shader_state_matrix_set_program(&shaders_ft, 6, &mat4_identity);
shaders_ft.state_matrix_set_modelview(0, rctx->view_mat, true);
shaders_ft.state_matrix_set_program(6, mat4_identity);
uniform_value[U_BONE_MAT] = 1;
}
else {
@@ -79,8 +79,8 @@ void draw_object_draw(render_context* rctx, draw_object* draw, mat4* model,
void draw_object_draw_default(render_context* rctx, draw_object* draw) {
if (draw->set_blend_color) {
vec4 blend_color = draw->blend_color;
shader_env_vert_set_ptr(&shaders_ft, 3, &blend_color);
shader_env_vert_set_ptr(&shaders_ft, 4, &vec4_null);
shaders_ft.env_vert_set(3, blend_color);
shaders_ft.env_vert_set(4, vec4_null);
}
if (!draw->draw_object_func)
@@ -117,8 +117,8 @@ void draw_object_draw_default(render_context* rctx, draw_object* draw) {
draw_object_vertex_attrib_reset_default(draw);
if (draw->set_blend_color) {
shader_env_vert_set_ptr(&shaders_ft, 3, &vec4_identity);
shader_env_vert_set_ptr(&shaders_ft, 4, &vec4_null);
shaders_ft.env_vert_set(3, vec4_identity);
shaders_ft.env_vert_set(4, vec4_null);
}
rctx->draw_state.stats.object_draw_count++;
@@ -154,12 +154,12 @@ void draw_object_draw_sss(render_context* rctx, draw_object* draw) {
}
if (aniso) {
shader_env_frag_set(&shaders_ft, 25, 0.0f, 0.0f, 0.0f, 0.5f);
shaders_ft.env_frag_set(25, 0.0f, 0.0f, 0.0f, 0.5f);
uniform_value[U37] = 1;
}
else {
vec4 sss_param = rctx->draw_pass.sss_data.param;
shader_env_frag_set(&shaders_ft, 25, sss_param.x, sss_param.y, sss_param.z, 0.5f);
shaders_ft.env_frag_set(25, sss_param.x, sss_param.y, sss_param.z, 0.5f);
uniform_value[U37] = 0;
}
draw_object_draw_default(rctx, draw);
@@ -231,11 +231,11 @@ void draw_object_draw_translucent(render_context* rctx, draw_object* draw) {
std::vector<GLuint>* textures = draw->textures;
if (rctx->draw_state.shader_index != -1) {
vec4 emission = draw->emission;
shader_state_material_set_emission_ptr(&shaders_ft, false, &emission);
shaders_ft.state_material_set_emission(false, emission);
draw_object_material_set_uniform(rctx, material, 0);
if (material->material.attrib.m.alpha_texture)
uniform_value[U_TEXTURE_COUNT] = 0;
shader_set(&shaders_ft, rctx->draw_state.shader_index);
shaders_ft.set(rctx->draw_state.shader_index);
}
draw_object_vertex_attrib_set_default(draw);
@@ -311,8 +311,8 @@ void draw_object_draw_translucent(render_context* rctx, draw_object* draw) {
}
inline void draw_object_model_mat_load(render_context* rctx, mat4* mat) {
shader_state_matrix_set_modelview_separate(&shaders_ft, 0, mat, &rctx->view_mat, true);
shader_state_matrix_set_program(&shaders_ft, 6, mat);
shaders_ft.state_matrix_set_modelview(0, *mat, rctx->view_mat, true);
shaders_ft.state_matrix_set_program(6, *mat);
}
inline void model_mat_face_camera_position(mat4* view, mat4* src, mat4* dst) {
@@ -372,12 +372,12 @@ void obj_sub_mesh_draw(render_context* rctx, obj_primitive_type primitive_type,
if (primitive_type == OBJ_PRIMITIVE_TRIANGLE_STRIP && index_format == OBJ_INDEX_U16) {
gl_state_enable_primitive_restart();
glPrimitiveRestartIndex(0xFFFF);
shader_draw_range_elements(&shaders_ft, GL_TRIANGLE_STRIP,
shaders_ft.draw_range_elements(GL_TRIANGLE_STRIP,
start, end, count, GL_UNSIGNED_SHORT, (void*)indices);
gl_state_disable_primitive_restart();
}
else
shader_draw_elements(&shaders_ft, mesh_draw_mode[primitive_type],
shaders_ft.draw_elements(mesh_draw_mode[primitive_type],
count, mesh_indices_type[index_format], (void*)indices);
rctx->draw_state.stats.draw_count += count;
@@ -610,14 +610,14 @@ static void draw_object_material_set_default(render_context* rctx, draw_object*
vec4 diffuse = material->material.color.diffuse;
vec4 emission = draw->emission;
draw_object_chara_color_fog_set(rctx, draw, disable_fog);
shader_state_material_set_ambient_ptr(&shaders_ft, false, &ambient);
shader_state_material_set_diffuse_ptr(&shaders_ft, false, &diffuse);
shader_state_material_set_emission_ptr(&shaders_ft, false, &emission);
shaders_ft.state_material_set_ambient(false, ambient);
shaders_ft.state_material_set_diffuse(false, diffuse);
shaders_ft.state_material_set_emission(false, emission);
float_t line_light;
if (lighting_type == OBJ_MATERIAL_SHADER_LIGHTING_PHONG) {
vec4 specular = material->material.color.specular;
shader_state_material_set_specular_ptr(&shaders_ft, false, &specular);
shaders_ft.state_material_set_specular(false, specular);
float_t luma;
vec3 luma_coeff = { 0.30f, 0.59f, 0.11f };
@@ -636,21 +636,21 @@ static void draw_object_material_set_default(render_context* rctx, draw_object*
line_light = 0.0;
if (!use_shader)
shader_set(&shaders_ft, SHADER_FT_SIMPLE);
shaders_ft.set(SHADER_FT_SIMPLE);
else if (rctx->draw_state.shader_index != -1)
shader_set(&shaders_ft, rctx->draw_state.shader_index);
shaders_ft.set(rctx->draw_state.shader_index);
else if (material->material.shader.index != -1) {
if (material->material.shader.index != SHADER_FT_BLINN)
shader_set(&shaders_ft, material->material.shader.index);
shaders_ft.set(material->material.shader.index);
else if (lighting_type == OBJ_MATERIAL_SHADER_LIGHTING_LAMBERT)
shader_set(&shaders_ft, SHADER_FT_LAMBERT);
shaders_ft.set(SHADER_FT_LAMBERT);
else if (lighting_type == OBJ_MATERIAL_SHADER_LIGHTING_PHONG)
shader_set(&shaders_ft, SHADER_FT_BLINN);
shaders_ft.set(SHADER_FT_BLINN);
else
shader_set(&shaders_ft, SHADER_FT_CONSTANT);
shaders_ft.set(SHADER_FT_CONSTANT);
}
else
shader_set(&shaders_ft, SHADER_FT_CONSTANT);
shaders_ft.set(SHADER_FT_CONSTANT);
if (lighting_type != OBJ_MATERIAL_SHADER_LIGHTING_CONSTANT) {
float_t shininess;
@@ -660,7 +660,7 @@ static void draw_object_material_set_default(render_context* rctx, draw_object*
shininess = (material->material.color.shininess - 16.0f) * (float_t)(1.0 / 112.0);
shininess = max(shininess, 0.0f);
}
shader_state_material_set_shininess(&shaders_ft, false, shininess, 0.0f, 0.0f, 1.0f);
shaders_ft.state_material_set_shininess(false, shininess, 0.0f, 0.0f, 1.0f);
float_t fresnel = (float_t)material->material.shader_info.m.fresnel_type;
if (fresnel > 9.0)
@@ -669,12 +669,12 @@ static void draw_object_material_set_default(render_context* rctx, draw_object*
fresnel = rctx->draw_state.fresnel;
fresnel = (fresnel - 1.0f) * (0.12f * 0.82f);
shader_local_vert_set(&shaders_ft, 0, fresnel, 0.18f, line_light, 0.0f);
shader_local_frag_set(&shaders_ft, 9, fresnel, 0.18f, line_light, 0.0f);
shaders_ft.local_vert_set(0, fresnel, 0.18f, line_light, 0.0f);
shaders_ft.local_frag_set(9, fresnel, 0.18f, line_light, 0.0f);
shininess = max(material->material.color.shininess, 1.0f);
shader_local_vert_set(&shaders_ft, 1, shininess, 0.0f, 0.0f, 0.0f);
shader_local_frag_set(&shaders_ft, 3, shininess, 0.0f, 0.0f, 0.0f);
shaders_ft.local_vert_set(1, shininess, 0.0f, 0.0f, 0.0f);
shaders_ft.local_frag_set(3, shininess, 0.0f, 0.0f, 0.0f);
switch (material->material.shader.index) {
case SHADER_FT_SKIN: {
@@ -686,15 +686,15 @@ static void draw_object_material_set_default(render_context* rctx, draw_object*
texture_color_coeff.w *= 0.015f;
texture_specular_coeff.w *= 0.015f;
shader_local_frag_set_ptr(&shaders_ft, 5, &texture_color_coeff);
shader_local_frag_set_ptr(&shaders_ft, 6, &texture_color_offset);
shader_local_frag_set_ptr(&shaders_ft, 7, &texture_specular_coeff);
shader_local_frag_set_ptr(&shaders_ft, 8, &texture_specular_offset);
shaders_ft.local_frag_set(5, texture_color_coeff);
shaders_ft.local_frag_set(6, texture_color_offset);
shaders_ft.local_frag_set(7, texture_specular_coeff);
shaders_ft.local_frag_set(8, texture_specular_offset);
} break;
case SHADER_FT_HAIR:
case SHADER_FT_CLOTH:
case SHADER_FT_TIGHTS:
shader_local_frag_set(&shaders_ft, 5, 1.0f - draw->texture_color_coeff.w * 0.4f,
shaders_ft.local_frag_set(5, 1.0f - draw->texture_color_coeff.w * 0.4f,
0.0f, 0.0f, draw->texture_color_coeff.w * 0.02f);
break;
}
@@ -718,7 +718,7 @@ static void draw_object_material_set_parameter(render_context* rctx, obj_materia
vec4 specular = mat_data->material.color.specular;
specular.w = rctx->draw_state.specular_alpha;
shader_state_material_set_specular_ptr(&shaders_ft, false, &specular);
shaders_ft.state_material_set_specular(false, specular);
}
else {
bump_depth = mat_data->material.bump_depth;
@@ -730,17 +730,17 @@ static void draw_object_material_set_parameter(render_context* rctx, obj_materia
intensity = max(intensity, 1.0f);
shader_local_vert_set(&shaders_ft, 2, inv_bump_depth, bump_depth, 0.0f, 0.0f);
shader_local_frag_set(&shaders_ft, 0, inv_bump_depth, bump_depth, 0.0f, 0.0f);
shaders_ft.local_vert_set(2, inv_bump_depth, bump_depth, 0.0f, 0.0f);
shaders_ft.local_frag_set(0, inv_bump_depth, bump_depth, 0.0f, 0.0f);
shader_local_frag_set(&shaders_ft, 1, intensity, intensity, intensity * 25.5f, 1.0f);
shader_local_frag_set(&shaders_ft, 2,
shaders_ft.local_frag_set(1, intensity, intensity, intensity * 25.5f, 1.0f);
shaders_ft.local_frag_set(2,
reflect_uv_scale, reflect_uv_scale, refract_uv_scale, refract_uv_scale);
vec4 specular;
shader_env_vert_get_ptr(&shaders_ft, 17, &specular);
shaders_ft.env_vert_get(17, specular);
vec3_mult(*(vec3*)&specular, *(vec3*)&mat_data->material.color.specular, *(vec3*)&specular);
shader_env_vert_set_ptr(&shaders_ft, 18, &specular);
shaders_ft.env_vert_set(18, specular);
}
static void draw_object_material_set_reflect(render_context* rctx, draw_object* draw) {
@@ -808,11 +808,11 @@ static void draw_object_material_set_reflect(render_context* rctx, draw_object*
}
draw_object_material_set_uniform(rctx, material, true);
shader_set(&shaders_ft, rctx->draw_state.shader_index);
shader_state_material_set_ambient_ptr(&shaders_ft, false, &ambient);
shader_state_material_set_diffuse_ptr(&shaders_ft, false, &diffuse);
shader_state_material_set_emission_ptr(&shaders_ft, false, &emission);
shader_state_material_set_specular_ptr(&shaders_ft, false, &specular);
shaders_ft.set(rctx->draw_state.shader_index);
shaders_ft.state_material_set_ambient(false, ambient);
shaders_ft.state_material_set_diffuse(false, diffuse);
shaders_ft.state_material_set_emission(false, emission);
shaders_ft.state_material_set_specular(false, specular);
draw_object_material_set_parameter(rctx, draw->material);
}
@@ -894,8 +894,8 @@ static void draw_object_vertex_attrib_reset_default(draw_object* draw) {
uniform_value[U_INSTANCE] = 0;
gl_state_bind_element_array_buffer(0);
shader_state_matrix_set_texture(&shaders_ft, 0, &mat4_identity);
shader_state_matrix_set_texture(&shaders_ft, 1, &mat4_identity);
shaders_ft.state_matrix_set_texture(0, mat4_identity);
shaders_ft.state_matrix_set_texture(1, mat4_identity);
gl_state_active_texture(0);
}
@@ -919,8 +919,8 @@ static void draw_object_vertex_attrib_reset_default_compressed(draw_object* draw
uniform_value[U_INSTANCE] = 0;
gl_state_bind_element_array_buffer(0);
shader_state_matrix_set_texture(&shaders_ft, 0, &mat4_identity);
shader_state_matrix_set_texture(&shaders_ft, 1, &mat4_identity);
shaders_ft.state_matrix_set_texture(0, mat4_identity);
shaders_ft.state_matrix_set_texture(1, mat4_identity);
gl_state_active_texture(0);
}
@@ -948,7 +948,7 @@ static void draw_object_vertex_attrib_reset_reflect(draw_object* draw) {
}
gl_state_bind_element_array_buffer(0);
shader_state_matrix_set_texture(&shaders_ft, 0, &mat4_identity);
shaders_ft.state_matrix_set_texture(0, mat4_identity);
gl_state_active_texture(0);
}
@@ -971,7 +971,7 @@ inline static void draw_object_vertex_attrib_reset_reflect_compressed(draw_objec
}
gl_state_bind_element_array_buffer(0);
shader_state_matrix_set_texture(&shaders_ft, 0, &mat4_identity);
shaders_ft.state_matrix_set_texture(0, mat4_identity);
gl_state_active_texture(0);
}
@@ -1043,12 +1043,12 @@ static void draw_object_vertex_attrib_set_default(draw_object* draw) {
int32_t texture_id = material->material.texdata[i].tex_index;
mat4 mat = material->material.texdata[i].tex_coord_mat;
shader_state_matrix_set_texture(&shaders_ft, texcoord_index, &mat);
shaders_ft.state_matrix_set_texture(texcoord_index, mat);
if (material->material.texdata[i].shader_info.m.tex_type == OBJ_MATERIAL_TEXTURE_COLOR)
for (int32_t k = 0; k < draw->texture_transform_count; k++)
if (draw->texture_transform_array[k].id == texture_id) {
mat = draw->texture_transform_array[k].mat;
shader_state_matrix_set_texture(&shaders_ft, texcoord_index, &mat);
mat4 mat = draw->texture_transform_array[k].mat;
shaders_ft.state_matrix_set_texture(texcoord_index, mat);
texcoord_mat_set[texcoord_index] = true;
break;
}
@@ -1175,7 +1175,7 @@ static void draw_object_vertex_attrib_set_default(draw_object* draw) {
if (vertex_format & OBJ_VERTEX_FORMAT_UNKNOWN)
offset += 16;
shader_env_vert_set(&shaders_ft, 13, draw->morph_value, 1.0f - draw->morph_value, 0.0f, 0.0f);
shaders_ft.env_vert_set(13, draw->morph_value, 1.0f - draw->morph_value, 0.0f, 0.0f);
}
gl_state_bind_array_buffer(0);
@@ -1245,12 +1245,12 @@ inline static void draw_object_vertex_attrib_set_default_compressed(draw_object*
int32_t tex_index = material->material.texdata[i].tex_index;
mat4 mat = material->material.texdata[i].tex_coord_mat;
shader_state_matrix_set_texture(&shaders_ft, texcoord_index, &mat);
shaders_ft.state_matrix_set_texture(texcoord_index, mat);
if (material->material.texdata[i].shader_info.m.tex_type == OBJ_MATERIAL_TEXTURE_COLOR)
for (int32_t k = 0; k < draw->texture_transform_count; k++)
if (draw->texture_transform_array[k].id == tex_index) {
mat = draw->texture_transform_array[k].mat;
shader_state_matrix_set_texture(&shaders_ft, texcoord_index, &mat);
mat4 mat = draw->texture_transform_array[k].mat;
shaders_ft.state_matrix_set_texture(texcoord_index, mat);
texcoord_mat_set[texcoord_index] = true;
break;
}
@@ -1357,7 +1357,7 @@ inline static void draw_object_vertex_attrib_set_default_compressed(draw_object*
if (vertex_format & OBJ_VERTEX_FORMAT_BONE_DATA)
offset += 16;
shader_env_vert_set(&shaders_ft, 13, draw->morph_value, 1.0f - draw->morph_value, 0.0f, 0.0f);
shaders_ft.env_vert_set(13, draw->morph_value, 1.0f - draw->morph_value, 0.0f, 0.0f);
}
gl_state_bind_array_buffer(0);
@@ -1416,12 +1416,12 @@ static void draw_object_vertex_attrib_set_reflect(draw_object* draw) {
int32_t tex_index = material->material.texdata[0].tex_index;
mat4 mat = material->material.texdata[0].tex_coord_mat;
shader_state_matrix_set_texture(&shaders_ft, 0, &mat);
shaders_ft.state_matrix_set_texture(0, mat);
if (material->material.texdata[0].shader_info.m.tex_type == OBJ_MATERIAL_TEXTURE_COLOR)
for (int32_t j = 0; j < draw->texture_transform_count; j++)
if (draw->texture_transform_array[j].id == tex_index) {
mat = draw->texture_transform_array[j].mat;
shader_state_matrix_set_texture(&shaders_ft, 0, &mat);
mat4 mat = draw->texture_transform_array[j].mat;
shaders_ft.state_matrix_set_texture(0, mat);
break;
}
}
@@ -1541,7 +1541,7 @@ static void draw_object_vertex_attrib_set_reflect(draw_object* draw) {
if (vertex_format & OBJ_VERTEX_FORMAT_UNKNOWN)
offset += 16;
shader_env_vert_set(&shaders_ft, 13, draw->morph_value, 1.0f - draw->morph_value, 0.0f, 0.0f);
shaders_ft.env_vert_set(13, draw->morph_value, 1.0f - draw->morph_value, 0.0f, 0.0f);
}
gl_state_bind_array_buffer(0);
@@ -1589,12 +1589,12 @@ inline static void draw_object_vertex_attrib_set_reflect_compressed(draw_object*
int32_t tex_index = material->material.texdata[0].tex_index;
mat4 mat = material->material.texdata[0].tex_coord_mat;
shader_state_matrix_set_texture(&shaders_ft, 0, &mat);
shaders_ft.state_matrix_set_texture(0, mat);
if (material->material.texdata[0].shader_info.m.tex_type == OBJ_MATERIAL_TEXTURE_COLOR)
for (int32_t j = 0; j < draw->texture_transform_count; j++)
if (draw->texture_transform_array[j].id == tex_index) {
mat = draw->texture_transform_array[j].mat;
shader_state_matrix_set_texture(&shaders_ft, 0, &mat);
mat4 mat = draw->texture_transform_array[j].mat;
shaders_ft.state_matrix_set_texture(0, mat);
break;
}
}
@@ -1699,7 +1699,7 @@ inline static void draw_object_vertex_attrib_set_reflect_compressed(draw_object*
if (vertex_format & OBJ_VERTEX_FORMAT_BONE_DATA)
offset += 16;
shader_env_vert_set(&shaders_ft, 13, draw->morph_value, 1.0f - draw->morph_value, 0.0f, 0.0f);
shaders_ft.env_vert_set(13, draw->morph_value, 1.0f - draw->morph_value, 0.0f, 0.0f);
}
gl_state_bind_array_buffer(0);
+3 -4
View File
@@ -5,10 +5,9 @@
#pragma once
#include "../KKdLib/default.h"
#include "../KKdLib/mat.h"
#include "../KKdLib/vec.h"
#include "../KKdLib/vector.h"
#include "../KKdLib/default.hpp"
#include "../KKdLib/mat.hpp"
#include "../KKdLib/vec.hpp"
#include "object.hpp"
#include "render_context.hpp"
+126 -123
View File
@@ -5,14 +5,14 @@
#include "draw_pass.h"
#include "Glitter/glitter.hpp"
#include "light_param/fog.h"
#include "light_param/light.h"
#include "light_param/fog.hpp"
#include "light_param/light.hpp"
#include "gl_state.h"
#include "post_process.hpp"
#include "rob.hpp"
#include "render_texture.h"
#include "shader_ft.h"
#include "shader_glsl.h"
#include "shader_glsl.hpp"
#include "static_var.h"
#include "texture.hpp"
@@ -38,7 +38,7 @@ static void draw_pass_sss_contour(render_context* rctx, post_process* pp);
static void draw_pass_sss_filter(render_context* rctx, sss_data* a1);
static void draw_pass_reflect(render_context* rctx, draw_pass* a1);
static void draw_pass_refract(render_context* rctx, draw_pass* a1);
static void draw_pass_preprocess(render_context* rctx, draw_pass* a1);
static void draw_pass_pre_process(render_context* rctx, draw_pass* a1);
static void draw_pass_3d(render_context* rctx, draw_pass* a1);
static int32_t draw_pass_3d_get_translucent_count(render_context* rctx);
static void draw_pass_3d_shadow_reset(render_context* rctx);
@@ -58,7 +58,7 @@ extern bool draw_grid_3d;
extern shader_glsl grid_shader;
extern GLuint grid_vbo;
extern size_t grid_vertex_count;
extern vec3 clear_color;
extern vec4u8 clear_color;
extern light_param_data_storage* light_param_data_storage_data;
void draw_pass_main(render_context* rctx) {
@@ -72,7 +72,7 @@ void draw_pass_main(render_context* rctx) {
gl_state_active_bind_texture_cube_map(ibl_texture_index[i],
light_param_data_storage_data->textures[i]);
shader_env_frag_set(&shaders_ft, 0,
shaders_ft.env_frag_set(0,
1.0f / (float_t)rctx->post_process.render_width,
1.0f / (float_t)rctx->post_process.render_height,
(float_t)rctx->post_process.render_width,
@@ -94,7 +94,7 @@ void draw_pass_main(render_context* rctx) {
case DRAW_PASS_SHADOW:
draw_pass_shadow(rctx, &rctx->draw_pass);
break;
case DRAW_PASS_SSS:
case DRAW_PASS_SS_SSS:
draw_pass_sss(rctx, &rctx->draw_pass);
break;
case DRAW_PASS_REFLECT:
@@ -103,18 +103,18 @@ void draw_pass_main(render_context* rctx) {
case DRAW_PASS_REFRACT:
draw_pass_refract(rctx, &rctx->draw_pass);
break;
case DRAW_PASS_PREPROCESS:
draw_pass_preprocess(rctx, &rctx->draw_pass);
case DRAW_PASS_PRE_PROCESS:
draw_pass_pre_process(rctx, &rctx->draw_pass);
break;
case DRAW_PASS_TYPE_6: {
case DRAW_PASS_CLEAR: {
render_texture_bind(&rctx->post_process.rend_texture, 0);
vec4 color;
*(vec3*)&color = clear_color;
color.w = 1.0f;
glClearBufferfv(GL_COLOR, 0, (GLfloat*)&color);
vec4 _clear_color;
vec4u8_to_vec4(clear_color, _clear_color);
vec4_mult_scalar(_clear_color, (float_t)(1.0 / 255.0), _clear_color);
glClearBufferfv(GL_COLOR, 0, (GLfloat*)&_clear_color);
//sub_140501470(rctx, &rctx->draw_pass);
} break;
case DRAW_PASS_TYPE_7:
case DRAW_PASS_PRE_SPRITE:
//sub_140501600(rctx, &rctx->draw_pass);
break;
case DRAW_PASS_3D:
@@ -153,7 +153,7 @@ static void draw_pass_shadow(render_context* rctx, draw_pass* a1) {
rctx->draw_state.shader_index = -1;
uniform_value[U0A] = 0;
draw_pass_shadow_filter(&rctx->litproj->shadow_texture[0],
&rctx->litproj->shadow_texture[1], 0, 1.5f, 0.0099999998f, true);
&rctx->litproj->shadow_texture[1], 0, 1.5f, 0.01f, true);
if (draw_pass_shadow_litproj(rctx, rctx->litproj)) {
draw_pass_set_camera(rctx->camera);
@@ -233,7 +233,7 @@ static void draw_pass_shadow(render_context* rctx, draw_pass* a1) {
mat4 proj;
mat4_ortho(-v16, v16, -v16, v16, shad->z_near, shad->z_far, &proj);
mat4_mult(&proj, &temp, &proj);
shader_state_matrix_set_projection(&shaders_ft, &proj, false);
shaders_ft.state_matrix_set_projection(proj, false);
mat4_look_at(view_point, interest, &rctx->view_mat);
@@ -263,20 +263,20 @@ static void draw_pass_shadow(render_context* rctx, draw_pass* a1) {
texture_params_get(v5, &tex_params[0], v7, &tex_params[1], v6, &tex_params[2]);
render_texture_bind(&shad->field_8[6], 0);
uniform_value[U_ESM_FILTER] = 0;
shader_set(&shaders_ft, SHADER_FT_ESMFILT);
shader_local_frag_set(&shaders_ft, 0, 1.0f / (float_t)tex_params[1].width,
shaders_ft.set(SHADER_FT_ESMFILT);
shaders_ft.local_frag_set(0, 1.0f / (float_t)tex_params[1].width,
1.0f / (float_t)tex_params[1].height, 0.0f, 0.0f);
gl_state_active_bind_texture_2d(0, v7);
shader_state_matrix_set_mvp(&shaders_ft, &mat4_identity);
shaders_ft.state_matrix_set_mvp(mat4_identity);
render_texture_draw_custom(&shaders_ft);
render_texture_bind(&shad->field_8[5], 0);
uniform_value[U_ESM_FILTER] = 1;
shader_set(&shaders_ft, SHADER_FT_ESMFILT);
shader_local_frag_set(&shaders_ft, 0, 0.75f / (float_t)tex_params[2].width,
shaders_ft.set(SHADER_FT_ESMFILT);
shaders_ft.local_frag_set(0, 0.75f / (float_t)tex_params[2].width,
0.75f / (float_t)tex_params[2].height, 0.0f, 0.0f);
gl_state_active_bind_texture_2d(0, v6);
shader_state_matrix_set_mvp(&shaders_ft, &mat4_identity);
shaders_ft.state_matrix_set_mvp(mat4_identity);
render_texture_draw_custom(&shaders_ft);
texture_params_restore(&tex_params[0], &tex_params[1], &tex_params[2]);
}
@@ -291,18 +291,18 @@ static void draw_pass_shadow(render_context* rctx, draw_pass* a1) {
texture_param tex_params[3];
texture_params_get(v11, &tex_params[0], v12, &tex_params[1], 0, 0);
uniform_value[U_IMAGE_FILTER] = 5;
shader_set(&shaders_ft, SHADER_FT_IMGFILT);
shader_local_frag_set_ptr(&shaders_ft, 0, &vec4_identity);
shader_state_matrix_set_texture(&shaders_ft, 0, &mat4_identity);
shader_state_matrix_set_texture(&shaders_ft, 1, &mat4_identity);
shader_state_matrix_set_texture(&shaders_ft, 2, &mat4_identity);
shader_state_matrix_set_texture(&shaders_ft, 3, &mat4_identity);
shader_state_matrix_set_texture(&shaders_ft, 4, &mat4_identity);
shader_state_matrix_set_texture(&shaders_ft, 5, &mat4_identity);
shader_state_matrix_set_texture(&shaders_ft, 6, &mat4_identity);
shader_state_matrix_set_texture(&shaders_ft, 7, &mat4_identity);
shaders_ft.set(SHADER_FT_IMGFILT);
shaders_ft.local_frag_set(0, vec4_identity);
shaders_ft.state_matrix_set_texture(0, mat4_identity);
shaders_ft.state_matrix_set_texture(1, mat4_identity);
shaders_ft.state_matrix_set_texture(2, mat4_identity);
shaders_ft.state_matrix_set_texture(3, mat4_identity);
shaders_ft.state_matrix_set_texture(4, mat4_identity);
shaders_ft.state_matrix_set_texture(5, mat4_identity);
shaders_ft.state_matrix_set_texture(6, mat4_identity);
shaders_ft.state_matrix_set_texture(7, mat4_identity);
gl_state_active_bind_texture_2d(0, v12);
shader_state_matrix_set_mvp(&shaders_ft, &mat4_identity);
shaders_ft.state_matrix_set_mvp(mat4_identity);
render_texture_draw_custom(&shaders_ft);
texture_params_restore(&tex_params[0], &tex_params[1], 0);
}
@@ -364,11 +364,11 @@ static void draw_pass_shadow_filter(render_texture* a1, render_texture* a2,
render_texture_bind(a2, 0);
uniform_value[U_LIGHT_PROJ] = enable_lit_proj ? 1 : 0;
shader_set(&shaders_ft, SHADER_FT_ESMGAUSS);
shader_local_frag_set(&shaders_ft, 0, 1.0f / (float_t)tex_params[0].width, 0.0f, 0.0f, 0.0f);
shader_local_frag_set_ptr(&shaders_ft, 1, &v15[0]);
shader_local_frag_set_ptr(&shaders_ft, 2, &v15[1]);
shader_local_frag_set(&shaders_ft, 3, far_texel_offset, far_texel_offset, 0.0f, 0.0f);
shaders_ft.set(SHADER_FT_ESMGAUSS);
shaders_ft.local_frag_set(0, 1.0f / (float_t)tex_params[0].width, 0.0f, 0.0f, 0.0f);
shaders_ft.local_frag_set(1, v15[0]);
shaders_ft.local_frag_set(2, v15[1]);
shaders_ft.local_frag_set(3, far_texel_offset, far_texel_offset, 0.0f, 0.0f);
gl_state_active_bind_texture_2d(0, v11);
glActiveTexture(GL_TEXTURE0);
@@ -382,18 +382,18 @@ static void draw_pass_shadow_filter(render_texture* a1, render_texture* a2,
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
}
gl_state_active_bind_texture_2d(0, v11);
shader_state_matrix_set_mvp(&shaders_ft, &mat4_identity);
shaders_ft.state_matrix_set_mvp(mat4_identity);
render_texture_draw_custom(&shaders_ft);
render_texture_bind(a1, 0);
shader_local_frag_set(&shaders_ft, 0, 0.0f, 1.0f / (float_t)tex_params[0].height, 0.0f, 0.0f);
shader_local_frag_set_ptr(&shaders_ft, 1, &v15[0]);
shader_local_frag_set_ptr(&shaders_ft, 2, &v15[1]);
shader_local_frag_set(&shaders_ft, 3, far_texel_offset, far_texel_offset, 0.0f, 0.0f);
shaders_ft.local_frag_set(0, 0.0f, 1.0f / (float_t)tex_params[0].height, 0.0f, 0.0f);
shaders_ft.local_frag_set(1, v15[0]);
shaders_ft.local_frag_set(2, v15[1]);
shaders_ft.local_frag_set(3, far_texel_offset, far_texel_offset, 0.0f, 0.0f);
gl_state_active_bind_texture_2d(0, v9);
shader_state_matrix_set_mvp(&shaders_ft, &mat4_identity);
shaders_ft.state_matrix_set_mvp(mat4_identity);
render_texture_draw_custom(&shaders_ft);
shader_unbind();
shader::unbind();
texture_params_restore(&tex_params[0], &tex_params[1], 0);
}
@@ -438,7 +438,7 @@ static void draw_pass_sss(render_context* rctx, draw_pass* a1) {
return;
if (!sss->enable) {
shader_env_frag_set(&shaders_ft, 25, 0.0f, 0.0f, 0.0f, 0.0f);
shaders_ft.env_frag_set(25, 0.0f, 0.0f, 0.0f, 0.0f);
return;
}
@@ -507,8 +507,8 @@ static void draw_pass_sss(render_context* rctx, draw_pass* a1) {
static void draw_pass_sss_contour(render_context* rctx, post_process* pp) {
render_texture_bind(&pp->sss_contour_texture, 0);
shader_state_matrix_set_modelview(&shaders_ft, 0, &mat4_identity, false);
shader_state_matrix_set_projection(&shaders_ft, &mat4_identity, true);
shaders_ft.state_matrix_set_modelview(0, mat4_identity, false);
shaders_ft.state_matrix_set_projection(mat4_identity, true);
gl_state_enable_depth_test();
gl_state_set_depth_func(GL_ALWAYS);
gl_state_set_depth_mask(GL_TRUE);
@@ -524,7 +524,7 @@ static void draw_pass_sss_contour(render_context* rctx, post_process* pp) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
gl_state_active_texture(0);
shader_set(&shaders_ft, SHADER_FT_CONTOUR);
shaders_ft.set(SHADER_FT_CONTOUR);
camera* cam = rctx->camera;
float_t v3 = 1.0f / tanf((float_t)(cam->fov_rad * 0.5));
@@ -542,7 +542,7 @@ static void draw_pass_sss_contour(render_context* rctx, post_process* pp) {
if (v9 < 0.0f)
v9 = 0.0f;
shader_local_frag_set(&shaders_ft, 4, v9 * 0.004f + 0.0027f, 0.003f, v3 * 0.35f, 0.0008f);
shaders_ft.local_frag_set(4, v9 * 0.004f + 0.0027f, 0.003f, v3 * 0.35f, 0.0008f);
render_texture_draw_params(&shaders_ft, pp->render_width, pp->render_height, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
}
@@ -593,7 +593,7 @@ static void draw_pass_sss_filter_calc_coef(double_t a1, size_t a2, double_t a3,
a7++;
a8++;
}
shader_local_frag_set_ptr_array(&shaders_ft, 4, a2 * a2, params);
shaders_ft.local_frag_set(4, a2 * a2, params);
}
static void draw_pass_sss_filter(render_context* rctx, sss_data* a1) {
@@ -601,35 +601,35 @@ static void draw_pass_sss_filter(render_context* rctx, sss_data* a1) {
vec3 interest = rctx->camera->interest;
vec3 view_point = rctx->camera->view_point;
vec3 v46[2];
v46[0] = vec3_null;
v46[1] = vec3_null;
float_t v14[2];
vec3 chara_position[2];
chara_position[0] = vec3_null;
chara_position[1] = vec3_null;
float_t chara_distance[2];
for (int32_t i = 0; i < 2; i++) {
v46[i] = interest;
v14[i] = 999999.0f;
chara_position[i] = interest;
chara_distance[i] = 999999.0f;
rob_chara_bone_data* v16 = rob_chara_array[i].bone_data;
if (rob_chara_pv_data_array[i].type != ROB_CHARA_TYPE_NONE && rob_chara_array[i].data.field_0 & 1) {
mat4* v17 = rob_chara_bone_data_get_mats_mat(v16, MOTION_BONE_N_HARA_CP);
if (v17) {
mat4_get_translation(v17, &v46[i]);
vec3_distance(view_point, v46[i], v14[i]);
mat4* mat = rob_chara_bone_data_get_mats_mat(v16, MOTION_BONE_N_HARA_CP);
if (mat) {
mat4_get_translation(mat, &chara_position[i]);
vec3_distance(view_point, chara_position[i], chara_distance[i]);
}
}
}
vec3 v24;
if (v14[0] > v14[1]) {
v24 = v46[1];
v46[0] = v46[1];
vec3 closest_chara_position;
if (chara_distance[0] > chara_distance[1]) {
closest_chara_position = chara_position[1];
chara_position[0] = chara_position[1];
}
else
v24 = v46[0];
closest_chara_position = chara_position[0];
float_t length;
vec3_distance(interest, v24, length);
vec3_distance(interest, closest_chara_position, length);
if (length > 1.25f)
interest = v46[0];
interest = chara_position[0];
float_t v29;
vec3_distance(view_point, interest, v29);
@@ -648,10 +648,10 @@ static void draw_pass_sss_filter(render_context* rctx, sss_data* a1) {
v33 = (v36 * 8.0f) * 0.6f;
}
shader_env_frag_set(&shaders_ft, 25, v33, 0.0f, 0.0f, 0.0f);
shaders_ft.env_frag_set(25, v33, 0.0f, 0.0f, 0.0f);
shader_state_matrix_set_projection(&shaders_ft, &mat4_identity, false);
shader_state_matrix_set_modelview(&shaders_ft, 0, &mat4_identity, true);
shaders_ft.state_matrix_set_projection(mat4_identity, false);
shaders_ft.state_matrix_set_modelview(0, mat4_identity, true);
gl_state_active_texture(0);
if (a1->npr_contour) {
@@ -660,21 +660,21 @@ static void draw_pass_sss_filter(render_context* rctx, sss_data* a1) {
post_process* pp = &rctx->post_process;
gl_state_bind_texture_2d(pp->rend_texture.color_texture->tex);
uniform_value[U_REDUCE] = 0;
shader_set(&shaders_ft, SHADER_FT_REDUCE);
shaders_ft.set(SHADER_FT_REDUCE);
shader_state_matrix_set_texture(&shaders_ft, 0, &mat4_identity);
shaders_ft.state_matrix_set_texture(0, mat4_identity);
render_texture_draw_params(&shaders_ft, 640, 360, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f);
}
render_texture_bind(&a1->textures[2], 0);
glViewport(0, 0, 320, 180);
gl_state_bind_texture_2d(a1->textures[0].color_texture->tex);
uniform_value[U_SSS_FILTER] = 0;
shader_set(&shaders_ft, SHADER_FT_SSS_FILT);
shaders_ft.set(SHADER_FT_SSS_FILT);
render_texture_draw_params(&shaders_ft, 640, 360, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f);
render_texture_bind(&a1->textures[1], 0);
uniform_value[U_SSS_FILTER] = 3;
shader_set(&shaders_ft, SHADER_FT_SSS_FILT);
shader_local_frag_set(&shaders_ft, 1, 5.0f, 0.0f, 0.0f, 0.0f);
shaders_ft.set(SHADER_FT_SSS_FILT);
shaders_ft.local_frag_set(1, 5.0f, 0.0f, 0.0f, 0.0f);
double_t a5[3];
double_t a6[3];
@@ -694,7 +694,7 @@ static void draw_pass_sss_filter(render_context* rctx, sss_data* a1) {
a8[2] = 2.0;
draw_pass_sss_filter_calc_coef(1.0, sss_count, v34, 3, a5, a6, a7, a8);
shader_local_frag_set(&shaders_ft, 1, (float_t)(sss_count - 1), 0.0f, 1.0f, 1.0f);
shaders_ft.local_frag_set(1, (float_t)(sss_count - 1), 0.0f, 1.0f, 1.0f);
glViewport(0, 0, 320, 180);
gl_state_bind_texture_2d(a1->textures[2].color_texture->tex);
render_texture_draw_params(&shaders_ft, 320, 180, 1.0f, 1.0f, 0.96f, 1.0f, 0.0f);
@@ -807,7 +807,7 @@ static void draw_pass_refract(render_context* rctx, draw_pass* a1) {
}
}
static void draw_pass_preprocess(render_context* rctx, draw_pass* a1) {
static void draw_pass_pre_process(render_context* rctx, draw_pass* a1) {
}
@@ -874,10 +874,13 @@ static void draw_pass_3d(render_context* rctx, draw_pass* a1) {
if (a1->draw_pass_3d[DRAW_PASS_3D_TRANSPARENT])
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TRANSPARENT, 0, 0, 1, -1);
/*if (rctx->draw_pass.field_120)
draw_task_draw_objects_by_type(DRAW_OBJECT_TYPE_7, 0, 0, 1, -1);*/
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TYPE_7, 0, 0, 1, -1);*/
rctx->post_process.exposure->get_exposure_chara_data(&rctx->post_process, rctx->camera);
gl_state_bind_vertex_array(rctx->vao);
//post_process_draw_lens_flare(a1->post_process);
//draw_stars();
//draw_stars(&stars);
draw_task_draw_objects_by_type_translucent(rctx,
a1->draw_pass_3d[DRAW_PASS_3D_OPAQUE],
@@ -950,7 +953,7 @@ static void draw_pass_3d(render_context* rctx, draw_pass* a1) {
gl_state_active_bind_texture_2d(15, 0);
/*if (a1->shadow)
draw_pass_3d_shadow_reset();*/
shader_unbind();
shader::unbind();
}
static int32_t draw_pass_3d_get_translucent_count(render_context* rctx) {
@@ -970,8 +973,8 @@ static int32_t draw_pass_3d_get_translucent_count(render_context* rctx) {
static void draw_pass_3d_shadow_reset(render_context* rctx) {
gl_state_active_bind_texture_2d(6, 0);
gl_state_active_bind_texture_2d(7, 0);
shader_state_matrix_set_texture(&shaders_ft, 6, &mat4_identity);
shader_state_matrix_set_texture(&shaders_ft, 7, &mat4_identity);
shaders_ft.state_matrix_set_texture(6, mat4_identity);
shaders_ft.state_matrix_set_texture(7, mat4_identity);
rctx->draw_state.self_shadow = false;
rctx->draw_state.light = false;
}
@@ -981,7 +984,7 @@ static void draw_pass_3d_shadow_set(shadow* shad, render_context* rctx) {
gl_state_active_bind_texture_2d(19, shad->field_8[3].color_texture->tex);
gl_state_active_bind_texture_2d(20, shad->field_8[5].color_texture->tex);
gl_state_active_texture(0);
shader_env_frag_set(&shaders_ft, 23,
shaders_ft.env_frag_set(23,
((shad->field_2D8 * shad->field_208) * 2.0f) * 1.442695f, 0.0f, 0.0f, 0.0f);
rctx->draw_state.self_shadow = true;
}
@@ -1022,7 +1025,7 @@ static void draw_pass_3d_shadow_set(shadow* shad, render_context* rctx) {
mat4 view;
mat4_look_at(view_point, interest, &view);
mat4_mult(&view, &proj, &view);
shader_state_matrix_set_texture(&shaders_ft, 6ULL + i, &view);
shaders_ft.state_matrix_set_texture(6ULL + i, view);
}
for (int32_t i = 0, j = 0; i < 2; i++) {
@@ -1047,8 +1050,8 @@ static void draw_pass_3d_shadow_set(shadow* shad, render_context* rctx) {
ambient.z = shad->ambient;
}
shader_env_frag_set(&shaders_ft, 12, ambient.x, ambient.y, ambient.z, 1.0f);
shader_env_frag_set(&shaders_ft, 13, 1.0f - ambient.x, 1.0f - ambient.y, 1.0f - ambient.z, 0.0f);
shaders_ft.env_frag_set(12, ambient.x, ambient.y, ambient.z, 1.0f);
shaders_ft.env_frag_set(13, 1.0f - ambient.x, 1.0f - ambient.y, 1.0f - ambient.z, 0.0f);
}
else {
rctx->draw_state.light = false;
@@ -1057,8 +1060,8 @@ static void draw_pass_3d_shadow_set(shadow* shad, render_context* rctx) {
gl_state_active_bind_texture_2d(6 + i, shad->field_158[1 + i]->color_texture->tex);
gl_state_active_texture(0);
shader_env_frag_set_ptr(&shaders_ft, 12, &vec4_identity);
shader_env_frag_set_ptr(&shaders_ft, 13, &vec4_null);
shaders_ft.env_frag_set(12, vec4_identity);
shaders_ft.env_frag_set(13, vec4_null);
}
}
@@ -1071,7 +1074,7 @@ static void draw_pass_show_vector(render_context* rctx, draw_pass* a1) {
glViewport(0, 0, rctx->post_process.render_width, rctx->post_process.render_height);
draw_pass_set_camera(rctx->camera);
shader_env_vert_set(&shaders_ft, 20, a1->show_vector_length, a1->show_vector_z_offset, 0.0f, 0.0f);
shaders_ft.env_vert_set(20, a1->show_vector_length, a1->show_vector_z_offset, 0.0f, 0.0f);
for (int32_t i = 1; i < 4; i++) {
if (~a1->show_vector_flags & (1 << (i - 1)))
continue;
@@ -1124,7 +1127,7 @@ static void draw_pass_3d_grid(render_context* rctx) {
gl_state_set_depth_mask(GL_TRUE);
grid_shader.use();
shader_glsl_set_mat4(&grid_shader, "vp", GL_FALSE, rctx->camera->view_projection);
grid_shader.set("vp", false, rctx->camera->view_projection);
gl_state_bind_array_buffer(grid_vbo);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE,
@@ -1144,15 +1147,15 @@ static void draw_pass_3d_grid(render_context* rctx) {
}
static void draw_pass_set_camera(camera* cam) {
shader_state_matrix_set_modelview(&shaders_ft, 0, &cam->view, false);
shader_state_matrix_set_projection(&shaders_ft, &cam->projection, true);
shader_state_matrix_set_program(&shaders_ft, 5, &cam->view);
shaders_ft.state_matrix_set_modelview(0, cam->view, false);
shaders_ft.state_matrix_set_projection(cam->projection, true);
shaders_ft.state_matrix_set_program(5, cam->view);
shader_env_frag_set(&shaders_ft, 20,
shaders_ft.env_frag_set(20,
(float_t)(0.5 / (cam->fov_rad * cam->aspect)),
(float_t)(0.5 / cam->fov_rad),
0.0f, 0.0f);
shader_env_frag_set(&shaders_ft, 32,
shaders_ft.env_frag_set(32,
(float_t)(cam->max_distance / (cam->max_distance - cam->min_distance)),
(float_t)(-(cam->max_distance * cam->min_distance) / (cam->max_distance - cam->min_distance)),
0.0f, 0.0f);
@@ -1196,8 +1199,8 @@ static void texture_params_get(GLuint tex_0, texture_param* tex_0_param,
mat4 mat;
mat4_ortho(0.0f, (float_t)tex_0_param->width,
0.0f, (float_t)tex_0_param->height, -1.0f, 1.0f, &mat);
shader_state_matrix_set_projection(&shaders_ft, &mat, false);
shader_state_matrix_set_modelview(&shaders_ft, 0, &mat4_identity, true);
shaders_ft.state_matrix_set_projection(mat, false);
shaders_ft.state_matrix_set_modelview(0, mat4_identity, true);
glViewport(0, 0, tex_0_param->width, tex_0_param->height);
}
}
@@ -1215,11 +1218,11 @@ static void blur_filter_apply(GLuint tex_0, GLuint tex_1, blur_filter_mode filte
texture_param tex_params[2];
texture_params_get(tex_0, &tex_params[0], tex_1, &tex_params[1], 0, 0);
uniform_value[U_IMAGE_FILTER] = filter == BLUR_FILTER_32 ? 1 : 0;
shader_set(&shaders_ft, SHADER_FT_IMGFILT);
shaders_ft.set(SHADER_FT_IMGFILT);
float_t scale = filter == BLUR_FILTER_32 ? (float_t)(1.0 / 8.0) : (float_t)(1.0 / 4.0);
shader_local_frag_set(&shaders_ft, 0, scale, scale, scale, scale);
shader_local_frag_set(&shaders_ft, 1, 0.0f, 0.0f, 0.0f, 0.0f);
shaders_ft.local_frag_set(0, scale, scale, scale, scale);
shaders_ft.local_frag_set(1, 0.0f, 0.0f, 0.0f, 0.0f);
float_t w = 1.0f / (float_t)tex_params[1].width;
float_t h = 1.0f / (float_t)tex_params[1].height;
switch (filter) {
@@ -1229,10 +1232,10 @@ static void blur_filter_apply(GLuint tex_0, GLuint tex_1, blur_filter_mode filte
mat4_translate( 0.0f * w, 1.0f * h, 0.0f, &m[1]);
mat4_translate( 1.0f * w, -1.0f * h, 0.0f, &m[2]);
mat4_translate( 0.0f * w, -1.0f * h, 0.0f, &m[3]);
shader_state_matrix_set_texture(&shaders_ft, 0, &m[0]);
shader_state_matrix_set_texture(&shaders_ft, 1, &m[1]);
shader_state_matrix_set_texture(&shaders_ft, 2, &m[2]);
shader_state_matrix_set_texture(&shaders_ft, 3, &m[3]);
shaders_ft.state_matrix_set_texture(0, m[0]);
shaders_ft.state_matrix_set_texture(1, m[1]);
shaders_ft.state_matrix_set_texture(2, m[2]);
shaders_ft.state_matrix_set_texture(3, m[3]);
} break;
case BLUR_FILTER_9: {
mat4 m[4];
@@ -1240,10 +1243,10 @@ static void blur_filter_apply(GLuint tex_0, GLuint tex_1, blur_filter_mode filte
mat4_translate( 0.5f * w, 0.5f * h, 0.0f, &m[1]);
mat4_translate(-0.5f * w, -0.5f * h, 0.0f, &m[2]);
mat4_translate( 0.5f * w, -0.5f * h, 0.0f, &m[3]);
shader_state_matrix_set_texture(&shaders_ft, 0, &m[0]);
shader_state_matrix_set_texture(&shaders_ft, 1, &m[1]);
shader_state_matrix_set_texture(&shaders_ft, 2, &m[2]);
shader_state_matrix_set_texture(&shaders_ft, 3, &m[3]);
shaders_ft.state_matrix_set_texture(0, m[0]);
shaders_ft.state_matrix_set_texture(1, m[1]);
shaders_ft.state_matrix_set_texture(2, m[2]);
shaders_ft.state_matrix_set_texture(3, m[3]);
} break;
case BLUR_FILTER_16: {
mat4 m[4];
@@ -1251,10 +1254,10 @@ static void blur_filter_apply(GLuint tex_0, GLuint tex_1, blur_filter_mode filte
mat4_translate(-1.5f * w, 0.5f * h, 0.0f, &m[1]);
mat4_translate( 1.5f * w, -0.5f * h, 0.0f, &m[2]);
mat4_translate(-0.5f * w, 1.5f * h, 0.0f, &m[3]);
shader_state_matrix_set_texture(&shaders_ft, 0, &m[0]);
shader_state_matrix_set_texture(&shaders_ft, 1, &m[1]);
shader_state_matrix_set_texture(&shaders_ft, 2, &m[2]);
shader_state_matrix_set_texture(&shaders_ft, 3, &m[3]);
shaders_ft.state_matrix_set_texture(0, m[0]);
shaders_ft.state_matrix_set_texture(1, m[1]);
shaders_ft.state_matrix_set_texture(2, m[2]);
shaders_ft.state_matrix_set_texture(3, m[3]);
} break;
case BLUR_FILTER_32: {
mat4 m[8];
@@ -1266,18 +1269,18 @@ static void blur_filter_apply(GLuint tex_0, GLuint tex_1, blur_filter_mode filte
mat4_translate( 1.5f * w, 1.5f * h, 0.0f, &m[5]);
mat4_translate( 1.5f * w, 3.5f * h, 0.0f, &m[6]);
mat4_translate(-3.5f * w, 3.5f * h, 0.0f, &m[7]);
shader_state_matrix_set_texture(&shaders_ft, 0, &m[0]);
shader_state_matrix_set_texture(&shaders_ft, 1, &m[1]);
shader_state_matrix_set_texture(&shaders_ft, 2, &m[2]);
shader_state_matrix_set_texture(&shaders_ft, 3, &m[3]);
shader_state_matrix_set_texture(&shaders_ft, 4, &m[4]);
shader_state_matrix_set_texture(&shaders_ft, 5, &m[5]);
shader_state_matrix_set_texture(&shaders_ft, 6, &m[6]);
shader_state_matrix_set_texture(&shaders_ft, 7, &m[7]);
shaders_ft.state_matrix_set_texture(0, m[0]);
shaders_ft.state_matrix_set_texture(1, m[1]);
shaders_ft.state_matrix_set_texture(2, m[2]);
shaders_ft.state_matrix_set_texture(3, m[3]);
shaders_ft.state_matrix_set_texture(4, m[4]);
shaders_ft.state_matrix_set_texture(5, m[5]);
shaders_ft.state_matrix_set_texture(6, m[6]);
shaders_ft.state_matrix_set_texture(7, m[7]);
} break;
}
gl_state_active_bind_texture_2d(0, tex_1);
shader_state_matrix_set_mvp(&shaders_ft, &mat4_identity);
shaders_ft.state_matrix_set_mvp(mat4_identity);
render_texture_draw_custom(&shaders_ft);
texture_params_restore(&tex_params[0], &tex_params[1], 0);
}
+3 -3
View File
@@ -5,9 +5,9 @@
#pragma once
#include "../KKdLib/default.h"
#include "../KKdLib/mat.h"
#include "../KKdLib/vec.h"
#include "../KKdLib/default.hpp"
#include "../KKdLib/mat.hpp"
#include "../KKdLib/vec.hpp"
#include "draw_task.h"
extern void draw_pass_main(render_context* rctx);
+3 -4
View File
@@ -5,8 +5,7 @@
#pragma once
#include "../KKdLib/default.h"
#include "../KKdLib/mat.h"
#include "../KKdLib/vec.h"
#include "../KKdLib/vector.h"
#include "../KKdLib/default.hpp"
#include "../KKdLib/mat.hpp"
#include "../KKdLib/vec.hpp"
#include "gl_state.h"
+6 -6
View File
@@ -133,7 +133,7 @@ void draw_task_draw_objects_by_type(render_context* rctx, draw_object_type type,
default:
break;
}
shader_env_frag_set(&shaders_ft, 21, 0.0f, 0.0f, 0.0f, min_alpha);
shaders_ft.env_frag_set(21, 0.0f, 0.0f, 0.0f, min_alpha);
uniform_value[U_ALPHA_TEST] = alpha_test;
std::vector<draw_task*>& vec = rctx->object_data.draw_task_array[type];
@@ -218,7 +218,7 @@ void draw_task_draw_objects_by_type(render_context* rctx, draw_object_type type,
}
uniform_value_reset();
shader_unbind();
shader::unbind();
gl_state_set_blend_func(GL_ONE, GL_ZERO);
}
@@ -480,7 +480,7 @@ bool draw_task_add_draw_object(render_context* rctx, obj* object,
obj_material_attrib_member attrib = material->material.attrib.m;
if (draw_task_flags & (DRAW_TASK_10000 | DRAW_TASK_20000 | DRAW_TASK_40000)
&& task->data.object.blend_color.w < 1.0f) {
if (~draw_task_flags | DRAW_TASK_NO_TRANSLUCENCY) {
if (~draw_task_flags & DRAW_TASK_NO_TRANSLUCENCY) {
if (attrib.flag_28 || (attrib.punch_through
|| !(attrib.alpha_texture | attrib.alpha_material))
&& !sub_mesh->attrib.m.transparent) {
@@ -525,7 +525,7 @@ bool draw_task_add_draw_object(render_context* rctx, obj* object,
draw_task_add(rctx, DRAW_OBJECT_SSS, task);
if (material->material.attrib.m.punch_through) {
if (~draw_task_flags & DRAW_TASK_NO_TRANSLUCENCY)
if (!(draw_task_flags & DRAW_TASK_NO_TRANSLUCENCY))
draw_task_add(rctx, DRAW_OBJECT_TRANSPARENT, task);
if (draw_task_flags & DRAW_TASK_CHARA_REFLECT)
@@ -538,7 +538,7 @@ bool draw_task_add_draw_object(render_context* rctx, obj* object,
draw_task_add(rctx, DRAW_OBJECT_REFRACT_TRANSPARENT, task);
}
else {
if (~draw_task_flags & DRAW_TASK_NO_TRANSLUCENCY)
if (!(draw_task_flags & DRAW_TASK_NO_TRANSLUCENCY))
draw_task_add(rctx, DRAW_OBJECT_OPAQUE, task);
if (draw_task_flags & DRAW_TASK_20)
@@ -558,7 +558,7 @@ bool draw_task_add_draw_object(render_context* rctx, obj* object,
draw_task_add(rctx, DRAW_OBJECT_RIPPLE, task);
continue;
}
else if (~draw_task_flags & DRAW_TASK_NO_TRANSLUCENCY) {
else if (!(draw_task_flags & DRAW_TASK_NO_TRANSLUCENCY)) {
if (!attrib.translucent_priority)
if (mesh->attrib.m.translucent_no_shadow
|| draw_task_flags & DRAW_TASK_TRANSLUCENT_NO_SHADOW)
+3 -3
View File
@@ -5,9 +5,9 @@
#pragma once
#include "../KKdLib/default.h"
#include "../KKdLib/mat.h"
#include "../KKdLib/vec.h"
#include "../KKdLib/default.hpp"
#include "../KKdLib/mat.hpp"
#include "../KKdLib/vec.hpp"
#include "draw_object.h"
#include "draw_primitive.h"
+46 -30
View File
@@ -45,8 +45,8 @@ struct file_handler_storage {
file_handler_storage* file_handler_storage_data;
static bool file_handler_load_file(void* data, const char* path, const char* file, uint32_t hash);
static bool file_handler_load_farc_file(void* data, const char* path, const char* file, uint32_t hash);
static bool file_handler_load_file(void* data, const char* dir, const char* file, uint32_t hash);
static bool file_handler_load_farc_file(void* data, const char* dir, const char* file, uint32_t hash);
static void file_handler_storage_ctrl_list();
static void file_handler_storage_thread_ctrl();
@@ -64,8 +64,8 @@ void file_handler::call_callback(int32_t index) {
return;
std::unique_lock<std::mutex> u_lock(mtx);
void* data = this->data;
void(*callback_func)(void*, void*, size_t) = this->callback[index].func;
const void* data = this->data;
void(*callback_func)(void*, const void*, size_t) = this->callback[index].func;
void* callback_data = this->callback[index].data;
bool ready = this->callback[index].ready;
this->callback[index].ready = true;
@@ -88,13 +88,14 @@ void file_handler::set_farc_file(const char* farc_file, bool cache) {
u_lock.unlock();
}
void file_handler::set_path(const char* path) {
void file_handler::set_dir(const char* dir) {
std::unique_lock<std::mutex> u_lock(mtx);
this->path = path;
this->dir = dir;
u_lock.unlock();
}
void file_handler::set_callback_data(int32_t index, void(* func)(void*, void*, size_t), void* data) {
void file_handler::set_callback_data(int32_t index,
void(*func)(void*, const void*, size_t), void* data) {
std::unique_lock<std::mutex> u_lock(mtx);
if (index < 2) {
callback[index].func = func;
@@ -219,8 +220,8 @@ void file_handler_storage_free() {
delete file_handler_storage_data;
}
static bool file_handler_load_file(void* data, const char* path, const char* file, uint32_t hash) {
std::string file_path = path;
static bool file_handler_load_file(void* data, const char* dir, const char* file, uint32_t hash) {
std::string file_path = dir;
file_path += file;
struct stat st;
@@ -234,16 +235,15 @@ static bool file_handler_load_file(void* data, const char* path, const char* fil
return false;
stream s;
io_open(&s, file_path.c_str(), "rb");
bool ret = s.io.stream && io_read(&s, fhndl->data, fhndl->size);
io_free(&s);
s.open(file_path.c_str(), "rb");
bool ret = s.io.stream && s.read(fhndl->data, fhndl->size);
if (!ret)
free(fhndl->data);
return ret;
}
static bool file_handler_load_farc_file(void* data, const char* path, const char* file, uint32_t hash) {
std::string file_path = path;
static bool file_handler_load_farc_file(void* data, const char* dir, const char* file, uint32_t hash) {
std::string file_path = dir;
file_path += file;
file_handler* fhndl = (file_handler*)data;
@@ -308,10 +308,10 @@ static void file_handler_storage_thread_ctrl() {
if (i->not_ready) {
if (i->farc_file.size())
i->not_ready = !((data_struct*)i->ds)->load_file(i,
i->path.c_str(), i->farc_file.c_str(), file_handler_load_farc_file);
i->dir.c_str(), i->farc_file.c_str(), file_handler_load_farc_file);
else
i->not_ready = !((data_struct*)i->ds)->load_file(i,
i->path.c_str(), i->file.c_str(), file_handler_load_file);
i->dir.c_str(), i->file.c_str(), file_handler_load_file);
}
i->reading = false;
u_lock.unlock();
@@ -365,7 +365,7 @@ void p_file_handler::free_data() {
ptr = 0;
}
void* p_file_handler::get_data() {
const void* p_file_handler::get_data() {
if (!ptr || ptr->not_ready)
return 0;
return ptr->data;
@@ -377,9 +377,24 @@ ssize_t p_file_handler::get_size() {
return ptr->size;
}
bool p_file_handler::read_file(void* data, const char* path,
bool p_file_handler::read_file(void* data, const char* path) {
const char* t = strrchr(path, '/');
if (t) {
std::string dir = std::string(path, t - path + 1);
return read_file(data, dir.c_str(), 0, t + 1, false);
}
t = strrchr(path, '\\');
if (t) {
std::string dir = std::string(path, t - path + 1);
return read_file(data, dir.c_str(), 0, t + 1, false);
}
return false;
}
bool p_file_handler::read_file(void* data, const char* dir,
const char* farc_file, const char* file, bool cache) {
if (!path || !file)
if (!dir || !file)
return false;
if (ptr) {
@@ -388,7 +403,7 @@ bool p_file_handler::read_file(void* data, const char* path,
free_data();
}
if (!((data_struct*)data)->check_file_exists(path, farc_file ? farc_file : file))
if (!((data_struct*)data)->check_file_exists(dir, farc_file ? farc_file : file))
return false;
ptr = new file_handler;
@@ -401,7 +416,7 @@ bool p_file_handler::read_file(void* data, const char* path,
ptr->count++;
u_lock.unlock();
ptr->set_path(path);
ptr->set_dir(dir);
if (farc_file)
ptr->set_farc_file(farc_file, cache);
ptr->set_file(file);
@@ -413,12 +428,12 @@ bool p_file_handler::read_file(void* data, const char* path,
return true;
}
bool p_file_handler::read_file(void* data, const char* path, const char* file) {
return read_file(data, path, 0, file, false);
bool p_file_handler::read_file(void* data, const char* dir, const char* file) {
return read_file(data, dir, 0, file, false);
}
bool p_file_handler::read_file(void* data, const char* path, uint32_t hash, const char* ext) {
if (!path || !hash || hash == hash_murmurhash_empty)
bool p_file_handler::read_file(void* data, const char* dir, uint32_t hash, const char* ext) {
if (!dir || !hash || hash == hash_murmurhash_empty)
return false;
if (ptr) {
@@ -428,7 +443,7 @@ bool p_file_handler::read_file(void* data, const char* path, uint32_t hash, cons
}
std::string file;
if (!((data_struct*)data)->get_file(path, hash, ext, &file))
if (!((data_struct*)data)->get_file(dir, hash, ext, file))
return false;
ptr = new file_handler;
@@ -441,7 +456,7 @@ bool p_file_handler::read_file(void* data, const char* path, uint32_t hash, cons
ptr->count++;
u_lock.unlock();
ptr->set_path(path);
ptr->set_dir(dir);
ptr->set_file(file.c_str());
std::unique_lock<std::mutex> u_lock1(ptr->mtx);
@@ -463,10 +478,10 @@ void p_file_handler::read_now() {
bool ret;
if (ptr->farc_file.size())
ret = ((data_struct*)ptr->ds)->load_file(
ptr, ptr->path.c_str(), ptr->farc_file.c_str(), file_handler_load_farc_file);
ptr, ptr->dir.c_str(), ptr->farc_file.c_str(), file_handler_load_farc_file);
else
ret = ((data_struct*)ptr->ds)->load_file(
ptr, ptr->path.c_str(), ptr->file.c_str(), file_handler_load_file);
ptr, ptr->dir.c_str(), ptr->file.c_str(), file_handler_load_file);
if (ret)
ptr->not_ready = false;
@@ -479,7 +494,8 @@ void p_file_handler::read_now() {
}
}
void p_file_handler::set_callback_data(int32_t index, void(*func)(void*, void*, size_t), void* data) {
void p_file_handler::set_callback_data(int32_t index,
void(*func)(void*, const void*, size_t), void* data) {
if (ptr)
ptr->set_callback_data(index, func, data);
}
+13 -12
View File
@@ -10,11 +10,11 @@
#include <mutex>
#include <string>
#include <thread>
#include "../KKdLib/default.h"
#include "../KKdLib/default.hpp"
#include "../KKdLib/farc.hpp"
struct file_handler_read_func_data {
void(*func)(void*, void*, size_t);
struct file_handler_callback_func {
void(*func)(void*, const void*, size_t);
void* data;
bool ready;
};
@@ -24,11 +24,11 @@ struct file_handler {
std::mutex mtx;
bool not_ready;
bool reading;
std::string path;
std::string dir;
std::string farc_file;
std::string file;
bool cache;
file_handler_read_func_data callback[2];
file_handler_callback_func callback[2];
ssize_t size;
void* data;
void* ds;
@@ -40,8 +40,8 @@ struct file_handler {
void free_data_lock();
void set_file(const char* file);
void set_farc_file(const char* farc_file, bool cache);
void set_path(const char* path);
void set_callback_data(int32_t index, void(*func)(void*, void*, size_t), void* data);
void set_dir(const char* dir);
void set_callback_data(int32_t index, void(*func)(void*, const void*, size_t), void* data);
};
struct p_file_handler {
@@ -53,13 +53,14 @@ struct p_file_handler {
void call_free_func_free_data();
bool check_not_ready();
void free_data();
void* get_data();
const void* get_data();
ssize_t get_size();
bool read_file(void* data, const char* path, const char* farc_file, const char* file, bool cache);
bool read_file(void* data, const char* path, const char* file);
bool read_file(void* data, const char* path, uint32_t hash, const char* ext);
bool read_file(void* data, const char* path);
bool read_file(void* data, const char* dir, const char* farc_file, const char* file, bool cache);
bool read_file(void* data, const char* dir, const char* file);
bool read_file(void* data, const char* dir, uint32_t hash, const char* ext);
void read_now();
void set_callback_data(int32_t index, void(* func)(void*, void*, size_t), void* data);
void set_callback_data(int32_t index, void(* func)(void*, const void*, size_t), void* data);
};
extern void file_handler_storage_init();
+1 -1
View File
@@ -5,7 +5,7 @@
#pragma once
#include "../KKdLib/default.h"
#include "../KKdLib/default.hpp"
class FrameRateControl {
public:
+1 -1
View File
@@ -5,7 +5,7 @@
#pragma once
#include "../KKdLib/default.h"
#include "../KKdLib/default.hpp"
#include <glad/glad.h>
struct gl_state_struct {
+3 -4
View File
@@ -3,8 +3,8 @@
GitHub/GitLab: korenkonder
*/
#include "../KKdLib/io/path.h"
#include "../KKdLib/str_utils.h"
#include "../KKdLib/io/path.hpp"
#include "../KKdLib/str_utils.hpp"
#include "data.hpp"
#include "item_table.hpp"
@@ -156,12 +156,11 @@ static bool item_table_array_read(data_struct* data, const char* path) {
farc_file* ff = f.read_file(file);
if (ff) {
stream s;
io_open(&s, ff->data, ff->size);
s.open(ff->data, ff->size);
itm_table itm;
itm.read(ff->data, ff->size);
if (itm.ready)
item_table_load(data, &item_table_array[i], &itm);
io_free(&s);
}
}
free(path_farc);
+1 -1
View File
@@ -5,7 +5,7 @@
#pragma once
#include "../KKdLib/default.h"
#include "../KKdLib/default.hpp"
#include "../KKdLib/database/item_table.hpp"
#include "file_handler.hpp"
#include "object.hpp"
+1 -1
View File
@@ -5,7 +5,7 @@
#include "light_param.hpp"
#include "../KKdLib/hash.hpp"
#include "../KKdLib/str_utils.h"
#include "../KKdLib/str_utils.hpp"
#include "render_context.hpp"
static void light_param_data_get_stage_name_string(std::string* str, int32_t stage_index);
+2 -3
View File
@@ -7,10 +7,9 @@
#include <map>
#include <map>
#include "../KKdLib/default.h"
#include "../KKdLib/default.hpp"
#include "../KKdLib/farc.hpp"
#include "../KKdLib/mat.h"
#include "../KKdLib/vector.h"
#include "../KKdLib/mat.hpp"
#include "../KKdLib/light_param/face.hpp"
#include "../KKdLib/light_param/fog.hpp"
#include "../KKdLib/light_param/glow.hpp"
@@ -3,13 +3,13 @@
GitHub/GitLab: korenkonder
*/
#include "face.h"
#include "face.hpp"
void face_init(face* face) {
face->offset = 1.0f;
face->scale = 0.35f;
face->position = vec3_null;
face->direction = vec3_null;
face::face() {
offset = 1.0f;
scale = 0.35f;
position = vec3_null;
direction = vec3_null;
}
inline float_t face_get_offset(face* face) {
@@ -5,9 +5,9 @@
#pragma once
#include "../../KKdLib/default.h"
#include "../../KKdLib/default.hpp"
#include "../../KKdLib/light_param/face.hpp"
#include "../../KKdLib/vec.h"
#include "../../KKdLib/vec.hpp"
#include "../static_var.h"
struct face {
@@ -15,9 +15,10 @@ struct face {
float_t scale;
vec3 position;
vec3 direction;
face();
};
extern void face_init(face* face);
extern float_t face_get_offset(face* face);
extern void face_set_offset(face* face, float_t value);
extern float_t face_get_scale(face* face);
@@ -3,16 +3,16 @@
GitHub/GitLab: korenkonder
*/
#include "fog.h"
#include "fog.hpp"
#include "../shader_ft.h"
void fog_init(fog* fog) {
fog->type = FOG_NONE;
fog->density = 0.0f;
fog->start = 20.0f;
fog->end = 1000.0f;
fog->index = 0;
fog->color = { 1.0f, 1.0f, 1.0f, 0.0f };
fog::fog() {
type = FOG_NONE;
density = 0.0f;
start = 20.0f;
end = 1000.0f;
index = 0;
color = { 1.0f, 1.0f, 1.0f, 0.0f };
}
inline fog_type fog_get_type(fog* fog) {
@@ -72,7 +72,7 @@ void fog_data_set(fog* fog, fog_id id) {
float_t start = fog_get_start(fog);
float_t end = fog_get_end(fog);
if (start >= end)
start = end - 0.0099999998f;
start = end - 0.01f;
vec4 params;
params.x = density;
@@ -84,22 +84,22 @@ void fog_data_set(fog* fog, fog_id id) {
case FOG_DEPTH: {
vec4 color;
fog_get_color(fog, &color);
shader_env_vert_set_ptr(&shaders_ft, 29, &color);
shader_env_frag_set_ptr(&shaders_ft, 4, &color);
shaders_ft.env_vert_set(29, color);
shaders_ft.env_frag_set(4, color);
vec4_mult_scalar(color, (float_t)(1.0 / 8.0), color);
shader_state_fog_set_color_ptr(&shaders_ft, &color);
shader_state_fog_set_params_ptr(&shaders_ft, &params);
shaders_ft.state_fog_set_color(color);
shaders_ft.state_fog_set_params(params);
} break;
case FOG_HEIGHT: {
vec4 color;
fog_get_color(fog, &color);
shader_env_vert_set_ptr(&shaders_ft, 30, &color);
shader_env_frag_set_ptr(&shaders_ft, 11, &color);
shader_env_vert_set_ptr(&shaders_ft, 14, &params);
shaders_ft.env_vert_set(30, color);
shaders_ft.env_frag_set(11, color);
shaders_ft.env_vert_set(14, params);
} break;
case FOG_BUMP: {
shader_env_vert_set_ptr(&shaders_ft, 19, &params);
shaders_ft.env_vert_set(19, params);
} break;
}
}
@@ -5,9 +5,9 @@
#pragma once
#include "../../KKdLib/default.h"
#include "../../KKdLib/default.hpp"
#include "../../KKdLib/light_param/fog.hpp"
#include "../../KKdLib/vec.h"
#include "../../KKdLib/vec.hpp"
#include "../static_var.h"
struct fog {
@@ -17,9 +17,10 @@ struct fog {
float_t end;
int32_t index;
vec4 color;
fog();
};
extern void fog_init(fog* fog);
extern fog_type fog_get_type(fog* fog);
extern void fog_set_type(fog* fog, fog_type value);
extern float_t fog_get_density(fog* fog);
@@ -3,8 +3,8 @@
GitHub/GitLab: korenkonder
*/
#include "light.h"
#include "../../KKdLib/mat.h"
#include "light.hpp"
#include "../../KKdLib/mat.hpp"
#include "../shader_ft.h"
extern bool light_chara_ambient;
@@ -12,43 +12,47 @@ extern vec4 npr_spec_color;
static void light_get_direction_from_position(vec4* pos_dir, light_data* light, bool force);
void light_set_init(light_set* set) {
vec3 tv3;
vec4 tv4;
for (int32_t i = LIGHT_CHARA; i <= LIGHT_PROJECTION; i++) {
light_data* light = &set->lights[i];
light_set_type(light, LIGHT_OFF);
tv4 = { 0.0f, 0.0, 0.0f, 1.0f };
light_set_ambient(light, &tv4);
tv4 = { 1.0f, 1.0, 1.0f, 0.0f };
light_set_diffuse(light, &tv4);
tv4 = { 1.0f, 1.0f, 1.0f, 0.0f };
light_set_specular(light, &tv4);
tv3 = { 0.0f, 1.0f, 1.0f };
light_set_position(light, &tv3);
tv3 = { 0.0f, 0.0f, -1.0f };
light_set_spot_direction(light, &tv3);
light_set_spot_exponent(light, 0.0f);
light_set_spot_cutoff(light, 45.0f);
light_set_constant(light, 1.0f);
light_set_linear(light, 0.0f);
light_set_quadratic(light, 0.0f);
tv4 = { 0.0f, 0.0f, 0.0f, 0.0f };
light_set_ibl_specular(light, &tv4);
tv4 = { 0.0f, 0.0f, 0.0f, 0.0f };
light_set_ibl_back(light, &tv4);
tv4 = { 0.0f, 0.0f, 0.0f, 0.0f };
light_set_ibl_direction(light, &tv4);
tv3 = { 0.0f, 0.0f, 0.0f };
light_set_tone_curve(light, &tv3);
}
tv4 = { 0.2f, 0.2f, 0.2f, 1.0f };
light_set_set_ambient_intensity(set, &tv4);
tv4 = { 1.0f, 1.0f, 1.0f, 1.0f };
light_set_diffuse(&set->lights[LIGHT_CHARA], &tv4);
tv4 = { 1.0f, 1.0f, 1.0f, 1.0f };
light_set_specular(&set->lights[LIGHT_CHARA], &tv4);
light_set_set_irradiance(set, &mat4_identity, &mat4_identity, &mat4_identity);
light_data::light_data() : type(), ambient(), diffuse(), specular(), position(),
spot_direction(), spot_exponent(), spot_cutoff(), constant(), linear(), quadratic(),
ibl_specular(), ibl_back(), ibl_direction(), tone_curve(),clip_plane() {
vec3 temp3;
vec4 temp4;
light_set_type(this, LIGHT_OFF);
temp4 = { 0.0f, 0.0, 0.0f, 1.0f };
light_set_ambient(this, &temp4);
temp4 = { 1.0f, 1.0, 1.0f, 0.0f };
light_set_diffuse(this, &temp4);
temp4 = { 1.0f, 1.0f, 1.0f, 0.0f };
light_set_specular(this, &temp4);
temp3 = { 0.0f, 1.0f, 1.0f };
light_set_position(this, &temp3);
temp3 = { 0.0f, 0.0f, -1.0f };
light_set_spot_direction(this, &temp3);
light_set_spot_exponent(this, 0.0f);
light_set_spot_cutoff(this, 45.0f);
light_set_constant(this, 1.0f);
light_set_linear(this, 0.0f);
light_set_quadratic(this, 0.0f);
temp4 = { 0.0f, 0.0f, 0.0f, 0.0f };
light_set_ibl_specular(this, &temp4);
temp4 = { 0.0f, 0.0f, 0.0f, 0.0f };
light_set_ibl_back(this, &temp4);
temp4 = { 0.0f, 0.0f, 0.0f, 0.0f };
light_set_ibl_direction(this, &temp4);
temp3 = { 0.0f, 0.0f, 0.0f };
light_set_tone_curve(this, &temp3);
}
light_set::light_set() : ambient_intensity(),
irradiance_r(), irradiance_g(), irradiance_b() {
vec4 temp;
temp = { 0.2f, 0.2f, 0.2f, 1.0f };
light_set_set_ambient_intensity(this, &temp);
temp = { 1.0f, 1.0f, 1.0f, 1.0f };
light_set_diffuse(&lights[LIGHT_CHARA], &temp);
temp = { 1.0f, 1.0f, 1.0f, 1.0f };
light_set_specular(&lights[LIGHT_CHARA], &temp);
light_set_set_irradiance(this, &mat4_identity, &mat4_identity, &mat4_identity);
}
inline light_type light_get_type(light_data* light) {
@@ -232,32 +236,32 @@ inline void light_set_set_irradiance(light_set* set, const mat4* r, const mat4*
void light_set_data_set(light_set* set, face* face, light_set_id id) {
vec4 ambient_intensity;
light_set_get_ambient_intensity(set, &ambient_intensity);
shader_state_lightmodel_set_ambient_ptr(&shaders_ft, false, &ambient_intensity);
shaders_ft.state_lightmodel_set_ambient(false, ambient_intensity);
for (int32_t i = LIGHT_CHARA; i <= LIGHT_PROJECTION; i++) {
light_data* light = &set->lights[i];
if (light_chara_ambient || i != LIGHT_CHARA) {
vec4 ambient = light->ambient;
shader_state_light_set_ambient_ptr(&shaders_ft, i, &ambient);
shaders_ft.state_light_set_ambient(i, ambient);
}
else
shader_state_light_set_ambient(&shaders_ft, i, 0.0f, 0.0f, 0.0f, 1.0f);
shaders_ft.state_light_set_ambient(i, 0.0f, 0.0f, 0.0f, 1.0f);
vec4 diffuse = light->diffuse;
vec4 specular = light->specular;
shader_state_light_set_diffuse_ptr(&shaders_ft, i, &diffuse);
shader_state_light_set_specular_ptr(&shaders_ft, i, &specular);
shaders_ft.state_light_set_diffuse(i, diffuse);
shaders_ft.state_light_set_specular(i, specular);
vec4 light_position = light->position;
if (light->type == LIGHT_PARALLEL)
light_get_direction_from_position(&light_position, 0, true);
shader_state_light_set_position_ptr(&shaders_ft, i, &light_position);
shaders_ft.state_light_set_position(i, light_position);
shader_state_light_set_attenuation(&shaders_ft, i,
shaders_ft.state_light_set_attenuation(i,
light->constant, light->linear, light->quadratic, light->spot_exponent);
vec3 spot_direction = light->spot_direction;
shader_state_light_set_spot_direction(&shaders_ft, i,
shaders_ft.state_light_set_spot_direction(i,
spot_direction.x, spot_direction.y, spot_direction.z, light->spot_cutoff);
}
@@ -279,26 +283,26 @@ void light_set_data_set(light_set* set, face* face, light_set_id id) {
light_get_diffuse(&set->lights[LIGHT_CHARA], &diffuse);
light_get_specular(&set->lights[LIGHT_CHARA], &specular);
shader_env_vert_set_ptr(&shaders_ft, 5, &position);
shader_env_frag_set_ptr(&shaders_ft, 5, &position);
shaders_ft.env_vert_set(5, position);
shaders_ft.env_frag_set(5, position);
vec4_mult(diffuse, ibl_specular, temp);
shader_env_vert_set_ptr(&shaders_ft, 6, &temp);
shader_env_frag_set_ptr(&shaders_ft, 6, &temp);
shaders_ft.env_vert_set(6, temp);
shaders_ft.env_frag_set(6, temp);
vec4_mult(specular, ibl_specular, temp);
vec4_mult_scalar(temp, spec_coef, temp);
shader_env_vert_set_ptr(&shaders_ft, 7, &temp);
shader_env_frag_set_ptr(&shaders_ft, 7, &temp);
shaders_ft.env_vert_set(7, temp);
shaders_ft.env_frag_set(7, temp);
vec4_mult_scalar(ibl_specular, luce_coef, temp);
shader_env_vert_set_ptr(&shaders_ft, 8, &temp);
shader_env_frag_set_ptr(&shaders_ft, 8, &temp);
shaders_ft.env_vert_set(8, temp);
shaders_ft.env_frag_set(8, temp);
vec4_mult(specular, ibl_back, temp);
vec4_mult_scalar(temp, spec_coef, temp);
shader_env_vert_set_ptr(&shaders_ft, 9, &temp);
shader_env_frag_set_ptr(&shaders_ft, 9, &temp);
shaders_ft.env_vert_set(9, temp);
shaders_ft.env_frag_set(9, temp);
light_get_position_vec4(&set->lights[LIGHT_STAGE], &position);
light_get_direction_from_position(&position, &set->lights[LIGHT_STAGE], false);
@@ -306,30 +310,30 @@ void light_set_data_set(light_set* set, face* face, light_set_id id) {
light_get_diffuse(&set->lights[LIGHT_STAGE], &diffuse);
light_get_specular(&set->lights[LIGHT_STAGE], &specular);
shader_env_vert_set_ptr(&shaders_ft, 10, &position);
shader_env_frag_set_ptr(&shaders_ft, 14, &position);
shaders_ft.env_vert_set(10, position);
shaders_ft.env_frag_set(14, position);
vec4_mult(diffuse, ibl_specular, temp);
shader_env_vert_set_ptr(&shaders_ft, 11, &temp);
shader_env_frag_set_ptr(&shaders_ft, 16, &temp);
shaders_ft.env_vert_set(11, temp);
shaders_ft.env_frag_set(16, temp);
vec4_mult(specular, ibl_specular, temp);
vec4_mult_scalar(temp, spec_coef, temp);
shader_env_vert_set_ptr(&shaders_ft, 12, &temp);
shader_env_frag_set_ptr(&shaders_ft, 17, &temp);
shaders_ft.env_vert_set(12, temp);
shaders_ft.env_frag_set(17, temp);
mat4 irradiance_r;
mat4 irradiance_g;
mat4 irradiance_b;
light_set_get_irradiance(set, &irradiance_r, &irradiance_g, &irradiance_b);
shader_state_matrix_set_program(&shaders_ft, 0, &irradiance_r);
shader_state_matrix_set_program(&shaders_ft, 1, &irradiance_g);
shader_state_matrix_set_program(&shaders_ft, 2, &irradiance_b);
shaders_ft.state_matrix_set_program(0, irradiance_r);
shaders_ft.state_matrix_set_program(1, irradiance_g);
shaders_ft.state_matrix_set_program(2, irradiance_b);
float_t offset = face_get_offset(face);
float_t v28 = (float_t)(1.0 - exp(offset * -0.44999999)) * 2.0f;
offset = max(offset, 0.0f);
shader_env_vert_set(&shaders_ft, 0x11, v28 * 0.1f, offset * 0.06f, 1.0, 1.0);
shaders_ft.env_vert_set(0x11, v28 * 0.1f, offset * 0.06f, 1.0, 1.0);
if (light_get_type(&set->lights[LIGHT_CHARA_COLOR]) == LIGHT_PARALLEL) {
light_get_ambient(&set->lights[LIGHT_CHARA_COLOR], &ambient);
@@ -337,14 +341,14 @@ void light_set_data_set(light_set* set, face* face, light_set_id id) {
light_get_specular(&set->lights[LIGHT_CHARA_COLOR], &specular);
if (specular.w > 1.0)
specular.w = 1.0;
shader_env_frag_set_ptr(&shaders_ft, 33, &ambient);
shader_env_frag_set_ptr(&shaders_ft, 34, &diffuse);
shader_env_frag_set_ptr(&shaders_ft, 35, &specular);
shaders_ft.env_frag_set(33, ambient);
shaders_ft.env_frag_set(34, diffuse);
shaders_ft.env_frag_set(35, specular);
}
else {
shader_env_frag_set_ptr(&shaders_ft, 33, &vec4_null);
shader_env_frag_set_ptr(&shaders_ft, 34, &vec4_null);
shader_env_frag_set_ptr(&shaders_ft, 35, &vec4_null);
shaders_ft.env_frag_set(33, vec4_null);
shaders_ft.env_frag_set(34, vec4_null);
shaders_ft.env_frag_set(35, vec4_null);
}
if (light_get_type(&set->lights[LIGHT_TONE_CURVE]) == LIGHT_PARALLEL) {
@@ -362,19 +366,19 @@ void light_set_data_set(light_set* set, face* face, light_set_id id) {
else
tone_curve.y = 0.0f;
shader_env_frag_set_ptr(&shaders_ft, 36, &position);
shader_env_frag_set_ptr(&shaders_ft, 37, &ambient);
shader_env_frag_set_ptr(&shaders_ft, 38, &diffuse);
shader_env_frag_set_ptr(&shaders_ft, 39, &specular);
shader_env_frag_set(&shaders_ft, 40, tone_curve.x, tone_curve.y, tone_curve.z, 0.0f);
shaders_ft.env_frag_set(36, position);
shaders_ft.env_frag_set(37, ambient);
shaders_ft.env_frag_set(38, diffuse);
shaders_ft.env_frag_set(39, specular);
shaders_ft.env_frag_set(40, tone_curve.x, tone_curve.y, tone_curve.z, 0.0f);
}
else {
uniform_value[U_TONE_CURVE] = 0;
shader_env_frag_set(&shaders_ft, 36, 0.0f, 1.0f, 0.0f, 0.0f);
shader_env_frag_set(&shaders_ft, 37, 0.0f, 0.0f, 0.0f, 0.0f);
shader_env_frag_set(&shaders_ft, 38, 0.0f, 0.0f, 0.0f, 0.0f);
shader_env_frag_set(&shaders_ft, 39, 0.0f, 0.0f, 0.0f, 0.0f);
shader_env_frag_set(&shaders_ft, 40, 0.0f, 0.0f, 0.0f, 0.0f);
shaders_ft.env_frag_set(36, 0.0f, 1.0f, 0.0f, 0.0f);
shaders_ft.env_frag_set(37, 0.0f, 0.0f, 0.0f, 0.0f);
shaders_ft.env_frag_set(38, 0.0f, 0.0f, 0.0f, 0.0f);
shaders_ft.env_frag_set(39, 0.0f, 0.0f, 0.0f, 0.0f);
shaders_ft.env_frag_set(40, 0.0f, 0.0f, 0.0f, 0.0f);
}
light_get_position_vec4(&set->lights[LIGHT_CHARA], &position);
@@ -387,8 +391,8 @@ void light_set_data_set(light_set* set, face* face, light_set_id id) {
vec3_mult_scalar(*(vec3*)&position, 1.0f / length, *(vec3*)&position);
}
shader_env_vert_set(&shaders_ft, 15, position.x, position.y, position.z, 1.0f);
shader_env_vert_set(&shaders_ft, 16, -position.x, -position.y, -position.z, 1.0f);
shaders_ft.env_vert_set(15, position.x, position.y, position.z, 1.0f);
shaders_ft.env_vert_set(16, -position.x, -position.y, -position.z, 1.0f);
if (light_get_type(&set->lights[LIGHT_REFLECT]) == LIGHT_SPOT) {
vec4 spot_direction;
@@ -399,16 +403,16 @@ void light_set_data_set(light_set* set, face* face, light_set_id id) {
vec3_dot(*(vec3*)&position, *(vec3*)&spot_direction, spot_direction.w);
spot_direction.w = -spot_direction.w;
shader_env_vert_set_ptr(&shaders_ft, 28, &spot_direction);
shader_env_frag_set_ptr(&shaders_ft, 22, &spot_direction);
shaders_ft.env_vert_set(28, spot_direction);
shaders_ft.env_frag_set(22, spot_direction);
}
else if (light_get_type(&set->lights[LIGHT_REFLECT]) == LIGHT_POINT) {
shader_env_vert_set(&shaders_ft, 28, 0.0f, -1.0f, 0.0f, 9999.0f);
shader_env_frag_set(&shaders_ft, 22, 0.0f, -1.0f, 0.0f, 9999.0f);
shaders_ft.env_vert_set(28, 0.0f, -1.0f, 0.0f, 9999.0f);
shaders_ft.env_frag_set(22, 0.0f, -1.0f, 0.0f, 9999.0f);
}
else {
shader_env_vert_set(&shaders_ft, 28, 0.0f, -1.0f, 0.0f, 0.0f);
shader_env_frag_set(&shaders_ft, 22, 0.0f, -1.0f, 0.0f, 0.0f);
shaders_ft.env_vert_set(28, 0.0f, -1.0f, 0.0f, 0.0f);
shaders_ft.env_frag_set(22, 0.0f, -1.0f, 0.0f, 0.0f);
}
mat4 v63 = mat4_identity;
@@ -446,10 +450,10 @@ void light_set_data_set(light_set* set, face* face, light_set_id id) {
}
mat4_transpose(&v63, &v63);
shader_env_frag_set_ptr(&shaders_ft, 26, &v63.row0);
shader_env_frag_set_ptr(&shaders_ft, 27, &v63.row1);
shader_env_frag_set_ptr(&shaders_ft, 28, &v63.row2);
shader_env_frag_set_ptr(&shaders_ft, 42, &npr_spec_color);
shaders_ft.env_frag_set(26, v63.row0);
shaders_ft.env_frag_set(27, v63.row1);
shaders_ft.env_frag_set(28, v63.row2);
shaders_ft.env_frag_set(42, npr_spec_color);
}
static void light_get_direction_from_position(vec4* pos_dir, light_data* light, bool force) {
@@ -5,11 +5,11 @@
#pragma once
#include "../../KKdLib/default.h"
#include "../../KKdLib/default.hpp"
#include "../../KKdLib/light_param/light.hpp"
#include "../../KKdLib/vec.h"
#include "../../KKdLib/vec.hpp"
#include "../static_var.h"
#include "face.h"
#include "face.hpp"
struct light_data {
light_type type;
@@ -28,6 +28,8 @@ struct light_data {
vec4u ibl_direction;
vec3 tone_curve;
bool clip_plane[4];
light_data();
};
struct light_set {
@@ -36,9 +38,9 @@ struct light_set {
mat4u irradiance_r;
mat4u irradiance_g;
mat4u irradiance_b;
};
extern void light_set_init(light_set* set);
light_set();
};
extern light_type light_get_type(light_data* light);
extern void light_set_type(light_data* light, light_type value);
extern void light_get_ambient(light_data* light, vec4* value);
+3 -3
View File
@@ -5,9 +5,9 @@
#pragma once
#include "../../KKdLib/default.h"
#include "../../KKdLib/default.hpp"
#include "../../KKdLib/light_param/wind.hpp"
#include "../../KKdLib/vec.h"
#include "../../KKdLib/vec.hpp"
#include "../static_var.h"
#include "../task.hpp"
@@ -46,7 +46,7 @@ struct wind {
void reset();
};
class TaskWind : public Task {
class TaskWind : public app::Task {
public:
wind* ptr;
+1 -1
View File
@@ -5,7 +5,7 @@
#pragma once
#include "../KKdLib/default.h"
#include "../KKdLib/default.hpp"
struct lock {
CRITICAL_SECTION cs;
+12 -12
View File
@@ -11,7 +11,7 @@
#include "gl_state.h"
#include "shader_ft.h"
#include "../KKdLib/hash.hpp"
#include "../KKdLib/str_utils.h"
#include "../KKdLib/str_utils.hpp"
struct material_change_handler {
int32_t load_count;
@@ -29,8 +29,8 @@ static void obj_set_handler_calc_axis_aligned_bounding_box(obj_set_handler* hand
static void obj_set_handler_get_shader_index_texture_index(obj_set_handler* handler);
static bool obj_set_handler_index_buffer_load(obj_set_handler* handler);
static void obj_set_handler_index_buffer_free(obj_set_handler* handler);
static bool obj_set_handler_load_textures(obj_set_handler* handler, void* data, bool big_endian);
static bool obj_set_handler_load_textures_modern(obj_set_handler* handler, void* data, size_t size);
static bool obj_set_handler_load_textures(obj_set_handler* handler, const void* data, bool big_endian);
static bool obj_set_handler_load_textures_modern(obj_set_handler* handler, const void* data, size_t size);
static bool obj_set_handler_vertex_buffer_load(obj_set_handler* handler);
static void obj_set_handler_vertex_buffer_free(obj_set_handler* handler);
static void obj_skin_block_constraint_attach_point_load(
@@ -702,7 +702,7 @@ int32_t object_storage_load_set_hash(void* data, uint32_t hash) {
return 1;
std::string file;
if (!((data_struct*)data)->get_file("root+/objset/", hash, ".farc", &file))
if (!((data_struct*)data)->get_file("root+/objset/", hash, ".farc", file))
return 1;
obj_set_handler* handler = object_storage_get_obj_set_handler(hash);
@@ -735,7 +735,7 @@ bool object_storage_load_obj_set_check_not_read(uint32_t set_id,
if (!handler->modern) {
if (!handler->obj_loaded && !handler->obj_file_handler.check_not_ready()) {
void* data = handler->obj_file_handler.get_data();
const void* data = handler->obj_file_handler.get_data();
size_t size = handler->obj_file_handler.get_size();
if (!data || !size)
return false;
@@ -775,7 +775,7 @@ bool object_storage_load_obj_set_check_not_read(uint32_t set_id,
}
}
else if (!handler->obj_loaded && !handler->farc_file_handler.check_not_ready()) {
void* data = handler->farc_file_handler.get_data();
const void* data = handler->farc_file_handler.get_data();
size_t size = handler->farc_file_handler.get_size();
if (!data || !size)
return false;
@@ -1212,7 +1212,7 @@ static void obj_set_handler_get_shader_index_texture_index(obj_set_handler* hand
obj_material* material = &material_data->material;
if (*(int32_t*)&material->shader.name[4] != 0xDEADFF) {
material->shader.index = shader_get_index_by_name(&shaders_ft, material->shader.name);
material->shader.index = shaders_ft.get_index_by_name(material->shader.name);
*(int32_t*)&material->shader.name[4] = 0xDEADFF;
}
@@ -1280,7 +1280,7 @@ static int32_t obj_set_tex_id_data_sort(void const* src1, void const* src2) {
return p1->first - p2->first;
}
static bool obj_set_handler_load_textures(obj_set_handler* handler, void* data, bool big_endian) {
static bool obj_set_handler_load_textures(obj_set_handler* handler, const void* data, bool big_endian) {
obj_set* set = handler->obj_set;
if (!set || !data)
return true;
@@ -1306,7 +1306,7 @@ static bool obj_set_handler_load_textures(obj_set_handler* handler, void* data,
return false;
}
static bool obj_set_handler_load_textures_modern(obj_set_handler* handler, void* data, size_t size) {
static bool obj_set_handler_load_textures_modern(obj_set_handler* handler, const void* data, size_t size) {
obj_set* set = handler->obj_set;
if (!set || !data || !size)
return true;
@@ -1385,19 +1385,19 @@ inline static void obj_skin_block_constraint_up_vector_load(
up_vector->roll = up_vector_file->roll;
up_vector->affected_axis = up_vector_file->affected_axis;
up_vector->point_at = up_vector_file->point_at;
string_copy(&up_vector_file->name, &up_vector->name);
up_vector->name = str_utils_copy(up_vector_file->name);
}
inline static void obj_skin_block_node_load(obj_skin_block_node* node,
obj_skin_block_node* node_file) {
string_copy(&node_file->parent_name, &node->parent_name);
node->parent_name = str_utils_copy(node_file->parent_name);
node->position = node_file->position;
node->rotation = node_file->rotation;
node->scale = node_file->scale;
}
inline static void obj_skin_block_node_free(obj_skin_block_node* node) {
string_free(&node->parent_name);
free(node->parent_name);
}
inline static size_t obj_vertex_format_get_vertex_size(obj_vertex_format format) {
+3 -3
View File
@@ -5,13 +5,13 @@
#pragma once
#include "../KKdLib/default.h"
#include "../KKdLib/default.hpp"
#include "../KKdLib/database/object.hpp"
#include "../KKdLib/database/texture.hpp"
#include "../KKdLib/mat.h"
#include "../KKdLib/mat.hpp"
#include "../KKdLib/obj.hpp"
#include "../KKdLib/txp.hpp"
#include "../KKdLib/vec.h"
#include "../KKdLib/vec.hpp"
#include "file_handler.hpp"
#include "static_var.h"
#include "texture.hpp"
+116 -34
View File
@@ -19,6 +19,27 @@ lens_flare_count(), lens_flare_pos(), lens_shaft_scale(), lens_shaft_inv_scale()
lens_flare_power(), field_A10(), lens_flare_appear_power(), render_width(), render_height(),
view_point(), interest(), view_point_prev(), interest_prev(), reset_exposure(), sprite_width(),
sprite_height(), screen_x_offset(), screen_y_offset(), screen_width(), screen_height(), mag_filter() {
static const char* query_vert_shader =
"#version 430 core\n"
"layout(location = 0) in vec4 a_position;\n"
"\n"
"uniform mat4 mat;\n"
"uniform float scale;\n"
"\n"
"void main() {\n"
" vec4 pos = a_position;\n"
" pos.xy *= scale;\n"
" gl_Position = mat * pos;\n"
"}\n";
static const char* query_frag_shader =
"#version 430 core\n"
"layout(location = 0) out vec4 result;\n"
"\n"
"void main() {\n"
" result = vec4(0.0); \n"
"}\n";
static const char* alpha_layer_vert_shader =
"#version 430 core\n"
"out VertexData {\n"
@@ -52,11 +73,11 @@ sprite_height(), screen_x_offset(), screen_y_offset(), screen_width(), screen_he
" result = mix(cb, cl, g_opacity.x);\n"
"}\n";
aa = post_process_aa_init();
blur = post_process_blur_init();
aa = new post_process_aa();
blur = new post_process_blur();
dof = new post_process_dof();
exposure = post_process_exposure_init();
tone_map = post_process_tone_map_init();
exposure = new post_process_exposure();
tone_map = new post_process_tone_map();
stage_index = -1;
stage_index_prev = -1;
@@ -70,8 +91,34 @@ sprite_height(), screen_x_offset(), screen_y_offset(), screen_width(), screen_he
glSamplerParameteri(samplers[1], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glSamplerParameteri(samplers[1], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
shader_glsl_param param;
memset(&param, 0, sizeof(shader_glsl_param));
const float_t verts_quad[] = {
-1.0f, 1.0f, 0.15f, 0.85f,
-1.0f, -1.0f, 0.15f, 0.15f,
1.0f, -1.0f, 0.85f, 0.15f,
1.0f, 1.0f, 0.85f, 0.85f,
};
glGenVertexArrays(1, &query_vao);
glGenBuffers(1, &query_vbo);
glBindBuffer(GL_ARRAY_BUFFER, query_vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(verts_quad), verts_quad, GL_STATIC_DRAW);
gl_state_bind_vertex_array(query_vao);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 16, (void*)0); // Pos
glVertexAttrib4f(3, 1.0f, 1.0f, 1.0f, 1.0f); // Color0
glVertexAttrib4f(4, 1.0f, 1.0f, 1.0f, 1.0f); // Color1
glEnableVertexAttribArray(8);
glVertexAttribPointer(8, 2, GL_FLOAT, GL_FALSE, 16, (void*)8); // TexCoord0
gl_state_bind_vertex_array(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
shader_glsl_param param = {};
param.name = "Exposure Chara";
query_shader.load(query_vert_shader,
query_frag_shader, 0, &param);
param = {};
param.name = "Alpha Layer";
alpha_layer_shader.load(alpha_layer_vert_shader,
alpha_layer_frag_shader, 0, &param);
@@ -79,16 +126,31 @@ sprite_height(), screen_x_offset(), screen_y_offset(), screen_width(), screen_he
}
post_process::~post_process() {
post_process_aa_dispose(aa);
post_process_blur_dispose(blur);
if (aa) {
delete aa;
aa = 0;
}
if (blur) {
delete blur;
blur = 0;
}
if (dof) {
delete dof;
dof = 0;
}
post_process_exposure_dispose(exposure);
post_process_tone_map_dispose(tone_map);
if (exposure) {
delete exposure;
exposure = 0;
}
if (tone_map) {
delete tone_map;
tone_map = 0;
}
::render_texture_free(&rend_texture);
::render_texture_free(&buf_texture);
::render_texture_free(&sss_contour_texture);
@@ -97,12 +159,24 @@ post_process::~post_process() {
::render_texture_free(&fbo_texture);
::render_texture_free(&alpha_layer_texture);
::render_texture_free(&screen_texture);
alpha_layer_shader.unload();
if (samplers[0]) {
glDeleteSamplers(2, samplers);
samplers[0] = 0;
}
if (query_vao) {
glDeleteVertexArrays(1, &query_vao);
query_vao = 0;
}
if (query_vbo) {
glDeleteBuffers(1, &query_vbo);
query_vbo = 0;
}
query_shader.unload();
alpha_layer_shader.unload();
}
void post_process::apply(camera* cam, texture* light_proj_tex, int32_t npr_param) {
@@ -115,19 +189,17 @@ void post_process::apply(camera* cam, texture* light_proj_tex, int32_t npr_param
dof->apply(&rend_texture, samplers, cam);
shader_state_matrix_set_mvp_separate(&shaders_ft,
&mat4_identity, &mat4_identity, &mat4_identity);
shaders_ft.state_matrix_set_mvp(mat4_identity, mat4_identity, mat4_identity);
post_process_get_blur(blur, &rend_texture);
post_process_get_exposure(exposure, cam, render_width, render_height, reset_exposure,
blur->get_blur(&rend_texture);
exposure->get_exposure(cam, render_width, render_height, reset_exposure,
blur->tex[4].color_texture->tex, blur->tex[2].color_texture->tex);
post_process_apply_tone_map(tone_map, &rend_texture, light_proj_tex, 0,
tone_map->apply(&rend_texture, light_proj_tex, 0,
&rend_texture, &buf_texture, &sss_contour_texture,
blur->tex[0].color_texture->tex,
exposure->exposure.color_texture->tex, npr_param);
if (mlaa)
post_process_apply_mlaa(aa, &rend_texture,
&buf_texture, samplers, parent_bone_node);
aa->apply_mlaa(&rend_texture, &buf_texture, samplers, parent_bone_node);
for (int32_t i = 0; i < 16; i++) {
if (!render_textures_data[i])
@@ -144,7 +216,7 @@ void post_process::apply(camera* cam, texture* light_proj_tex, int32_t npr_param
glViewport(0, 0, t->width, t->height);
gl_state_active_bind_texture_2d(0, rend_texture.color_texture->tex);
gl_state_bind_sampler(0, samplers[0]);
shader_set(&shaders_ft, SHADER_FT_REDUCE);
shaders_ft.set(SHADER_FT_REDUCE);
render_texture_draw_params(&shaders_ft, render_width,
render_height, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
}
@@ -160,7 +232,7 @@ void post_process::apply(camera* cam, texture* light_proj_tex, int32_t npr_param
gl_state_bind_sampler(0, samplers[0]);
uniform_value[U01] = parent_bone_node ? 1 : 0;
uniform_value[U_REDUCE] = 0;
shader_set(&shaders_ft, SHADER_FT_REDUCE);
shaders_ft.set(SHADER_FT_REDUCE);
render_texture_draw_params(&shaders_ft, render_width,
render_height, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
uniform_value[U01] = 0;
@@ -186,11 +258,11 @@ void post_process::apply(camera* cam, texture* light_proj_tex, int32_t npr_param
break;
}
shader_set(&shaders_ft, SHADER_FT_MAGNIFY);
shaders_ft.set(SHADER_FT_MAGNIFY);
render_texture_draw_params(&shaders_ft, render_width,
render_height, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
}
shader_unbind();
shader::unbind();
for (int32_t i = 0; i < 8; i++)
gl_state_bind_sampler(i, 0);
@@ -234,6 +306,16 @@ void post_process::ctrl(camera* cam) {
reset_exposure = true;
}
void post_process::draw_query_samples(GLuint query, float_t scale, mat4& mat) {
glBeginQuery(GL_SAMPLES_PASSED, query);
gl_state_bind_vertex_array(query_vao);
query_shader.set("mat", false, mat);
query_shader.set("scale", scale);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
gl_state_bind_vertex_array(0);
glEndQuery(GL_SAMPLES_PASSED);
}
void post_process::init_fbo(int32_t render_width, int32_t render_height,
int32_t sprite_width, int32_t sprite_height, int32_t screen_width, int32_t screen_height) {
if (this->render_width == render_width && this->render_height == render_height
@@ -241,11 +323,11 @@ void post_process::init_fbo(int32_t render_width, int32_t render_height,
return;
if (this->render_width != render_width || this->render_height != render_height) {
post_process_aa_init_fbo(aa, render_width, render_height);
post_process_blur_init_fbo(blur, render_width, render_height);
aa->init_fbo(render_width, render_height);
blur->init_fbo(render_width, render_height);
dof->init_fbo(render_width, render_height);
post_process_exposure_init_fbo(exposure);
post_process_tone_map_init_fbo(tone_map);
exposure->init_fbo();
tone_map->init_fbo();
render_texture_init(&rend_texture, render_width,
render_height, 0, GL_RGBA16F, GL_DEPTH24_STENCIL8);
render_texture_init(&buf_texture, render_width,
@@ -350,13 +432,13 @@ void post_process::reset() {
mlaa = true;
mag_filter = POST_PROCESS_MAG_FILTER_BILINEAR;
dof->initialize_data(0, 0);
vec3 radius = { 2.0f, 2.0f, 2.0f };
vec3 intensity = { 1.0f, 1.0f, 1.0f };
post_process_blur_initialize_data(blur, &radius, &intensity);
vec3 scene_fade_color = { 1.0f, 1.0f, 1.0f };
vec3 tone_trans_start = { 0.0f, 0.0f, 0.0f };
vec3 tone_trans_end = { 1.0f, 1.0f, 1.0f };
post_process_tone_map_initialize_data(tone_map, 2.0f, true, 1.0f, 1, 1.0f,
&scene_fade_color, 0.0f, 0, &tone_trans_start, &tone_trans_end, TONE_MAP_YCC_EXPONENT);
const vec3 radius = { 2.0f, 2.0f, 2.0f };
const vec3 intensity = { 1.0f, 1.0f, 1.0f };
blur->initialize_data(radius, intensity);
const vec3 scene_fade_color = { 1.0f, 1.0f, 1.0f };
const vec3 tone_trans_start = { 0.0f, 0.0f, 0.0f };
const vec3 tone_trans_end = { 1.0f, 1.0f, 1.0f };
tone_map->initialize_data(2.0f, true, 1.0f, 1, 1.0f, scene_fade_color, 0.0f,
0, tone_trans_start, tone_trans_end, TONE_MAP_YCC_EXPONENT);
reset_exposure = true;
}
+10 -6
View File
@@ -5,13 +5,13 @@
#pragma once
#include "../KKdLib/default.h"
#include "../KKdLib/vec.h"
#include "post_process/aa.h"
#include "post_process/blur.h"
#include "../KKdLib/default.hpp"
#include "../KKdLib/vec.hpp"
#include "post_process/aa.hpp"
#include "post_process/blur.hpp"
#include "post_process/dof.hpp"
#include "post_process/exposure.h"
#include "post_process/tone_map.h"
#include "post_process/exposure.hpp"
#include "post_process/tone_map.hpp"
#include "camera.h"
enum post_process_mag_filter_type {
@@ -46,6 +46,9 @@ struct post_process {
post_process_exposure* exposure;
post_process_tone_map* tone_map;
GLuint samplers[2];
shader_glsl query_shader;
GLuint query_vao;
GLuint query_vbo;
shader_glsl alpha_layer_shader;
GLuint lens_flare_texture;
GLuint lens_shaft_texture;
@@ -79,6 +82,7 @@ struct post_process {
void apply(camera* cam, texture* light_proj_tex, int32_t npr_param);
void ctrl(camera* cam);
void draw_query_samples(GLuint query, float_t scale, mat4& mat);
void init_fbo(int32_t render_width, int32_t render_height,
int32_t sprite_width, int32_t sprite_height, int32_t screen_width, int32_t screen_height);
int32_t movie_texture_set(texture* movie_texture);
@@ -3,52 +3,67 @@
GitHub/GitLab: korenkonder
*/
#include "aa.h"
#include "aa.hpp"
#include "../fbo.hpp"
#include "../gl_state.h"
#include "../post_process.hpp"
#include "../shader_ft.h"
static void post_process_aa_free_fbo(post_process_aa* exp);
static void post_process_aa_generate_area_texture(post_process_aa* aa);
static void post_process_aa_calculate_area_texture_data(uint8_t* a1, int32_t a2, int32_t a3);
static void post_process_aa_calculate_area_texture_data_sub(float_t* a1,
float_t* a2, int32_t a3, int32_t a4, int32_t a5, int32_t a6);
static float_t post_process_aa_calculate_area_texture_data_sub_sub(int32_t a1, int32_t a2);
post_process_aa* post_process_aa_init() {
post_process_aa* aa = force_malloc_s(post_process_aa, 1);
post_process_aa_generate_area_texture(aa);
return aa;
post_process_aa::post_process_aa() : width(), height(), mlaa_area_texture() {
uint8_t pixels[35 * 35 * 2];
for (int32_t i = 0; i < 5; i++)
for (int32_t j = 0; j < 5; j++)
post_process_aa_calculate_area_texture_data(pixels, j, i);
glGenTextures(1, &mlaa_area_texture);
gl_state_bind_texture_2d(mlaa_area_texture);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RG8, 35, 35, 0, GL_RG, GL_UNSIGNED_BYTE, pixels);
gl_state_bind_texture_2d(0);
}
void post_process_apply_mlaa(post_process_aa* aa, render_texture* rt,
post_process_aa::~post_process_aa() {
if (!this)
return;
render_texture_free(&mlaa_buffer[0]);
render_texture_free(&mlaa_buffer[1]);
glDeleteTextures(1, &mlaa_area_texture);
}
void post_process_aa::apply_mlaa(render_texture* rt,
render_texture* buf_rt, GLuint* samplers, int32_t a4) {
render_texture_bind(aa->mlaa_buffer, 0);
render_texture_bind(mlaa_buffer, 0);
gl_state_active_bind_texture_2d(0, rt->color_texture->tex);
gl_state_bind_sampler(0, samplers[1]);
uniform_value[U_MLAA] = 0;
shader_set(&shaders_ft, SHADER_FT_MLAA);
render_texture_draw_params(&shaders_ft, aa->width, aa->height, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
shaders_ft.set(SHADER_FT_MLAA);
render_texture_draw_params(&shaders_ft, width, height, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
render_texture_bind(&aa->mlaa_buffer[1], 0);
gl_state_active_bind_texture_2d(0, aa->mlaa_buffer[0].color_texture->tex);
gl_state_active_bind_texture_2d(1, aa->mlaa_area_texture);
render_texture_bind(&mlaa_buffer[1], 0);
gl_state_active_bind_texture_2d(0, mlaa_buffer[0].color_texture->tex);
gl_state_active_bind_texture_2d(1, mlaa_area_texture);
gl_state_bind_sampler(0, samplers[0]);
gl_state_bind_sampler(1, samplers[1]);
uniform_value[U20] = 2;
uniform_value[U_MLAA] = 1;
shader_set(&shaders_ft, SHADER_FT_MLAA);
render_texture_draw_params(&shaders_ft, aa->width, aa->height, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
shaders_ft.set(SHADER_FT_MLAA);
render_texture_draw_params(&shaders_ft, width, height, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
render_texture_bind(buf_rt, 0);
gl_state_active_bind_texture_2d(0, rt->color_texture->tex);
gl_state_active_bind_texture_2d(1, aa->mlaa_buffer[1].color_texture->tex);
gl_state_active_bind_texture_2d(1, mlaa_buffer[1].color_texture->tex);
gl_state_bind_sampler(0, samplers[1]);
uniform_value[U_MLAA] = 2;
uniform_value[U01] = a4 ? 1 : 0;
shader_set(&shaders_ft, SHADER_FT_MLAA);
render_texture_draw_params(&shaders_ft, aa->width, aa->height, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
shaders_ft.set(SHADER_FT_MLAA);
render_texture_draw_params(&shaders_ft, width, height, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
uniform_value[U01] = 0;
gl_state_active_bind_texture_2d(0, 0);
gl_state_active_bind_texture_2d(1, 0);
@@ -58,43 +73,15 @@ void post_process_apply_mlaa(post_process_aa* aa, render_texture* rt,
0, 0, rt->color_texture->width, rt->color_texture->height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
}
void post_process_aa_init_fbo(post_process_aa* aa,
int32_t width, int32_t height) {
if (!aa || (aa->width == width && aa->height == height))
void post_process_aa::init_fbo(int32_t width, int32_t height) {
if (!this || (this->width == width && this->height == height))
return;
aa->width = width > 1 ? width : 1;
aa->height = height > 1 ? height : 1;
this->width = width > 1 ? width : 1;
this->height = height > 1 ? height : 1;
render_texture_init(&aa->mlaa_buffer[0], aa->width, aa->height, 0, GL_RGBA8, 0);
render_texture_init(&aa->mlaa_buffer[1], aa->width, aa->height, 0, GL_RGBA8, 0);
}
void post_process_aa_dispose(post_process_aa* exp) {
if (!exp)
return;
post_process_aa_free_fbo(exp);
free(exp);
}
static void post_process_aa_free_fbo(post_process_aa* aa) {
render_texture_free(&aa->mlaa_buffer[0]);
render_texture_free(&aa->mlaa_buffer[1]);
glDeleteTextures(1, &aa->mlaa_area_texture);
}
static void post_process_aa_generate_area_texture(post_process_aa* aa) {
uint8_t pixels[35 * 35 * 2];
for (int32_t i = 0; i < 5; i++)
for (int32_t j = 0; j < 5; j++)
post_process_aa_calculate_area_texture_data(pixels, j, i);
glGenTextures(1, &aa->mlaa_area_texture);
gl_state_bind_texture_2d(aa->mlaa_area_texture);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RG8, 35, 35, 0, GL_RG, GL_UNSIGNED_BYTE, pixels);
gl_state_bind_texture_2d(0);
render_texture_init(&mlaa_buffer[0], this->width, this->height, 0, GL_RGBA8, 0);
render_texture_init(&mlaa_buffer[1], this->width, this->height, 0, GL_RGBA8, 0);
}
static void post_process_aa_calculate_area_texture_data(uint8_t* a1, int32_t a2, int32_t a3) {
-24
View File
@@ -1,24 +0,0 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#pragma once
#include "../../KKdLib/default.h"
#include "../../KKdLib/vec.h"
#include "../shared.h"
#include "../render_texture.h"
struct post_process_aa {
int32_t width;
int32_t height;
render_texture mlaa_buffer[2];
GLuint mlaa_area_texture;
};
extern post_process_aa* post_process_aa_init();
extern void post_process_apply_mlaa(post_process_aa* aa, render_texture* rt,
render_texture* buf_rt, GLuint* samplers, int32_t a4);
extern void post_process_aa_init_fbo(post_process_aa* aa, int32_t width, int32_t height);
extern void post_process_aa_dispose(post_process_aa* aa);
+25
View File
@@ -0,0 +1,25 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#pragma once
#include "../../KKdLib/default.hpp"
#include "../../KKdLib/vec.hpp"
#include "../shared.h"
#include "../render_texture.h"
struct post_process_aa {
int32_t width;
int32_t height;
render_texture mlaa_buffer[2];
GLuint mlaa_area_texture;
post_process_aa();
virtual ~post_process_aa();
void apply_mlaa(render_texture* rt,
render_texture* buf_rt, GLuint* samplers, int32_t a4);
void init_fbo(int32_t width, int32_t height);
};
-337
View File
@@ -1,337 +0,0 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#include "blur.h"
#include "../fbo.hpp"
#include "../gl_state.h"
#include "../post_process.hpp"
#include "../shader_ft.h"
static void post_process_blur_free_fbo(post_process_blur* blur);
static void post_process_blur_radius_calculate(post_process_blur* blur);
static void post_process_blur_radius_calculate_gaussian_kernel(float_t* gaussian_kernel,
float_t radius, int32_t stride, int32_t offset);
post_process_blur* post_process_blur_init() {
post_process_blur* blur = force_malloc_s(post_process_blur, 1);
return blur;
}
void post_process_get_blur(post_process_blur* blur, render_texture* rt) {
if (!blur)
return;
uniform_value[U01] = 0;
int32_t i = 0;
if (blur->count_down > 0) {
uniform_value[U_REDUCE] = 1;
render_texture_shader_set(&shaders_ft, SHADER_FT_REDUCE);
for (; i < blur->count_down; i++) {
glViewport(0, 0, blur->width_down[i], blur->height_down[i]);
render_texture_bind(&blur->tex_down[i], 0);
gl_state_active_bind_texture_2d(0, i
? blur->tex_down[i - 1].color_texture->tex
: rt->color_texture->tex);
render_texture_draw_params(&shaders_ft,
blur->width_down[i], blur->height_down[i], 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
}
i--;
}
uniform_value[U_REDUCE] = 3;
render_texture_shader_set(&shaders_ft, SHADER_FT_REDUCE);
shader_local_frag_set(&shaders_ft, 2, 1.1f, 1.1f, 1.1f, 0.0f);
glViewport(0, 0, 256, 144);
render_texture_bind(&blur->tex[0], 0);
gl_state_active_bind_texture_2d(0, blur->count_down > 0
? blur->tex_down[i].color_texture->tex
: rt->color_texture->tex);
render_texture_draw_params(&shaders_ft, blur->width, blur->height, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
uniform_value[U_GAUSS] = 1;
render_texture_shader_set(&shaders_ft, SHADER_FT_GAUSS);
glViewport(0, 0, 256, 144);
render_texture_bind(&blur->tex[5], 0);
gl_state_active_bind_texture_2d(0, blur->tex[0].color_texture->tex);
render_texture_draw_params(&shaders_ft, 256, 144,
1.0f, blur->data.intensity.x * 0.5f, blur->data.intensity.y * 0.5f, blur->data.intensity.z * 0.5f, 1.0f);
uniform_value[U_REDUCE] = 1;
render_texture_shader_set(&shaders_ft, SHADER_FT_REDUCE);
glViewport(0, 0, 128, 72);
render_texture_bind(&blur->tex[1], 0);
gl_state_active_bind_texture_2d(0, blur->tex[0].color_texture->tex);
render_texture_draw_params(&shaders_ft, 256, 144, 0.75f, 1.0f, 1.0f, 1.0f, 1.0f);
uniform_value[U_REDUCE] = 1;
render_texture_shader_set(&shaders_ft, SHADER_FT_REDUCE);
glViewport(0, 0, 64, 36);
render_texture_bind(&blur->tex[2], 0);
gl_state_active_bind_texture_2d(0, blur->tex[1].color_texture->tex);
render_texture_draw_params(&shaders_ft, 128, 72, 0.75f, 1.0f, 1.0f, 1.0f, 1.0f);
uniform_value[U_REDUCE] = 1;
render_texture_shader_set(&shaders_ft, SHADER_FT_REDUCE);
glViewport(0, 0, 32, 18);
render_texture_bind(&blur->tex[3], 0);
gl_state_active_bind_texture_2d(0, blur->tex[2].color_texture->tex);
render_texture_draw_params(&shaders_ft, 64, 36, 0.75f, 1.0f, 1.0f, 1.0f, 1.0f);
uniform_value[U_EXPOSURE] = 0;
render_texture_shader_set(&shaders_ft, SHADER_FT_EXPOSURE);
glViewport(0, 0, 8, 8);
render_texture_bind(&blur->tex[4], 0);
gl_state_active_bind_texture_2d(0, blur->tex[3].color_texture->tex);
render_texture_draw_params(&shaders_ft, 32, 18, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
vec3 intensity = blur->data.intensity;
vec3* gauss = blur->data.gauss;
vec3 v[POST_PROCESS_BLUR_GAUSSIAN_KERNEL_SIZE];
for (int32_t i = 0; i < POST_PROCESS_BLUR_GAUSSIAN_KERNEL_SIZE; i++)
vec3_mult(gauss[i], intensity, v[i]);
uniform_value[U_GAUSS] = 0;
render_texture_shader_set(&shaders_ft, SHADER_FT_GAUSS);
shader_local_frag_set(&shaders_ft, 1, 1.0f, 0.0f, 1.0f, 0.0f);
for (int32_t i = 0; i < POST_PROCESS_BLUR_GAUSSIAN_KERNEL_SIZE; i++)
shader_local_frag_set(&shaders_ft, 4ULL + i, v[i].x, v[i].y, v[i].z, 0.0f);
glViewport(0, 0, 128, 72);
render_texture_bind(&blur->tex[0], 0);
gl_state_active_bind_texture_2d(0, blur->tex[1].color_texture->tex);
render_texture_draw_params(&shaders_ft, 128, 72, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
fbo::blit(blur->tex[0].fbos[0], blur->tex[1].fbos[0],
0, 0, 128, 72,
0, 0, 128, 72, GL_COLOR_BUFFER_BIT, GL_LINEAR);
glViewport(0, 0, 64, 36);
render_texture_bind(&blur->tex[0], 0);
gl_state_active_bind_texture_2d(0, blur->tex[2].color_texture->tex);
render_texture_draw_params(&shaders_ft, 64, 36, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
fbo::blit(blur->tex[0].fbos[0], blur->tex[2].fbos[0],
0, 0, 64, 36,
0, 0, 64, 36, GL_COLOR_BUFFER_BIT, GL_LINEAR);
glViewport(0, 0, 32, 18);
render_texture_bind(&blur->tex[0], 0);
gl_state_active_bind_texture_2d(0, blur->tex[3].color_texture->tex);
render_texture_draw_params(&shaders_ft, 32, 18, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
fbo::blit(blur->tex[0].fbos[0], blur->tex[3].fbos[0],
0, 0, 32, 18,
0, 0, 32, 18, GL_COLOR_BUFFER_BIT, GL_LINEAR);
shader_local_frag_set(&shaders_ft, 1, 0.0f, 1.0f, 0.0f, 1.0f);
glViewport(0, 0, 128, 72);
render_texture_bind(&blur->tex[0], 0);
gl_state_active_bind_texture_2d(0, blur->tex[1].color_texture->tex);
render_texture_draw_params(&shaders_ft, 128, 72, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
fbo::blit(blur->tex[0].fbos[0], blur->tex[1].fbos[0],
0, 0, 128, 72,
0, 0, 128, 72, GL_COLOR_BUFFER_BIT, GL_LINEAR);
glViewport(0, 0, 64, 36);
render_texture_bind(&blur->tex[0], 0);
gl_state_active_bind_texture_2d(0, blur->tex[2].color_texture->tex);
render_texture_draw_params(&shaders_ft, 64, 36, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
fbo::blit(blur->tex[0].fbos[0], blur->tex[2].fbos[0],
0, 0, 64, 36,
0, 0, 64, 36, GL_COLOR_BUFFER_BIT, GL_LINEAR);
glViewport(0, 0, 32, 18);
render_texture_bind(&blur->tex[0], 0);
gl_state_active_bind_texture_2d(0, blur->tex[3].color_texture->tex);
render_texture_draw_params(&shaders_ft, 32, 18, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
fbo::blit(blur->tex[0].fbos[0], blur->tex[3].fbos[0],
0, 0, 32, 18,
0, 0, 32, 18, GL_COLOR_BUFFER_BIT, GL_LINEAR);
uniform_value[U_REDUCE] = 7;
render_texture_shader_set(&shaders_ft, SHADER_FT_REDUCE);
glViewport(0, 0, 256, 144);
render_texture_bind(&blur->tex[0], 0);
gl_state_active_bind_texture_2d(0, blur->tex[5].color_texture->tex);
gl_state_active_bind_texture_2d(1, blur->tex[1].color_texture->tex);
gl_state_active_bind_texture_2d(2, blur->tex[2].color_texture->tex);
gl_state_active_bind_texture_2d(3, blur->tex[3].color_texture->tex);
render_texture_draw_params(&shaders_ft, 32, 18, 0.25f, 0.15f, 0.25f, 0.25f, 0.25f);
}
void post_process_blur_init_fbo(post_process_blur* blur,
int32_t width, int32_t height) {
if (!blur || (blur->width == width && blur->height == height))
return;
if (!blur->tex[0].color_texture)
render_texture_init(&blur->tex[0], 256, 144, 0, GL_RGBA16F, 0);
if (!blur->tex[1].color_texture)
render_texture_init(&blur->tex[1], 128, 72, 0, GL_RGBA16F, 0);
if (!blur->tex[2].color_texture)
render_texture_init(&blur->tex[2], 64, 36, 0, GL_RGBA16F, 0);
if (!blur->tex[3].color_texture)
render_texture_init(&blur->tex[3], 32, 18, 0, GL_RGBA16F, 0);
if (!blur->tex[4].color_texture)
render_texture_init(&blur->tex[4], 8, 8, 0, GL_R32F, 0);
if (!blur->tex[5].color_texture)
render_texture_init(&blur->tex[5], 256, 144, 0, GL_RGBA16F, 0);
blur->width = width > 1 ? width : 1;
blur->height = height > 1 ? height : 1;
int32_t i = 0;
width = blur->width;
height = blur->height;
while (width > 512 && height > 288) {
width /= 2;
height /= 2;
i++;
}
render_texture* tex_down = blur->tex_down;
int32_t* width_down = blur->width_down;
int32_t* height_down = blur->height_down;
if (!tex_down)
tex_down = force_malloc_s(render_texture, i);
else if (blur->count_down < i) {
render_texture* temp = force_malloc_s(render_texture, i);
memcpy(temp, tex_down, sizeof(render_texture) * blur->count_down);
free(tex_down);
tex_down = temp;
}
if (!width_down)
width_down = force_malloc_s(int32_t, i);
else if (blur->count_down < i) {
int32_t* temp = force_malloc_s(int32_t, i);
memcpy(temp, width_down, sizeof(int32_t) * blur->count_down);
free(width_down);
width_down = temp;
}
if (!height_down)
height_down = force_malloc_s(int32_t, i);
else if (blur->count_down < i) {
int32_t* temp = force_malloc_s(int32_t, i);
memcpy(temp, height_down, sizeof(int32_t) * blur->count_down);
free(height_down);
height_down = temp;
}
blur->count_down = i;
i = 0;
width = blur->width;
height = blur->height;
while (width > 512 && height > 288) {
width_down[i] = width /= 2;
height_down[i] = height /= 2;
i++;
}
for (i = 0; i < blur->count_down; i++)
render_texture_init(&tex_down[i], width_down[i], height_down[i], 0, GL_RGBA16F, 0);
gl_state_bind_framebuffer(0);
blur->tex_down = tex_down;
blur->width_down = width_down;
blur->height_down = height_down;
}
void post_process_blur_dispose(post_process_blur* blur) {
if (!blur)
return;
post_process_blur_free_fbo(blur);
free(blur);
}
static void post_process_blur_free_fbo(post_process_blur* blur) {
for (int32_t i = 0; i < blur->count_down; i++)
render_texture_free(&blur->tex_down[i]);
for (int32_t i = 0; i < 6; i++)
render_texture_free(&blur->tex[i]);
free(blur->tex_down);
free(blur->height_down);
free(blur->width_down);
}
void post_process_blur_initialize_data(post_process_blur* blur, const vec3* radius, const vec3* intensity) {
blur->data.radius.x = clamp(radius->x, 0.0f, 3.0f);
blur->data.radius.y = clamp(radius->y, 0.0f, 3.0f);
blur->data.radius.z = clamp(radius->z, 0.0f, 3.0f);
blur->data.intensity.x = clamp(intensity->x, 0.0f, 2.0f);
blur->data.intensity.y = clamp(intensity->y, 0.0f, 2.0f);
blur->data.intensity.z = clamp(intensity->z, 0.0f, 2.0f);
post_process_blur_radius_calculate(blur);
}
inline void post_process_blur_get_radius(post_process_blur* blur, vec3* value) {
*value = blur->data.radius;
}
inline void post_process_blur_set_radius(post_process_blur* blur, const vec3* value) {
vec3 temp;
temp.x = clamp(value->x, 0.0f, 3.0f);
temp.y = clamp(value->y, 0.0f, 3.0f);
temp.z = clamp(value->z, 0.0f, 3.0f);
if (temp.x != blur->data.radius.x || temp.y
!= blur->data.radius.y || temp.z != blur->data.radius.z) {
blur->data.radius = temp;
post_process_blur_radius_calculate(blur);
}
}
inline void post_process_blur_get_intensity(post_process_blur* blur, vec3* value) {
*value = blur->data.intensity;
}
inline void post_process_blur_set_intensity(post_process_blur* blur, const vec3* value) {
blur->data.intensity.x = clamp(value->x, 0.0f, 2.0f);
blur->data.intensity.y = clamp(value->y, 0.0f, 2.0f);
blur->data.intensity.z = clamp(value->z, 0.0f, 2.0f);
}
static void post_process_blur_radius_calculate(post_process_blur* blur) {
float_t radius_scale = 0.8f;
vec3 radius = blur->data.radius;
post_process_blur_radius_calculate_gaussian_kernel((float_t*)blur->data.gauss, radius.x * radius_scale, 3, 0);
post_process_blur_radius_calculate_gaussian_kernel((float_t*)blur->data.gauss, radius.y * radius_scale, 3, 1);
post_process_blur_radius_calculate_gaussian_kernel((float_t*)blur->data.gauss, radius.z * radius_scale, 3, 2);
}
static void post_process_blur_radius_calculate_gaussian_kernel(float_t* gaussian_kernel,
float_t radius, int32_t stride, int32_t offset) {
if (stride < 1)
stride = 1;
if (offset < 0)
offset = 0;
gaussian_kernel[0 * stride + offset] = 1.0f;
for (int32_t i = 1; i < POST_PROCESS_BLUR_GAUSSIAN_KERNEL_SIZE; i++)
gaussian_kernel[i * stride + offset] = 0.0f;
double_t temp_gaussian_kernel[POST_PROCESS_BLUR_GAUSSIAN_KERNEL_SIZE];
double_t s = radius;
s = -1.0 / (2.0 * s * s);
double_t sum = 0.5;
temp_gaussian_kernel[0] = 1.0;
for (size_t i = 1; i < POST_PROCESS_BLUR_GAUSSIAN_KERNEL_SIZE; i++)
sum += temp_gaussian_kernel[i] = exp(i * i * s);
sum = 0.5 / sum;
for (size_t i = 0; i < POST_PROCESS_BLUR_GAUSSIAN_KERNEL_SIZE; i++)
gaussian_kernel[i * stride + offset] = (float_t)(temp_gaussian_kernel[i] * sum);
}
+325
View File
@@ -0,0 +1,325 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#include "blur.hpp"
#include "../fbo.hpp"
#include "../gl_state.h"
#include "../post_process.hpp"
#include "../shader_ft.h"
static void post_process_blur_radius_calculate(post_process_blur* blur);
static void post_process_blur_radius_calculate_gaussian_kernel(float_t* gaussian_kernel,
float_t radius, int32_t stride, int32_t offset);
post_process_blur::post_process_blur() : data(),
width(), height(), width_down(), height_down(), tex_down(), count_down() {
}
post_process_blur:: ~post_process_blur() {
if (!this)
return;
for (int32_t i = 0; i < count_down; i++)
render_texture_free(&tex_down[i]);
for (int32_t i = 0; i < 6; i++)
render_texture_free(&tex[i]);
free(tex_down);
free(height_down);
free(width_down);
}
void post_process_blur::get_blur(render_texture* rt) {
uniform_value[U01] = 0;
int32_t i = 0;
if (count_down > 0) {
uniform_value[U_REDUCE] = 1;
render_texture_shader_set(&shaders_ft, SHADER_FT_REDUCE);
for (; i < count_down; i++) {
glViewport(0, 0, width_down[i], height_down[i]);
render_texture_bind(&tex_down[i], 0);
gl_state_active_bind_texture_2d(0, i
? tex_down[i - 1].color_texture->tex
: rt->color_texture->tex);
render_texture_draw_params(&shaders_ft,
width_down[i], height_down[i], 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
}
i--;
}
uniform_value[U_REDUCE] = 3;
render_texture_shader_set(&shaders_ft, SHADER_FT_REDUCE);
shaders_ft.local_frag_set(2, 1.1f, 1.1f, 1.1f, 0.0f);
glViewport(0, 0, 256, 144);
render_texture_bind(&tex[0], 0);
gl_state_active_bind_texture_2d(0, count_down > 0
? tex_down[i].color_texture->tex
: rt->color_texture->tex);
render_texture_draw_params(&shaders_ft, width, height, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
uniform_value[U_GAUSS] = 1;
render_texture_shader_set(&shaders_ft, SHADER_FT_GAUSS);
glViewport(0, 0, 256, 144);
render_texture_bind(&tex[5], 0);
gl_state_active_bind_texture_2d(0, tex[0].color_texture->tex);
render_texture_draw_params(&shaders_ft, 256, 144,
1.0f, data.intensity.x * 0.5f, data.intensity.y * 0.5f, data.intensity.z * 0.5f, 1.0f);
uniform_value[U_REDUCE] = 1;
render_texture_shader_set(&shaders_ft, SHADER_FT_REDUCE);
glViewport(0, 0, 128, 72);
render_texture_bind(&tex[1], 0);
gl_state_active_bind_texture_2d(0, tex[0].color_texture->tex);
render_texture_draw_params(&shaders_ft, 256, 144, 0.75f, 1.0f, 1.0f, 1.0f, 1.0f);
uniform_value[U_REDUCE] = 1;
render_texture_shader_set(&shaders_ft, SHADER_FT_REDUCE);
glViewport(0, 0, 64, 36);
render_texture_bind(&tex[2], 0);
gl_state_active_bind_texture_2d(0, tex[1].color_texture->tex);
render_texture_draw_params(&shaders_ft, 128, 72, 0.75f, 1.0f, 1.0f, 1.0f, 1.0f);
uniform_value[U_REDUCE] = 1;
render_texture_shader_set(&shaders_ft, SHADER_FT_REDUCE);
glViewport(0, 0, 32, 18);
render_texture_bind(&tex[3], 0);
gl_state_active_bind_texture_2d(0, tex[2].color_texture->tex);
render_texture_draw_params(&shaders_ft, 64, 36, 0.75f, 1.0f, 1.0f, 1.0f, 1.0f);
uniform_value[U_EXPOSURE] = 0;
render_texture_shader_set(&shaders_ft, SHADER_FT_EXPOSURE);
glViewport(0, 0, 8, 8);
render_texture_bind(&tex[4], 0);
gl_state_active_bind_texture_2d(0, tex[3].color_texture->tex);
render_texture_draw_params(&shaders_ft, 32, 18, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
vec3 intensity = data.intensity;
vec3* gauss = data.gauss;
vec3 v[POST_PROCESS_BLUR_GAUSSIAN_KERNEL_SIZE];
for (int32_t i = 0; i < POST_PROCESS_BLUR_GAUSSIAN_KERNEL_SIZE; i++)
vec3_mult(gauss[i], intensity, v[i]);
uniform_value[U_GAUSS] = 0;
render_texture_shader_set(&shaders_ft, SHADER_FT_GAUSS);
shaders_ft.local_frag_set(1, 1.0f, 0.0f, 1.0f, 0.0f);
for (int32_t i = 0; i < POST_PROCESS_BLUR_GAUSSIAN_KERNEL_SIZE; i++)
shaders_ft.local_frag_set(4ULL + i, v[i].x, v[i].y, v[i].z, 0.0f);
glViewport(0, 0, 128, 72);
render_texture_bind(&tex[0], 0);
gl_state_active_bind_texture_2d(0, tex[1].color_texture->tex);
render_texture_draw_params(&shaders_ft, 128, 72, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
fbo::blit(tex[0].fbos[0], tex[1].fbos[0],
0, 0, 128, 72,
0, 0, 128, 72, GL_COLOR_BUFFER_BIT, GL_LINEAR);
glViewport(0, 0, 64, 36);
render_texture_bind(&tex[0], 0);
gl_state_active_bind_texture_2d(0, tex[2].color_texture->tex);
render_texture_draw_params(&shaders_ft, 64, 36, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
fbo::blit(tex[0].fbos[0], tex[2].fbos[0],
0, 0, 64, 36,
0, 0, 64, 36, GL_COLOR_BUFFER_BIT, GL_LINEAR);
glViewport(0, 0, 32, 18);
render_texture_bind(&tex[0], 0);
gl_state_active_bind_texture_2d(0, tex[3].color_texture->tex);
render_texture_draw_params(&shaders_ft, 32, 18, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
fbo::blit(tex[0].fbos[0], tex[3].fbos[0],
0, 0, 32, 18,
0, 0, 32, 18, GL_COLOR_BUFFER_BIT, GL_LINEAR);
shaders_ft.local_frag_set(1, 0.0f, 1.0f, 0.0f, 1.0f);
glViewport(0, 0, 128, 72);
render_texture_bind(&tex[0], 0);
gl_state_active_bind_texture_2d(0, tex[1].color_texture->tex);
render_texture_draw_params(&shaders_ft, 128, 72, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
fbo::blit(tex[0].fbos[0], tex[1].fbos[0],
0, 0, 128, 72,
0, 0, 128, 72, GL_COLOR_BUFFER_BIT, GL_LINEAR);
glViewport(0, 0, 64, 36);
render_texture_bind(&tex[0], 0);
gl_state_active_bind_texture_2d(0, tex[2].color_texture->tex);
render_texture_draw_params(&shaders_ft, 64, 36, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
fbo::blit(tex[0].fbos[0], tex[2].fbos[0],
0, 0, 64, 36,
0, 0, 64, 36, GL_COLOR_BUFFER_BIT, GL_LINEAR);
glViewport(0, 0, 32, 18);
render_texture_bind(&tex[0], 0);
gl_state_active_bind_texture_2d(0, tex[3].color_texture->tex);
render_texture_draw_params(&shaders_ft, 32, 18, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
fbo::blit(tex[0].fbos[0], tex[3].fbos[0],
0, 0, 32, 18,
0, 0, 32, 18, GL_COLOR_BUFFER_BIT, GL_LINEAR);
uniform_value[U_REDUCE] = 7;
render_texture_shader_set(&shaders_ft, SHADER_FT_REDUCE);
glViewport(0, 0, 256, 144);
render_texture_bind(&tex[0], 0);
gl_state_active_bind_texture_2d(0, tex[5].color_texture->tex);
gl_state_active_bind_texture_2d(1, tex[1].color_texture->tex);
gl_state_active_bind_texture_2d(2, tex[2].color_texture->tex);
gl_state_active_bind_texture_2d(3, tex[3].color_texture->tex);
render_texture_draw_params(&shaders_ft, 32, 18, 0.25f, 0.15f, 0.25f, 0.25f, 0.25f);
}
void post_process_blur::init_fbo(int32_t width, int32_t height) {
if (!this || (this->width == width && this->height == height))
return;
if (!tex[0].color_texture)
render_texture_init(&tex[0], 256, 144, 0, GL_RGBA16F, 0);
if (!tex[1].color_texture)
render_texture_init(&tex[1], 128, 72, 0, GL_RGBA16F, 0);
if (!tex[2].color_texture)
render_texture_init(&tex[2], 64, 36, 0, GL_RGBA16F, 0);
if (!tex[3].color_texture)
render_texture_init(&tex[3], 32, 18, 0, GL_RGBA16F, 0);
if (!tex[4].color_texture)
render_texture_init(&tex[4], 8, 8, 0, GL_R32F, 0);
if (!tex[5].color_texture)
render_texture_init(&tex[5], 256, 144, 0, GL_RGBA16F, 0);
this->width = width > 1 ? width : 1;
this->height = height > 1 ? height : 1;
int32_t i = 0;
width = this->width;
height = this->height;
while (width > 512 && height > 288) {
width /= 2;
height /= 2;
i++;
}
render_texture* tex_down = this->tex_down;
int32_t* width_down = this->width_down;
int32_t* height_down = this->height_down;
if (!tex_down)
tex_down = force_malloc_s(render_texture, i);
else if (count_down < i) {
render_texture* temp = force_malloc_s(render_texture, i);
memcpy(temp, tex_down, sizeof(render_texture) * count_down);
free(tex_down);
tex_down = temp;
}
if (!width_down)
width_down = force_malloc_s(int32_t, i);
else if (count_down < i) {
int32_t* temp = force_malloc_s(int32_t, i);
memcpy(temp, width_down, sizeof(int32_t) * count_down);
free(width_down);
width_down = temp;
}
if (!height_down)
height_down = force_malloc_s(int32_t, i);
else if (count_down < i) {
int32_t* temp = force_malloc_s(int32_t, i);
memcpy(temp, height_down, sizeof(int32_t) * count_down);
free(height_down);
height_down = temp;
}
count_down = i;
i = 0;
width = this->width;
height = this->height;
while (width > 512 && height > 288) {
width_down[i] = width /= 2;
height_down[i] = height /= 2;
i++;
}
for (i = 0; i < count_down; i++)
render_texture_init(&tex_down[i], width_down[i], height_down[i], 0, GL_RGBA16F, 0);
gl_state_bind_framebuffer(0);
this->tex_down = tex_down;
this->width_down = width_down;
this->height_down = height_down;
}
void post_process_blur::initialize_data(const vec3& radius, const vec3& intensity) {
data.radius.x = clamp(radius.x, 1.0f, 3.0f);
data.radius.y = clamp(radius.y, 1.0f, 3.0f);
data.radius.z = clamp(radius.z, 1.0f, 3.0f);
data.intensity.x = clamp(intensity.x, 0.0f, 2.0f);
data.intensity.y = clamp(intensity.y, 0.0f, 2.0f);
data.intensity.z = clamp(intensity.z, 0.0f, 2.0f);
post_process_blur_radius_calculate(this);
}
vec3 post_process_blur::get_intensity() {
return data.intensity;
}
void post_process_blur::set_intensity(const vec3& value) {
data.intensity.x = clamp(value.x, 0.0f, 2.0f);
data.intensity.y = clamp(value.y, 0.0f, 2.0f);
data.intensity.z = clamp(value.z, 0.0f, 2.0f);
}
vec3 post_process_blur::get_radius() {
return data.radius;
}
void post_process_blur::set_radius(const vec3& value) {
vec3 temp;
temp.x = clamp(value.x, 1.0f, 3.0f);
temp.y = clamp(value.y, 1.0f, 3.0f);
temp.z = clamp(value.z, 1.0f, 3.0f);
if (memcmp(&temp, &data.radius, sizeof(vec3))) {
data.radius = temp;
post_process_blur_radius_calculate(this);
}
}
static void post_process_blur_radius_calculate(post_process_blur* blur) {
float_t radius_scale = 0.8f;
vec3 radius = blur->data.radius;
post_process_blur_radius_calculate_gaussian_kernel((float_t*)blur->data.gauss, radius.x * radius_scale, 3, 0);
post_process_blur_radius_calculate_gaussian_kernel((float_t*)blur->data.gauss, radius.y * radius_scale, 3, 1);
post_process_blur_radius_calculate_gaussian_kernel((float_t*)blur->data.gauss, radius.z * radius_scale, 3, 2);
}
static void post_process_blur_radius_calculate_gaussian_kernel(float_t* gaussian_kernel,
float_t radius, int32_t stride, int32_t offset) {
if (stride < 1)
stride = 1;
if (offset < 0)
offset = 0;
gaussian_kernel[0 * stride + offset] = 1.0f;
for (int32_t i = 1; i < POST_PROCESS_BLUR_GAUSSIAN_KERNEL_SIZE; i++)
gaussian_kernel[i * stride + offset] = 0.0f;
double_t temp_gaussian_kernel[POST_PROCESS_BLUR_GAUSSIAN_KERNEL_SIZE];
double_t s = radius;
s = -1.0 / (2.0 * s * s);
double_t sum = 0.5;
temp_gaussian_kernel[0] = 1.0;
for (size_t i = 1; i < POST_PROCESS_BLUR_GAUSSIAN_KERNEL_SIZE; i++)
sum += temp_gaussian_kernel[i] = exp(i * i * s);
sum = 0.5 / sum;
for (size_t i = 0; i < POST_PROCESS_BLUR_GAUSSIAN_KERNEL_SIZE; i++)
gaussian_kernel[i * stride + offset] = (float_t)(temp_gaussian_kernel[i] * sum);
}
-42
View File
@@ -1,42 +0,0 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#pragma once
#include "../../KKdLib/default.h"
#include "../../KKdLib/vec.h"
#include "../shared.h"
#include "../render_texture.h"
#define POST_PROCESS_BLUR_GAUSSIAN_KERNEL_SIZE 7
struct post_process_blur_data {
vec3 gauss[POST_PROCESS_BLUR_GAUSSIAN_KERNEL_SIZE];
vec3 radius;
vec3 intensity;
};
struct post_process_blur {
post_process_blur_data data;
int32_t width;
int32_t height;
render_texture tex[6];
int32_t* width_down;
int32_t* height_down;
render_texture* tex_down;
int32_t count_down;
};
extern post_process_blur* post_process_blur_init();
extern void post_process_get_blur(post_process_blur* blur, render_texture* rt);
extern void post_process_blur_init_fbo(post_process_blur* blur,
int32_t width, int32_t height);
extern void post_process_blur_dispose(post_process_blur* blur);
extern void post_process_blur_initialize_data(post_process_blur* blur, const vec3* radius, const vec3* intensity);
extern void post_process_blur_get_radius(post_process_blur* blur, vec3* value);
extern void post_process_blur_set_radius(post_process_blur* blur, const vec3* value);
extern void post_process_blur_get_intensity(post_process_blur* blur, vec3* value);
extern void post_process_blur_set_intensity(post_process_blur* blur, const vec3* value);
+42
View File
@@ -0,0 +1,42 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#pragma once
#include "../../KKdLib/default.hpp"
#include "../../KKdLib/vec.hpp"
#include "../shared.h"
#include "../render_texture.h"
#define POST_PROCESS_BLUR_GAUSSIAN_KERNEL_SIZE 7
struct post_process_blur_data {
vec3 gauss[POST_PROCESS_BLUR_GAUSSIAN_KERNEL_SIZE];
vec3 radius;
vec3 intensity;
};
struct post_process_blur {
post_process_blur_data data;
int32_t width;
int32_t height;
render_texture tex[6];
int32_t* width_down;
int32_t* height_down;
render_texture* tex_down;
int32_t count_down;
post_process_blur();
virtual ~post_process_blur();
void get_blur(render_texture* rt);
void init_fbo(int32_t width, int32_t height);
void initialize_data(const vec3& radius, const vec3& intensity);
vec3 get_intensity();
void set_intensity(const vec3& value);
vec3 get_radius();
void set_radius(const vec3& value);
};
+195 -186
View File
@@ -4,7 +4,7 @@
*/
#include "dof.hpp"
#include "../../KKdLib/str_utils.h"
#include "../../KKdLib/str_utils.hpp"
#include "../gl_state.h"
#include "../rob.hpp"
@@ -30,7 +30,7 @@ static const char* dof_vert_shader =
static const char* dof_frag_shader_version = "#version 430 core\n";
static const char* dof_frag_shader_step_2 =
static const char* dof_frag_shader_render_tiles_part_2 =
"#version 430 core\n"
"layout(binding = 0) uniform sampler2D g_tile; //r=min_depth_m, g=max_coc_pixel\n"
"\n"
@@ -150,7 +150,7 @@ static const char* dof_frag_shader_shared =
"}\n"
"\n";
static const char* dof_frag_shader_step_1 =
static const char* dof_frag_shader_render_tiles_part_1 =
"layout(binding = 0) uniform sampler2D g_depth;\n"
"\n"
"layout(location = 0) out vec4 result; //r=min_depth_m, g=max_coc_pixel\n"
@@ -240,7 +240,7 @@ static const char* dof_frag_shader_step_1 =
"}\n"
"#endif\n";
static const char* dof_frag_shader_step_3 =
static const char* dof_frag_shader_downsample =
"layout(binding = 0) uniform sampler2D g_depth_point_sampler;\n"
"layout(binding = 1) uniform sampler2D g_color_linear_sampler;\n"
"layout(binding = 2) uniform sampler2D g_tile_sampler;\n"
@@ -400,7 +400,7 @@ static const char* dof_frag_shader_step_3 =
" result_presort = presort(coc_center_pixel, depth_center);\n"
"}\n";
static const char* dof_frag_shader_step_4 =
static const char* dof_frag_shader_apply_main_filter =
"layout(binding = 0) uniform sampler2D g_presort; //r=coc[sample],"
" g=background_weight(=depth_cmp*sample_alpha), b=foreground_weight(=depth_cmp*sample_alpha)\n"
"layout(binding = 1) uniform sampler2D g_color;\n"
@@ -465,7 +465,7 @@ static const char* dof_frag_shader_step_4 =
" result_alpha = alpha;\n"
"}\n";
static const char* dof_frag_shader_step_5 =
static const char* dof_frag_shader_upsample =
"layout(binding = 0) uniform sampler2D g_filtered_rgb_sampler;\n"
"layout(binding = 1) uniform sampler2D g_filtered_a_sampler;\n"
"layout(binding = 2) uniform sampler2D g_tile_sampler;\n"
@@ -593,29 +593,36 @@ static const dof_pv dof_pv_default = {
},
};
static void post_process_apply_dof_f2(post_process_dof* dof, render_texture* rt,
GLuint* samplers, GLuint color_texture, GLuint depth_texture,
float_t min_distance, float_t max_distance, float_t fov, float_t focus,
float_t focus_range, float_t fuzzing_range, float_t ratio);
static void post_process_apply_dof_physical(post_process_dof* dof, render_texture* rt,
GLuint* samplers, GLuint color_texture, GLuint depth_texture,
float_t min_distance, float_t max_distance, float_t focus,
float_t focal_length, float_t fov, float_t f_number);
static void post_process_apply_dof_steps_1_2(post_process_dof* dof,
GLuint* samplers, GLuint depth_texture, bool f2);
static void post_process_apply_dof_step_3(post_process_dof* dof,
GLuint* samplers, GLuint color_texture, GLuint depth_texture, bool f2);
static void post_process_apply_dof_step_4(post_process_dof* dof, GLuint* samplers, bool f2);
static void post_process_apply_dof_step_5(post_process_dof* dof, render_texture* rt,
GLuint* samplers, GLuint color_texture, GLuint depth_texture, bool f2);
namespace renderer {
struct DOF3 {
static void apply_f2(post_process_dof* dof, render_texture* rt,
GLuint* samplers, GLuint color_texture, GLuint depth_texture,
float_t min_distance, float_t max_distance, float_t fov, float_t focus,
float_t focus_range, float_t fuzzing_range, float_t ratio);
static void apply_physical(post_process_dof* dof, render_texture* rt,
GLuint* samplers, GLuint color_texture, GLuint depth_texture,
float_t min_distance, float_t max_distance, float_t focus,
float_t focal_length, float_t fov, float_t f_number);
static void render_tiles(post_process_dof* dof,
GLuint* samplers, GLuint depth_texture, bool f2);
static void downsample(post_process_dof* dof,
GLuint* samplers, GLuint color_texture, GLuint depth_texture, bool f2);
static void apply_main_filter(post_process_dof* dof, GLuint* samplers, bool f2);
static void upsample(post_process_dof* dof, render_texture* rt,
GLuint* samplers, GLuint color_texture, GLuint depth_texture, bool f2);
static void update_data(post_process_dof* dof, float_t min_dist,
float_t max_dist, float_t fov, float_t dist, float_t focal_length,
float_t f_number, float_t focus_range, float_t fuzzing_range, float_t ratio);
};
}
static void post_process_dof_calculate_texcoords(vec2* data, float_t size);
static void post_process_dof_free_fbo(post_process_dof* dof);
static void post_process_dof_load_shaders(post_process_dof* dof);
static GLuint post_process_dof_program_link(GLuint vert_shad, GLuint frag_shad);
static GLuint post_process_dof_shader_compile(GLenum type, const char* data);
static void post_process_dof_update_data(post_process_dof* dof, float_t min_dist,
float_t max_dist, float_t fov, float_t dist, float_t focal_length,
float_t f_number, float_t focus_range, float_t fuzzing_range, float_t ratio);
static void sub_1405163C0(rob_chara* rob_chr, int32_t a2, mat4* mat);
@@ -668,14 +675,14 @@ void post_process_dof::apply(render_texture* rt, GLuint* samplers, camera* cam)
}
focus = max(focus, (float_t)cam->min_distance);
post_process_apply_dof_physical(this, rt, samplers,
renderer::DOF3::apply_physical(this, rt, samplers,
rt->color_texture->tex, rt->depth_texture->tex,
(float_t)cam->min_distance, (float_t)cam->max_distance, focus,
data.debug.focal_length, (float_t)cam->fov_rad, data.debug.f_number);
}
else {
float_t fuzzing_range = max(data.debug.f2.fuzzing_range, 0.01f);
post_process_apply_dof_f2(this, rt, samplers,
renderer::DOF3::apply_f2(this, rt, samplers,
rt->color_texture->tex, rt->depth_texture->tex,
(float_t)cam->min_distance, (float_t)cam->max_distance, (float_t)cam->fov_rad,
data.debug.f2.focus, data.debug.f2.focus_range, fuzzing_range, data.debug.f2.ratio);
@@ -685,7 +692,7 @@ void post_process_dof::apply(render_texture* rt, GLuint* samplers, camera* cam)
}
else if (data.pv.enable && data.pv.f2.ratio > 0.0f) {
float_t fuzzing_range = max(data.pv.f2.fuzzing_range, 0.01f);
post_process_apply_dof_f2(this, rt, samplers,
renderer::DOF3::apply_f2(this, rt, samplers,
rt->color_texture->tex, rt->depth_texture->tex,
(float_t)cam->min_distance, (float_t)cam->max_distance, (float_t)cam->fov_rad,
data.pv.f2.focus, data.pv.f2.focus_range, fuzzing_range, data.pv.f2.ratio);
@@ -781,134 +788,6 @@ void post_process_dof::set_dof_pv(dof_pv* pv) {
data.pv = dof_pv_default;
}
static void post_process_apply_dof_f2(post_process_dof* dof, render_texture* rt,
GLuint* samplers, GLuint color_texture, GLuint depth_texture,
float_t min_distance, float_t max_distance, float_t fov, float_t focus,
float_t focus_range, float_t fuzzing_range, float_t ratio) {
gl_state_disable_blend();
gl_state_set_depth_mask(GL_FALSE);
gl_state_set_depth_func(GL_ALWAYS);
post_process_dof_update_data(dof, min_distance, max_distance,
fov, focus, 0.0f, 1.0f, focus_range, fuzzing_range, ratio);
gl_state_bind_vertex_array(dof->vao);
post_process_apply_dof_steps_1_2(dof, samplers, depth_texture, true);
post_process_apply_dof_step_3(dof, samplers, color_texture, depth_texture, true);
post_process_apply_dof_step_4(dof, samplers, true);
post_process_apply_dof_step_5(dof, rt, samplers, color_texture, depth_texture, true);
gl_state_use_program(0);
for (int32_t i = 0; i < 8; i++) {
gl_state_bind_sampler(i, 0);
gl_state_active_bind_texture_2d(i, 0);
}
gl_state_bind_vertex_array(0);
}
static void post_process_apply_dof_physical(post_process_dof* dof, render_texture* rt,
GLuint* samplers, GLuint color_texture, GLuint depth_texture,
float_t min_distance, float_t max_distance, float_t focus,
float_t focal_length, float_t fov, float_t f_number) {
gl_state_disable_blend();
gl_state_set_depth_mask(GL_FALSE);
gl_state_set_depth_func(GL_ALWAYS);
post_process_dof_update_data(dof, min_distance, max_distance,
fov, focus, focal_length, f_number, 0.0f, 0.1f, 0.0f);
gl_state_bind_vertex_array(dof->vao);
post_process_apply_dof_steps_1_2(dof, samplers, depth_texture, false);
post_process_apply_dof_step_3(dof, samplers, color_texture, depth_texture, false);
post_process_apply_dof_step_4(dof, samplers, false);
post_process_apply_dof_step_5(dof, rt, samplers, color_texture, depth_texture, false);
gl_state_use_program(0);
for (int32_t i = 0; i < 8; i++) {
gl_state_bind_sampler(i, 0);
gl_state_active_bind_texture_2d(i, 0);
}
gl_state_bind_vertex_array(0);
}
static void post_process_apply_dof_steps_1_2(post_process_dof* dof,
GLuint* samplers, GLuint depth_texture, bool f2) {
gl_state_bind_framebuffer(dof->fbo[0].buffer);
glViewport(0, 0, dof->fbo[0].width, dof->fbo[0].height);
if (f2)
gl_state_use_program(dof->program[5]);
else
gl_state_use_program(dof->program[1]);
gl_state_bind_uniform_buffer_base(0, dof->ubo[0]);
gl_state_active_bind_texture_2d(0, depth_texture);
gl_state_bind_sampler(0, samplers[1]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
gl_state_bind_framebuffer(dof->fbo[1].buffer);
glViewport(0, 0, dof->fbo[1].width, dof->fbo[1].height);
gl_state_use_program(dof->program[0]);
gl_state_active_bind_texture_2d(0, dof->textures[0]);
gl_state_bind_sampler(0, samplers[1]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
}
static void post_process_apply_dof_step_3(post_process_dof* dof,
GLuint* samplers, GLuint color_texture, GLuint depth_texture, bool f2) {
gl_state_bind_framebuffer(dof->fbo[2].buffer);
glViewport(0, 0, dof->fbo[2].width, dof->fbo[2].height);
if (f2)
gl_state_use_program(dof->program[6]);
else
gl_state_use_program(dof->program[2]);
gl_state_bind_uniform_buffer_base(0, dof->ubo[0]);
gl_state_active_bind_texture_2d(0, depth_texture);
gl_state_bind_sampler(0, samplers[1]);
gl_state_active_bind_texture_2d(1, color_texture);
gl_state_bind_sampler(1, samplers[0]);
gl_state_active_bind_texture_2d(2, dof->textures[1]);
gl_state_bind_sampler(2, samplers[1]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
}
static void post_process_apply_dof_step_4(post_process_dof* dof, GLuint* samplers, bool f2) {
gl_state_bind_framebuffer(dof->fbo[3].buffer);
glViewport(0, 0, dof->fbo[3].width, dof->fbo[3].height);
if (f2)
gl_state_use_program(dof->program[7]);
else
gl_state_use_program(dof->program[3]);
gl_state_bind_uniform_buffer_base(0, dof->ubo[0]);
gl_state_bind_uniform_buffer_base(1, dof->ubo[1]);
gl_state_active_bind_texture_2d(0, dof->textures[3]);
gl_state_bind_sampler(0, samplers[1]);
gl_state_active_bind_texture_2d(1, dof->textures[2]);
gl_state_bind_sampler(1, samplers[1]);
gl_state_active_bind_texture_2d(2, dof->textures[1]);
gl_state_bind_sampler(2, samplers[1]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
}
static void post_process_apply_dof_step_5(post_process_dof* dof, render_texture* rt,
GLuint* samplers, GLuint color_texture, GLuint depth_texture, bool f2) {
render_texture_bind(rt, 0);
glViewport(0, 0, dof->width, dof->height);
if (f2)
gl_state_use_program(dof->program[8]);
else
gl_state_use_program(dof->program[4]);
gl_state_bind_uniform_buffer_base(0, dof->ubo[0]);
gl_state_bind_uniform_buffer_base(1, dof->ubo[1]);
gl_state_active_bind_texture_2d(0, dof->textures[4]);
gl_state_bind_sampler(0, samplers[1]);
gl_state_active_bind_texture_2d(1, dof->textures[5]);
gl_state_bind_sampler(1, samplers[1]);
gl_state_active_bind_texture_2d(2, dof->textures[1]);
gl_state_bind_sampler(2, samplers[1]);
gl_state_active_bind_texture_2d(3, color_texture);
gl_state_bind_sampler(3, samplers[1]);
gl_state_active_bind_texture_2d(4, depth_texture);
gl_state_bind_sampler(4, samplers[1]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
}
static void post_process_dof_calculate_texcoords(vec2* data, float_t size) {
size_t i;
size_t j;
@@ -976,7 +855,7 @@ static void post_process_dof_free_fbo(post_process_dof* dof) {
static void post_process_dof_load_shaders(post_process_dof* dof) {
char* frag_shader_string[9];
frag_shader_string[0] = str_utils_copy(dof_frag_shader_step_2);
frag_shader_string[0] = str_utils_copy(dof_frag_shader_render_tiles_part_2);
for (int32_t i = 0; i < 2; i++) {
char* t0;
char* t1;
@@ -985,25 +864,25 @@ static void post_process_dof_load_shaders(post_process_dof* dof) {
t0 = str_utils_copy(dof_frag_shader_version);
t1 = str_utils_add(t0, shared);
frag_shader_string[1 + i * 4] = str_utils_add(t1, dof_frag_shader_step_1);
frag_shader_string[1 + i * 4] = str_utils_add(t1, dof_frag_shader_render_tiles_part_1);
free(t0);
free(t1);
t0 = str_utils_copy(dof_frag_shader_version);
t1 = str_utils_add(t0, shared);
frag_shader_string[2 + i * 4] = str_utils_add(t1, dof_frag_shader_step_3);
frag_shader_string[2 + i * 4] = str_utils_add(t1, dof_frag_shader_downsample);
free(t0);
free(t1);
t0 = str_utils_copy(dof_frag_shader_version);
t1 = str_utils_add(t0, shared);
frag_shader_string[3 + i * 4] = str_utils_add(t1, dof_frag_shader_step_4);
frag_shader_string[3 + i * 4] = str_utils_add(t1, dof_frag_shader_apply_main_filter);
free(t0);
free(t1);
t0 = str_utils_copy(dof_frag_shader_version);
t1 = str_utils_add(t0, shared);
frag_shader_string[4 + i * 4] = str_utils_add(t1, dof_frag_shader_step_5);
frag_shader_string[4 + i * 4] = str_utils_add(t1, dof_frag_shader_upsample);
free(t0);
free(t1);
free(shared);
@@ -1063,34 +942,164 @@ static GLuint post_process_dof_program_link(GLuint vert_shad, GLuint frag_shad)
return program;
};
static void post_process_dof_update_data(post_process_dof* dof, float_t min_dist,
float_t max_dist, float_t fov, float_t dist, float_t focal_length,
float_t f_number, float_t focus_range, float_t fuzzing_range, float_t ratio) {
float_t fl = focal_length;
if (dist <= focal_length)
fl = dist + 0.1f;
fl = fl / (dist - fl) * fl / f_number;
post_process_dof_shader_data data;
data.g_depth_params.x = 1.0f / (min_dist * max_dist) * (min_dist - max_dist);
data.g_depth_params.y = 1.0f / min_dist;
data.g_depth_params.z = -((fl * dist * (min_dist - max_dist)) * (1.0f / (min_dist * max_dist)));
data.g_depth_params.w = (1.0f - 1.0f / min_dist * dist) * fl;
data.g_spread_scale.x = 720.0f / (tanf(fov * 0.5f) * (min_dist * 2.0f));
data.g_spread_scale.y = data.g_spread_scale.x * (float_t)(1.0 / 3.0);
data.g_spread_scale.z = (float_t)(1.0 / 3.0);
data.g_spread_scale.w = 3.0f;
data.g_depth_params2.x = dist;
data.g_depth_params2.y = focus_range;
data.g_depth_params2.z = -4.5f / (fuzzing_range * fuzzing_range);
data.g_depth_params2.w = ratio * 8.0f;
gl_state_bind_uniform_buffer(dof->ubo[0]);
glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(post_process_dof_shader_data), &data);
}
static void sub_1405163C0(rob_chara* rob_chr, int32_t a2, mat4* mat) {
if (a2 >= 0 && a2 <= 26)
*mat = rob_chr->data.field_1E68.field_78[a2];
}
namespace renderer {
void DOF3::apply_f2(post_process_dof* dof, render_texture* rt,
GLuint* samplers, GLuint color_texture, GLuint depth_texture,
float_t min_distance, float_t max_distance, float_t fov, float_t focus,
float_t focus_range, float_t fuzzing_range, float_t ratio) {
gl_state_disable_blend();
gl_state_set_depth_mask(GL_FALSE);
gl_state_set_depth_func(GL_ALWAYS);
update_data(dof, min_distance, max_distance,
fov, focus, 0.0f, 1.0f, focus_range, fuzzing_range, ratio);
gl_state_bind_vertex_array(dof->vao);
render_tiles(dof, samplers, depth_texture, true);
downsample(dof, samplers, color_texture, depth_texture, true);
apply_main_filter(dof, samplers, true);
upsample(dof, rt, samplers, color_texture, depth_texture, true);
gl_state_use_program(0);
for (int32_t i = 0; i < 8; i++) {
gl_state_bind_sampler(i, 0);
gl_state_active_bind_texture_2d(i, 0);
}
gl_state_bind_vertex_array(0);
}
void DOF3::apply_physical(post_process_dof* dof, render_texture* rt,
GLuint* samplers, GLuint color_texture, GLuint depth_texture,
float_t min_distance, float_t max_distance, float_t focus,
float_t focal_length, float_t fov, float_t f_number) {
gl_state_disable_blend();
gl_state_set_depth_mask(GL_FALSE);
gl_state_set_depth_func(GL_ALWAYS);
update_data(dof, min_distance, max_distance,
fov, focus, focal_length, f_number, 0.0f, 0.1f, 0.0f);
gl_state_bind_vertex_array(dof->vao);
render_tiles(dof, samplers, depth_texture, false);
downsample(dof, samplers, color_texture, depth_texture, false);
apply_main_filter(dof, samplers, false);
upsample(dof, rt, samplers, color_texture, depth_texture, false);
gl_state_use_program(0);
for (int32_t i = 0; i < 8; i++) {
gl_state_bind_sampler(i, 0);
gl_state_active_bind_texture_2d(i, 0);
}
gl_state_bind_vertex_array(0);
}
void DOF3::render_tiles(post_process_dof* dof,
GLuint* samplers, GLuint depth_texture, bool f2) {
gl_state_bind_framebuffer(dof->fbo[0].buffer);
glViewport(0, 0, dof->fbo[0].width, dof->fbo[0].height);
if (f2)
gl_state_use_program(dof->program[5]);
else
gl_state_use_program(dof->program[1]);
gl_state_bind_uniform_buffer_base(0, dof->ubo[0]);
gl_state_active_bind_texture_2d(0, depth_texture);
gl_state_bind_sampler(0, samplers[1]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
gl_state_bind_framebuffer(dof->fbo[1].buffer);
glViewport(0, 0, dof->fbo[1].width, dof->fbo[1].height);
gl_state_use_program(dof->program[0]);
gl_state_active_bind_texture_2d(0, dof->textures[0]);
gl_state_bind_sampler(0, samplers[1]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
}
void DOF3::downsample(post_process_dof* dof,
GLuint* samplers, GLuint color_texture, GLuint depth_texture, bool f2) {
gl_state_bind_framebuffer(dof->fbo[2].buffer);
glViewport(0, 0, dof->fbo[2].width, dof->fbo[2].height);
if (f2)
gl_state_use_program(dof->program[6]);
else
gl_state_use_program(dof->program[2]);
gl_state_bind_uniform_buffer_base(0, dof->ubo[0]);
gl_state_active_bind_texture_2d(0, depth_texture);
gl_state_bind_sampler(0, samplers[1]);
gl_state_active_bind_texture_2d(1, color_texture);
gl_state_bind_sampler(1, samplers[0]);
gl_state_active_bind_texture_2d(2, dof->textures[1]);
gl_state_bind_sampler(2, samplers[1]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
}
void DOF3::apply_main_filter(post_process_dof* dof, GLuint* samplers, bool f2) {
gl_state_bind_framebuffer(dof->fbo[3].buffer);
glViewport(0, 0, dof->fbo[3].width, dof->fbo[3].height);
if (f2)
gl_state_use_program(dof->program[7]);
else
gl_state_use_program(dof->program[3]);
gl_state_bind_uniform_buffer_base(0, dof->ubo[0]);
gl_state_bind_uniform_buffer_base(1, dof->ubo[1]);
gl_state_active_bind_texture_2d(0, dof->textures[3]);
gl_state_bind_sampler(0, samplers[1]);
gl_state_active_bind_texture_2d(1, dof->textures[2]);
gl_state_bind_sampler(1, samplers[1]);
gl_state_active_bind_texture_2d(2, dof->textures[1]);
gl_state_bind_sampler(2, samplers[1]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
}
void DOF3::upsample(post_process_dof* dof, render_texture* rt,
GLuint* samplers, GLuint color_texture, GLuint depth_texture, bool f2) {
render_texture_bind(rt, 0);
glViewport(0, 0, dof->width, dof->height);
if (f2)
gl_state_use_program(dof->program[8]);
else
gl_state_use_program(dof->program[4]);
gl_state_bind_uniform_buffer_base(0, dof->ubo[0]);
gl_state_bind_uniform_buffer_base(1, dof->ubo[1]);
gl_state_active_bind_texture_2d(0, dof->textures[4]);
gl_state_bind_sampler(0, samplers[1]);
gl_state_active_bind_texture_2d(1, dof->textures[5]);
gl_state_bind_sampler(1, samplers[1]);
gl_state_active_bind_texture_2d(2, dof->textures[1]);
gl_state_bind_sampler(2, samplers[1]);
gl_state_active_bind_texture_2d(3, color_texture);
gl_state_bind_sampler(3, samplers[1]);
gl_state_active_bind_texture_2d(4, depth_texture);
gl_state_bind_sampler(4, samplers[1]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
}
void DOF3::update_data(post_process_dof* dof, float_t min_dist,
float_t max_dist, float_t fov, float_t dist, float_t focal_length,
float_t f_number, float_t focus_range, float_t fuzzing_range, float_t ratio) {
float_t fl = focal_length;
if (dist <= focal_length)
fl = dist + 0.1f;
fl = fl / (dist - fl) * fl / f_number;
post_process_dof_shader_data data;
data.g_depth_params.x = 1.0f / (min_dist * max_dist) * (min_dist - max_dist);
data.g_depth_params.y = 1.0f / min_dist;
data.g_depth_params.z = -((fl * dist * (min_dist - max_dist)) * (1.0f / (min_dist * max_dist)));
data.g_depth_params.w = (1.0f - 1.0f / min_dist * dist) * fl;
data.g_spread_scale.x = 720.0f / (tanf(fov * 0.5f) * (min_dist * 2.0f));
data.g_spread_scale.y = data.g_spread_scale.x * (float_t)(1.0 / 3.0);
data.g_spread_scale.z = (float_t)(1.0 / 3.0);
data.g_spread_scale.w = 3.0f;
data.g_depth_params2.x = dist;
data.g_depth_params2.y = focus_range;
data.g_depth_params2.z = -4.5f / (fuzzing_range * fuzzing_range);
data.g_depth_params2.w = ratio * 8.0f;
gl_state_bind_uniform_buffer(dof->ubo[0]);
glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(post_process_dof_shader_data), &data);
}
}
+3 -2
View File
@@ -5,8 +5,8 @@
#pragma once
#include "../../KKdLib/default.h"
#include "../../KKdLib/vec.h"
#include "../../KKdLib/default.hpp"
#include "../../KKdLib/vec.hpp"
#include "../camera.h"
#include "../fbo.hpp"
#include "../render_texture.h"
@@ -60,6 +60,7 @@ struct post_process_dof {
void apply(render_texture* rt, GLuint* samplers, camera* cam);
void init_fbo(int32_t width, int32_t height);
void initialize_data(dof_debug* debug, dof_pv* pv);
void get_dof_debug(dof_debug* debug);
void set_dof_debug(dof_debug* debug);
void get_dof_pv(dof_pv* pv);
-207
View File
@@ -1,207 +0,0 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#include "exposure.h"
#include "../fbo.hpp"
#include "../gl_state.h"
#include "../post_process.hpp"
#include "../rob.hpp"
#include "../shader_ft.h"
struct struc_188 {
vec4u field_0[8];
float_t field_80;
GLuint field_84[3];
GLuint field_90[3];
};
static void post_process_exposure_free_fbo(post_process_exposure* exp);
static void sub_1405163C0(rob_chara* rob_chr, int32_t a2, mat4* mat);
post_process_exposure::post_process_exposure() : exposure_history_counter() {
}
post_process_exposure* post_process_exposure_init() {
post_process_exposure* exp = force_malloc_s(post_process_exposure, 1);
return exp;
}
void post_process_get_exposure(post_process_exposure* exp, camera* cam, int32_t render_width,
int32_t render_height, bool reset_exposure, GLuint in_tex_0, GLuint in_tex_1) {
if (!exp)
return;
struc_188 field_648[ROB_CHARA_COUNT];
for (struc_188& i : field_648)
i = {};
bool v2 = false;
float_t v18 = (float_t)render_height / (float_t)render_width;
float_t v20 = powf(tanf((float_t)(cam->fov_rad * 0.5f)) * 3.4f, 2.0f);
if (reset_exposure)
goto LABEL_30;
for (struc_188& i : field_648) {
rob_chara* rob_chr = rob_chara_array_get((int32_t)(&i - field_648));
if (!rob_chr || ~rob_chr->data.field_0 & 0x01)
continue;
vec4 v34 = { 0.05f, 0.0f, -0.04f, 1.0f };
vec4 v33 = { 1.0f, 0.0f, 0.0f, 0.0f };
mat4 v44;
sub_1405163C0(rob_chr, 4, &v44);
mat4 v42 = cam->view;
mat4 v43 = cam->projection;
mat4_mult(&v44, &v42, &v42);
mat4_mult(&v42, &v43, &v43);
vec4 v41;
mat4_mult_vec(&v42, &v34, &v41);
vec4 v40;
mat4_mult_vec(&v43, &v34, &v40);
float_t v11 = v41.z;
float_t v12 = 1.0f / v40.w;
float_t v13 = v40.x * v12;
float_t v14 = v40.y * v12;
if (v41.z >= 0.0f || fabsf(v13) >= 1.0f || fabsf(v14) >= 1.0f)
continue;
float_t v31 = 0.5f - (fabsf(v14) - 1.0f) * 2.5f;
float_t v32 = 0.5f - (fabsf(v13) - 1.0f) * 2.5f;
float_t v16;
if (v32 <= v31)
v16 = v32;
else
v16 = v31;
v16 = min(v16, 1.0f);
vec4 v39;
mat4_mult_vec(&v42, &v33, &v39);
float_t v17 = (v39.z + 1.0f) * 0.5f;
v17 = clamp(v17, 0.0f, 0.8f);
float_t v21 = 0.25f / sqrtf(v20 * (v11 * v11));
float_t v22;
if (v21 >= 0.055f) {
v22 = 1.0f;
if (v21 > 0.5f)
v22 = 1.0f - (v21 - 0.5f) * (float_t)(10.0 / 3.0f);
}
else
v22 = (v21 - 0.035f) * 50.0f;
v22 = max(v22, 0.0f);
float_t v23 = (v13 + 1.0f) * 0.5f;
float_t v24 = (v21 * -0.5f + v14 + 1.0f) * 0.5f;
float_t v25 = (v14 - v21 * 0.1f + 1.0f) * 0.5f;
i.field_80 = v16 * 1.6f * v17 * v22;
i.field_0[0].x = v23;
i.field_0[0].y = (v21 * 0.1f + v14 + 1.0f) * 0.5f;
i.field_0[0].z = 0.0f;
i.field_0[0].w = 4.0f;
i.field_0[1].x = v23;
i.field_0[1].y = (v14 - v21 * 0.3f + 1.0f) * 0.5f;
i.field_0[1].z = 0.0f;
i.field_0[1].w = 4.0f;
i.field_0[2].x = (v21 * -0.5f * v18 + v13 + 1.0f) * 0.5f;
i.field_0[2].y = v24;
i.field_0[2].z = 0.0f;
i.field_0[2].w = 3.0f;
i.field_0[3].x = (v13 - v21 * 0.6f * v18 + 1.0f) * 0.5f;
i.field_0[3].y = v25;
i.field_0[3].z = 0.0f;
i.field_0[3].w = 2.0f;
i.field_0[4].x = (v21 * 0.6f * v18 + v13 + 1.0f) * 0.5f;
i.field_0[4].y = v25;
i.field_0[4].z = 0.0f;
i.field_0[4].w = 2.0f;
i.field_0[5].x = (v21 * 0.5f * v18 + v13 + 1.0f) * 0.5f;
i.field_0[5].y = v24;
i.field_0[5].z = 0.0f;
i.field_0[5].w = 3.0f;
i.field_0[6].x = v23;
i.field_0[6].y = (v14 - v21 * 0.8f + 1.0f) * 0.5f;
i.field_0[6].z = 0.0f;
i.field_0[6].w = 3.0f;
if (i.field_80 > 0.0f && false/*!i.field_90[pp->field_9F4]*/)
v2 = true;
}
if (!v2 || reset_exposure) {
LABEL_30:
uniform_value[U_EXPOSURE] = 1;
render_texture_shader_set(&shaders_ft, SHADER_FT_EXPOSURE);
shader_local_frag_set(&shaders_ft, 1,
field_648[0].field_80,
field_648[1].field_80,
field_648[2].field_80,
field_648[3].field_80);
int32_t index = 0;
for (struc_188& i : field_648) {
shader_local_frag_set_ptr_array(&shaders_ft, 4ULL + index * 8ULL, 8, (vec4*)field_648->field_0);
if (++index >= 4)
break;
}
if (reset_exposure)
glViewport(0, 0, 32, 1);
else
glViewport(exp->exposure_history_counter, 0, 1, 1);
render_texture_bind(&exp->exposure_history, 0);
gl_state_active_bind_texture_2d(0, in_tex_0);
gl_state_active_bind_texture_2d(1, in_tex_1);
render_texture_draw_params(&shaders_ft,
reset_exposure ? 32 : 1, 1, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
exp->exposure_history_counter++;
exp->exposure_history_counter %= 32;
}
uniform_value[U_EXPOSURE] = 2;
render_texture_shader_set(&shaders_ft, SHADER_FT_EXPOSURE);
glViewport(0, 0, 1, 1);
render_texture_bind(&exp->exposure, 0);
gl_state_active_bind_texture_2d(0, exp->exposure_history.color_texture->tex);
render_texture_draw_params(&shaders_ft, 1, 1, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
}
void post_process_exposure_init_fbo(post_process_exposure* exp) {
if (!exp)
return;
exp->exposure_history_counter = 0;
if (!exp->exposure_history.color_texture)
render_texture_init(&exp->exposure_history, 32, 1, 0, GL_R32F, 0);
if (!exp->exposure.color_texture)
render_texture_init(&exp->exposure, 1, 1, 0, GL_R32F, 0);
}
void post_process_exposure_dispose(post_process_exposure* exp) {
if (!exp)
return;
post_process_exposure_free_fbo(exp);
free(exp);
}
static void post_process_exposure_free_fbo(post_process_exposure* exp) {
render_texture_free(&exp->exposure_history);
render_texture_free(&exp->exposure);
}
static void sub_1405163C0(rob_chara* rob_chr, int32_t a2, mat4* mat) {
if (a2 >= 0 && a2 <= 26)
*mat = rob_chr->data.field_1E68.field_78[a2];
}
+235
View File
@@ -0,0 +1,235 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#include "exposure.hpp"
#include "../fbo.hpp"
#include "../gl_state.h"
#include "../post_process.hpp"
#include "../rob.hpp"
#include "../shader_ft.h"
static void sub_1405163C0(rob_chara* rob_chr, int32_t a2, mat4* mat);
post_process_exposure::post_process_exposure() : exposure_history_counter(),
chara_data(), query_index() {
chara_data = new post_process_exposure_chara_data[ROB_CHARA_COUNT];
for (int32_t i = 0; i < ROB_CHARA_COUNT; i++) {
chara_data[i].query_data[0] = -1;
chara_data[i].query_data[1] = -1;
chara_data[i].query_data[2] = -1;
}
}
post_process_exposure::~post_process_exposure() {
if (!this)
return;
render_texture_free(&exposure_history);
render_texture_free(&exposure);
for (int32_t i = 0; i < ROB_CHARA_COUNT; i++)
glDeleteQueries(3, chara_data[i].query);
delete chara_data;
}
void post_process_exposure::get_exposure(camera* cam, int32_t render_width,
int32_t render_height, bool reset_exposure, GLuint in_tex_0, GLuint in_tex_1) {
bool v2 = false;
if (!reset_exposure) {
post_process_exposure_chara_data* v6 = chara_data;
float_t v18 = (float_t)render_height / (float_t)render_width;
float_t v20 = powf(tanf((float_t)(cam->fov_rad * 0.5f)) * 3.4f, 2.0f);
for (int32_t i = 0; i < ROB_CHARA_COUNT; i++, v6++) {
rob_chara* rob_chr = rob_chara_array_get(i);
if (!rob_chr || ~rob_chr->data.field_0 & 1)
continue;
vec4 v34 = { 0.05f, 0.0f, -0.04f, 1.0f };
vec4 v33 = { 1.0f, 0.0f, 0.0f, 0.0f };
mat4 v44;
sub_1405163C0(rob_chr, 4, &v44);
mat4 v42 = cam->view;
mat4 v43 = cam->projection;
mat4_mult(&v44, &v42, &v42);
mat4_mult(&v42, &v43, &v43);
vec4 v41;
vec4 v40;
mat4_mult_vec(&v42, &v34, &v41);
mat4_mult_vec(&v43, &v34, &v40);
float_t v12 = 1.0f / v40.w;
float_t v13 = v40.x * v12;
float_t v14 = v40.y * v12;
if (v41.z >= 0.0f || fabsf(v13) >= 1.0f || fabsf(v14) >= 1.0f)
continue;
float_t v31 = 0.5f - (fabsf(v14) - 1.0f) * 2.5f;
float_t v32 = 0.5f - (fabsf(v13) - 1.0f) * 2.5f;
float_t v16;
if (v32 <= v31)
v16 = v32;
else
v16 = v31;
if (v16 > 1.0f)
v16 = 1.0f;
vec4 v39;
mat4_mult_vec(&v42, &v33, &v39);
float_t v17 = (v39.z + 1.0f) * 0.5f;
if (v17 > 0.8f)
v17 = 0.8f;
else if (v17 < 0.2f)
v17 = 0.0f;
float_t v21 = 0.25f / sqrtf(powf(v20 * 3.4f, 2.0f) * (v41.z * v41.z));
float_t v22;
if (v21 < 0.055f) {
v22 = (v21 - 0.035f) * 50.0f;
if (v22 < 0.0f)
v22 = 0.0f;
}
else if (v21 > 0.5f) {
v22 = 1.0f - (v21 - 0.5f) * 3.3333333f;
if (v22 < 0.0f)
v22 = 0.0f;
}
else
v22 = 1.0f;
v6->field_0[0].x = (v13 + v21 * 0.0f * v18 + 1.0f) * 0.5f;
v6->field_0[0].y = (v14 + v21 * 0.1f + 1.0f) * 0.5f;
v6->field_0[0].z = 0.0f;
v6->field_0[0].w = 4.0f;
v6->field_0[1].x = (v13 + v21 * 0.0f * v18 + 1.0f) * 0.5f;
v6->field_0[1].y = (v14 - v21 * 0.3f + 1.0f) * 0.5f;
v6->field_0[1].z = 0.0f;
v6->field_0[1].w = 4.0f;
v6->field_0[2].x = (v13 + v21 * -0.5f * v18 + 1.0f) * 0.5f;
v6->field_0[2].y = (v14 + v21 * -0.5f + 1.0f) * 0.5f;
v6->field_0[2].z = 0.0f;
v6->field_0[2].w = 3.0f;
v6->field_0[3].x = (v13 - v21 * 0.6f * v18 + 1.0f) * 0.5f;
v6->field_0[3].y = (v14 - v21 * 0.1f + 1.0f) * 0.5f;
v6->field_0[3].z = 0.0f;
v6->field_0[3].w = 2.0f;
v6->field_0[4].x = (v13 + v21 * 0.6f * v18 + 1.0f) * 0.5f;
v6->field_0[4].y = (v14 - v21 * 0.1f + 1.0f) * 0.5f;
v6->field_0[4].z = 0.0f;
v6->field_0[4].w = 2.0f;
v6->field_0[5].x = (v13 + v21 * 0.5f * v18 + 1.0f) * 0.5f;
v6->field_0[5].y = (v14 + v21 * -0.5f + 1.0f) * 0.5f;
v6->field_0[5].z = 0.0f;
v6->field_0[5].w = 3.0f;
v6->field_0[6].x = (v13 + v21 * 0.0f * v18 + 1.0f) * 0.5f;
v6->field_0[6].y = (v14 - v21 * 0.8f + 1.0f) * 0.5f;
v6->field_0[6].z = 0.0f;
v6->field_0[6].w = 3.0f;
v6->field_80 = v16 * 1.6f * v17 * v22;
if (v6->field_80 > 0.0f && !v6->query_data[query_index])
v2 = true;
}
}
if (!v2 || reset_exposure) {
uniform_value[U_EXPOSURE] = 1;
render_texture_shader_set(&shaders_ft, SHADER_FT_EXPOSURE);
shaders_ft.local_frag_set(1,
chara_data[0].field_80,
chara_data[1].field_80,
chara_data[2].field_80,
chara_data[3].field_80);
post_process_exposure_chara_data* v27 = chara_data;
for (int32_t i = 0; i < 4 && i < ROB_CHARA_COUNT; i++, v27++)
shaders_ft.local_frag_set(4ULL + (size_t)i * 8, 8, v27->field_0);
if (reset_exposure)
glViewport(0, 0, 32, 1);
else
glViewport(exposure_history_counter, 0, 1, 1);
render_texture_bind(&exposure_history, 0);
gl_state_active_bind_texture_2d(0, in_tex_0);
gl_state_active_bind_texture_2d(1, in_tex_1);
render_texture_draw_params(&shaders_ft,
reset_exposure ? 32 : 1, 1, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
exposure_history_counter++;
exposure_history_counter %= 32;
}
glViewport(0, 0, 1, 1);
render_texture_bind(&exposure, 0);
gl_state_active_bind_texture_2d(0, exposure_history.color_texture->tex);
render_texture_draw_params(&shaders_ft, 1, 1, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
}
void post_process_exposure::get_exposure_chara_data(void* pp, camera* cam) {
shader::unbind();
gl_state_set_color_mask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
gl_state_set_depth_mask(GL_FALSE);
post_process_exposure_chara_data* v3 = chara_data;
int32_t v4 = query_index++ % 3;
int32_t v7 = (v4 + 2) % 3;
for (int32_t i = 0; i < ROB_CHARA_COUNT; i++, v3++) {
rob_chara* rob_chr = rob_chara_array_get(i);
if (!rob_chr || ~rob_chr->data.field_0 & 1)
continue;
float_t max_face_depth = rob_chr->get_max_face_depth();
mat4 mat = mat4_identity;
sub_1405163C0(rob_chr, 4, &mat);
mat4_mult(&mat, &cam->view, &mat);
mat4_translate_mult(&mat, max_face_depth + 0.1f, 0.0f, -0.06f, &mat);
mat4_clear_rot(&mat, &mat);
mat4_mult( &mat, &cam->projection,&mat);
((post_process*)pp)->draw_query_samples(v3->query[v7], 0.0035f, mat);
if (v3->query_data[v7] == -1)
v3->query_data[v7] = 0;
if (v3->query_data[v4] != -1) {
int32_t v14 = 0;
glGetQueryObjectiv(v3->query[v4], GL_QUERY_RESULT_AVAILABLE, &v14);
if (v14)
glGetQueryObjectuiv(v3->query[v4], GL_QUERY_RESULT, v3->query_data);
else
v3->query_data[v4] = 0;
}
}
gl_state_set_color_mask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
gl_state_set_depth_mask(GL_TRUE);
}
void post_process_exposure::init_fbo() {
if (!this)
return;
exposure_history_counter = 0;
if (!exposure_history.color_texture)
render_texture_init(&exposure_history, 32, 1, 0, GL_R32F, 0);
if (!exposure.color_texture)
render_texture_init(&exposure, 1, 1, 0, GL_R32F, 0);
for (int32_t i = 0; i < ROB_CHARA_COUNT; i++)
if (!chara_data[i].query[0])
glGenQueries(3, chara_data[i].query);
}
static void sub_1405163C0(rob_chara* rob_chr, int32_t a2, mat4* mat) {
if (a2 >= 0 && a2 <= 26)
*mat = rob_chr->data.field_1E68.field_78[a2];
}
-26
View File
@@ -1,26 +0,0 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#pragma once
#include "../../KKdLib/default.h"
#include "../../KKdLib/vec.h"
#include "../camera.h"
#include "../render_texture.h"
#include "../shared.h"
struct post_process_exposure {
render_texture exposure_history;
render_texture exposure;
int32_t exposure_history_counter;
post_process_exposure();
};
extern post_process_exposure* post_process_exposure_init();
extern void post_process_get_exposure(post_process_exposure* exp, camera* cam, int32_t render_width,
int32_t render_height, bool reset_exposure, GLuint in_tex_0, GLuint in_tex_1);
extern void post_process_exposure_init_fbo(post_process_exposure* exp);
extern void post_process_exposure_dispose(post_process_exposure* exp);
+35
View File
@@ -0,0 +1,35 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#pragma once
#include "../../KKdLib/default.hpp"
#include "../../KKdLib/vec.hpp"
#include "../camera.h"
#include "../render_texture.h"
#include "../shared.h"
struct post_process_exposure_chara_data {
vec4 field_0[8];
float_t field_80;
GLuint query[3];
GLuint query_data[3];
};
struct post_process_exposure {
render_texture exposure_history;
render_texture exposure;
int32_t exposure_history_counter;
post_process_exposure_chara_data* chara_data;
int32_t query_index;
post_process_exposure();
virtual ~post_process_exposure();
void get_exposure(camera* cam, int32_t render_width, int32_t render_height,
bool reset_exposure, GLuint in_tex_0, GLuint in_tex_1);
void get_exposure_chara_data(void* pp, camera* cam);
void init_fbo();
};
-436
View File
@@ -1,436 +0,0 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#include "tone_map.h"
#include "../fbo.hpp"
#include "../gl_state.h"
#include "../post_process.hpp"
#include "../shader_ft.h"
static void post_process_tone_map_free_fbo(post_process_tone_map* tm);
static void post_process_tone_map_calculate_data(post_process_tone_map* tm);
static void post_process_tone_map_calculate_tex(post_process_tone_map* tm);
post_process_tone_map* post_process_tone_map_init() {
post_process_tone_map* exp = force_malloc_s(post_process_tone_map, 1);
return exp;
}
void post_process_apply_tone_map(post_process_tone_map* tm,
render_texture* in_tex, texture* light_proj_tex, texture* back_2d_tex,
render_texture* rt, render_texture* buf_rt, render_texture* contour_rt,
GLuint in_tex_0, GLuint in_tex_1, int32_t npr_param) {
if (!tm)
return;
if (tm->data.update) {
post_process_tone_map_calculate_data(tm);
tm->data.update = false;
}
if (tm->data.update_tex) {
post_process_tone_map_calculate_tex(tm);
glBindTexture(GL_TEXTURE_1D, tm->tone_map);
glTexImage1D(GL_TEXTURE_1D, 0, GL_RG16F,
16 * POST_PROCESS_TONE_MAP_SAT_GAMMA_SAMPLES, 0, GL_RG, GL_FLOAT, tm->data.tex);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
GLint swizzle[] = { GL_RED, GL_RED, GL_RED, GL_GREEN };
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteriv(GL_TEXTURE_1D, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
glBindTexture(GL_TEXTURE_1D, 0);
tm->data.update_tex = false;
}
mat4 lens_flare_mat;
mat4 lens_shaft_mat;
mat4_scale(1.0f, (float_t)rt->color_texture->height
/ (float_t)rt->color_texture->width, 1.0f, &lens_flare_mat);
mat4_scale(1.0f, (float_t)rt->color_texture->height
/ (float_t)rt->color_texture->width, 1.0f, &lens_shaft_mat);
uniform_value[U16] = 0;
uniform_value[U_TONE_MAP] = (int32_t)tm->data.tone_map_method;
uniform_value[U_FLARE] = 0;
uniform_value[U_SCENE_FADE] = tm->data.scene_fade.w > 0.009999999f ? 1 : 0;
uniform_value[U_AET_BACK] = 0;
uniform_value[U_LIGHT_PROJ] = 0;
uniform_value[U_NPR] = 0;
uniform_value[U25] = 0;
glViewport(0, 0, rt->color_texture->width, rt->color_texture->height);
render_texture_bind(buf_rt, 0);
shader_set(&shaders_ft, SHADER_FT_TONEMAP);
shader_state_matrix_set_texture(&shaders_ft, 4, &lens_flare_mat);
shader_state_matrix_set_texture(&shaders_ft, 5, &lens_shaft_mat);
shader_local_vert_set_ptr(&shaders_ft, 1, &tm->shader_data.p_exposure);
shader_local_frag_set_ptr(&shaders_ft, 1, &tm->shader_data.p_flare_coef);
shader_local_frag_set_ptr(&shaders_ft, 2, &tm->shader_data.p_fade_color);
shader_local_frag_set_ptr(&shaders_ft, 4, &tm->shader_data.p_tone_scale);
shader_local_frag_set_ptr(&shaders_ft, 5, &tm->shader_data.p_tone_offset);
shader_local_frag_set_ptr(&shaders_ft, 6, &tm->shader_data.p_fade_func);
shader_local_frag_set_ptr(&shaders_ft, 7, &tm->shader_data.p_inv_tone);
gl_state_active_bind_texture_2d(0, in_tex->color_texture->tex);
gl_state_active_bind_texture_2d(1, in_tex_0);
gl_state_active_bind_texture_2d(2, 0);
gl_state_active_texture(2);
glBindTexture(GL_TEXTURE_1D, tm->tone_map);
gl_state_active_bind_texture_2d(3, in_tex_1);
if (uniform_value[U_LIGHT_PROJ] && light_proj_tex)
gl_state_active_bind_texture_2d(6, light_proj_tex->tex);
else if (uniform_value[U_AET_BACK] && back_2d_tex)
gl_state_active_bind_texture_2d(6, back_2d_tex->tex);
if (npr_param == 1) {
gl_state_active_bind_texture_2d(16, contour_rt->color_texture->tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl_state_active_bind_texture_2d(17, contour_rt->depth_texture->tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl_state_active_bind_texture_2d(14, rt->depth_texture->tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
render_texture_draw_custom(&shaders_ft);
gl_state_active_texture(2);
glBindTexture(GL_TEXTURE_1D, 0);
uniform_value[U16] = 1;
fbo::blit(buf_rt->fbos[0], rt->fbos[0],
0, 0, buf_rt->color_texture->width, buf_rt->color_texture->height,
0, 0, rt->color_texture->width, rt->color_texture->height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
}
void post_process_tone_map_init_fbo(post_process_tone_map* tm) {
if (!tm)
return;
if (!tm->tone_map)
glGenTextures(1, &tm->tone_map);
}
void post_process_tone_map_dispose(post_process_tone_map* tm) {
if (!tm)
return;
post_process_tone_map_free_fbo(tm);
free(tm);
}
static void post_process_tone_map_free_fbo(post_process_tone_map* tm) {
glDeleteTextures(1, &tm->tone_map);
}
void post_process_tone_map_initialize_data(post_process_tone_map* tm, float_t exposure, bool auto_exposure,
float_t gamma, int32_t saturate_power, float_t saturate_coeff,
const vec3* scene_fade, float_t scene_fade_alpha, int32_t scene_fade_blend_func,
const vec3* tone_trans_start, const vec3* tone_trans_end, tone_map_method tone_map_method) {
post_process_tone_map_initialize_rate(tm, exposure, auto_exposure, 1.0f,
gamma, saturate_power, saturate_coeff, scene_fade, scene_fade_alpha, scene_fade_blend_func,
tone_trans_start, tone_trans_end, tone_map_method);
}
void post_process_tone_map_initialize_rate(post_process_tone_map* tm, float_t exposure, bool auto_exposure,
float_t gamma, float_t gamma_rate, int32_t saturate_power, float_t saturate_coeff,
const vec3* scene_fade, float_t scene_fade_alpha, int32_t scene_fade_blend_func,
const vec3* tone_trans_start, const vec3* tone_trans_end, tone_map_method tone_map_method) {
tm->data.exposure = clamp(exposure, 0.0f, 4.0f);
tm->data.auto_exposure = auto_exposure;
tm->data.gamma = clamp(gamma, 0.2f, 2.2f);
tm->data.gamma_rate = clamp(gamma_rate, 0.5f, 2.0f);
tm->data.saturate_power = clamp(saturate_power, 1, 6);
tm->data.saturate_coeff = clamp(saturate_coeff, 0.0f, 1.0f);
tm->data.scene_fade.x = clamp(scene_fade->x, 0.0f, 1.0f);
tm->data.scene_fade.y = clamp(scene_fade->y, 0.0f, 1.0f);
tm->data.scene_fade.z = clamp(scene_fade->z, 0.0f, 1.0f);
tm->data.scene_fade.w = clamp(scene_fade_alpha, 0.0f, 1.0f);
tm->data.scene_fade_blend_func = clamp(scene_fade_blend_func, 0, 2);
tm->data.tone_trans_start.x = clamp(tone_trans_start->x, 0.0f, 1.0f);
tm->data.tone_trans_start.y = clamp(tone_trans_start->y, 0.0f, 1.0f);
tm->data.tone_trans_start.z = clamp(tone_trans_start->z, 0.0f, 1.0f);
tm->data.tone_trans_end.x = clamp(tone_trans_end->x, 0.0f, 1.0f);
tm->data.tone_trans_end.y = clamp(tone_trans_end->y, 0.0f, 1.0f);
tm->data.tone_trans_end.z = clamp(tone_trans_end->z, 0.0f, 1.0f);
tm->data.tone_map_method = clamp(tone_map_method, TONE_MAP_YCC_EXPONENT, TONE_MAP_RGB_LINEAR2);
tm->data.update_tex = false;
tm->data.update = true;
tm->data.update_tex = true;
}
inline float_t post_process_tone_map_get_exposure(post_process_tone_map* tm) {
return tm->data.exposure;
}
inline void post_process_tone_map_set_exposure(post_process_tone_map* tm, float_t value) {
value = clamp(value, 0.0f, 4.0f);
if (value != tm->data.exposure) {
tm->data.exposure = value;
tm->data.update = true;
tm->data.update_tex = true;
}
}
inline bool post_process_tone_map_get_auto_exposure(post_process_tone_map* tm) {
return tm->data.auto_exposure;
}
inline void post_process_tone_map_set_auto_exposure(post_process_tone_map* tm, bool value) {
if (value != tm->data.auto_exposure) {
tm->data.auto_exposure = value;
tm->data.update = true;
tm->data.update_tex = true;
}
}
inline float_t post_process_tone_map_get_gamma(post_process_tone_map* tm) {
return tm->data.gamma;
}
inline void post_process_tone_map_set_gamma(post_process_tone_map* tm, float_t value) {
value = clamp(value, 0.2f, 2.2f);
if (value != tm->data.gamma) {
tm->data.gamma = value;
tm->data.update = true;
tm->data.update_tex = true;
}
}
inline float_t post_process_tone_map_get_gamma_rate(post_process_tone_map* tm) {
return tm->data.gamma_rate;
}
inline void post_process_tone_map_set_gamma_rate(post_process_tone_map* tm, float_t value) {
value = clamp(value, 0.5f, 2.0f);
if (value != tm->data.gamma_rate) {
tm->data.gamma_rate = value;
tm->data.update_tex = true;
}
}
inline int32_t post_process_tone_map_get_saturate_power(post_process_tone_map* tm) {
return tm->data.saturate_power;
}
inline void post_process_tone_map_set_saturate_power(post_process_tone_map* tm, int32_t value) {
value = clamp(value, 1, 6);
if (value != tm->data.saturate_power) {
tm->data.saturate_power = value;
tm->data.update_tex = true;
}
}
inline float_t post_process_tone_map_get_saturate_coeff(post_process_tone_map* tm) {
return tm->data.saturate_coeff;
}
inline void post_process_tone_map_set_saturate_coeff(post_process_tone_map* tm, float_t value) {
value = clamp(value, 0.0f, 1.0f);
if (value != tm->data.saturate_coeff) {
tm->data.saturate_coeff = value;
tm->data.update_tex = true;
}
}
inline void post_process_tone_map_get_scene_fade(post_process_tone_map* tm, vec4* value) {
*value = tm->data.scene_fade;
}
inline void post_process_tone_map_set_scene_fade(post_process_tone_map* tm, const vec4* value) {
vec4 temp;
temp.x = clamp(value->x, 0.0f, 1.0f);
temp.y = clamp(value->y, 0.0f, 1.0f);
temp.z = clamp(value->z, 0.0f, 1.0f);
temp.w = clamp(value->w, 0.0f, 1.0f);
if (temp.x != tm->data.scene_fade.x
|| temp.y != tm->data.scene_fade.y
|| temp.z != tm->data.scene_fade.z
|| temp.w != tm->data.scene_fade.w) {
tm->data.scene_fade = temp;
tm->data.update = true;
}
}
inline void post_process_tone_map_get_scene_fade_color(post_process_tone_map* tm, vec3* value) {
*value = *(vec3*)&tm->data.scene_fade;
}
inline void post_process_tone_map_set_scene_fade_color(post_process_tone_map* tm, const vec3* value) {
vec3 temp;
temp.x = clamp(value->x, 0.0f, 1.0f);
temp.y = clamp(value->y, 0.0f, 1.0f);
temp.z = clamp(value->z, 0.0f, 1.0f);
if (temp.x != tm->data.scene_fade.x
|| temp.y != tm->data.scene_fade.y
|| temp.z != tm->data.scene_fade.z) {
*(vec3*)&tm->data.scene_fade = temp;
tm->data.update = true;
}
}
inline float_t post_process_tone_map_get_scene_fade_alpha(post_process_tone_map* tm) {
return tm->data.scene_fade.w;
}
inline void post_process_tone_map_set_scene_fade_alpha(post_process_tone_map* tm, float_t value) {
value = clamp(value, 0.0f, 1.0f);
if (value != tm->data.scene_fade.w) {
tm->data.scene_fade.w = value;
tm->data.update = true;
}
}
inline int32_t post_process_tone_map_get_scene_fade_blend_func(post_process_tone_map* tm) {
return tm->data.scene_fade_blend_func;
}
inline void post_process_tone_map_set_scene_fade_blend_func(post_process_tone_map* tm, int32_t value) {
value = clamp(value, 0, 2);
if (value != tm->data.scene_fade_blend_func) {
tm->data.scene_fade_blend_func = value;
tm->data.update = true;
}
}
inline void post_process_tone_map_get_tone_trans_start(post_process_tone_map* tm, vec3* value) {
*value = tm->data.tone_trans_start;
}
inline void post_process_tone_map_set_tone_trans_start(post_process_tone_map* tm, const vec3* value) {
vec3 temp;
temp.x = clamp(value->x, 0.0f, 1.0f);
temp.y = clamp(value->y, 0.0f, 1.0f);
temp.z = clamp(value->z, 0.0f, 1.0f);
if (temp.x != tm->data.tone_trans_start.x
|| temp.y != tm->data.tone_trans_start.y
|| temp.z != tm->data.tone_trans_start.z) {
tm->data.tone_trans_start = temp;
tm->data.update = true;
}
}
inline void post_process_tone_map_get_tone_trans_end(post_process_tone_map* tm, vec3* value) {
*value = tm->data.tone_trans_end;
}
inline void post_process_tone_map_set_tone_trans_end(post_process_tone_map* tm, const vec3* value) {
vec3 temp;
temp.x = clamp(value->x, 0.009999999776f, 1.0f);
temp.y = clamp(value->y, 0.009999999776f, 1.0f);
temp.z = clamp(value->z, 0.009999999776f, 1.0f);
if (temp.x != tm->data.tone_trans_end.x
|| temp.y != tm->data.tone_trans_end.y
|| temp.z != tm->data.tone_trans_end.z) {
tm->data.tone_trans_end = temp;
tm->data.update = true;
}
}
inline tone_map_method post_process_tone_map_get_tone_map_method(post_process_tone_map* tm) {
return tm->data.tone_map_method;
}
inline void post_process_tone_map_set_tone_map_method(post_process_tone_map* tm, tone_map_method value) {
value = clamp(value, TONE_MAP_YCC_EXPONENT, TONE_MAP_RGB_LINEAR2);
if (value != tm->data.tone_map_method) {
tm->data.tone_map_method = value;
tm->data.update = true;
}
}
inline float_t post_process_tone_map_get_lens_flare(post_process_tone_map* tm) {
return tm->data.lens_flare;
}
inline void post_process_tone_map_set_lens_flare(post_process_tone_map* tm, float_t value) {
value = clamp(value, 0.0f, 1.0f);
if (value != tm->data.lens_flare) {
tm->data.lens_flare = value;
tm->data.update = true;
}
}
inline float_t post_process_tone_map_get_lens_shaft(post_process_tone_map* tm) {
return tm->data.lens_shaft;
}
inline void post_process_tone_map_set_lens_shaft(post_process_tone_map* tm, float_t value) {
value = clamp(value, 0.0f, 1.0f);
if (value != tm->data.lens_shaft) {
tm->data.lens_shaft = value;
tm->data.update = true;
}
}
inline float_t post_process_tone_map_get_lens_ghost(post_process_tone_map* tm) {
return tm->data.lens_ghost;
}
inline void post_process_tone_map_set_lens_ghost(post_process_tone_map* tm, float_t value) {
tm->data.lens_ghost = clamp(value, 0.0f, 1.0f);
}
static void post_process_tone_map_calculate_data(post_process_tone_map* tm) {
vec3 tone_trans, tone_trans_scale, tone_trans_offset;
vec3_sub(tm->data.tone_trans_end, tm->data.tone_trans_start, tone_trans);
vec3_rcp(tone_trans, tone_trans_scale);
vec3_mult(tone_trans_scale, tm->data.tone_trans_start, tone_trans_offset);
vec3_negate(tone_trans_offset, tone_trans_offset);
post_process_tone_map_shader_data* v = &tm->shader_data;
v->p_exposure.x = tm->data.exposure;
v->p_exposure.y = 0.0625f;
v->p_exposure.z = tm->data.exposure * 0.5f;
v->p_exposure.w = tm->data.auto_exposure ? 1.0f : 0.0f;
v->p_flare_coef.x = (tm->data.lens_flare * 2.0f)
* (tm->data.lens_flare_appear_power + tm->data.lens_flare_power);
v->p_flare_coef.y = tm->data.lens_shaft * 2.0f;
v->p_flare_coef.z = 0.0f;
v->p_flare_coef.w = 0.0f;
v->p_fade_color = tm->data.scene_fade;
if (tm->data.scene_fade_blend_func == 1 || tm->data.scene_fade_blend_func == 2)
vec3_mult_scalar(*(vec3*)&v->p_fade_color, v->p_fade_color.w, *(vec3*)&v->p_fade_color);
v->p_tone_scale.x = tone_trans_scale.x;
v->p_tone_scale.y = tone_trans_scale.y;
v->p_tone_scale.z = tone_trans_scale.z;
v->p_tone_offset.x = tone_trans_offset.x;
v->p_tone_offset.y = tone_trans_offset.y;
v->p_tone_offset.z = tone_trans_offset.z;
v->p_fade_func.x = (float_t)tm->data.scene_fade_blend_func;
v->p_inv_tone.x = tm->data.gamma > 0.0f ? 2.0f / (tm->data.gamma * 3.0f) : 0.0f;
}
static void post_process_tone_map_calculate_tex(post_process_tone_map* tm) {
const float_t post_process_tone_map__scale = (float_t)(1.0 / (double_t)POST_PROCESS_TONE_MAP_SAT_GAMMA_SAMPLES);
const int32_t post_process_tone_map__size = 16 * POST_PROCESS_TONE_MAP_SAT_GAMMA_SAMPLES;
int32_t i, j;
int32_t saturate_power;
float_t saturate_coeff;
vec2* tex = tm->data.tex;
float_t gamma_power, gamma, saturation;
gamma_power = tm->data.gamma * tm->data.gamma_rate * 1.5f;
saturate_power = tm->data.saturate_power;
saturate_coeff = tm->data.saturate_coeff;
tex[0].x = 0.0f;
tex[0].y = 0.0f;
for (i = 1; i < post_process_tone_map__size; i++) {
gamma = powf(1.0f - expf(-i * post_process_tone_map__scale), gamma_power);
saturation = gamma * 2.0f - 1.0f;
for (j = 0; j < saturate_power; j++) {
saturation *= saturation;
saturation *= saturation;
saturation *= saturation;
saturation *= saturation;
}
tex[i].x = gamma;
tex[i].y = gamma * saturate_coeff
* ((float_t)POST_PROCESS_TONE_MAP_SAT_GAMMA_SAMPLES / (float_t)i) * (1.0f - saturation);
}
}
+429
View File
@@ -0,0 +1,429 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#include "tone_map.hpp"
#include "../fbo.hpp"
#include "../gl_state.h"
#include "../post_process.hpp"
#include "../shader_ft.h"
static void post_process_tone_map_calculate_data(post_process_tone_map* tm);
static void post_process_tone_map_calculate_tex(post_process_tone_map* tm);
post_process_tone_map::post_process_tone_map() : data(), shader_data(), tone_map() {
}
post_process_tone_map::~post_process_tone_map() {
if (!this)
return;
glDeleteTextures(1, &tone_map);
}
void post_process_tone_map::apply(render_texture* in_tex, texture* light_proj_tex, texture* back_2d_tex,
render_texture* rt, render_texture* buf_rt, render_texture* contour_rt,
GLuint in_tex_0, GLuint in_tex_1, int32_t npr_param) {
if (!this)
return;
if (data.update) {
post_process_tone_map_calculate_data(this);
data.update = false;
}
if (data.update_tex) {
post_process_tone_map_calculate_tex(this);
glBindTexture(GL_TEXTURE_1D, tone_map);
glTexImage1D(GL_TEXTURE_1D, 0, GL_RG16F,
16 * POST_PROCESS_TONE_MAP_SAT_GAMMA_SAMPLES, 0, GL_RG, GL_FLOAT, data.tex);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
GLint swizzle[] = { GL_RED, GL_RED, GL_RED, GL_GREEN };
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteriv(GL_TEXTURE_1D, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
glBindTexture(GL_TEXTURE_1D, 0);
data.update_tex = false;
}
mat4 lens_flare_mat;
mat4 lens_shaft_mat;
mat4_scale(1.0f, (float_t)rt->color_texture->height
/ (float_t)rt->color_texture->width, 1.0f, &lens_flare_mat);
mat4_scale(1.0f, (float_t)rt->color_texture->height
/ (float_t)rt->color_texture->width, 1.0f, &lens_shaft_mat);
uniform_value[U16] = 0;
uniform_value[U_TONE_MAP] = (int32_t)data.tone_map_method;
uniform_value[U_FLARE] = 0;
uniform_value[U_SCENE_FADE] = data.scene_fade.w > 0.009999999f ? 1 : 0;
uniform_value[U_AET_BACK] = 0;
uniform_value[U_LIGHT_PROJ] = 0;
uniform_value[U_NPR] = 0;
uniform_value[U25] = 0;
glViewport(0, 0, rt->color_texture->width, rt->color_texture->height);
render_texture_bind(buf_rt, 0);
shaders_ft.set(SHADER_FT_TONEMAP);
shaders_ft.state_matrix_set_texture(4, lens_flare_mat);
shaders_ft.state_matrix_set_texture(5, lens_shaft_mat);
shaders_ft.local_vert_set(1, shader_data.p_exposure);
shaders_ft.local_frag_set(1, shader_data.p_flare_coef);
shaders_ft.local_frag_set(2, shader_data.p_fade_color);
shaders_ft.local_frag_set(4, shader_data.p_tone_scale);
shaders_ft.local_frag_set(5, shader_data.p_tone_offset);
shaders_ft.local_frag_set(6, shader_data.p_fade_func);
shaders_ft.local_frag_set(7, shader_data.p_inv_tone);
gl_state_active_bind_texture_2d(0, in_tex->color_texture->tex);
gl_state_active_bind_texture_2d(1, in_tex_0);
gl_state_active_bind_texture_2d(2, 0);
gl_state_active_texture(2);
glBindTexture(GL_TEXTURE_1D, tone_map);
gl_state_active_bind_texture_2d(3, in_tex_1);
if (uniform_value[U_LIGHT_PROJ] && light_proj_tex)
gl_state_active_bind_texture_2d(6, light_proj_tex->tex);
else if (uniform_value[U_AET_BACK] && back_2d_tex)
gl_state_active_bind_texture_2d(6, back_2d_tex->tex);
if (npr_param == 1) {
gl_state_active_bind_texture_2d(16, contour_rt->color_texture->tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl_state_active_bind_texture_2d(17, contour_rt->depth_texture->tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl_state_active_bind_texture_2d(14, rt->depth_texture->tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
render_texture_draw_custom(&shaders_ft);
gl_state_active_texture(2);
glBindTexture(GL_TEXTURE_1D, 0);
uniform_value[U16] = 1;
fbo::blit(buf_rt->fbos[0], rt->fbos[0],
0, 0, buf_rt->color_texture->width, buf_rt->color_texture->height,
0, 0, rt->color_texture->width, rt->color_texture->height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
}
void post_process_tone_map::init_fbo() {
if (!this)
return;
if (!tone_map)
glGenTextures(1, &tone_map);
}
void post_process_tone_map::initialize_data(float_t exposure, bool auto_exposure,
float_t gamma, int32_t saturate_power, float_t saturate_coeff,
const vec3& scene_fade_color, float_t scene_fade_alpha, int32_t scene_fade_blend_func,
const vec3& tone_trans_start, const vec3& tone_trans_end, tone_map_method tone_map_method) {
initialize_data(exposure, auto_exposure, 1.0f, gamma, saturate_power, saturate_coeff,
scene_fade_color, scene_fade_alpha, scene_fade_blend_func,
tone_trans_start, tone_trans_end, tone_map_method);
}
void post_process_tone_map::initialize_data(float_t exposure, bool auto_exposure,
float_t gamma, float_t gamma_rate, int32_t saturate_power, float_t saturate_coeff,
const vec3& scene_fade_color, float_t scene_fade_alpha, int32_t scene_fade_blend_func,
const vec3& tone_trans_start, const vec3& tone_trans_end, tone_map_method tone_map_method) {
data.exposure = clamp(exposure, 0.0f, 4.0f);
data.auto_exposure = auto_exposure;
data.gamma = clamp(gamma, 0.2f, 2.2f);
data.gamma_rate = clamp(gamma_rate, 0.5f, 2.0f);
data.saturate_power = clamp(saturate_power, 1, 6);
data.saturate_coeff = clamp(saturate_coeff, 0.0f, 1.0f);
data.scene_fade.x = clamp(scene_fade_color.x, 0.0f, 1.0f);
data.scene_fade.y = clamp(scene_fade_color.y, 0.0f, 1.0f);
data.scene_fade.z = clamp(scene_fade_color.z, 0.0f, 1.0f);
data.scene_fade.w = clamp(scene_fade_alpha, 0.0f, 1.0f);
data.scene_fade_blend_func = clamp(scene_fade_blend_func, 0, 2);
data.tone_trans_start.x = clamp(tone_trans_start.x, 0.0f, 1.0f);
data.tone_trans_start.y = clamp(tone_trans_start.y, 0.0f, 1.0f);
data.tone_trans_start.z = clamp(tone_trans_start.z, 0.0f, 1.0f);
data.tone_trans_end.x = clamp(tone_trans_end.x, 0.0f, 1.0f);
data.tone_trans_end.y = clamp(tone_trans_end.y, 0.0f, 1.0f);
data.tone_trans_end.z = clamp(tone_trans_end.z, 0.0f, 1.0f);
data.tone_map_method = clamp(tone_map_method, TONE_MAP_YCC_EXPONENT, TONE_MAP_RGB_LINEAR2);
data.update_tex = false;
data.update = true;
data.update_tex = true;
}
bool post_process_tone_map::get_auto_exposure() {
return data.auto_exposure;
}
void post_process_tone_map::set_auto_exposure(bool value) {
if (value != data.auto_exposure) {
data.auto_exposure = value;
data.update = true;
data.update_tex = true;
}
}
float_t post_process_tone_map::get_exposure() {
return data.exposure;
}
void post_process_tone_map::set_exposure(float_t value) {
value = clamp(value, 0.0f, 4.0f);
if (value != data.exposure) {
data.exposure = value;
data.update = true;
data.update_tex = true;
}
}
float_t post_process_tone_map::get_gamma() {
return data.gamma;
}
void post_process_tone_map::set_gamma(float_t value) {
value = clamp(value, 0.2f, 2.2f);
if (value != data.gamma) {
data.gamma = value;
data.update = true;
data.update_tex = true;
}
}
float_t post_process_tone_map::get_gamma_rate() {
return data.gamma_rate;
}
void post_process_tone_map::set_gamma_rate(float_t value) {
value = clamp(value, 0.5f, 2.0f);
if (value != data.gamma_rate) {
data.gamma_rate = value;
data.update_tex = true;
}
}
float_t post_process_tone_map::get_lens_flare() {
return data.lens_flare;
}
void post_process_tone_map::set_lens_flare(float_t value) {
value = clamp(value, 0.0f, 1.0f);
if (value != data.lens_flare) {
data.lens_flare = value;
data.update = true;
}
}
float_t post_process_tone_map::get_lens_ghost() {
return data.lens_ghost;
}
void post_process_tone_map::set_lens_ghost(float_t value) {
data.lens_ghost = clamp(value, 0.0f, 1.0f);
}
float_t post_process_tone_map::get_lens_shaft() {
return data.lens_shaft;
}
void post_process_tone_map::set_lens_shaft(float_t value) {
value = clamp(value, 0.0f, 1.0f);
if (value != data.lens_shaft) {
data.lens_shaft = value;
data.update = true;
}
}
float_t post_process_tone_map::get_saturate_coeff() {
return data.saturate_coeff;
}
void post_process_tone_map::set_saturate_coeff(float_t value) {
value = clamp(value, 0.0f, 1.0f);
if (value != data.saturate_coeff) {
data.saturate_coeff = value;
data.update_tex = true;
}
}
int32_t post_process_tone_map::get_saturate_power() {
return data.saturate_power;
}
void post_process_tone_map::set_saturate_power(int32_t value) {
value = clamp(value, 1, 6);
if (value != data.saturate_power) {
data.saturate_power = value;
data.update_tex = true;
}
}
vec4 post_process_tone_map::get_scene_fade() {
return data.scene_fade;
}
void post_process_tone_map::set_scene_fade(const vec4& value) {
vec4 temp;
temp.x = clamp(value.x, 0.0f, 1.0f);
temp.y = clamp(value.y, 0.0f, 1.0f);
temp.z = clamp(value.z, 0.0f, 1.0f);
temp.z = clamp(value.w, 0.0f, 1.0f);
if (memcmp(&temp, &data.scene_fade, sizeof(vec4))) {
data.scene_fade = temp;
data.update = true;
}
}
float_t post_process_tone_map::get_scene_fade_alpha() {
return data.scene_fade.w;
}
void post_process_tone_map::set_scene_fade_alpha(float_t value) {
value = clamp(value, 0.0f, 1.0f);
if (value != data.scene_fade.w) {
data.scene_fade.w = value;
data.update = true;
}
}
int32_t post_process_tone_map::get_scene_fade_blend_func() {
return data.scene_fade_blend_func;
}
void post_process_tone_map::set_scene_fade_blend_func(int32_t value) {
value = clamp(value, 0, 2);
if (value != data.scene_fade_blend_func) {
data.scene_fade_blend_func = value;
data.update = true;
}
}
vec3 post_process_tone_map::get_scene_fade_color() {
return *(vec3*)&data.scene_fade;
}
void post_process_tone_map::set_scene_fade_color(const vec3& value) {
vec3 temp;
temp.x = clamp(value.x, 0.0f, 1.0f);
temp.y = clamp(value.y, 0.0f, 1.0f);
temp.z = clamp(value.z, 0.0f, 1.0f);
if (memcmp(&temp, &data.scene_fade, sizeof(vec3))) {
*(vec3*)&data.scene_fade = temp;
data.update = true;
}
}
tone_map_method post_process_tone_map::get_tone_map_method() {
return data.tone_map_method;
}
void post_process_tone_map::set_tone_map_method(tone_map_method value) {
value = clamp(value, TONE_MAP_YCC_EXPONENT, TONE_MAP_RGB_LINEAR2);
if (value != data.tone_map_method) {
data.tone_map_method = value;
data.update = true;
}
}
void post_process_tone_map::get_tone_trans(vec3& start, vec3& end) {
start = get_tone_trans_start();
end = get_tone_trans_start();
}
void post_process_tone_map::set_tone_trans(const vec3& start, const vec3& end) {
set_tone_trans_start(start);
set_tone_trans_end(end);
}
vec3 post_process_tone_map::get_tone_trans_end() {
return data.tone_trans_end;
}
void post_process_tone_map::set_tone_trans_end(const vec3& value) {
vec3 temp;
temp.x = clamp(value.x, 0.0f, 1.0f);
temp.y = clamp(value.y, 0.0f, 1.0f);
temp.z = clamp(value.z, 0.0f, 1.0f);
if (memcmp(&temp, &data.tone_trans_end, sizeof(vec3))) {
data.tone_trans_end = temp;
data.update = true;
}
}
vec3 post_process_tone_map::get_tone_trans_start() {
return data.tone_trans_start;
}
void post_process_tone_map::set_tone_trans_start(const vec3& value) {
vec3 temp;
temp.x = clamp(value.x, 0.0f, 1.0f);
temp.y = clamp(value.y, 0.0f, 1.0f);
temp.z = clamp(value.z, 0.0f, 1.0f);
if (memcmp(&temp, &data.tone_trans_start, sizeof(vec3))) {
data.tone_trans_start = temp;
data.update = true;
}
}
static void post_process_tone_map_calculate_data(post_process_tone_map* tm) {
vec3 tone_trans, tone_trans_scale, tone_trans_offset;
vec3_sub(tm->data.tone_trans_end, tm->data.tone_trans_start, tone_trans);
vec3_rcp(tone_trans, tone_trans_scale);
vec3_mult(tone_trans_scale, tm->data.tone_trans_start, tone_trans_offset);
vec3_negate(tone_trans_offset, tone_trans_offset);
post_process_tone_map_shader_data* v = &tm->shader_data;
v->p_exposure.x = tm->data.exposure;
v->p_exposure.y = 0.0625f;
v->p_exposure.z = tm->data.exposure * 0.5f;
v->p_exposure.w = tm->data.auto_exposure ? 1.0f : 0.0f;
v->p_flare_coef.x = (tm->data.lens_flare * 2.0f)
* (tm->data.lens_flare_appear_power + tm->data.lens_flare_power);
v->p_flare_coef.y = tm->data.lens_shaft * 2.0f;
v->p_flare_coef.z = 0.0f;
v->p_flare_coef.w = 0.0f;
v->p_fade_color = tm->data.scene_fade;
if (tm->data.scene_fade_blend_func == 1 || tm->data.scene_fade_blend_func == 2)
vec3_mult_scalar(*(vec3*)&v->p_fade_color, v->p_fade_color.w, *(vec3*)&v->p_fade_color);
v->p_tone_scale.x = tone_trans_scale.x;
v->p_tone_scale.y = tone_trans_scale.y;
v->p_tone_scale.z = tone_trans_scale.z;
v->p_tone_offset.x = tone_trans_offset.x;
v->p_tone_offset.y = tone_trans_offset.y;
v->p_tone_offset.z = tone_trans_offset.z;
v->p_fade_func.x = (float_t)tm->data.scene_fade_blend_func;
v->p_inv_tone.x = tm->data.gamma > 0.0f ? 2.0f / (tm->data.gamma * 3.0f) : 0.0f;
}
static void post_process_tone_map_calculate_tex(post_process_tone_map* tm) {
const float_t post_process_tone_map__scale = (float_t)(1.0 / (double_t)POST_PROCESS_TONE_MAP_SAT_GAMMA_SAMPLES);
const int32_t post_process_tone_map__size = 16 * POST_PROCESS_TONE_MAP_SAT_GAMMA_SAMPLES;
int32_t i, j;
int32_t saturate_power;
float_t saturate_coeff;
vec2* tex = tm->data.tex;
float_t gamma_power, gamma, saturation;
gamma_power = tm->data.gamma * tm->data.gamma_rate * 1.5f;
saturate_power = tm->data.saturate_power;
saturate_coeff = tm->data.saturate_coeff;
tex[0].x = 0.0f;
tex[0].y = 0.0f;
for (i = 1; i < post_process_tone_map__size; i++) {
gamma = powf(1.0f - expf(-i * post_process_tone_map__scale), gamma_power);
saturation = gamma * 2.0f - 1.0f;
for (j = 0; j < saturate_power; j++) {
saturation *= saturation;
saturation *= saturation;
saturation *= saturation;
saturation *= saturation;
}
tex[i].x = gamma;
tex[i].y = gamma * saturate_coeff
* ((float_t)POST_PROCESS_TONE_MAP_SAT_GAMMA_SAMPLES / (float_t)i) * (1.0f - saturation);
}
}
-101
View File
@@ -1,101 +0,0 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#pragma once
#include "../../KKdLib/default.h"
#include "../../KKdLib/light_param/glow.hpp"
#include "../../KKdLib/vec.h"
#include "../shared.h"
#include "../render_texture.h"
#define POST_PROCESS_TONE_MAP_SAT_GAMMA_SAMPLES 32
struct post_process_tone_map_shader_data {
vec4 p_exposure;
vec4 p_flare_coef;
vec4 p_fade_color;
vec4 p_tone_scale;
vec4 p_tone_offset;
vec4 p_fade_func;
vec4 p_inv_tone;
};
struct post_process_tone_map_data {
vec2 tex[16 * POST_PROCESS_TONE_MAP_SAT_GAMMA_SAMPLES];
float_t exposure;
bool auto_exposure;
float_t gamma;
float_t gamma_rate;
int32_t saturate_power;
float_t saturate_coeff;
vec4 scene_fade;
int32_t scene_fade_blend_func;
vec3 tone_trans_start;
vec3 tone_trans_end;
tone_map_method tone_map_method;
float_t lens_flare;
float_t lens_shaft;
float_t lens_ghost;
float_t lens_flare_power;
float_t lens_flare_appear_power;
bool update;
bool update_tex;
};
struct post_process_tone_map {
post_process_tone_map_data data;
post_process_tone_map_shader_data shader_data;
GLuint tone_map;
};
extern post_process_tone_map* post_process_tone_map_init();
extern void post_process_apply_tone_map(post_process_tone_map* tm,
render_texture* in_tex, texture* light_proj_tex, texture* back_2d_tex,
render_texture* rt, render_texture* buf_rt, render_texture* contour_rt,
GLuint in_tex_0, GLuint in_tex_1, int32_t npr_param);
extern void post_process_tone_map_init_fbo(post_process_tone_map* tm);
extern void post_process_tone_map_dispose(post_process_tone_map* tm);
extern void post_process_tone_map_initialize_data(post_process_tone_map* tm, float_t exposure, bool auto_exposure,
float_t gamma, int32_t saturate_power, float_t saturate_coeff,
const vec3* scene_fade_color, float_t scene_fade_alpha, int32_t scene_fade_blend_func,
const vec3* tone_trans_start, const vec3* tone_trans_end, tone_map_method tone_map_method);
extern void post_process_tone_map_initialize_rate(post_process_tone_map* tm, float_t exposure, bool auto_exposure,
float_t gamma, float_t gamma_rate, int32_t saturate_power, float_t saturate_coeff,
const vec3* scene_fade_color, float_t scene_fade_alpha, int32_t scene_fade_blend_func,
const vec3* tone_trans_start, const vec3* tone_trans_end, tone_map_method tone_map_method);
extern float_t post_process_tone_map_get_exposure(post_process_tone_map* tm);
extern void post_process_tone_map_set_exposure(post_process_tone_map* tm, float_t value);
extern bool post_process_tone_map_get_auto_exposure(post_process_tone_map* tm);
extern void post_process_tone_map_set_auto_exposure(post_process_tone_map* tm, bool value);
extern float_t post_process_tone_map_get_gamma(post_process_tone_map* tm);
extern void post_process_tone_map_set_gamma(post_process_tone_map* tm, float_t value);
extern float_t post_process_tone_map_get_gamma_rate(post_process_tone_map* tm);
extern void post_process_tone_map_set_gamma_rate(post_process_tone_map* tm, float_t value);
extern int32_t post_process_tone_map_get_saturate_power(post_process_tone_map* tm);
extern void post_process_tone_map_set_saturate_power(post_process_tone_map* tm, int32_t value);
extern float_t post_process_tone_map_get_saturate_coeff(post_process_tone_map* tm);
extern void post_process_tone_map_set_saturate_coeff(post_process_tone_map* tm, float_t value);
extern void post_process_tone_map_get_scene_fade(post_process_tone_map* tm, vec4* value);
extern void post_process_tone_map_set_scene_fade(post_process_tone_map* tm, const vec4* value);
extern void post_process_tone_map_get_scene_fade_color(post_process_tone_map* tm, vec3* value);
extern void post_process_tone_map_set_scene_fade_color(post_process_tone_map* tm, const vec3* value);
extern float_t post_process_tone_map_get_scene_fade_alpha(post_process_tone_map* tm);
extern void post_process_tone_map_set_scene_fade_alpha(post_process_tone_map* tm, float_t value);
extern int32_t post_process_tone_map_get_scene_fade_blend_func(post_process_tone_map* tm);
extern void post_process_tone_map_set_scene_fade_blend_func(post_process_tone_map* tm, int32_t value);
extern void post_process_tone_map_get_tone_trans_start(post_process_tone_map* tm, vec3* value);
extern void post_process_tone_map_set_tone_trans_start(post_process_tone_map* tm, const vec3* value);
extern void post_process_tone_map_get_tone_trans_end(post_process_tone_map* tm, vec3* value);
extern void post_process_tone_map_set_tone_trans_end(post_process_tone_map* tm, const vec3* value);
extern tone_map_method post_process_tone_map_get_tone_map_method(post_process_tone_map* tm);
extern void post_process_tone_map_set_tone_map_method(post_process_tone_map* tm, tone_map_method value);
extern float_t post_process_tone_map_get_lens_flare(post_process_tone_map* tm);
extern void post_process_tone_map_set_lens_flare(post_process_tone_map* tm, float_t value);
extern float_t post_process_tone_map_get_lens_shaft(post_process_tone_map* tm);
extern void post_process_tone_map_set_lens_shaft(post_process_tone_map* tm, float_t value);
extern float_t post_process_tone_map_get_lens_ghost(post_process_tone_map* tm);
extern void post_process_tone_map_set_lens_ghost(post_process_tone_map* tm, float_t value);
+103
View File
@@ -0,0 +1,103 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#pragma once
#include "../../KKdLib/default.hpp"
#include "../../KKdLib/light_param/glow.hpp"
#include "../../KKdLib/vec.hpp"
#include "../shared.h"
#include "../render_texture.h"
#define POST_PROCESS_TONE_MAP_SAT_GAMMA_SAMPLES 32
struct post_process_tone_map_shader_data {
vec4 p_exposure;
vec4 p_flare_coef;
vec4 p_fade_color;
vec4 p_tone_scale;
vec4 p_tone_offset;
vec4 p_fade_func;
vec4 p_inv_tone;
};
struct post_process_tone_map_data {
vec2 tex[16 * POST_PROCESS_TONE_MAP_SAT_GAMMA_SAMPLES];
float_t exposure;
bool auto_exposure;
float_t gamma;
float_t gamma_rate;
int32_t saturate_power;
float_t saturate_coeff;
vec4 scene_fade;
int32_t scene_fade_blend_func;
vec3 tone_trans_start;
vec3 tone_trans_end;
tone_map_method tone_map_method;
float_t lens_flare;
float_t lens_shaft;
float_t lens_ghost;
float_t lens_flare_power;
float_t lens_flare_appear_power;
bool update;
bool update_tex;
};
struct post_process_tone_map {
post_process_tone_map_data data;
post_process_tone_map_shader_data shader_data;
GLuint tone_map;
post_process_tone_map();
virtual ~post_process_tone_map();
void apply(render_texture* in_tex, texture* light_proj_tex, texture* back_2d_tex,
render_texture* rt, render_texture* buf_rt, render_texture* contour_rt,
GLuint in_tex_0, GLuint in_tex_1, int32_t npr_param);
void init_fbo();
void initialize_data(float_t exposure, bool auto_exposure,
float_t gamma, int32_t saturate_power, float_t saturate_coeff,
const vec3& scene_fade_color, float_t scene_fade_alpha, int32_t scene_fade_blend_func,
const vec3& tone_trans_start, const vec3& tone_trans_end, tone_map_method tone_map_method);
void initialize_data(float_t exposure, bool auto_exposure,
float_t gamma, float_t gamma_rate, int32_t saturate_power, float_t saturate_coeff,
const vec3& scene_fade_color, float_t scene_fade_alpha, int32_t scene_fade_blend_func,
const vec3& tone_trans_start, const vec3& tone_trans_end, tone_map_method tone_map_method);
bool get_auto_exposure();
void set_auto_exposure(bool value);
float_t get_exposure();
void set_exposure(float_t value);
float_t get_gamma();
void set_gamma(float_t value);
float_t get_gamma_rate();
void set_gamma_rate(float_t value);
float_t get_lens_flare();
void set_lens_flare(float_t value);
float_t get_lens_ghost();
void set_lens_ghost(float_t value);
float_t get_lens_shaft();
void set_lens_shaft(float_t value);
float_t get_saturate_coeff();
void set_saturate_coeff(float_t value);
int32_t get_saturate_power();
void set_saturate_power(int32_t value);
vec4 get_scene_fade();
void set_scene_fade(const vec4& value);
float_t get_scene_fade_alpha();
void set_scene_fade_alpha(float_t value);
int32_t get_scene_fade_blend_func();
void set_scene_fade_blend_func(int32_t value);
vec3 get_scene_fade_color();
void set_scene_fade_color(const vec3& value);
tone_map_method get_tone_map_method();
void set_tone_map_method(tone_map_method value);
void get_tone_trans(vec3& start, vec3& end);
void set_tone_trans(const vec3& start, const vec3& end);
vec3 get_tone_trans_end();
void set_tone_trans_end(const vec3& value);
vec3 get_tone_trans_start();
void set_tone_trans_start(const vec3& value);
};
+2033
View File
File diff suppressed because it is too large Load Diff
+518
View File
@@ -0,0 +1,518 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#pragma once
#include <bitset>
#include <list>
#include <map>
#include <string>
#include <vector>
#include "../KKdLib/default.hpp"
#include "../KKdLib/key_val.hpp"
#include "rob.hpp"
#include "task.hpp"
enum pv_attribute_type {
PV_ATTRIBUTE_ORIGINAL = 0x00,
PV_ATTRIBUTE_EXTRA = 0x01,
PV_ATTRIBUTE_END = 0x02,
};
enum pv_chreff_data_type {
PV_CHREFF_DATA_AUTH3D = 0x00,
PV_CHREFF_DATA_AUTH3D_OBJ = 0x01,
};
enum pv_movie_surface {
PV_MOVIE_SURFACE_BACK = 0x00,
PV_MOVIE_SURFACE_FRONT = 0x01,
};
enum pv_difficulty {
PV_DIFFICULTY_EASY = 0x00,
PV_DIFFICULTY_NORMAL = 0x01,
PV_DIFFICULTY_HARD = 0x02,
PV_DIFFICULTY_EXTREME = 0x03,
PV_DIFFICULTY_ENCORE = 0x04,
PV_DIFFICULTY_MAX = 0x05,
};
enum pv_frame_texture_type {
PV_FRAME_TEXTURE_PRE_PP = 0x00,
PV_FRAME_TEXTURE_POST_PP = 0x01,
PV_FRAME_TEXTURE_FB = 0x02,
};
enum pv_level {
PV_LV_00_0 = 0x00,
PV_LV_00_5 = 0x01,
PV_LV_01_0 = 0x02,
PV_LV_01_5 = 0x03,
PV_LV_02_0 = 0x04,
PV_LV_02_5 = 0x05,
PV_LV_03_0 = 0x06,
PV_LV_03_5 = 0x07,
PV_LV_04_0 = 0x08,
PV_LV_04_5 = 0x09,
PV_LV_05_0 = 0x0A,
PV_LV_05_5 = 0x0B,
PV_LV_06_0 = 0x0C,
PV_LV_06_5 = 0x0D,
PV_LV_07_0 = 0x0E,
PV_LV_07_5 = 0x0F,
PV_LV_08_0 = 0x10,
PV_LV_08_5 = 0x11,
PV_LV_09_0 = 0x12,
PV_LV_09_5 = 0x13,
PV_LV_10_0 = 0x14,
PV_LV_MAX = 0x15,
};
enum pv_performer_size {
PV_PERFORMER_NORMAL = 0x00,
PV_PERFORMER_PLAY_CHARA = 0x01,
PV_PERFORMER_PV_CHARA = 0x02,
PV_PERFORMER_SHORT = 0x03,
PV_PERFORMER_TALL = 0x04,
};
enum pv_performer_type {
PV_PERFORMER_VOCAL = 0x00,
PV_PERFORMER_PSEUDO_DEFAULT = 0x01,
PV_PERFORMER_PSEUDO_SAME = 0x02,
PV_PERFORMER_PSEUDO_SWIM = 0x03,
PV_PERFORMER_PSEUDO_SWIM_S = 0x04,
PV_PERFORMER_PSEUDO_MYCHARA = 0x05,
PV_PERFORMER_GUEST = 0x06,
};
struct pv_db_pv_lyric {
int32_t index;
std::string data;
pv_db_pv_lyric();
~pv_db_pv_lyric();
};
struct pv_db_pv_sabi {
float_t start_time;
float_t play_time;
};
struct pv_db_pv_performer {
pv_performer_type type;
int32_t chara;
int32_t costume;
int32_t pv_costume[5];
bool fixed;
int32_t exclude;
pv_performer_size size;
int32_t pseudo_same_id;
int32_t item[4];
pv_db_pv_performer();
void set_pv_costume(int32_t pv_costume, int32_t difficulty);
};
struct pv_db_pv_attribute {
pv_attribute_type type;
std::bitset<128> bitset;
pv_db_pv_attribute();
~pv_db_pv_attribute();
void reset();
};
struct pv_db_pv_motion {
int32_t index;
int32_t id;
std::string name;
pv_db_pv_motion();
~pv_db_pv_motion();
};
struct pv_db_pv_field {
int32_t index;
int32_t stage_index;
int32_t ex_stage_index;
std::vector<std::string> auth_3d_list;
std::vector<std::string> ex_auth_3d_list;
std::vector<int32_t> auth_3d_frame_list;
std::string light;
int32_t light_frame;
bool light_frame_set;
std::vector<std::string> aet[4];
std::vector<std::string> aet_id[4];
std::vector<int32_t> aet_frame[4];
std::string spr_set_back;
bool stage_flag;
int32_t npr_type;
int32_t cam_blur;
bool sdw_off;
std::vector<std::string> play_eff_list;
std::vector<std::string> stop_eff_list;
std::vector<std::string> effect_rs_list;
std::vector<float_t> effect_emision_rs_list;
pv_db_pv_field();
~pv_db_pv_field();
void reset();
};
struct pv_db_pv_field_parent {
std::vector<pv_db_pv_field> data;
bool ex_stage_set;
pv_db_pv_field_parent();
~pv_db_pv_field_parent();
void reset();
};
struct pv_db_pv_item {
int32_t index;
std::string name;
pv_db_pv_item();
~pv_db_pv_item();
};
struct pv_db_pv_hand_item {
int32_t index;
int32_t id;
std::string name;
pv_db_pv_hand_item();
~pv_db_pv_hand_item();
};
struct struc_426 {
int32_t field_0;
int32_t field_4;
int32_t field_8;
};
struct pv_db_pv_edit_effect {
int32_t index;
std::string name;
bool low_field;
pv_db_pv_edit_effect();
~pv_db_pv_edit_effect();
void reset();
};
struct pv_db_pv_title_image {
float_t time;
float_t end_time;
std::string aet_name;
pv_db_pv_title_image();
~pv_db_pv_title_image();
void reset();
};
struct pv_db_pv_songinfo {
std::string music;
std::string lyrics;
std::string arranger;
std::string manipulator;
std::string pv_editor;
std::string guitar_player;
std::pair<std::string, std::string> ex_info[4];
pv_db_pv_songinfo();
~pv_db_pv_songinfo();
void reset();
};
struct pv_db_pv_movie {
int32_t index;
std::string name;
pv_db_pv_movie();
~pv_db_pv_movie();
};
struct pv_db_pv_difficulty {
pv_difficulty difficulty;
int32_t edition;
pv_db_pv_attribute attribute;
std::string script_file_name;
pv_level level;
int32_t level_sort_index;
std::string se_name;
std::string pvbranch_success_se_name;
std::string slide_name;
std::string chainslide_first_name;
std::string chainslide_sub_name;
std::string chainslide_success_name;
std::string chainslide_failure_name;
std::string slidertouch_name;
std::vector<pv_db_pv_motion> motion[ROB_CHARA_COUNT];
pv_db_pv_field_parent field;
std::vector<pv_db_pv_item> pv_item;
std::vector<pv_db_pv_hand_item> hand_item;
std::vector<struc_426> field_228;
std::vector<void*> field_240;
std::vector<void*> field_258;
std::vector<pv_db_pv_edit_effect> edit_effect;
pv_db_pv_title_image title_image;
pv_db_pv_songinfo songinfo;
std::vector<pv_db_pv_movie> movie_list;
pv_movie_surface movie_surface;
std::string effect_se_file_name;
std::vector<std::string> effect_se_name_list;
int32_t version;
int32_t script_format;
int32_t high_speed_rate;
float_t hidden_timing;
float_t sudden_timing;
bool edit_chara_scale;
pv_db_pv_difficulty();
~pv_db_pv_difficulty();
void reset();
};
struct pv_db_pv_ex_song_ex_auth {
std::string org_name;
std::string name;
pv_db_pv_ex_song_ex_auth();
~pv_db_pv_ex_song_ex_auth();
};
struct pv_db_pv_ex_song {
int32_t chara[ROB_CHARA_COUNT];
std::string file;
std::string name;
std::vector<pv_db_pv_ex_song_ex_auth> ex_auth;
pv_db_pv_ex_song();
~pv_db_pv_ex_song();
void reset();
};
struct pv_db_pv_ex_song_parent {
int32_t chara_count;
std::vector<pv_db_pv_ex_song> data;
pv_db_pv_ex_song_parent();
~pv_db_pv_ex_song_parent();
void reset();
};
struct pv_db_pv_mdata {
bool flag;
std::string dir;
pv_db_pv_mdata();
~pv_db_pv_mdata();
void reset();
};
struct pv_db_pv_osage_init {
std::string motion;
int32_t frame;
int32_t stage;
pv_db_pv_osage_init();
~pv_db_pv_osage_init();
};
struct pv_db_pv_stage_param {
int32_t stage;
int32_t mhd_id;
std::string collision_file;
std::string wind_file;
pv_db_pv_stage_param();
~pv_db_pv_stage_param();
};
struct pv_db_pv_disp2d {
std::string set_name;
int32_t target_shadow_type;
int32_t title_start_2d_field;
int32_t title_end_2d_field;
int32_t title_start_2d_low_field;
int32_t title_end_2d_low_field;
int32_t title_start_3d_field;
int32_t title_end_3d_field;
std::string title_2d_layer;
pv_db_pv_disp2d();
~pv_db_pv_disp2d();
void reset();
};
struct pv_db_pv_chreff_data {
pv_chreff_data_type type;
std::string name;
pv_db_pv_chreff_data();
~pv_db_pv_chreff_data();
};
struct pv_db_pv_chreff {
int32_t id;
std::string name;
std::vector<pv_db_pv_chreff_data> data;
pv_db_pv_chreff();
~pv_db_pv_chreff();
};
struct pv_db_pv_chrcam {
int32_t id;
std::string chara;
std::string org_name;
std::string name;
pv_db_pv_chrcam();
~pv_db_pv_chrcam();
};
struct pv_db_pv_chrmot {
int32_t id;
std::string chara;
std::string org_name;
std::string name;
pv_db_pv_chrmot();
~pv_db_pv_chrmot();
};
struct pv_db_pv_eyes_rot_rate {
float_t xp_rate;
float_t xn_rate;
};
struct pv_db_pv_another_song {
std::string name;
std::string song_file_name;
pv_db_pv_another_song();
~pv_db_pv_another_song();
};
struct pv_db_pv_frame_texture {
std::string data;
pv_frame_texture_type type;
pv_db_pv_frame_texture();
~pv_db_pv_frame_texture();
void reset();
};
struct pv_db_pv_auth_replace_by_module {
int32_t id;
int32_t module_id;
std::string org_name;
std::string name;
pv_db_pv_auth_replace_by_module();
~pv_db_pv_auth_replace_by_module();
};
struct pv_db_pv {
int32_t id;
int32_t date;
std::string song_name;
std::string song_name_reading;
int32_t remix_parent;
int32_t bpm;
std::string song_file_name;
std::vector<pv_db_pv_lyric> lyric;
pv_db_pv_sabi sabi;
int32_t edit;
bool disable_calc_motfrm_limit;
std::vector<pv_db_pv_performer> performer;
std::vector<pv_db_pv_difficulty> difficulty[PV_DIFFICULTY_MAX];
pv_db_pv_ex_song_parent ex_song;
pv_db_pv_mdata mdata;
std::vector<pv_db_pv_osage_init> osage_init;
std::vector<pv_db_pv_stage_param> stage_param;
pv_db_pv_disp2d disp2d;
bool use_osage_play_data;
std::string pv_expression_file_name;
std::vector<pv_db_pv_chreff> chreff;
std::vector<pv_db_pv_chrcam> chrcam;
std::vector<pv_db_pv_chrmot> chrmot;
bool eyes_xrot_adjust;
bool is_old_pv;
eyes_base_adjust_type eyes_base_adjust_type;
std::map<chara_index, pv_db_pv_eyes_rot_rate> eyes_rot_rate;
std::vector<pv_db_pv_another_song> another_song;
bool pre_play_script;
pv_db_pv_frame_texture frame_texture[6];
std::vector<pv_db_pv_auth_replace_by_module> auth_replace_by_module;
pv_db_pv();
~pv_db_pv();
pv_db_pv_difficulty* get_difficulty(int32_t difficulty, pv_attribute_type attribute_type);
pv_db_pv_difficulty* get_difficulty(int32_t difficulty, int32_t edition);
void reset();
};
namespace pv_db {
class TaskPvDB : public app::Task {
public:
int32_t state;
std::list<std::pair<std::string, std::string>> paths;
p_file_handler file_handler;
std::list<pv_db_pv> pv_data;
bool reset;
bool field_99;
std::map<std::string, pv_performer_type> performer_types;
std::map<std::string, pv_performer_size> performer_sizes;
std::map<std::string, pv_chreff_data_type> chreff_data_types;
std::map<std::string, pv_movie_surface> movie_surfaces;
std::map<std::string, pv_level> pv_levels;
TaskPvDB();
virtual ~TaskPvDB() override;
virtual bool Init() override;
virtual bool Ctrl() override;
virtual bool Dest() override;
void InitChrEffDataTypes();
void InitMovieSurfaces();
void InitPerformerSizes();
void InitPerformerTypes();
void InitPvLevels();
bool ParsePvDb(pv_db_pv* pv, key_val& kv, int32_t pv_id);
bool ParsePvField(pv_db_pv* pv, key_val& kv, int32_t pv_id);
};
}
extern bool task_pv_db_append_task();
extern void task_pv_db_free_task();
extern pv_db::TaskPvDB* task_pv_db_get();
extern uint32_t task_pv_db_get_paths_count();
extern pv_db_pv* task_pv_db_get_pv(int32_t pv_id);
extern pv_db_pv_difficulty* task_pv_db_get_pv_difficulty(int32_t pv_id,
int32_t difficulty, pv_attribute_type attribute_type);
extern pv_db_pv_difficulty* task_pv_db_get_pv_difficulty(int32_t pv_id,
int32_t difficulty, int32_t edition);
extern bool task_pv_db_is_paths_empty();
@@ -3,68 +3,70 @@
GitHub/GitLab: korenkonder
*/
#include "pv_param_task.hpp"
#include "pv_param.hpp"
#include "post_process.hpp"
#include "render_context.hpp"
extern render_context* rctx_ptr;
pv_param_bloom::pv_param_bloom() {
id = -1;
color = vec3_null;
brightpass = vec3_null;
range = 0.0f;
}
namespace pv_param {
bloom::bloom() {
id = -1;
color = vec3_null;
brightpass = vec3_null;
range = 0.0f;
}
pv_param_dof::pv_param_dof() {
id = -1;
focus = 0.0f;
focus_range = 100.0f;
fuzzing_range = 2.0f;
ratio = 0.0f;
quality = 1.0f;
}
dof::dof() {
id = -1;
focus = 0.0f;
focus_range = 100.0f;
fuzzing_range = 2.0f;
ratio = 0.0f;
quality = 1.0f;
}
pv_param_chara_alpha::pv_param_chara_alpha() {
frame = -1.0f;
duration = 1.0f;
prev_alpha = 1.0f;
alpha = 1.0f;
type = 0;
}
chara_alpha::chara_alpha() {
frame = -1.0f;
duration = 1.0f;
prev_alpha = 1.0f;
alpha = 1.0f;
type = 0;
}
pv_param_color_correction::pv_param_color_correction() {
id = -1;
hue = 1.0f;
saturation = 1.0f;
lightness = 1.0f;
exposure = 1.0f;
gamma = vec3_identity;
contrast = 1.0f;
}
color_correction::color_correction() {
id = -1;
hue = 1.0f;
saturation = 1.0f;
lightness = 1.0f;
exposure = 1.0f;
gamma = vec3_identity;
contrast = 1.0f;
}
pv_param_post_process_data_struct::pv_param_post_process_data_struct() {
post_process_data_struct::post_process_data_struct() {
}
}
pv_param_post_process_data_struct::~pv_param_post_process_data_struct() {
post_process_data_struct::~post_process_data_struct() {
}
}
pv_param_file_data_struct::pv_param_file_data_struct() {
file_data_struct::file_data_struct() {
}
}
pv_param_file_data_struct::~pv_param_file_data_struct() {
file_data_struct::~file_data_struct() {
}
}
pv_param_light_data_struct::pv_param_light_data_struct() {
light_data_struct::light_data_struct() {
}
}
pv_param_light_data_struct::~pv_param_light_data_struct() {
light_data_struct::~light_data_struct() {
}
}
namespace pv_param_task {
@@ -107,7 +109,7 @@ namespace pv_param_task {
else
vec3_lerp_scalar(data.data_prev.color, data.data.color, value, frame / duration);
post_process_blur_set_intensity(rctx_ptr->post_process.blur, &value);
rctx_ptr->post_process.blur->set_intensity(value);
frame += 1.0f;
if (frame > duration) {
@@ -162,8 +164,8 @@ namespace pv_param_task {
}
post_process_tone_map* tone_map = rctx_ptr->post_process.tone_map;
post_process_tone_map_set_saturate_coeff(tone_map, saturation);
post_process_tone_map_set_exposure(tone_map, exposure * 2.0f);
tone_map->set_saturate_coeff(saturation);
tone_map->set_exposure(exposure * 2.0f);
vec3 tone_trans_start;
vec3 tone_trans_end;
@@ -171,8 +173,7 @@ namespace pv_param_task {
CalcToneTrans(contrast + gamma.y, tone_trans_start.y, tone_trans_end.y);
CalcToneTrans(contrast + gamma.z, tone_trans_start.z, tone_trans_end.z);
post_process_tone_map_set_tone_trans_start(tone_map, &tone_trans_start);
post_process_tone_map_set_tone_trans_end(tone_map, &tone_trans_end);
tone_map->set_tone_trans(tone_trans_start, tone_trans_end);
frame += 1.0f;
if (frame > duration) {
@@ -211,13 +212,13 @@ namespace pv_param_task {
}
void PostProcessCtrlCharaAlpha::Reset() {
for (pv_param_chara_alpha& i : data.data)
for (pv_param::chara_alpha& i : data.data)
i = {};
}
void PostProcessCtrlCharaAlpha::Set() {
int32_t index = 0;
for (pv_param_chara_alpha& i : data.data) {
for (pv_param::chara_alpha& i : data.data) {
if (i.frame < 0.0f) {
index++;
continue;
@@ -266,7 +267,7 @@ namespace pv_param_task {
void PostProcessCtrlCharaItemAlpha::Set() {
int32_t index = 0;
for (pv_param_chara_alpha& i : data.data) {
for (pv_param::chara_alpha& i : data.data) {
if (i.frame < 0.0f) {
index++;
continue;
@@ -355,7 +356,7 @@ namespace pv_param_task {
}
}
void PostProcessCtrlDof::SetData(pv_param_dof* dof, float_t duration) {
void PostProcessCtrlDof::SetData(pv_param::dof* dof, float_t duration) {
frame = 0.0f;
this->duration = duration;
data.data = *dof;
@@ -375,11 +376,11 @@ namespace pv_param_task {
PostProcessTask::PostProcessTask() {
}
PostProcessTask::~PostProcessTask() {
}
bool PostProcessTask::Init() {
dof.Reset();
cc.Reset();
@@ -388,7 +389,7 @@ namespace pv_param_task {
chara_item_alpha.Reset();
return true;
}
bool PostProcessTask::Ctrl() {
dof.Set();
cc.Set();
@@ -397,7 +398,7 @@ namespace pv_param_task {
chara_item_alpha.Set();
return false;
}
bool PostProcessTask::Dest() {
dof.Reset();
cc.Reset();
+204
View File
@@ -0,0 +1,204 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#pragma once
#include <map>
#include <string>
#include <vector>
#include "../KKdLib/default.hpp"
#include "../KKdLib/vec.hpp"
#include "light_param.hpp"
#include "rob.hpp"
#include "task.hpp"
namespace pv_param {
struct bloom {
int32_t id;
vec3 color;
vec3 brightpass;
float_t range;
bloom();
};
struct dof {
int32_t id;
float_t focus;
float_t focus_range;
float_t fuzzing_range;
float_t ratio;
float_t quality;
dof();
};
struct chara_alpha {
float_t frame;
float_t duration;
float_t prev_alpha;
float_t alpha;
int32_t type;
chara_alpha();
};
struct color_correction {
int32_t id;
float_t hue;
float_t saturation;
float_t lightness;
float_t exposure;
vec3 gamma;
float_t contrast;
color_correction();
};
struct post_process_data_struct {
dof dof_default;
color_correction cc_default;
bloom bloom_default;
std::string dof_file;
std::string cc_file;
std::string bloom_file;
std::vector<dof> dof;
std::vector<color_correction> cc;
std::vector<bloom> bloom;
post_process_data_struct();
~post_process_data_struct();
};
struct file_data_struct {
std::vector<dof> dof_default;
std::vector<color_correction> cc_default;
std::vector<bloom> bloom_default;
std::map<std::string, std::vector<dof>> dof;
std::map<std::string, std::vector<color_correction>> cc;
std::map<std::string, std::vector<bloom>> bloom;
file_data_struct();
~file_data_struct();
};
struct light_data_struct {
light_param_light_data light_default;
std::string chara_light_file;
std::string stage_light_file;
std::map<int32_t, light_param_light_data> chara_light;
std::map<int32_t, light_param_light_data> stage_light;
light_data_struct();
~light_data_struct();
};
}
namespace pv_param_task {
class PostProcessCtrl {
public:
float_t frame;
float_t duration;
PostProcessCtrl();
~PostProcessCtrl();
virtual void Reset() = 0;
virtual void Set() = 0;
};
class PostProcessCtrlBloom : public PostProcessCtrl {
public:
struct Data {
pv_param::bloom data;
pv_param::bloom data_prev;
Data();
} data;
PostProcessCtrlBloom();
~PostProcessCtrlBloom();
virtual void Reset() override;
virtual void Set() override;
};
class PostProcessCtrlCC : public PostProcessCtrl {
public:
struct Data {
pv_param::color_correction data;
pv_param::color_correction data_prev;
Data();
} data;
PostProcessCtrlCC();
~PostProcessCtrlCC();
virtual void Reset() override;
virtual void Set() override;
void CalcToneTrans(float_t value, float_t& tone_trans_start, float_t& tone_trans_end);
};
class PostProcessCtrlCharaAlpha : public PostProcessCtrl {
public:
struct Data {
pv_param::chara_alpha data[ROB_CHARA_COUNT];
Data();
} data;
PostProcessCtrlCharaAlpha();
~PostProcessCtrlCharaAlpha();
virtual void Reset() override;
virtual void Set() override;
};
class PostProcessCtrlCharaItemAlpha : public PostProcessCtrlCharaAlpha {
public:
PostProcessCtrlCharaItemAlpha();
~PostProcessCtrlCharaItemAlpha();
virtual void Set() override;
};
class PostProcessCtrlDof : public PostProcessCtrl {
public:
struct Data {
pv_param::dof data;
pv_param::dof data_prev;
Data();
} data;
PostProcessCtrlDof();
~PostProcessCtrlDof();
virtual void Reset() override;
virtual void Set() override;
void SetData(pv_param::dof* dof, float_t duration);
};
class PostProcessTask : public app::Task {
public:
PostProcessCtrlDof dof;
PostProcessCtrlCC cc;
PostProcessCtrlBloom bloom;
PostProcessCtrlCharaAlpha chara_alpha;
PostProcessCtrlCharaItemAlpha chara_item_alpha;
PostProcessTask();
virtual ~PostProcessTask() override;
virtual bool Init() override;
virtual bool Ctrl() override;
virtual bool Dest() override;
};
extern PostProcessTask post_process_task;
}
-202
View File
@@ -1,202 +0,0 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#pragma once
#include <map>
#include <string>
#include <vector>
#include "../KKdLib/default.h"
#include "../KKdLib/vec.h"
#include "light_param.hpp"
#include "rob.hpp"
#include "task.hpp"
struct pv_param_bloom {
int32_t id;
vec3 color;
vec3 brightpass;
float_t range;
pv_param_bloom();
};
struct pv_param_dof {
int32_t id;
float_t focus;
float_t focus_range;
float_t fuzzing_range;
float_t ratio;
float_t quality;
pv_param_dof();
};
struct pv_param_chara_alpha {
float_t frame;
float_t duration;
float_t prev_alpha;
float_t alpha;
int32_t type;
pv_param_chara_alpha();
};
struct pv_param_color_correction {
int32_t id;
float_t hue;
float_t saturation;
float_t lightness;
float_t exposure;
vec3 gamma;
float_t contrast;
pv_param_color_correction();
};
struct pv_param_post_process_data_struct {
pv_param_dof dof_default;
pv_param_color_correction cc_default;
pv_param_bloom bloom_default;
std::string dof_file;
std::string cc_file;
std::string bloom_file;
std::vector<pv_param_dof> dof;
std::vector<pv_param_color_correction> cc;
std::vector<pv_param_bloom> bloom;
pv_param_post_process_data_struct();
~pv_param_post_process_data_struct();
};
struct pv_param_file_data_struct {
std::vector<pv_param_dof> dof_default;
std::vector<pv_param_color_correction> cc_default;
std::vector<pv_param_bloom> bloom_default;
std::map<std::string, std::vector<pv_param_dof>> dof;
std::map<std::string, std::vector<pv_param_color_correction>> cc;
std::map<std::string, std::vector<pv_param_bloom>> bloom;
pv_param_file_data_struct();
~pv_param_file_data_struct();
};
struct pv_param_light_data_struct {
light_param_light_data light_default;
std::string chara_light_file;
std::string stage_light_file;
std::map<int32_t, light_param_light_data> chara_light;
std::map<int32_t, light_param_light_data> stage_light;
pv_param_light_data_struct();
~pv_param_light_data_struct();
};
namespace pv_param_task {
class PostProcessCtrl {
public:
float_t frame;
float_t duration;
PostProcessCtrl();
~PostProcessCtrl();
virtual void Reset() = 0;
virtual void Set() = 0;
};
class PostProcessCtrlBloom : public PostProcessCtrl {
public:
struct Data {
pv_param_bloom data;
pv_param_bloom data_prev;
Data();
} data;
PostProcessCtrlBloom();
~PostProcessCtrlBloom();
virtual void Reset() override;
virtual void Set() override;
};
class PostProcessCtrlCC : public PostProcessCtrl {
public:
struct Data {
pv_param_color_correction data;
pv_param_color_correction data_prev;
Data();
} data;
PostProcessCtrlCC();
~PostProcessCtrlCC();
virtual void Reset() override;
virtual void Set() override;
void CalcToneTrans(float_t value, float_t& tone_trans_start, float_t& tone_trans_end);
};
class PostProcessCtrlCharaAlpha : public PostProcessCtrl {
public:
struct Data {
pv_param_chara_alpha data[ROB_CHARA_COUNT];
Data();
} data;
PostProcessCtrlCharaAlpha();
~PostProcessCtrlCharaAlpha();
virtual void Reset() override;
virtual void Set() override;
};
class PostProcessCtrlCharaItemAlpha : public PostProcessCtrlCharaAlpha {
public:
PostProcessCtrlCharaItemAlpha();
~PostProcessCtrlCharaItemAlpha();
virtual void Set() override;
};
class PostProcessCtrlDof : public PostProcessCtrl {
public:
struct Data {
pv_param_dof data;
pv_param_dof data_prev;
Data();
} data;
PostProcessCtrlDof();
~PostProcessCtrlDof();
virtual void Reset() override;
virtual void Set() override;
void SetData(pv_param_dof* dof, float_t duration);
};
class PostProcessTask : public Task {
public:
PostProcessCtrlDof dof;
PostProcessCtrlCC cc;
PostProcessCtrlBloom bloom;
PostProcessCtrlCharaAlpha chara_alpha;
PostProcessCtrlCharaItemAlpha chara_item_alpha;
PostProcessTask();
virtual ~PostProcessTask() override;
virtual bool Init() override;
virtual bool Ctrl() override;
virtual bool Dest() override;
};
extern PostProcessTask post_process_task;
}
+1 -1
View File
@@ -5,7 +5,7 @@
#pragma once
#include "../KKdLib/default.h"
#include "../KKdLib/default.hpp"
#include <random>
struct RandState {

Some files were not shown because too many files have changed in this diff Show More