Moved Light Param data to it's file

This commit is contained in:
korenkonder
2024-04-12 23:06:47 +03:00
parent f50f5733c2
commit b1af79b1dd
23 changed files with 633 additions and 616 deletions
+1
View File
@@ -15,6 +15,7 @@
#include "../KKdLib/str_utils.hpp"
#include "rob/rob.hpp"
#include "clear_color.hpp"
#include "data.hpp"
#include "effect.hpp"
#include "object.hpp"
#include "pv_db.hpp"
+1
View File
@@ -8,6 +8,7 @@
#include <map>
#include <vector>
#include "../KKdLib/default.hpp"
#include "../KKdLib/database/auth_3d.hpp"
#include "../KKdLib/database/object.hpp"
#include "../KKdLib/database/texture.hpp"
#include "../KKdLib/a3da.hpp"
+602 -318
View File
File diff suppressed because it is too large Load Diff
+3 -37
View File
@@ -29,47 +29,11 @@ enum light_param_data_storage_flags {
LIGHT_PARAM_DATA_STORAGE_ALL = 0x3F,
};
struct light_param_data {
std::string name;
std::string paths[6];
std::string files[6];
bool pv;
light_param_light light;
light_param_fog fog;
light_param_glow glow;
light_param_ibl ibl;
light_param_wind wind;
light_param_face face;
light_param_data();
~light_param_data();
};
struct light_param_data_storage {
GLuint textures[5];
int32_t state;
std::string name;
int32_t stage_index;
light_param_data default_light_param;
std::map<int32_t, light_param_data> stage;
std::map<int32_t, light_param_data>* default_stage_node;
std::map<int32_t, light_param_data> pv_cut;
std::map<int32_t, light_param_data>::iterator stage_light_param_iterator;
p_file_handler file_handlers[6];
p_file_handler farc_file_handler;
int32_t pv_id;
light_param_data_storage();
~light_param_data_storage();
static void load(data_struct* data);
static void unload();
};
extern void light_param_data_storage_data_init();
extern void light_param_data_storage_data_free_file_handlers();
extern int32_t light_param_data_storage_data_get_pv_id();
extern int32_t light_param_data_storage_data_get_stage_index();
extern void light_param_data_storage_data_load();
extern int32_t light_param_data_storage_data_load_file();
extern void light_param_data_storage_data_load_stage(int32_t stage_index);
extern void light_param_data_storage_data_load_stage(uint32_t stage_hash, stage_database* stage_data);
@@ -79,9 +43,11 @@ extern void light_param_data_storage_data_load_stages(
extern void light_param_data_storage_data_reset();
extern void light_param_data_storage_data_set_default_light_param(
light_param_data_storage_flags flags = LIGHT_PARAM_DATA_STORAGE_ALL);
extern void light_param_data_storage_data_set_ibl();
extern void light_param_data_storage_data_set_pv_id(int32_t pv_id);
extern void light_param_data_storage_data_set_pv_cut(int32_t cut_id,
light_param_data_storage_flags flags = LIGHT_PARAM_DATA_STORAGE_ALL);
extern void light_param_data_storage_data_set_stage(int32_t stage_id,
light_param_data_storage_flags flags = LIGHT_PARAM_DATA_STORAGE_ALL);
extern void light_param_data_storage_data_unload();
extern void light_param_data_storage_data_free();
+1
View File
@@ -4,6 +4,7 @@
*/
#include "disp_manager.hpp"
#include "../../KKdLib/database/stage.hpp"
#include "../Glitter/glitter.hpp"
#include "../render_context.hpp"
#include "../shader_ft.hpp"
+1
View File
@@ -6,6 +6,7 @@
#include "pv_db.hpp"
#include "../KKdLib/hash.hpp"
#include "../KKdLib/str_utils.hpp"
#include "data.hpp"
#include "hand_item.hpp"
#include "mdata_manager.hpp"
#include "render_context.hpp"
+1
View File
@@ -9,6 +9,7 @@
#include "../KKdLib/hash.hpp"
#include "../KKdLib/str_utils.hpp"
#include "rob/rob.hpp"
#include "data.hpp"
#include "render_context.hpp"
struct pv_expression_file {
-235
View File
@@ -17,9 +17,6 @@ extern render_context* rctx_ptr;
//extern void dw_gui_ctrl_disp();
static void render_context_light_param_data_ibl_set_diffuse(light_param_ibl_diffuse* diffuse, int32_t level);
static void render_context_light_param_data_ibl_set_specular(light_param_ibl_specular* specular);
static const GLuint POSITION_INDEX = 0;
static const GLuint BONE_WEIGHT_INDEX = 1;
static const GLuint NORMAL_INDEX = 2;
@@ -680,198 +677,6 @@ void render_context::init() {
screen_buffer.Init(sprite_width, sprite_height, 0, GL_RGBA8, 0);
}
void render_context::light_param_data_light_set(light_param_light * light) {
for (int32_t i = LIGHT_SET_MAIN; i < LIGHT_SET_MAX; i++) {
light_param_light_group* group = &light->group[i];
::light_set* set = &light_set[i];
for (int32_t j = LIGHT_CHARA; j < LIGHT_MAX; j++) {
light_param_light_data* data = &group->data[j];
light_data* light = &set->lights[j];
if (data->has_type)
light->set_type(data->type);
if (data->has_ambient)
light->set_ambient(data->ambient);
if (data->has_diffuse)
light->set_diffuse(data->diffuse);
if (data->has_specular)
light->set_specular(data->specular);
if (data->has_position)
light->set_position(data->position);
if (data->has_spot_direction)
light->set_spot_direction(data->spot_direction);
if (data->has_spot_exponent)
light->set_spot_exponent(data->spot_exponent);
if (data->has_spot_cutoff)
light->set_spot_cutoff(data->spot_cutoff);
if (data->has_attenuation)
light->set_attenuation(data->attenuation);
light->set_clip_plane(data->clip_plane);
if (data->has_tone_curve)
light->set_tone_curve(data->tone_curve);
}
}
}
void render_context::light_param_data_fog_set(light_param_fog* f) {
for (int32_t i = FOG_DEPTH; i < FOG_MAX; i++) {
light_param_fog_group* group = &f->group[i];
::fog* fog = &this->fog[i];
if (group->has_type)
fog->set_type(group->type);
if (group->has_density)
fog->set_density(group->density);
if (group->has_linear) {
fog->set_start(group->linear_start);
fog->set_end(group->linear_end);
}
if (group->has_color)
fog->set_color(group->color);
}
}
void render_context::light_param_data_glow_set(light_param_glow* glow) {
render.set_auto_exposure(true);
render.set_tone_map(TONE_MAP_YCC_EXPONENT);
render.reset_saturate_coeff(0, false);
render.reset_scene_fade(0);
render.reset_tone_trans(0);
if (glow->has_exposure)
render.set_exposure(glow->exposure);
if (glow->has_gamma)
render.set_gamma(glow->gamma);
if (glow->has_saturate_power)
render.set_saturate_power(glow->saturate_power);
if (glow->has_saturate_coef)
render.set_saturate_coeff(glow->saturate_coef, 0, false);
if (glow->has_flare)
render.set_lens(glow->flare);
if (glow->has_sigma)
render.set_radius(glow->sigma);
if (glow->has_intensity)
render.set_intensity(glow->intensity);
if (glow->has_auto_exposure)
render.set_auto_exposure(glow->auto_exposure);
if (glow->has_tone_map_method)
render.set_tone_map(glow->tone_map_method);
if (glow->has_fade_color) {
vec4 fade_color = glow->fade_color;
render.set_scene_fade(fade_color, 0);
render.set_scene_fade_blend_func(glow->fade_color_blend_func, 0);
}
if (glow->has_tone_transform)
render.set_tone_trans(glow->tone_transform_start, glow->tone_transform_end, 0);
}
void render_context::light_param_data_ibl_set(
light_param_ibl* ibl, light_param_data_storage* storage) {
if (!ibl->ready)
return;
for (int32_t i = 0, j = -1; i < 5; i++, j++) {
gl_state_bind_texture_cube_map(storage->textures[i]);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
if (!i) {
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, 1);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
render_context_light_param_data_ibl_set_diffuse(&ibl->diffuse[0], 0);
render_context_light_param_data_ibl_set_diffuse(&ibl->diffuse[1], 1);
}
else {
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, ibl->specular[j].max_level);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_LOD_BIAS, 0.0f);
render_context_light_param_data_ibl_set_specular(&ibl->specular[j]);
}
}
gl_state_bind_texture_cube_map(0);
::light_set* set = &light_set[LIGHT_SET_MAIN];
set->set_irradiance(ibl->diff_coef[1][0], ibl->diff_coef[1][1], ibl->diff_coef[1][2]);
float_t len;
vec3 pos;
light_data* l = &set->lights[LIGHT_CHARA];
l->get_position(pos);
len = vec3::length(pos);
if (fabsf(len - 1.0f) < 0.02f)
l->set_position(ibl->lit_dir[0]);
l->set_ibl_color0(ibl->lit_col[0]);
l->set_ibl_color1(ibl->lit_col[2]);
l->set_ibl_direction(ibl->lit_dir[0]);
l = &set->lights[LIGHT_STAGE];
l->get_position(pos);
len = vec3::length(pos);
if (fabsf(len - 1.0f) < 0.02f)
l->set_position(ibl->lit_dir[1]);
l->set_ibl_color0(ibl->lit_col[1]);
l->set_ibl_direction(ibl->lit_dir[1]);
}
void render_context::light_param_data_wind_set(light_param_wind* w) {
wind* wind = task_wind->ptr;
if (w->has_scale)
wind->scale = w->scale;
if (w->has_cycle)
wind->cycle = w->cycle;
if (w->has_rot) {
wind->rot_y = w->rot_y;
wind->rot_z = w->rot_z;
}
if (w->has_bias)
wind->bias = w->bias;
for (int32_t i = 0; i < 16; i++)
if (w->has_spc[i]) {
wind->spc[i].cos = w->spc[i].cos;
wind->spc[i].sin = w->spc[i].sin;
}
}
void render_context::light_param_data_face_set(light_param_face* face) {
this->face.set_offset(face->offset);
this->face.set_scale(face->scale);
this->face.set_position(face->position);
this->face.set_direction(face->direction);
}
void render_context::resize(int32_t render_width, int32_t render_height,
int32_t sprite_width, int32_t sprite_height,
int32_t screen_width, int32_t screen_height) {
@@ -907,43 +712,3 @@ void render_context::resize(int32_t render_width, int32_t render_height,
init();
}
}
static void render_context_light_param_data_ibl_set_diffuse(light_param_ibl_diffuse* diffuse, int32_t level) {
int32_t size = diffuse->size;
size_t data_size = size;
data_size = 4 * data_size * data_size;
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, GL_RGBA16F,
size, size, 0, GL_RGBA, GL_HALF_FLOAT, &diffuse->data[data_size * 0]);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, level, GL_RGBA16F,
size, size, 0, GL_RGBA, GL_HALF_FLOAT, &diffuse->data[data_size * 1]);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, level, GL_RGBA16F,
size, size, 0, GL_RGBA, GL_HALF_FLOAT, &diffuse->data[data_size * 2]);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, level, GL_RGBA16F,
size, size, 0, GL_RGBA, GL_HALF_FLOAT, &diffuse->data[data_size * 3]);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, level, GL_RGBA16F,
size, size, 0, GL_RGBA, GL_HALF_FLOAT, &diffuse->data[data_size * 4]);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, level, GL_RGBA16F,
size, size, 0, GL_RGBA, GL_HALF_FLOAT, &diffuse->data[data_size * 5]);
}
static void render_context_light_param_data_ibl_set_specular(light_param_ibl_specular* specular) {
int32_t size = specular->size;
int32_t max_level = specular->max_level;
for (int32_t i = 0; i <= max_level; i++, size /= 2) {
std::vector<half_t>& data = specular->data[i];
size_t data_size = size;
data_size = 4 * data_size * data_size;
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, i, GL_RGBA16F,
size, size, 0, GL_RGBA, GL_HALF_FLOAT, &data[data_size * 0]);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, i, GL_RGBA16F,
size, size, 0, GL_RGBA, GL_HALF_FLOAT, &data[data_size * 1]);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, i, GL_RGBA16F,
size, size, 0, GL_RGBA, GL_HALF_FLOAT, &data[data_size * 2]);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, i, GL_RGBA16F,
size, size, 0, GL_RGBA, GL_HALF_FLOAT, &data[data_size * 3]);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, i, GL_RGBA16F,
size, size, 0, GL_RGBA, GL_HALF_FLOAT, &data[data_size * 4]);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, i, GL_RGBA16F,
size, size, 0, GL_RGBA, GL_HALF_FLOAT, &data[data_size * 5]);
}
}
-7
View File
@@ -17,7 +17,6 @@
#include "light_param/wind.hpp"
#include "mdl/disp_manager.hpp"
#include "camera.hpp"
#include "light_param.hpp"
#include "render.hpp"
#include "render_manager.hpp"
#include "render_texture.hpp"
@@ -367,12 +366,6 @@ struct render_context {
void disp();
void free();
void init();
void light_param_data_light_set(light_param_light* light);
void light_param_data_fog_set(light_param_fog* f);
void light_param_data_glow_set(light_param_glow* glow);
void light_param_data_ibl_set(light_param_ibl* ibl, light_param_data_storage* storage);
void light_param_data_wind_set(light_param_wind* w);
void light_param_data_face_set(light_param_face* face);
void resize(int32_t render_width, int32_t render_height,
int32_t sprite_width, int32_t sprite_height,
int32_t screen_width, int32_t screen_height);
+7 -11
View File
@@ -12,6 +12,7 @@
#include "clear_color.hpp"
#include "effect.hpp"
#include "gl_state.hpp"
#include "light_param.hpp"
#include "render.hpp"
#include "render_context.hpp"
#include "render_texture.hpp"
@@ -45,7 +46,6 @@ static void blur_filter_apply(render_context* rctx, RenderTexture* dst, RenderTe
static void render_manager_free_render_textures();
static void render_manager_init_render_textures(int32_t multisample);
extern light_param_data_storage* light_param_data_storage_data;
extern render_context* rctx_ptr;
namespace rndr {
@@ -262,18 +262,14 @@ namespace rndr {
}
void RenderManager::render_all() {
static const int32_t ibl_texture_index[] = {
9, 10, 11, 12, 13
};
light_param_data_storage_data_set_ibl();
render_context* rctx = rctx_ptr;
camera* cam = rctx->camera;
static const vec4 color_clear = 0.0f;
for (int32_t i = 0; i < 5; i++)
gl_state_active_bind_texture_cube_map(ibl_texture_index[i],
light_param_data_storage_data->textures[i]);
gl_state_bind_framebuffer(0);
glClearBufferfv(GL_COLOR, 0, (float_t*)&color_clear);
rctx->obj_scene.g_framebuffer_size = {
rctx_ptr->obj_scene.g_framebuffer_size = {
1.0f / (float_t)render->render_width[0],
1.0f / (float_t)render->render_height[0],
(float_t)render->render_width[0],
@@ -300,7 +296,7 @@ namespace rndr {
RenderManager::render_single_pass((RenderPassID)i);
gl_state_end_event();
rctx->disp_manager->check_vertex_arrays();
rctx_ptr->disp_manager->check_vertex_arrays();
gl_state_bind_vertex_array(0);
gl_state_disable_primitive_restart();
gl_state_bind_uniform_buffer_base(0, 0);
+1
View File
@@ -4,6 +4,7 @@
*/
#include "motion.hpp"
#include "../data.hpp"
struct MotFile {
const motion_set_info* mot_set_info;
+1
View File
@@ -6,6 +6,7 @@
#include "rob.hpp"
#include "../../KKdLib/prj/algorithm.hpp"
#include "../../KKdLib/str_utils.hpp"
#include "../data.hpp"
#include "../mdata_manager.hpp"
#include "skin_param.hpp"
+2
View File
@@ -4,8 +4,10 @@
*/
#include "object.hpp"
#include "../../../CRE/object.hpp"
#include "../../../CRE/render_context.hpp"
#include "../../imgui_helper.hpp"
#include <map>
extern int32_t width;
extern int32_t height;
+1
View File
@@ -6,6 +6,7 @@
#include "texture.hpp"
#include "../../../CRE/render_context.hpp"
#include "../../imgui_helper.hpp"
#include <map>
extern int32_t width;
extern int32_t height;
@@ -4,6 +4,7 @@
*/
#include "post_process.hpp"
#include "../../../CRE/light_param.hpp"
#include "../../../CRE/render_context.hpp"
#include "../../../CRE/stage.hpp"
#include "../../imgui_helper.hpp"
+1
View File
@@ -5,6 +5,7 @@
#include "equip_test.hpp"
#include "../../CRE/rob/rob.hpp"
#include "../../CRE/data.hpp"
#include "../dw.hpp"
#include "auth_3d_test.hpp"
#include "motion_test.hpp"
+1
View File
@@ -8,6 +8,7 @@
#include "../../CRE/rob/motion.hpp"
#include "../../CRE/rob/skin_param.hpp"
#include "../../CRE/clear_color.hpp"
#include "../../CRE/data.hpp"
#include "../../CRE/hand_item.hpp"
#include "../../CRE/module_table.hpp"
#include "../../CRE/pv_db.hpp"
+1
View File
@@ -4,6 +4,7 @@
*/
#include "dw.hpp"
#include "../CRE/data.hpp"
#include "input_state.hpp"
#include "print_work.hpp"
+1
View File
@@ -8,6 +8,7 @@
#if defined(ReDIVA_DEV)
#include "../KKdLib/default.hpp"
#include "../CRE/Glitter/glitter.hpp"
#include "../CRE/data.hpp"
#include "task_window.hpp"
enum glitter_editor_selected_enum {
+1
View File
@@ -5,6 +5,7 @@
#include "print_work.hpp"
#include "../KKdLib/str_utils.hpp"
#include "../CRE/data.hpp"
#include "../CRE/shader_ft.hpp"
namespace app {
+1
View File
@@ -4,6 +4,7 @@
*/
#include "game_2d.hpp"
#include "../../CRE/data.hpp"
#include "pv_game.hpp"
const char* spr_life_bonus[] = {
+1
View File
@@ -4,6 +4,7 @@
*/
#include "pv_game_play_data.hpp"
#include "../../CRE/data.hpp"
#include "../print_work.hpp"
#include "game_2d.hpp"
#include "player_data.hpp"
+3 -8
View File
@@ -925,7 +925,8 @@ static render_context* render_context_load() {
for (int32_t i = 0; i < ROB_CHARA_COUNT; i++)
rob_chara_array_reset_pv_data(i);
light_param_data_storage::load(aft_data);
light_param_data_storage_data_load();
auth_3d_data_load_auth_3d_db(aft_auth_3d_db);
cmn_set_id = aft_mot_db->get_motion_set_id("CMN");
@@ -1157,12 +1158,6 @@ static void render_context_disp(render_context* rctx) {
glViewport(0, 0, internal_3d_res.x, internal_3d_res.y);
rctx->render.rend_texture[0].Bind();
gl_state_set_depth_mask(GL_TRUE);
glClearBufferfv(GL_COLOR, 0, (float_t*)&color_clear);
glClearBufferfv(GL_DEPTH, 0, &depth_clear);
gl_state_set_depth_mask(GL_FALSE);
cam->update();
rctx->disp();
@@ -1258,7 +1253,7 @@ static void render_context_dispose(render_context* rctx) {
render_timer->end_of_cycle();
}
light_param_data_storage::unload();
light_param_data_storage_data_unload();
x_pv_game_data_free();
task_data_test_glitter_particle_free();