mirror of
https://github.com/korenkonder/ReDIVA.git
synced 2026-10-04 12:47:56 +03:00
Moved Light Param data to it's file
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user