From c64a20f0c04b62defacfac270259980bd317901d Mon Sep 17 00:00:00 2001 From: korenkonder Date: Sun, 28 Dec 2025 21:47:05 +0300 Subject: [PATCH] Shader overhaul --- src/CRE/Glitter/file_reader.cpp | 9 +- src/CRE/Glitter/glitter.cpp | 9 +- src/CRE/effect.cpp | 17 ++- src/CRE/light_param/light.cpp | 17 +-- src/CRE/render.cpp | 221 ++++++++++++++++++++------------ src/CRE/render.hpp | 8 ++ src/CRE/render_context.cpp | 46 +++++-- src/CRE/render_context.hpp | 23 ++-- src/CRE/shader.cpp | 57 ++++++-- src/CRE/shader_ft.cpp | 58 +++++---- src/CRE/sprite.cpp | 14 +- 11 files changed, 320 insertions(+), 159 deletions(-) diff --git a/src/CRE/Glitter/file_reader.cpp b/src/CRE/Glitter/file_reader.cpp index 3b204c07..df4eb5b3 100644 --- a/src/CRE/Glitter/file_reader.cpp +++ b/src/CRE/Glitter/file_reader.cpp @@ -167,10 +167,13 @@ namespace Glitter { glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, buffer_size, (void*)(offsetof(Buffer, position) + offset)); glEnableVertexAttribArray(1); - glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, buffer_size, - (void*)(offsetof(Buffer, uv) + offset)); + glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, buffer_size, + (void*)(offsetof(Buffer, uv[0]) + offset)); glEnableVertexAttribArray(2); - glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, buffer_size, + glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, buffer_size, + (void*)(offsetof(Buffer, uv[1]) + offset)); + glEnableVertexAttribArray(3); + glVertexAttribPointer(3, 4, GL_FLOAT, GL_FALSE, buffer_size, (void*)(offsetof(Buffer, color) + offset)); buffer += k->max_count; diff --git a/src/CRE/Glitter/glitter.cpp b/src/CRE/Glitter/glitter.cpp index efc09521..2e3387c0 100644 --- a/src/CRE/Glitter/glitter.cpp +++ b/src/CRE/Glitter/glitter.cpp @@ -298,10 +298,13 @@ namespace Glitter { glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, buffer_size, (void*)offsetof(Buffer, position)); glEnableVertexAttribArray(1); - glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, buffer_size, - (void*)offsetof(Buffer, uv)); + glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, buffer_size, + (void*)offsetof(Buffer, uv[0])); glEnableVertexAttribArray(2); - glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, buffer_size, + glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, buffer_size, + (void*)offsetof(Buffer, uv[1])); + glEnableVertexAttribArray(3); + glVertexAttribPointer(3, 4, GL_FLOAT, GL_FALSE, buffer_size, (void*)offsetof(Buffer, color)); gl_state.bind_array_buffer(0); diff --git a/src/CRE/effect.cpp b/src/CRE/effect.cpp index 4f61e26a..cc24d5bc 100644 --- a/src/CRE/effect.cpp +++ b/src/CRE/effect.cpp @@ -864,7 +864,7 @@ struct particle_data { }; struct rain_particle_scene_shader_data { - vec4 g_view[4]; + vec4 g_view[3]; vec4 g_proj[4]; vec4 g_range_scale; vec4 g_range_offset; @@ -1400,7 +1400,6 @@ void rain_particle_draw(render_data_context& rend_data_ctx, const cam_data& cam) scene_shader_data.g_view[0] = temp.row0; scene_shader_data.g_view[1] = temp.row1; scene_shader_data.g_view[2] = temp.row2; - scene_shader_data.g_view[3] = temp.row3; mat4_transpose(&cam.proj_mat, &temp); scene_shader_data.g_proj[0] = temp.row0; scene_shader_data.g_proj[1] = temp.row1; @@ -6105,14 +6104,14 @@ static void particle_init(vec3* offset) { glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, buffer_size, (void*)offsetof(particle_vertex_data, position)); glEnableVertexAttribArray(1); - glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, buffer_size, - (void*)offsetof(particle_vertex_data, color)); - glEnableVertexAttribArray(2); - glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, buffer_size, - (void*)offsetof(particle_vertex_data, texcoord)); - glEnableVertexAttribArray(3); - glVertexAttribPointer(3, 3, GL_FLOAT, GL_FALSE, buffer_size, + glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, buffer_size, (void*)offsetof(particle_vertex_data, normal)); + glEnableVertexAttribArray(2); + glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, buffer_size, + (void*)offsetof(particle_vertex_data, color)); + glEnableVertexAttribArray(3); + glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, buffer_size, + (void*)offsetof(particle_vertex_data, texcoord)); gl_state.bind_vertex_array(0); gl_state.bind_array_buffer(0); diff --git a/src/CRE/light_param/light.cpp b/src/CRE/light_param/light.cpp index 5c402319..8ed93128 100644 --- a/src/CRE/light_param/light.cpp +++ b/src/CRE/light_param/light.cpp @@ -276,8 +276,10 @@ void light_set::data_set(render_data_context& rend_data_ctx, face& face, light_s vec4 light_env_reflect_diffuse; vec4 light_env_reflect_ambient; + vec4 light_env_reflect_specular; lights[LIGHT_REFLECT].get_diffuse(light_env_reflect_diffuse); lights[LIGHT_REFLECT].get_ambient(light_env_reflect_ambient); + lights[LIGHT_REFLECT].get_specular(light_env_reflect_specular); vec4 light_env_proj_diffuse; vec4 light_env_proj_specular; @@ -428,14 +430,13 @@ void light_set::data_set(render_data_context& rend_data_ctx, face& face, light_s } rend_data_ctx.set_scene_light(irradiance_r_transforms, irradiance_g_transforms, irradiance_b_transforms, - light_env_stage_diffuse, light_env_stage_specular, light_env_chara_diffuse, - light_env_chara_ambient, light_env_chara_specular, - light_env_reflect_diffuse, light_env_reflect_ambient, - light_env_proj_diffuse, light_env_proj_specular, - light_env_proj_position, light_stage_dir, light_stage_diff, - light_stage_spec, light_chara_dir, light_chara_spec, - light_chara_luce, light_chara_back, light_face_diff, - chara_color0, chara_color1, chara_f_dir, chara_f_ambient, + light_env_stage_diffuse, light_env_stage_specular, + light_env_chara_diffuse, light_env_chara_ambient, light_env_chara_specular, + light_env_reflect_diffuse, light_env_reflect_ambient, light_env_reflect_specular, + light_env_proj_diffuse, light_env_proj_specular, light_env_proj_position, + light_stage_dir, light_stage_diff, light_stage_spec, + light_chara_dir, light_chara_spec, light_chara_luce, light_chara_back, + light_face_diff, chara_color0, chara_color1, chara_f_dir, chara_f_ambient, chara_f_diffuse, chara_tc_param, normal_tangent_transforms, light_reflect_dir, clip_plane, npr_cloth_spec_color); diff --git a/src/CRE/render.cpp b/src/CRE/render.cpp index 61331578..e8f5f26e 100644 --- a/src/CRE/render.cpp +++ b/src/CRE/render.cpp @@ -403,7 +403,7 @@ namespace rndr { if (!tex) return; - float_t v5 = tanf(cam.get_fov() * 0.5f * DEG_TO_RAD_FLOAT); + float_t v5 = tanf(cam.get_fov() * 0.5f); light_set* set = &rctx_ptr->light_set[LIGHT_SET_MAIN]; light_data* data = &set->lights[LIGHT_SUN]; @@ -446,7 +446,7 @@ namespace rndr { float_t v19 = v5 / (float_t)height * 0.5f; float_t v20 = lens_flare_pos.y - (float_t)height * 0.5f; - float_t v22 = sqrtf(v17 * v19 * v17 * v19 + v20 * v19 * v20 * v19 + 1.0f); + float_t v22 = sqrtf((v17 * v19) * (v17 * v19) + (v20 * v19) * (v20 * v19) + 1.0f); float_t v23 = ((float_t)render_width[0] * (flt_1411ACB8C / v5)) * (v22 * v22 * 0.5f) * ((float_t)render_height[0] * (flt_1411ACB8C / v5)); float_t v24 = vec3::distance(position, view_point) * flt_1411ACB84; @@ -1615,47 +1615,113 @@ namespace rndr { update_tone_map_lut(rend_data_ctx.state); + int32_t fade_func = scene_fade_blend_func[scene_fade_index]; + + vec4 fade_color; + *(vec3*)&fade_color = scene_fade_color[scene_fade_index]; + fade_color.w = scene_fade_alpha[scene_fade_index]; + if (fade_color.w <= 0.01) + fade_color.w = 0.0f; + else if (fade_func == 1 || fade_func == 2) + *(vec3*)&fade_color *= fade_color.w; + + float_t litproj_quality = 1.0; + + GLuint litproj_tex = 0; + if (light_proj_tex) + litproj_tex = light_proj_tex->glid; + + GLuint composite_back_tex = 0; + if (composite_back) + composite_back_tex = this->composite_back_tex->glid; + + vec4 exposure; + exposure.x = this->exposure * exposure_rate; + exposure.y = 0.0625f; + exposure.z = this->exposure * exposure_rate * 0.5f; + exposure.w = auto_exposure ? 1.0f : 0.0f; + + float_t lens_flare_coef = (lens_flare * 2.0f) * (lens_flare_appear_power + lens_flare_power); + float_t lens_shaft_coef = lens_shaft * 2.0f; + + vec2 lens_flare_pos = *(vec2*)&this->lens_flare_pos; + + apply_tone_map(rend_data_ctx, 0, 0, render_width[0], render_height[0], + rend_texture[0].GetColorTex(), reduce_tex_draw, composite_back_tex, litproj_tex, litproj_quality, + inner_width, inner_height, render_post_width_scale, render_post_height_scale, + exposure, tone_trans_scale[tone_trans_index], tone_trans_offset[tone_trans_index], fade_func, fade_color, + tone_map, gamma, lens_flare_pos, lens_shaft_scale, lens_flare_coef, lens_shaft_coef, + sss_contour_texture->GetColorTex(), sss_contour_texture->GetDepthTex(), rend_texture[0].GetDepthTex(), + npr_param == 1, false, rctx->render_manager->npr_mask); + rend_data_ctx.state.end_event(); + } + + void Render::apply_tone_map(render_data_context& rend_data_ctx, int64_t a3, int64_t a4, + int32_t render_width, int32_t render_height, GLuint color_tex, GLuint bloom_tex, + GLuint composite_back_tex, GLuint litproj_tex, float_t litproj_quality, int32_t width, int32_t height, + float_t s0, float_t t0, const vec4& exposure, const vec3& tone_scale, const vec3& tone_offset, + int32_t fade_func, const vec4& fade_color, int32_t tone_map, float_t gamma, + const vec2& lens_flare_pos, float_t lens_shaft_scale, float_t lens_flare_coef, float_t lens_shaft_coef, + GLuint contour_color_tex, GLuint contour_depth_tex, GLuint scene_depth_tex, + bool npr1, bool a31, bool npr_mask) { + render_context* rctx = rctx_ptr; + rend_data_ctx.shader_flags.arr[U_TONE_MAP] = (int32_t)tone_map; rend_data_ctx.shader_flags.arr[U_FLARE] = 0; rend_data_ctx.shader_flags.arr[U_COMPOSITE_BACK] = 0; rend_data_ctx.shader_flags.arr[U_LIGHT_PROJ] = 0; - int32_t scene_fade_blend_func = this->scene_fade_blend_func[scene_fade_index]; - - tone_map_shader_data shader_data; - shader_data.g_exposure.x = exposure * exposure_rate; - shader_data.g_exposure.y = 0.0625f; - shader_data.g_exposure.z = exposure * exposure_rate * 0.5f; - shader_data.g_exposure.w = auto_exposure ? 1.0f : 0.0f; - shader_data.g_flare_coef.x = (lens_flare * 2.0f) * (lens_flare_appear_power + lens_flare_power); - shader_data.g_flare_coef.y = lens_shaft * 2.0f; - shader_data.g_flare_coef.z = 0.0f; - shader_data.g_flare_coef.w = 0.0f; - *(vec3*)&shader_data.g_fade_color = scene_fade_color[scene_fade_index]; - shader_data.g_fade_color.w = scene_fade_alpha[scene_fade_index]; - if (scene_fade_blend_func == 1 || scene_fade_blend_func == 2) - *(vec3*)&shader_data.g_fade_color *= shader_data.g_fade_color.w; - *(vec3*)&shader_data.g_tone_scale = tone_trans_scale[tone_trans_index]; - *(vec3*)&shader_data.g_tone_offset = tone_trans_offset[tone_trans_index]; - shader_data.g_tone_scale.w = (float_t)scene_fade_blend_func; - shader_data.g_tone_offset.w = gamma > 0.0f ? 2.0f / (gamma * 3.0f) : 0.0f; - - shader_data.g_texcoord_transforms[0] = { 1.0f, 0.0f, 0.0f, 0.0f }; - shader_data.g_texcoord_transforms[1] = { 0.0f, 1.0f, 0.0f, 0.0f }; - shader_data.g_texcoord_transforms[2] = { 1.0f, 0.0f, 0.0f, 0.0f }; - shader_data.g_texcoord_transforms[3] = { 0.0f, 1.0f, 0.0f, 0.0f }; - - rend_data_ctx.state.active_bind_texture_2d(0, rend_texture[0].GetColorTex()); + rend_data_ctx.state.active_bind_texture_2d(0, color_tex); rend_data_ctx.state.bind_sampler(0, rctx->render_samplers[1]); - rend_data_ctx.state.active_bind_texture_2d(1, reduce_tex_draw); + rend_data_ctx.state.active_bind_texture_2d(1, bloom_tex); rend_data_ctx.state.bind_sampler(1, rctx->render_samplers[2]); rend_data_ctx.state.active_bind_texture_2d(2, tonemap_lut_texture); rend_data_ctx.state.bind_sampler(2, rctx->render_samplers[0]); rend_data_ctx.state.active_bind_texture_2d(3, exposure_tex); rend_data_ctx.state.bind_sampler(3, rctx->render_samplers[3]); + if (composite_back) { + rend_data_ctx.shader_flags.arr[U_COMPOSITE_BACK] = 1; + rend_data_ctx.state.active_bind_texture_2d(6, composite_back_tex); + } + else + rend_data_ctx.state.active_bind_texture_2d(6, rctx->empty_texture_2d->glid); + rend_data_ctx.state.bind_sampler(6, rctx->render_samplers[2]); + + if (litproj_tex) { + rend_data_ctx.shader_flags.arr[U_LIGHT_PROJ] = 1; + rend_data_ctx.state.active_bind_texture_2d(7, litproj_tex); + } + else + rend_data_ctx.state.active_bind_texture_2d(7, rctx->empty_texture_2d->glid); + rend_data_ctx.state.bind_sampler(7, rctx->render_samplers[2]); + + struct tonemap_flare { + vec3 transform_x; + float_t coef; + vec3 transform_y; + + inline tonemap_flare() : coef() { + + } + }; + + struct tonemap_texcoord_transforms { + tonemap_flare flare; + float_t param; + + inline tonemap_texcoord_transforms() : param() { + + } + }; + + float_t v35 = (float_t)render_width / (float_t)render_width * s0; + float_t v36 = (float_t)render_height / (float_t)render_height * t0; + + tonemap_texcoord_transforms texcoord_transforms[2]; + if (lens_flare_texture) { - const float_t aspect = (float_t)height / (float_t)width; + const float_t aspect = (float_t)height * (1.0f / (float_t)width); rend_data_ctx.shader_flags.arr[U_FLARE] = 1; rend_data_ctx.state.active_bind_texture_2d(4, lens_flare_texture); @@ -1664,14 +1730,16 @@ namespace rndr { mat4 mat; mat4_translate(0.5f, 0.5f, 0.0f, &mat); mat4_scale_rot(&mat, 0.75f, 0.75f, 1.0f, &mat); - mat4_mul_rotate_z(&mat, (lens_flare_pos.x / (float_t)width) - * 25.0f * DEG_TO_RAD_FLOAT, &mat); - mat4_mul_translate(&mat, -((1.0f / (float_t)width) * lens_flare_pos.x), + mat4_mul_rotate_z(&mat, lens_flare_pos.x * (1.0f / (float_t)width) + * (float_t)(25.0 * DEG_TO_RAD_FLOAT), &mat); + mat4_mul_translate(&mat, lens_flare_pos.x * (-1.0f / (float_t)width), (lens_flare_pos.y - (float_t)height) * (1.0f / (float_t)width), 0.0f, &mat); - mat4_scale_rot(&mat, 1.0f, aspect, 1.0f, &mat); - mat4_transpose(&mat, &mat); - shader_data.g_texcoord_transforms[4] = mat.row0; - shader_data.g_texcoord_transforms[5] = mat.row1; + mat4_scale_rot(&mat, 0.5f, 0.5f * aspect, 1.0f, &mat); + mat4_mul_translate(&mat, 1.0f, 1.0f, 0.0f, &mat); + + texcoord_transforms[0].flare.transform_x = vec3(mat.row0.x, mat.row1.x, mat.row3.x); + texcoord_transforms[0].flare.coef = lens_flare_coef; + texcoord_transforms[0].flare.transform_y = vec3(mat.row0.y, mat.row1.y, mat.row3.y); if (lens_shaft_scale < 50.0f) { rend_data_ctx.shader_flags.arr[U_FLARE] = 2; @@ -1680,21 +1748,20 @@ namespace rndr { mat4_translate(0.5f, 0.5f, 0.0f, &mat); mat4_scale_rot(&mat, lens_shaft_scale, lens_shaft_scale, 1.0f, &mat); - mat4_mul_rotate_z(&mat, (lens_flare_pos.x / (float_t)width) - * 60.0f * DEG_TO_RAD_FLOAT, &mat); - mat4_mul_translate(&mat, -((1.0f / (float_t)width) * lens_flare_pos.x), + mat4_mul_rotate_z(&mat, lens_flare_pos.x * (1.0f / (float_t)width) + * (float_t)(60.0 * DEG_TO_RAD_FLOAT), &mat); + mat4_mul_translate(&mat, lens_flare_pos.x * (-1.0f / (float_t)width), (lens_flare_pos.y - (float_t)height) * (1.0f / (float_t)width), 0.0f, &mat); - mat4_scale_rot(&mat, 1.0f, aspect, 1.0f, &mat); - mat4_transpose(&mat, &mat); - shader_data.g_texcoord_transforms[6] = mat.row0; - shader_data.g_texcoord_transforms[7] = mat.row1; + mat4_scale_rot(&mat, 0.5f, 0.5f * aspect, 1.0f, &mat); + mat4_mul_translate(&mat, 1.0f, 1.0f, 0.0f, &mat); + + texcoord_transforms[1].flare.transform_x = vec3(mat.row0.x, mat.row1.x, mat.row3.x); + texcoord_transforms[1].flare.coef = lens_shaft_coef; + texcoord_transforms[1].flare.transform_y = vec3(mat.row0.y, mat.row1.y, mat.row3.y); } else { rend_data_ctx.state.active_bind_texture_2d(5, rctx->empty_texture_2d->glid); rend_data_ctx.state.bind_sampler(5, rctx->render_samplers[2]); - - shader_data.g_texcoord_transforms[6] = { 1.0f, 0.0f, 0.0f, 0.0f }; - shader_data.g_texcoord_transforms[7] = { 0.0f, 1.0f, 0.0f, 0.0f }; } } else { @@ -1702,46 +1769,38 @@ namespace rndr { rend_data_ctx.state.bind_sampler(4, rctx->render_samplers[2]); rend_data_ctx.state.active_bind_texture_2d(5, rctx->empty_texture_2d->glid); rend_data_ctx.state.bind_sampler(5, rctx->render_samplers[2]); - - shader_data.g_texcoord_transforms[4] = { 1.0f, 0.0f, 0.0f, 0.0f }; - shader_data.g_texcoord_transforms[5] = { 0.0f, 1.0f, 0.0f, 0.0f }; - shader_data.g_texcoord_transforms[6] = { 1.0f, 0.0f, 0.0f, 0.0f }; - shader_data.g_texcoord_transforms[7] = { 0.0f, 1.0f, 0.0f, 0.0f }; } - if (composite_back) { - rend_data_ctx.state.active_bind_texture_2d(6, composite_back_tex->glid); - rend_data_ctx.state.bind_sampler(6, rctx->render_samplers[2]); - rend_data_ctx.shader_flags.arr[U_COMPOSITE_BACK] = 1; - } - - if (light_proj_tex) { - rend_data_ctx.shader_flags.arr[U_LIGHT_PROJ] = 1; - rend_data_ctx.state.active_bind_texture_2d(7, light_proj_tex->glid); - rend_data_ctx.state.bind_sampler(7, rctx->render_samplers[2]); - - shader_data.g_flare_coef.z = 1.0f; - } - else { - rend_data_ctx.state.active_bind_texture_2d(7, rctx->empty_texture_2d->glid); - rend_data_ctx.state.bind_sampler(7, rctx->render_samplers[2]); - } - - if (composite_back && npr_param == 1) { - rend_data_ctx.state.active_bind_texture_2d(14, rend_texture[0].GetDepthTex()); + if (tone_map == 0 && composite_back_tex && npr1 && npr_mask) { + rend_data_ctx.state.active_bind_texture_2d(14, scene_depth_tex); rend_data_ctx.state.bind_sampler(14, rctx->render_samplers[1]); } + else { + rend_data_ctx.state.active_bind_texture_2d(14, rctx->empty_texture_2d->glid); + rend_data_ctx.state.bind_sampler(14, rctx->render_samplers[2]); + } + + texcoord_transforms[0].param = litproj_quality; + texcoord_transforms[1].param = litproj_tex ? 1.0f : 0.0f; + + tone_map_shader_data shader_data; + shader_data.g_exposure = exposure; + shader_data.g_fade_color = fade_color; + *(vec3*)&shader_data.g_tone_scale = tone_scale; + shader_data.g_tone_scale.w = (float_t)fade_func; + *(vec3*)&shader_data.g_tone_offset = tone_offset; + shader_data.g_tone_offset.w = gamma > 0.0f ? 2.0f / (gamma * 3.0f) : 0.0f; + memcpy(shader_data.g_texcoord_transforms, texcoord_transforms, sizeof(vec4) * 4); rctx->tone_map_ubo.WriteMemory(rend_data_ctx.state, shader_data); - rend_data_ctx.state.set_viewport(0, 0, render_width[0], render_height[0]); + rend_data_ctx.state.set_viewport(0, 0, render_width, render_height); taa_buffer[2].Bind(rend_data_ctx.state); shaders_ft.set(rend_data_ctx.state, rend_data_ctx.shader_flags, SHADER_FT_TONEMAP); rend_data_ctx.state.bind_uniform_buffer_base(1, rctx->tone_map_ubo); rend_data_ctx.state.bind_vertex_array(rctx->common_vao); rend_data_ctx.state.draw_arrays(GL_TRIANGLE_STRIP, 0, 4); rend_data_ctx.state.active_bind_texture_2d(2, 0); - rend_data_ctx.state.end_event(); } void Render::calc_exposure(render_data_context& rend_data_ctx, const cam_data& cam) { @@ -1999,21 +2058,21 @@ namespace rndr { } void Render::draw_lens_ghost(render_data_context& rend_data_ctx) { - static const float_t v13[16] = { + static const float_t pos_scale_array[16] = { -0.70f, -0.30f, 0.35f, 0.50f, -0.45f, -0.80f, 0.20f, 0.41f, - 0.17f, -0.10f, 0.06f, 0.10f, + -0.17f, -0.10f, 0.06f, 0.10f, 0.14f, 0.04f, -0.13f, -0.22f, }; - static const float_t v14[16] = { + static const float_t opacity_array[16] = { 0.8f, 1.0f, 1.0f, 1.0f, 0.4f, 0.5f, 0.8f, 0.8f, 0.6f, 0.7f, 0.8f, 0.7f, 0.8f, 0.7f, 0.6f, 0.8f, }; - static const float_t v15[16] = { + static const float_t scale_array[16] = { 1.3f, 1.5f, 1.00f, 1.1f, 2.5f, 0.8f, 0.50f, 0.5f, 0.7f, 0.4f, 0.35f, 0.5f, @@ -2047,12 +2106,12 @@ namespace rndr { const float_t lens_ghost = this->lens_ghost; const int32_t lens_ghost_count = this->lens_ghost_count; for (int32_t i = 0; i < lens_ghost_count; i++) { - float_t opacity = v9 * v14[i] * lens_ghost; + float_t opacity = v9 * opacity_array[i] * lens_ghost; - float_t scale = (v9a * 0.03f + 0.02f) * v15[i]; + float_t scale = (v9a * 0.03f + 0.02f) * scale_array[i]; mat4 mat; - mat4_translate(v13[i] * v7 + 0.5f, v13[i] * v8 + 0.5f, 0.0f, &mat); + mat4_translate(pos_scale_array[i] * v7 + 0.5f, pos_scale_array[i] * v8 + 0.5f, 0.0f, &mat); mat4_scale_rot(&mat, scale, scale * aspect, 1.0f, &mat); mat4_mul_rotate_z(&mat, angle_sin, angle_cos, &mat); make_ghost_quad((uint8_t)(i & 0x03), opacity, &mat, data); diff --git a/src/CRE/render.hpp b/src/CRE/render.hpp index 2213c328..4738495f 100644 --- a/src/CRE/render.hpp +++ b/src/CRE/render.hpp @@ -269,6 +269,14 @@ namespace rndr { void apply_mlaa(render_data_context& rend_data_ctx, int32_t destination, int32_t source, int32_t ss_alpha_mask); void apply_tone_map(render_data_context& rend_data_ctx, texture* light_proj_tex, int32_t npr_param); + void apply_tone_map(render_data_context& rend_data_ctx, int64_t a3, int64_t a4, + int32_t render_width, int32_t render_height, GLuint color_tex, GLuint bloom_tex, + GLuint composite_back_tex, GLuint litproj_tex, float_t litproj_quality, int32_t width, int32_t height, + float_t s0, float_t t0, const vec4& exposure, const vec3& tone_scale, const vec3& tone_offset, + int32_t fade_func, const vec4& fade_color, int32_t tone_map, float_t gamma, + const vec2& lens_flare_pos, float_t lens_shaft_scale, float_t lens_flare_coef, float_t lens_shaft_coef, + GLuint contour_color_tex, GLuint contour_depth_tex, GLuint scene_depth_tex, + bool npr1, bool a31, bool npr_mask); void calc_exposure(render_data_context& rend_data_ctx, const cam_data& cam); void calc_gaussian_blur(render_data_context& rend_data_ctx, float_t start, float_t step, int32_t kernel_size, float_t radius_scale, float_t intensity_scale); diff --git a/src/CRE/render_context.cpp b/src/CRE/render_context.cpp index 5120e286..9997162c 100644 --- a/src/CRE/render_context.cpp +++ b/src/CRE/render_context.cpp @@ -223,7 +223,9 @@ bool light_proj::set_mat(render_data_context& rend_data_ctx, cam_data& cam, bool mat4 mat; light_proj_get_view_proj_mat(cam, position, interest, fov * RAD_TO_DEG_FLOAT, 4.0f, 0.1f, 10.0f, &mat); - rend_data_ctx.set_scene_light_projection(mat); + + mat4 mat_depth = mat; + rend_data_ctx.set_scene_light_projection(mat, mat_depth); } else light_proj_get_view_proj_mat(cam, position, interest, @@ -328,6 +330,7 @@ void render_data::obj_scene_data::reset() { g_light_env_chara_specular = 0.0f; g_light_env_reflect_diffuse = 1.0f; g_light_env_reflect_ambient = 0.0f; + g_light_env_reflect_specular = 0.0f; g_light_env_proj_diffuse = 1.0f; g_light_env_proj_specular = 0.0f; g_light_env_proj_position = 0.0f; @@ -339,7 +342,6 @@ void render_data::obj_scene_data::reset() { g_light_chara_luce = 0.0f; g_light_chara_back = 0.0f; g_light_face_diff = 0.0f; - g_chara_color_rim = 0.0f; g_chara_color0 = 0.0f; g_chara_color1 = 0.0f; g_chara_f_dir = { 0.0f, 1.0f, 0.0f, 0.0f }; @@ -382,6 +384,10 @@ void render_data::obj_scene_data::reset() { g_light_projection[1] = mat4_identity.row1; g_light_projection[2] = mat4_identity.row2; g_light_projection[3] = mat4_identity.row3; + g_light_projection_depth[0] = mat4_identity.row0; + g_light_projection_depth[1] = mat4_identity.row1; + g_light_projection_depth[2] = mat4_identity.row2; + g_light_projection_depth[3] = mat4_identity.row3; g_forward_z_projection_row2 = 0.0f; } @@ -844,11 +850,12 @@ void render_data_context::set_scene_light(const mat4& irradiance_r_transforms, c const vec4& light_env_stage_specular, const vec4& light_env_chara_diffuse, const vec4& light_env_chara_ambient, const vec4& light_env_chara_specular, const vec4& light_env_reflect_diffuse, const vec4& light_env_reflect_ambient, - const vec4& light_env_proj_diffuse, const vec4& light_env_proj_specular, - const vec4& light_env_proj_position, const vec4& light_stage_dir, const vec4& light_stage_diff, - const vec4& light_stage_spec, const vec4& light_chara_dir, const vec4& light_chara_spec, - const vec4& light_chara_luce, const vec4& light_chara_back, const vec4& light_face_diff, - const vec4& chara_color0, const vec4& chara_color1, const vec4& chara_f_dir, const vec4& chara_f_ambient, + const vec4& light_env_reflect_specular, const vec4& light_env_proj_diffuse, + const vec4& light_env_proj_specular, const vec4& light_env_proj_position, + const vec4& light_stage_dir, const vec4& light_stage_diff, const vec4& light_stage_spec, + const vec4& light_chara_dir, const vec4& light_chara_spec, const vec4& light_chara_luce, + const vec4& light_chara_back, const vec4& light_face_diff, const vec4& chara_color0, + const vec4& chara_color1, const vec4& chara_f_dir, const vec4& chara_f_ambient, const vec4& chara_f_diffuse, const vec4& chara_tc_param, const mat4& normal_tangent_transforms, const vec4& light_reflect_dir, const vec4& clip_plane, const vec4& npr_cloth_spec_color) { mat4 temp; @@ -874,6 +881,7 @@ void render_data_context::set_scene_light(const mat4& irradiance_r_transforms, c data.buffer_scene_data.g_light_env_chara_specular = light_env_chara_specular; data.buffer_scene_data.g_light_env_reflect_diffuse = light_env_reflect_diffuse; data.buffer_scene_data.g_light_env_reflect_ambient = light_env_reflect_ambient; + data.buffer_scene_data.g_light_env_reflect_specular = light_env_reflect_specular; data.buffer_scene_data.g_light_env_proj_diffuse = light_env_proj_diffuse; data.buffer_scene_data.g_light_env_proj_specular = light_env_proj_specular; data.buffer_scene_data.g_light_env_proj_position = light_env_proj_position; @@ -901,13 +909,19 @@ void render_data_context::set_scene_light(const mat4& irradiance_r_transforms, c enum_or(data.flags, RENDER_DATA_SCENE_UPDATE); } -void render_data_context::set_scene_light_projection(const mat4& light_projection) { +void render_data_context::set_scene_light_projection( + const mat4& light_projection, const mat4& light_projection_depth) { mat4 temp; mat4_transpose(&light_projection, &temp); data.buffer_scene_data.g_light_projection[0] = temp.row0; data.buffer_scene_data.g_light_projection[1] = temp.row1; data.buffer_scene_data.g_light_projection[2] = temp.row2; data.buffer_scene_data.g_light_projection[3] = temp.row3; + mat4_transpose(&light_projection_depth, &temp); + data.buffer_scene_data.g_light_projection_depth[0] = temp.row0; + data.buffer_scene_data.g_light_projection_depth[1] = temp.row1; + data.buffer_scene_data.g_light_projection_depth[2] = temp.row2; + data.buffer_scene_data.g_light_projection_depth[3] = temp.row3; enum_or(data.flags, RENDER_DATA_SCENE_UPDATE); } @@ -1119,13 +1133,21 @@ sprite_width(), sprite_height(), screen_x_offset(), screen_y_offset(), screen_wi gl_state.bind_array_buffer(box_vbo); glEnableVertexAttribArray(0); - glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(float_t) * 16, (void*)0); + glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float_t) * 8, (void*)0); glEnableVertexAttribArray(1); - glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, sizeof(float_t) * 16, (void*)(sizeof(float_t) * 4)); + glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(float_t) * 8, (void*)(sizeof(float_t) * 2)); glEnableVertexAttribArray(2); - glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(float_t) * 16, (void*)(sizeof(float_t) * 8)); + glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(float_t) * 8, (void*)(sizeof(float_t) * 4)); glEnableVertexAttribArray(3); - glVertexAttribPointer(3, 4, GL_FLOAT, GL_FALSE, sizeof(float_t) * 16, (void*)(sizeof(float_t) * 12)); + glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, sizeof(float_t) * 8, (void*)(sizeof(float_t) * 6)); + glEnableVertexAttribArray(4); + glVertexAttribPointer(4, 2, GL_FLOAT, GL_FALSE, sizeof(float_t) * 8, (void*)(sizeof(float_t) * 8)); + glEnableVertexAttribArray(5); + glVertexAttribPointer(5, 2, GL_FLOAT, GL_FALSE, sizeof(float_t) * 8, (void*)(sizeof(float_t) * 10)); + glEnableVertexAttribArray(6); + glVertexAttribPointer(6, 2, GL_FLOAT, GL_FALSE, sizeof(float_t) * 8, (void*)(sizeof(float_t) * 12)); + glEnableVertexAttribArray(7); + glVertexAttribPointer(7, 2, GL_FLOAT, GL_FALSE, sizeof(float_t) * 8, (void*)(sizeof(float_t) * 14)); glGenVertexArrays(1, &lens_ghost_vao); gl_state.bind_vertex_array(lens_ghost_vao); diff --git a/src/CRE/render_context.hpp b/src/CRE/render_context.hpp index 43b79b35..1e739be1 100644 --- a/src/CRE/render_context.hpp +++ b/src/CRE/render_context.hpp @@ -208,11 +208,14 @@ struct sun_quad_shader_data { struct tone_map_shader_data { vec4 g_exposure; - vec4 g_flare_coef; //xy=flare_coef, z=light_proj vec4 g_fade_color; vec4 g_tone_scale; //xyz=tone_scale, w=fade_func vec4 g_tone_offset; //xyz=tone_offset, w=inv_tone - vec4 g_texcoord_transforms[8]; + //[0].xyz=texcoord_transforms[0].xyw, [0].w=lens_flare_coef + //[1].xyz=texcoord_transforms[1].xyw, [1].w=litproj_quality + //[2].xyz=texcoord_transforms[2].xyw, [2].w=lens_shaft_coef + //[3].xyz=texcoord_transforms[3].xyw, [3].w=litproj_enable + vec4 g_texcoord_transforms[4]; }; struct transparency_batch_shader_data { @@ -331,6 +334,7 @@ struct render_data { vec4 g_light_env_chara_specular; vec4 g_light_env_reflect_diffuse; vec4 g_light_env_reflect_ambient; + vec4 g_light_env_reflect_specular; vec4 g_light_env_proj_diffuse; vec4 g_light_env_proj_specular; vec4 g_light_env_proj_position; @@ -342,7 +346,6 @@ struct render_data { vec4 g_light_chara_luce; vec4 g_light_chara_back; vec4 g_light_face_diff; - vec4 g_chara_color_rim; vec4 g_chara_color0; vec4 g_chara_color1; vec4 g_chara_f_dir; @@ -368,6 +371,7 @@ struct render_data { vec4 g_projection_view[4]; vec4 g_view_position; vec4 g_light_projection[4]; + vec4 g_light_projection_depth[4]; vec4 g_forward_z_projection_row2; void reset(); @@ -483,14 +487,15 @@ struct render_data_context { const vec4& light_env_stage_specular, const vec4& light_env_chara_diffuse, const vec4& light_env_chara_ambient, const vec4& light_env_chara_specular, const vec4& light_env_reflect_diffuse, const vec4& light_env_reflect_ambient, - const vec4& light_env_proj_diffuse, const vec4& light_env_proj_specular, - const vec4& light_env_proj_position, const vec4& light_stage_dir, const vec4& light_stage_diff, - const vec4& light_stage_spec, const vec4& light_chara_dir, const vec4& light_chara_spec, - const vec4& light_chara_luce, const vec4& light_chara_back, const vec4& light_face_diff, - const vec4& chara_color0, const vec4& chara_color1, const vec4& chara_f_dir, const vec4& chara_f_ambient, + const vec4& light_env_reflect_specular, const vec4& light_env_proj_diffuse, + const vec4& light_env_proj_specular, const vec4& light_env_proj_position, + const vec4& light_stage_dir, const vec4& light_stage_diff, const vec4& light_stage_spec, + const vec4& light_chara_dir, const vec4& light_chara_spec, const vec4& light_chara_luce, + const vec4& light_chara_back, const vec4& light_face_diff, const vec4& chara_color0, + const vec4& chara_color1, const vec4& chara_f_dir, const vec4& chara_f_ambient, const vec4& chara_f_diffuse, const vec4& chara_tc_param, const mat4& normal_tangent_transforms, const vec4& light_reflect_dir, const vec4& clip_plane, const vec4& npr_cloth_spec_color); - void set_scene_light_projection(const mat4& light_projection); + void set_scene_light_projection(const mat4& light_projection, const mat4& light_projection_depth); void set_scene_shadow_params(const float_t esm_param, const mat4 mats[2], const vec4& shadow_ambient, const vec4& shadow_ambient1); void set_self_shadow(bool value); diff --git a/src/CRE/shader.cpp b/src/CRE/shader.cpp index 05aaa558..de69c3ef 100644 --- a/src/CRE/shader.cpp +++ b/src/CRE/shader.cpp @@ -300,6 +300,37 @@ static char* get_uniform_location(char* data, prj::vector_pair(length); + GLchar* info_log = force_malloc(length + 1LL); glGetShaderInfoLog(shader, length, 0, info_log); + info_log[length] = 0; + const char* type_str = "Unknown"; switch (type) { case GL_FRAGMENT_SHADER: @@ -1388,8 +1424,9 @@ static GLuint shader_compile_shader(GLenum type, const char* data, const char* f s.open(buf, L"wb"); s.write_utf8_string(data); s.write_utf8_string("\n/*\n"); - s.write_utf8_string(info_log); + s.write(info_log, length); s.write_utf8_string("*/\n"); + s.close(); } free_def(info_log); @@ -1420,8 +1457,10 @@ static GLuint shader_compile(const char* vert, const char* frag, const char* vp, if (!success) { GLint length = 0; glGetProgramiv(program, GL_INFO_LOG_LENGTH, &length); - GLchar* info_log = force_malloc(length); + GLchar* info_log = force_malloc(length + 1LL); glGetProgramInfoLog(program, length, 0, info_log); + info_log[length] = 0; + printf_debug("Program Shader Permut linking error:\nvp: %s; fp: %s\n%s\n", vp, fp, info_log); wchar_t temp_buf[MAX_PATH]; @@ -1444,7 +1483,7 @@ static GLuint shader_compile(const char* vert, const char* frag, const char* vp, s.open(buf, L"wb"); s.write_utf8_string(vert); s.write_utf8_string("\n/*\n"); - s.write_utf8_string(info_log); + s.write(info_log, length); s.write_utf8_string("*/\n"); s.close(); @@ -1455,7 +1494,7 @@ static GLuint shader_compile(const char* vert, const char* frag, const char* vp, s.open(buf, L"wb"); s.write_utf8_string(frag); s.write_utf8_string("\n/*\n"); - s.write_utf8_string(info_log); + s.write(info_log, length); s.write_utf8_string("*/\n"); s.close(); } @@ -1494,8 +1533,10 @@ static GLuint shader_compile_binary(const char* vert, const char* frag, const ch if (!success) { GLint length = 0; glGetProgramiv(program, GL_INFO_LOG_LENGTH, &length); - GLchar* info_log = force_malloc(length); + GLchar* info_log = force_malloc(length + 1LL); glGetProgramInfoLog(program, length, 0, info_log); + info_log[length] = 0; + printf_debug("Program Shader Permut linking error:\nvp: %s; fp: %s\n%s\n", vp, fp, info_log); wchar_t temp_buf[MAX_PATH]; @@ -1518,7 +1559,7 @@ static GLuint shader_compile_binary(const char* vert, const char* frag, const ch s.open(buf, L"wb"); s.write_utf8_string(vert); s.write_utf8_string("\n/*\n"); - s.write_utf8_string(info_log); + s.write(info_log, length); s.write_utf8_string("*/\n"); s.close(); @@ -1529,7 +1570,7 @@ static GLuint shader_compile_binary(const char* vert, const char* frag, const ch s.open(buf, L"wb"); s.write_utf8_string(frag); s.write_utf8_string("\n/*\n"); - s.write_utf8_string(info_log); + s.write(info_log, length); s.write_utf8_string("*/\n"); s.close(); } diff --git a/src/CRE/shader_ft.cpp b/src/CRE/shader_ft.cpp index a15b4b4d..9f9d929a 100644 --- a/src/CRE/shader_ft.cpp +++ b/src/CRE/shader_ft.cpp @@ -200,11 +200,11 @@ static const int32_t tights_fpt_unival_max[] = { }; static const int32_t sky_default_vpt_unival_max[] = { - 1, 0, + 1, }; static const int32_t sky_default_fpt_unival_max[] = { - 0, 1, + 0, }; static const int32_t glass_eye_vpt_unival_max[] = { @@ -248,19 +248,19 @@ static const int32_t lit_proj_fpt_unival_max[] = { }; static const int32_t simple_vpt_unival_max[] = { - 1, + 1, 0, }; static const int32_t simple_fpt_unival_max[] = { - 0, + 0, 1, }; static const int32_t silhouette_vpt_unival_max[] = { - 1, 1, 0, + 1, 1, 0, 0, }; static const int32_t silhouette_fpt_unival_max[] = { - 0, 0, 1, + 0, 0, 1, 1, }; static const int32_t lambert_vpt_unival_max[] = { @@ -568,11 +568,11 @@ static const int32_t puddle_fpt_unival_max[] = { }; static const int32_t simple_reflect_vpt_unival_max[] = { - 1, 1, 0, + 1, 1, 0, 0, }; static const int32_t simple_reflect_fpt_unival_max[] = { - 0, 0, 1, + 0, 0, 1, 1, }; static const int32_t simple_refract_vpt_unival_max[] = { @@ -1181,6 +1181,10 @@ static const shader_description simple_vpt_desc[] = { static const shader_description simple_fpt_desc[] = { { SHADER_DESCRIPTION_SAMPLER, 0, 0, U_INVALID, }, + { SHADER_DESCRIPTION_SAMPLER, 1, 0, U_INVALID, }, + { SHADER_DESCRIPTION_SAMPLER, 2, 0, U_INVALID, }, + { SHADER_DESCRIPTION_SAMPLER, 3, 0, U_INVALID, }, + { SHADER_DESCRIPTION_SAMPLER, 4, 0, U_INVALID, }, SHADER_DESCRIPTION_COMMON_SCENE, { SHADER_DESCRIPTION_FRAGMENT_OUTPUT, 0, 4, U_INVALID, }, { SHADER_DESCRIPTION_END, -1, -1, U_INVALID, }, @@ -1289,8 +1293,8 @@ static const shader_description tone_map_npr1_vpt_desc[] = { static const shader_description tone_map_npr1_fpt_desc[] = { { SHADER_DESCRIPTION_SAMPLER, 0, 0, U_INVALID, }, { SHADER_DESCRIPTION_SAMPLER, 1, 0, U_INVALID, }, - { SHADER_DESCRIPTION_SAMPLER, 6, 0, U_AET_BACK, }, - { SHADER_DESCRIPTION_SAMPLER, 14, 0, U_AET_BACK, }, + { SHADER_DESCRIPTION_SAMPLER, 6, 0, U_COMPOSITE_BACK, }, + { SHADER_DESCRIPTION_SAMPLER, 14, 0, U_COMPOSITE_BACK, }, SHADER_DESCRIPTION_COMMON_QUAD, { SHADER_DESCRIPTION_UNIFORM, 1, SHADER_DESCRIPTION_UNIFORM_READ_ONLY | sizeof(tone_map_shader_data), U_INVALID, }, @@ -1884,9 +1888,9 @@ static const shader_description fog_ptcl_fpt_desc[] = { static const shader_description particle_vpt_desc[] = { { SHADER_DESCRIPTION_VERTEX_INPUT, 0, 3, U_INVALID, }, - { SHADER_DESCRIPTION_VERTEX_INPUT, 1, 4, U_INVALID, }, - { SHADER_DESCRIPTION_VERTEX_INPUT, 2, 2, U_INVALID, }, - { SHADER_DESCRIPTION_VERTEX_INPUT, 3, 3, U_INVALID, }, + { SHADER_DESCRIPTION_VERTEX_INPUT, 1, 3, U_INVALID, }, + { SHADER_DESCRIPTION_VERTEX_INPUT, 2, 4, U_INVALID, }, + { SHADER_DESCRIPTION_VERTEX_INPUT, 3, 2, U_INVALID, }, { SHADER_DESCRIPTION_UNIFORM, 0, SHADER_DESCRIPTION_UNIFORM_READ_ONLY | 0x70, U_INVALID, }, // sizeof(particle_scene_shader_data) { SHADER_DESCRIPTION_END, -1, -1, U_INVALID, }, @@ -1904,8 +1908,9 @@ static const shader_description particle_fpt_desc[] = { static const shader_description glitter_particle_vpt_desc[] = { { SHADER_DESCRIPTION_VERTEX_INPUT, 0, 3, U_INVALID, }, - { SHADER_DESCRIPTION_VERTEX_INPUT, 1, 4, U_INVALID, }, - { SHADER_DESCRIPTION_VERTEX_INPUT, 2, 4, U_INVALID, }, + { SHADER_DESCRIPTION_VERTEX_INPUT, 1, 2, U_INVALID, }, + { SHADER_DESCRIPTION_VERTEX_INPUT, 2, 2, U_INVALID, }, + { SHADER_DESCRIPTION_VERTEX_INPUT, 3, 4, U_INVALID, }, SHADER_DESCRIPTION_EFFECT_TEXTURE_SAMPLER, { SHADER_DESCRIPTION_UNIFORM, -1, SHADER_DESCRIPTION_UNIFORM_READ_ONLY | sizeof(render_data::obj_shader_data), U_INVALID, }, @@ -1945,8 +1950,10 @@ static const shader_description font_fpt_desc[] = { }; static const shader_description box4_vpt_desc[] = { - { SHADER_DESCRIPTION_VERTEX_INPUT, 0, 4, U_INVALID, }, - { SHADER_DESCRIPTION_VERTEX_INPUT, 1, 4, U_INVALID, }, + { SHADER_DESCRIPTION_VERTEX_INPUT, 0, 2, U_INVALID, }, + { SHADER_DESCRIPTION_VERTEX_INPUT, 1, 2, U_INVALID, }, + { SHADER_DESCRIPTION_VERTEX_INPUT, 2, 2, U_INVALID, }, + { SHADER_DESCRIPTION_VERTEX_INPUT, 3, 2, U_INVALID, }, { SHADER_DESCRIPTION_UNIFORM, 0, SHADER_DESCRIPTION_UNIFORM_READ_ONLY | sizeof(filter_scene_shader_data), U_INVALID, }, { SHADER_DESCRIPTION_END, -1, -1, U_INVALID, }, @@ -1961,10 +1968,14 @@ static const shader_description box4_fpt_desc[] = { }; static const shader_description box8_vpt_desc[] = { - { SHADER_DESCRIPTION_VERTEX_INPUT, 0, 4, U_INVALID, }, - { SHADER_DESCRIPTION_VERTEX_INPUT, 1, 4, U_INVALID, }, - { SHADER_DESCRIPTION_VERTEX_INPUT, 2, 4, U_INVALID, }, - { SHADER_DESCRIPTION_VERTEX_INPUT, 3, 4, U_INVALID, }, + { SHADER_DESCRIPTION_VERTEX_INPUT, 0, 2, U_INVALID, }, + { SHADER_DESCRIPTION_VERTEX_INPUT, 1, 2, U_INVALID, }, + { SHADER_DESCRIPTION_VERTEX_INPUT, 2, 2, U_INVALID, }, + { SHADER_DESCRIPTION_VERTEX_INPUT, 3, 2, U_INVALID, }, + { SHADER_DESCRIPTION_VERTEX_INPUT, 4, 2, U_INVALID, }, + { SHADER_DESCRIPTION_VERTEX_INPUT, 5, 2, U_INVALID, }, + { SHADER_DESCRIPTION_VERTEX_INPUT, 6, 2, U_INVALID, }, + { SHADER_DESCRIPTION_VERTEX_INPUT, 7, 2, U_INVALID, }, { SHADER_DESCRIPTION_UNIFORM, 0, SHADER_DESCRIPTION_UNIFORM_READ_ONLY | sizeof(filter_scene_shader_data), U_INVALID, }, { SHADER_DESCRIPTION_END, -1, -1, U_INVALID, }, @@ -1996,6 +2007,7 @@ static const shader_description sprite_vpt_desc[] = { { SHADER_DESCRIPTION_VERTEX_INPUT, 0, 3, U_INVALID, }, { SHADER_DESCRIPTION_VERTEX_INPUT, 1, 4, U_INVALID, }, { SHADER_DESCRIPTION_VERTEX_INPUT, 2, 2, U_INVALID, }, + { SHADER_DESCRIPTION_VERTEX_INPUT, 3, 2, U_INVALID, }, { SHADER_DESCRIPTION_UNIFORM, 0, SHADER_DESCRIPTION_UNIFORM_READ_ONLY | sizeof(sprite_scene_shader_data), U_INVALID, }, { SHADER_DESCRIPTION_END, -1, -1, U_INVALID, }, @@ -2376,7 +2388,6 @@ static const uniform_name TIGHTS_uniform[] = { static const uniform_name SKY_uniform[] = { U_MORPH, - U_ALPHA_TEST, }; static const uniform_name GLASEYE_uniform[] = { @@ -2398,12 +2409,14 @@ static const uniform_name LITPROJ_uniform[] = { static const uniform_name SIMPLE_uniform[] = { U_SKINNING, + U_ALPHA_TEST, }; static const uniform_name SIL_uniform[] = { U_SKINNING, U_MORPH, U_ALPHA_TEST, + U_DEPTH, }; static const uniform_name LAMBERT_uniform[] = { @@ -2493,6 +2506,7 @@ static const uniform_name S_REFL_uniform[] = { U_SKINNING, U_MORPH, U_ALPHA_TEST, + U_CLIP_PLANE, }; static const uniform_name S_REFR_uniform[] = { diff --git a/src/CRE/sprite.cpp b/src/CRE/sprite.cpp index 71f52632..4602eabc 100644 --- a/src/CRE/sprite.cpp +++ b/src/CRE/sprite.cpp @@ -685,8 +685,11 @@ namespace spr { glVertexAttribPointer(1, 4, GL_UNSIGNED_BYTE, GL_TRUE, buffer_size_uv2, (void*)offsetof(sprite_vertex_data_uv2, color)); glEnableVertexAttribArray(2); - glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, buffer_size_uv2, - (void*)offsetof(sprite_vertex_data_uv2, uv)); + glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, buffer_size_uv2, + (void*)offsetof(sprite_vertex_data_uv2, uv[0])); + glEnableVertexAttribArray(3); + glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, buffer_size_uv2, + (void*)offsetof(sprite_vertex_data_uv2, uv[1])); gl_state.bind_array_buffer(0); gl_state.bind_vertex_array(0); @@ -765,8 +768,11 @@ namespace spr { glVertexAttribPointer(1, 4, GL_UNSIGNED_BYTE, GL_TRUE, buffer_size_uv2, (void*)offsetof(sprite_vertex_data_uv2, color)); glEnableVertexAttribArray(2); - glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, buffer_size_uv2, - (void*)offsetof(sprite_vertex_data_uv2, uv)); + glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, buffer_size_uv2, + (void*)offsetof(sprite_vertex_data_uv2, uv[0])); + glEnableVertexAttribArray(3); + glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, buffer_size_uv2, + (void*)offsetof(sprite_vertex_data_uv2, uv[1])); gl_state.bind_array_buffer(0); gl_state.bind_vertex_array(0);