Small overhaul
This commit is contained in:
Binary file not shown.
@@ -171,7 +171,6 @@ del "$(SolutionDir)bin\$(TargetName).lib"</Command>
|
||||
<ClCompile Include="pv_game\pv_game.cpp" />
|
||||
<ClCompile Include="renderer\dof.cpp" />
|
||||
<ClCompile Include="renderer\fbo.cpp" />
|
||||
<ClCompile Include="renderer\gl_program.cpp" />
|
||||
<ClCompile Include="renderer\transparency.cpp" />
|
||||
<ClCompile Include="rob\rob.cpp" />
|
||||
<ClCompile Include="auth_2d.cpp" />
|
||||
@@ -229,7 +228,6 @@ del "$(SolutionDir)bin\$(TargetName).lib"</Command>
|
||||
<ClInclude Include="pv_game\pvpp.hpp" />
|
||||
<ClInclude Include="pv_game\pvsr.hpp" />
|
||||
<ClInclude Include="pv_game\pv_game.hpp" />
|
||||
<ClInclude Include="renderer\gl_program.hpp" />
|
||||
<ClInclude Include="renderer\dof.hpp" />
|
||||
<ClInclude Include="renderer\fbo.hpp" />
|
||||
<ClInclude Include="renderer\transparency.hpp" />
|
||||
|
||||
+44
-46
@@ -894,11 +894,22 @@ HOOK(void, FASTCALL, leaf_particle_init, 0x000000014034C530, bool change_stage)
|
||||
for (; i < leaf_ptcl_count; i++, data++)
|
||||
data->type = 0;
|
||||
|
||||
if (!leaf_ptcl_vao)
|
||||
glGenVertexArrays(1, &leaf_ptcl_vao);
|
||||
size_t ebo_count = leaf_ptcl_vtx_count / 4 * 6;
|
||||
uint32_t* ebo_data = force_malloc<uint32_t>(ebo_count);
|
||||
for (size_t i = 0, j = 0; i < ebo_count; i += 6, j += 4) {
|
||||
ebo_data[i + 0] = (uint32_t)(j + 0);
|
||||
ebo_data[i + 1] = (uint32_t)(j + 1);
|
||||
ebo_data[i + 2] = (uint32_t)(j + 2);
|
||||
ebo_data[i + 3] = (uint32_t)(j + 0);
|
||||
ebo_data[i + 4] = (uint32_t)(j + 2);
|
||||
ebo_data[i + 5] = (uint32_t)(j + 3);
|
||||
}
|
||||
|
||||
static const GLsizei buffer_size = sizeof(leaf_particle_vertex_data);
|
||||
|
||||
if (!leaf_ptcl_vao)
|
||||
glGenVertexArrays(1, &leaf_ptcl_vao);
|
||||
|
||||
leaf_ptcl_vbo.Create(buffer_size * leaf_ptcl_vtx_count);
|
||||
leaf_ptcl_vbo.Bind();
|
||||
|
||||
@@ -913,24 +924,13 @@ HOOK(void, FASTCALL, leaf_particle_init, 0x000000014034C530, bool change_stage)
|
||||
glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, buffer_size,
|
||||
(void*)offsetof(leaf_particle_vertex_data, normal));
|
||||
|
||||
size_t ebo_count = leaf_ptcl_vtx_count / 4 * 6;
|
||||
uint32_t* ebo_data = force_malloc<uint32_t>(ebo_count);
|
||||
for (size_t i = 0, j = 0; i < ebo_count; i += 6, j += 4) {
|
||||
ebo_data[i + 0] = (uint32_t)(j + 0);
|
||||
ebo_data[i + 1] = (uint32_t)(j + 1);
|
||||
ebo_data[i + 2] = (uint32_t)(j + 2);
|
||||
ebo_data[i + 3] = (uint32_t)(j + 0);
|
||||
ebo_data[i + 4] = (uint32_t)(j + 2);
|
||||
ebo_data[i + 5] = (uint32_t)(j + 3);
|
||||
}
|
||||
|
||||
leaf_ptcl_ebo.Create(sizeof(uint32_t) * ebo_count, ebo_data);
|
||||
leaf_ptcl_ebo.Bind();
|
||||
free_def(ebo_data);
|
||||
|
||||
gl_state_bind_vertex_array(0);
|
||||
gl_state_bind_array_buffer(0);
|
||||
gl_state_bind_element_array_buffer(0);
|
||||
free_def(ebo_data);
|
||||
|
||||
leaf_particle_scene_ubo.Create(sizeof(leaf_particle_scene_shader_data));
|
||||
}
|
||||
@@ -1029,11 +1029,11 @@ HOOK(void, FASTCALL, particle_init, 0x0000000140351C50, vec3* offset) {
|
||||
else
|
||||
particle_wind = 0.0f;
|
||||
|
||||
static const GLsizei buffer_size = sizeof(particle_vertex_data);
|
||||
|
||||
if (!ptcl_vao)
|
||||
glGenVertexArrays(1, &ptcl_vao);
|
||||
|
||||
static const GLsizei buffer_size = sizeof(particle_vertex_data);
|
||||
|
||||
ptcl_vbo.Create(buffer_size * ptcl_vtx_count);
|
||||
ptcl_vbo.Bind();
|
||||
|
||||
@@ -1406,7 +1406,7 @@ void EffectFogRing::draw() {
|
||||
draw_state.set_fog_height(true);
|
||||
RenderTexture& rt = render_manager->get_render_texture(8);
|
||||
rt.Bind();
|
||||
glViewportDLL(0, 0,
|
||||
gl_state_set_viewport(0, 0,
|
||||
rt.color_texture->get_width_align_mip_level(),
|
||||
rt.color_texture->get_height_align_mip_level());
|
||||
glClearColorDLL(density_offset, density_offset, density_offset, 1.0f);
|
||||
@@ -1425,9 +1425,8 @@ static void sub_1403B6F60(texture* a1, texture* a2, texture* a3, EffectRipple::P
|
||||
int32_t width = a2->width;
|
||||
int32_t height = a2->height;
|
||||
|
||||
GLint v43[4];
|
||||
glGetIntegervDLL(GL_VIEWPORT, v43);
|
||||
glViewportDLL(1, 1, width - 2, height - 2);
|
||||
gl_state_rect viewport_rect = gl_state_get_viewport();
|
||||
gl_state_set_viewport(1, 1, width - 2, height - 2);
|
||||
|
||||
ripple_scene_shader_data ripple_scene = {};
|
||||
ripple_scene.g_transform = {
|
||||
@@ -1452,7 +1451,7 @@ static void sub_1403B6F60(texture* a1, texture* a2, texture* a3, EffectRipple::P
|
||||
gl_state_active_bind_texture_2d(0, 0);
|
||||
gl_state_bind_vertex_array(0);
|
||||
|
||||
glViewportDLL(v43[0], v43[1], v43[2], v43[3]);
|
||||
gl_state_set_viewport(viewport_rect);
|
||||
}
|
||||
|
||||
static void sub_1403B6ED0(RenderTexture* a1, RenderTexture* a2, RenderTexture* a3, EffectRipple::Params& params) {
|
||||
@@ -1484,13 +1483,12 @@ void EffectRipple::draw() {
|
||||
|
||||
rt[(counter + 1) % 3]->Bind();
|
||||
|
||||
GLint v43[4];
|
||||
glGetIntegervDLL(GL_VIEWPORT, v43);
|
||||
gl_state_rect viewport_rect = gl_state_get_viewport();
|
||||
|
||||
int32_t width = rt[0]->GetWidth();
|
||||
int32_t height = rt[0]->GetHeight();
|
||||
|
||||
glViewportDLL(1, 1, width - 2, height - 2);
|
||||
gl_state_set_viewport(1, 1, width - 2, height - 2);
|
||||
|
||||
draw_pass_set_camera();
|
||||
glClearDLL(GL_DEPTH_BUFFER_BIT);
|
||||
@@ -1511,7 +1509,7 @@ void EffectRipple::draw() {
|
||||
|
||||
sub_1403B6ED0(rt[(counter + 2) % 3], rt[(counter + 1) % 3], rt[counter % 3], params);
|
||||
|
||||
glViewportDLL(v43[0], v43[1], v43[2], v43[3]);
|
||||
gl_state_set_viewport(viewport_rect);
|
||||
|
||||
sub_1403584A0(rt[(counter + 2) % 3]);
|
||||
|
||||
@@ -1595,23 +1593,6 @@ void star_catalog_milky_way::create_buffers(int32_t subdivs, float_t uv_rec_scal
|
||||
vtx_data[vtx].texcoord.x = 1.0f;
|
||||
vtx_data[vtx].texcoord.y = (latitude_offset_degs_10 - (1.0f / uv_rec_scale_v) * 90.0f) * rec_latitude_degs_10;
|
||||
|
||||
if (!vao)
|
||||
glGenVertexArrays(1, &vao);
|
||||
|
||||
vbo.Create(sizeof(star_catalog_vertex) * vtx_count, vtx_data);
|
||||
vbo.Bind();
|
||||
free_def(vtx_data);
|
||||
|
||||
static const GLsizei buffer_size = sizeof(star_catalog_vertex);
|
||||
|
||||
gl_state_bind_vertex_array(vao);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, buffer_size,
|
||||
(void*)offsetof(star_catalog_vertex, position));
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, buffer_size,
|
||||
(void*)offsetof(star_catalog_vertex, texcoord));
|
||||
|
||||
const uint16_t first_vertex = 0;
|
||||
const uint16_t last_vertex = (uint16_t)(vtx_count - 1);
|
||||
uint16_t restart_index = this->restart_index;
|
||||
@@ -1643,8 +1624,29 @@ void star_catalog_milky_way::create_buffers(int32_t subdivs, float_t uv_rec_scal
|
||||
ebo_data[idx + 3] = restart_index;
|
||||
}
|
||||
|
||||
static const GLsizei buffer_size = sizeof(star_catalog_vertex);
|
||||
|
||||
if (!vao)
|
||||
glGenVertexArrays(1, &vao);
|
||||
|
||||
vbo.Create((size_t)buffer_size * vtx_count, vtx_data);
|
||||
vbo.Bind();
|
||||
|
||||
gl_state_bind_vertex_array(vao);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, buffer_size,
|
||||
(void*)offsetof(star_catalog_vertex, position));
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, buffer_size,
|
||||
(void*)offsetof(star_catalog_vertex, texcoord));
|
||||
|
||||
ebo.Create(sizeof(uint16_t) * ebo_count, ebo_data);
|
||||
ebo.Bind();
|
||||
|
||||
gl_state_bind_vertex_array(0);
|
||||
gl_state_bind_array_buffer(0);
|
||||
gl_state_bind_element_array_buffer(0);
|
||||
free_def(vtx_data);
|
||||
free_def(ebo_data);
|
||||
|
||||
if (!star_sampler)
|
||||
@@ -1653,10 +1655,6 @@ void star_catalog_milky_way::create_buffers(int32_t subdivs, float_t uv_rec_scal
|
||||
glSamplerParameteri(star_sampler, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glSamplerParameteri(star_sampler, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glSamplerParameteri(star_sampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
gl_state_bind_vertex_array(0);
|
||||
gl_state_bind_array_buffer(0);
|
||||
gl_state_bind_element_array_buffer(0);
|
||||
}
|
||||
|
||||
void star_catalog_milky_way::create_default_sphere() {
|
||||
|
||||
@@ -336,9 +336,11 @@ void gl_state_get() {
|
||||
glGetBooleanvDLL(GL_MULTISAMPLE, &gl_state.multisample);
|
||||
glGetBooleanvDLL(GL_PRIMITIVE_RESTART, &gl_state.primitive_restart);
|
||||
glGetIntegervDLL(GL_PRIMITIVE_RESTART_INDEX, (GLint*)&gl_state.primitive_restart_index);
|
||||
glGetIntegervDLL(GL_SCISSOR_BOX, (GLint*)&gl_state.scissor_box);
|
||||
glGetBooleanvDLL(GL_SCISSOR_TEST, &gl_state.scissor_test);
|
||||
glGetBooleanvDLL(GL_STENCIL_TEST, &gl_state.stencil_test);
|
||||
glGetIntegervDLL(GL_STENCIL_WRITEMASK, (GLint*)&gl_state.stencil_mask);
|
||||
glGetIntegervDLL(GL_VIEWPORT, (GLint*)&gl_state.viewport);
|
||||
|
||||
glPolygonModeDLL(GL_FRONT_AND_BACK, GL_FILL);
|
||||
gl_state.polygon_front_face_mode = GL_FILL;
|
||||
@@ -362,6 +364,28 @@ GLuint gl_state_get_program() {
|
||||
return gl_state.program;
|
||||
}
|
||||
|
||||
gl_state_rect gl_state_get_scissor() {
|
||||
return gl_state.scissor_box;
|
||||
}
|
||||
|
||||
void gl_state_get_scissor(GLint& x, GLint& y, GLsizei& width, GLsizei& height) {
|
||||
x = gl_state.scissor_box.x;
|
||||
y = gl_state.scissor_box.y;
|
||||
width = gl_state.scissor_box.width;
|
||||
height = gl_state.scissor_box.height;
|
||||
}
|
||||
|
||||
gl_state_rect gl_state_get_viewport() {
|
||||
return gl_state.viewport;
|
||||
}
|
||||
|
||||
void gl_state_get_viewport(GLint& x, GLint& y, GLsizei& width, GLsizei& height) {
|
||||
x = gl_state.viewport.x;
|
||||
y = gl_state.viewport.y;
|
||||
width = gl_state.viewport.width;
|
||||
height = gl_state.viewport.height;
|
||||
}
|
||||
|
||||
void gl_state_set_blend_func(GLenum src, GLenum dst, bool force) {
|
||||
if (force || gl_state.blend_src_rgb != src || gl_state.blend_dst_rgb != dst
|
||||
|| gl_state.blend_src_alpha != GL_ONE || gl_state.blend_dst_alpha != GL_ONE_MINUS_SRC_ALPHA) {
|
||||
@@ -474,6 +498,25 @@ void gl_state_set_primitive_restart_index(GLuint index, bool force) {
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_set_scissor(const gl_state_rect& rect, bool force) {
|
||||
if (force || gl_state.scissor_box.x != rect.x || gl_state.scissor_box.y != rect.y
|
||||
|| gl_state.scissor_box.width != rect.width || gl_state.scissor_box.height != rect.height) {
|
||||
glScissorDLL(rect.x, rect.y, rect.width, rect.height);
|
||||
gl_state.scissor_box = rect;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_set_scissor(GLint x, GLint y, GLsizei width, GLsizei height, bool force) {
|
||||
if (force || gl_state.scissor_box.x != x || gl_state.scissor_box.y != y
|
||||
|| gl_state.scissor_box.width != width || gl_state.scissor_box.height != height) {
|
||||
glScissorDLL(x, y, width, height);
|
||||
gl_state.scissor_box.x = x;
|
||||
gl_state.scissor_box.y = y;
|
||||
gl_state.scissor_box.width = width;
|
||||
gl_state.scissor_box.height = height;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_set_stencil_mask(GLuint mask, bool force) {
|
||||
if (force || gl_state.stencil_mask != mask) {
|
||||
glStencilMask(mask);
|
||||
@@ -481,6 +524,25 @@ void gl_state_set_stencil_mask(GLuint mask, bool force) {
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_set_viewport(const gl_state_rect& rect, bool force) {
|
||||
if (force || gl_state.viewport.x != rect.x || gl_state.viewport.y != rect.y
|
||||
|| gl_state.viewport.width != rect.width || gl_state.viewport.height != rect.height) {
|
||||
glViewportDLL(rect.x, rect.y, rect.width, rect.height);
|
||||
gl_state.viewport = rect;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_set_viewport(GLint x, GLint y, GLsizei width, GLsizei height, bool force) {
|
||||
if (force || gl_state.viewport.x != x || gl_state.viewport.y != y
|
||||
|| gl_state.viewport.width != width || gl_state.viewport.height != height) {
|
||||
glViewportDLL(x, y, width, height);
|
||||
gl_state.viewport.x = x;
|
||||
gl_state.viewport.y = y;
|
||||
gl_state.viewport.width = width;
|
||||
gl_state.viewport.height = height;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_use_program(GLuint program, bool force) {
|
||||
if (force || gl_state.program != program) {
|
||||
glUseProgram(program);
|
||||
|
||||
@@ -8,6 +8,13 @@
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "wrap.hpp"
|
||||
|
||||
struct gl_state_rect {
|
||||
GLint x;
|
||||
GLint y;
|
||||
GLsizei width;
|
||||
GLsizei height;
|
||||
};
|
||||
|
||||
struct gl_state_struct {
|
||||
GLint program;
|
||||
GLenum active_texture;
|
||||
@@ -46,9 +53,11 @@ struct gl_state_struct {
|
||||
GLboolean multisample;
|
||||
GLboolean primitive_restart;
|
||||
GLuint primitive_restart_index;
|
||||
gl_state_rect scissor_box;
|
||||
GLboolean scissor_test;
|
||||
GLboolean stencil_test;
|
||||
GLuint stencil_mask;
|
||||
gl_state_rect viewport;
|
||||
};
|
||||
|
||||
extern gl_state_struct gl_state;
|
||||
@@ -98,6 +107,10 @@ extern void gl_state_get();
|
||||
extern void gl_state_get_all_gl_errors();
|
||||
extern GLenum gl_state_get_error();
|
||||
extern GLuint gl_state_get_program();
|
||||
extern gl_state_rect gl_state_get_scissor();
|
||||
extern void gl_state_get_scissor(GLint& x, GLint& y, GLsizei& width, GLsizei& height);
|
||||
extern gl_state_rect gl_state_get_viewport();
|
||||
extern void gl_state_get_viewport(GLint& x, GLint& y, GLsizei& width, GLsizei& height);
|
||||
extern void gl_state_set_blend_func(GLenum src, GLenum dst, bool force = false);
|
||||
extern void gl_state_set_blend_func_separate(GLenum src_rgb, GLenum dst_rgb,
|
||||
GLenum src_alpha, GLenum dst_alpha, bool force = false);
|
||||
@@ -111,7 +124,11 @@ extern void gl_state_set_depth_func(GLenum func, bool force = false);
|
||||
extern void gl_state_set_depth_mask(GLboolean flag, bool force = false);
|
||||
extern void gl_state_set_polygon_mode(GLenum face, GLenum mode, bool force = false);
|
||||
extern void gl_state_set_primitive_restart_index(GLuint index, bool force = false);
|
||||
extern void gl_state_set_scissor(const gl_state_rect& rect, bool force = false);
|
||||
extern void gl_state_set_scissor(GLint x, GLint y, GLsizei width, GLsizei height, bool force = false);
|
||||
extern void gl_state_set_stencil_mask(GLuint mask, bool force = false);
|
||||
extern void gl_state_set_viewport(const gl_state_rect& rect, bool force = false);
|
||||
extern void gl_state_set_viewport(GLint x, GLint y, GLsizei width, GLsizei height, bool force = false);
|
||||
extern void gl_state_use_program(GLuint program, bool force = false);
|
||||
|
||||
template <size_t size>
|
||||
|
||||
@@ -609,6 +609,7 @@ static bool draw_object_blend_set_check_use_default_blend(int32_t index) {
|
||||
false, false, false, false, false, false, false, false, false, false, false, false,
|
||||
false, false, false, false, false, false, false, false, false, false, false, false,
|
||||
false, false, false, false, false, false, false, false, false, false, false, false,
|
||||
false, false,
|
||||
};
|
||||
|
||||
if (index >= 0 && index < SHADER_FT_MAX)
|
||||
|
||||
+18
-18
@@ -67,7 +67,7 @@ namespace rndr {
|
||||
else
|
||||
uniform->arr[U_REDUCE] = 0;
|
||||
|
||||
glViewportDLL(0, 0, t->width, t->height);
|
||||
gl_state_set_viewport(0, 0, t->width, t->height);
|
||||
gl_state_active_bind_texture_2d(0, taa_tex[taa_texture_selector]->glid);
|
||||
gl_state_bind_sampler(0, rctx->render_samplers[0]);
|
||||
shaders_ft.set(SHADER_FT_REDUCE);
|
||||
@@ -102,7 +102,7 @@ namespace rndr {
|
||||
|
||||
taa_texture = 2;
|
||||
taa_buffer[2].Bind();
|
||||
glViewportDLL(0, 0, render_width[0], render_height[0]);
|
||||
gl_state_set_viewport(0, 0, render_width[0], render_height[0]);
|
||||
gl_state_active_bind_texture_2d(0, taa_tex[taa_texture_selector]->glid);
|
||||
gl_state_bind_sampler(0, sampler);
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace rndr {
|
||||
}
|
||||
|
||||
rctx->screen_buffer.Bind();
|
||||
glViewportDLL(0, 0, rctx->screen_width, rctx->screen_height);
|
||||
gl_state_set_viewport(0, 0, rctx->screen_width, rctx->screen_height);
|
||||
if (ssaa) {
|
||||
gl_state_active_bind_texture_2d(0, taa_tex[taa_texture]->glid);
|
||||
gl_state_bind_sampler(0, rctx->render_samplers[0]);
|
||||
@@ -210,7 +210,7 @@ namespace rndr {
|
||||
}
|
||||
else
|
||||
rend_texture[0].Bind();
|
||||
glViewportDLL(0, 0, render_width[0], render_height[0]);
|
||||
gl_state_set_viewport(0, 0, render_width[0], render_height[0]);
|
||||
}
|
||||
|
||||
void Render::calc_exposure_chara_data() {
|
||||
@@ -347,7 +347,7 @@ namespace rndr {
|
||||
texture* movie_texture = sub_14041ED80(task_movie);
|
||||
if (movie_texture) {
|
||||
movie_textures[0].Bind();
|
||||
glViewportDLL(0, 0, movie_textures_data[0]->width, movie_textures_data[0]->height);
|
||||
gl_state_set_viewport(0, 0, movie_textures_data[0]->width, movie_textures_data[0]->height);
|
||||
gl_state_active_bind_texture_2d(0, movie_texture->glid);
|
||||
uniform->arr[U_REDUCE] = 0;
|
||||
shaders_ft.set(SHADER_FT_REDUCE);
|
||||
@@ -971,7 +971,7 @@ namespace rndr {
|
||||
rend_texture[i].Bind();
|
||||
gl_state_active_bind_texture_2d(0, rend_texture[i - 1].GetColorTex());
|
||||
gl_state_bind_sampler(0, rctx->render_samplers[0]);
|
||||
glViewportDLL(0, 0, render_width[i], render_height[i]);
|
||||
gl_state_set_viewport(0, 0, render_width[i], render_height[i]);
|
||||
draw_quad(
|
||||
render_post_width[i - 1], render_post_height[i - 1],
|
||||
render_post_width_scale, render_post_height_scale,
|
||||
@@ -982,7 +982,7 @@ namespace rndr {
|
||||
shaders_ft.set(SHADER_FT_REDUCE);
|
||||
|
||||
int32_t downsample = max_def(downsample_count - 2, 0);
|
||||
glViewportDLL(0, 0, reduce_width[0], reduce_height[0]);
|
||||
gl_state_set_viewport(0, 0, reduce_width[0], reduce_height[0]);
|
||||
reduce_texture[0].Bind();
|
||||
gl_state_active_bind_texture_2d(0, rend_texture[downsample].GetColorTex());
|
||||
gl_state_bind_sampler(0, rctx->render_samplers[0]);
|
||||
@@ -1008,7 +1008,7 @@ namespace rndr {
|
||||
shaders_ft.set(SHADER_FT_REDUCE);
|
||||
}
|
||||
|
||||
glViewportDLL(0, 0, reduce_width[i], reduce_height[i]);
|
||||
gl_state_set_viewport(0, 0, reduce_width[i], reduce_height[i]);
|
||||
draw_quad(reduce_width[i - 1], reduce_height[i - 1],
|
||||
1.0f, 1.0f, 0.0f, 0.0f, scale, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
gl_state_active_bind_texture_2d(0, reduce_tex[i]->glid);
|
||||
@@ -1045,7 +1045,7 @@ namespace rndr {
|
||||
texture* rend_tex = render_textures_data[index];
|
||||
uniform->arr[U_REDUCE] = 0;
|
||||
|
||||
glViewportDLL(0, 0, rend_tex->width, rend_tex->height);
|
||||
gl_state_set_viewport(0, 0, rend_tex->width, rend_tex->height);
|
||||
gl_state_active_bind_texture_2d(0, rctx->screen_buffer.GetColorTex());
|
||||
gl_state_bind_sampler(0, rctx->render_samplers[0]);
|
||||
shaders_ft.set(SHADER_FT_REDUCE);
|
||||
@@ -1318,7 +1318,7 @@ namespace rndr {
|
||||
|
||||
rctx->tone_map_ubo.WriteMemory(shader_data);
|
||||
|
||||
glViewportDLL(0, 0, render_width[0], render_height[0]);
|
||||
gl_state_set_viewport(0, 0, render_width[0], render_height[0]);
|
||||
taa_buffer[2].Bind();
|
||||
shaders_ft.set(SHADER_FT_TONEMAP);
|
||||
rctx->tone_map_ubo.Bind(1);
|
||||
@@ -1440,7 +1440,7 @@ namespace rndr {
|
||||
exposure_measure.g_spot_coefficients[i * 8 + j] = chara_data->spot_coefficients[j];
|
||||
rctx->exposure_measure_ubo.WriteMemory(exposure_measure);
|
||||
|
||||
glViewportDLL(0, 0, 32, 1);
|
||||
gl_state_set_viewport(0, 0, 32, 1);
|
||||
downsample_texture.Bind();
|
||||
|
||||
uniform->arr[U_EXPOSURE] = 1;
|
||||
@@ -1462,7 +1462,7 @@ namespace rndr {
|
||||
exposure_history_counter = (exposure_history_counter + 1) % 32;
|
||||
}
|
||||
|
||||
glViewportDLL(0, 0, 1, 1);
|
||||
gl_state_set_viewport(0, 0, 1, 1);
|
||||
exposure_texture.Bind();
|
||||
uniform->arr[U_EXPOSURE] = 2;
|
||||
shaders_ft.set(SHADER_FT_EXPOSURE);
|
||||
@@ -1572,7 +1572,7 @@ namespace rndr {
|
||||
|
||||
gl_state_active_bind_texture_2d(0, j.type == FRAME_TEXTURE_PRE_PP ? pre_pp_tex : post_pp_tex);
|
||||
gl_state_bind_sampler(0, rctx->render_samplers[0]);
|
||||
glViewportDLL(0, 0, dst_tex->width, dst_tex->height);
|
||||
gl_state_set_viewport(0, 0, dst_tex->width, dst_tex->height);
|
||||
uniform->arr[U_REDUCE] = 0;
|
||||
shaders_ft.set(SHADER_FT_REDUCE);
|
||||
draw_quad(dst_tex->width, dst_tex->height,
|
||||
@@ -1646,7 +1646,7 @@ namespace rndr {
|
||||
|
||||
rctx->lens_ghost_vbo.UnmapMemory();
|
||||
|
||||
glViewportDLL(0, 0, render_width[0], render_height[0]);
|
||||
gl_state_set_viewport(0, 0, render_width[0], render_height[0]);
|
||||
rend_texture[0].Bind();
|
||||
gl_state_enable_blend();
|
||||
gl_state_set_blend_func(GL_ONE, GL_ONE);
|
||||
@@ -1689,7 +1689,7 @@ namespace rndr {
|
||||
|
||||
downsample_texture.Bind();
|
||||
for (int32_t i = 1; i < 4; i++) {
|
||||
glViewportDLL(0, 0, reduce_width[i], reduce_height[i]);
|
||||
gl_state_set_viewport(0, 0, reduce_width[i], reduce_height[i]);
|
||||
gl_state_active_bind_texture_2d(0, reduce_tex[i]->glid);
|
||||
gl_state_bind_sampler(0, rctx->render_samplers[2]);
|
||||
draw_quad(reduce_width[i], reduce_height[i],
|
||||
@@ -1698,7 +1698,7 @@ namespace rndr {
|
||||
}
|
||||
|
||||
for (int32_t i = 1; i < 4; i++) {
|
||||
glViewportDLL(0, 0, reduce_width[i], reduce_height[i]);
|
||||
gl_state_set_viewport(0, 0, reduce_width[i], reduce_height[i]);
|
||||
gl_state_active_bind_texture_2d(0, reduce_tex[i]->glid);
|
||||
gl_state_bind_sampler(0, rctx->render_samplers[2]);
|
||||
draw_quad(reduce_width[i], reduce_height[i],
|
||||
@@ -1709,7 +1709,7 @@ namespace rndr {
|
||||
uniform->arr[U_GAUSS] = 1;
|
||||
shaders_ft.set(SHADER_FT_GAUSS);
|
||||
|
||||
glViewportDLL(0, 0, reduce_width[0], reduce_height[0]);
|
||||
gl_state_set_viewport(0, 0, reduce_width[0], reduce_height[0]);
|
||||
gl_state_active_bind_texture_2d(0, reduce_tex[0]->glid);
|
||||
gl_state_bind_sampler(0, rctx->render_samplers[2]);
|
||||
draw_quad(reduce_width[0], reduce_height[0],
|
||||
@@ -1719,7 +1719,7 @@ namespace rndr {
|
||||
uniform->arr[U_REDUCE] = 7;
|
||||
shaders_ft.set(SHADER_FT_REDUCE);
|
||||
|
||||
glViewportDLL(0, 0, reduce_width[0], reduce_height[0]);
|
||||
gl_state_set_viewport(0, 0, reduce_width[0], reduce_height[0]);
|
||||
reduce_texture[0].Bind();
|
||||
gl_state_active_bind_texture_2d(0, downsample_texture.GetColorTex());
|
||||
gl_state_active_bind_texture_2d(1, reduce_tex[1]->glid);
|
||||
|
||||
@@ -123,8 +123,6 @@ void obj_shader_shader_data::set_shader_flags(int32_t* shader_flags) {
|
||||
g_shader_flags.w.m.specular = shader_flags[U_SPECULAR];
|
||||
g_shader_flags.w.m.tone_map = shader_flags[U_TONE_MAP];
|
||||
g_shader_flags.w.m.u45 = shader_flags[U45];
|
||||
g_shader_flags.w.m.dof = 0; //shader_flags[U_DOF]; // Added
|
||||
g_shader_flags.w.m.dof_stage = 0; //shader_flags[U_DOF_STAGE]; // Added
|
||||
}
|
||||
|
||||
void obj_scene_shader_data::set_g_irradiance_r_transforms(const mat4& mat) {
|
||||
@@ -342,6 +340,7 @@ samplers(), render_samplers(), sprite_samplers(), screen_width(), screen_height(
|
||||
sss_filter_gaussian_coef_ubo.Create(sizeof(sss_filter_gaussian_coef_shader_data));
|
||||
sun_quad_ubo.Create(sizeof(sun_quad_shader_data));
|
||||
tone_map_ubo.Create(sizeof(tone_map_shader_data));
|
||||
transparency_batch_ubo.Create(sizeof(transparency_batch_shader_data));
|
||||
|
||||
obj_shader = {};
|
||||
obj_scene = {};
|
||||
@@ -455,8 +454,8 @@ render_context::~render_context() {
|
||||
obj_scene_ubo.Destroy();
|
||||
obj_shader_ubo.Destroy();
|
||||
|
||||
tone_map_ubo.Destroy();
|
||||
transparency_batch_ubo.Destroy();
|
||||
tone_map_ubo.Destroy();
|
||||
sun_quad_ubo.Destroy();
|
||||
sss_filter_gaussian_coef_ubo.Destroy();
|
||||
sprite_scene_ubo.Destroy();
|
||||
|
||||
@@ -227,8 +227,6 @@ struct obj_shader_shader_data {
|
||||
uint32_t specular : 1; // bit 96+14
|
||||
uint32_t tone_map : 2; // bit 96+15
|
||||
uint32_t u45 : 1; // bit 96+16
|
||||
uint32_t dof : 1; // bit 96+17 // Added
|
||||
uint32_t dof_stage : 3; // bit 96+18 // Added
|
||||
} m;
|
||||
uint32_t w;
|
||||
} w;
|
||||
@@ -366,6 +364,10 @@ struct tone_map_shader_data {
|
||||
vec4 g_texcoord_transforms[8];
|
||||
};
|
||||
|
||||
struct transparency_batch_shader_data {
|
||||
vec4 g_opacity;
|
||||
};
|
||||
|
||||
struct render_context {
|
||||
mat4 view_mat;
|
||||
mat4 proj_mat;
|
||||
@@ -399,8 +401,8 @@ struct render_context {
|
||||
GL::UniformBuffer sprite_scene_ubo;
|
||||
GL::UniformBuffer sss_filter_gaussian_coef_ubo;
|
||||
GL::UniformBuffer sun_quad_ubo;
|
||||
GL::UniformBuffer transparency_batch_ubo;
|
||||
GL::UniformBuffer tone_map_ubo;
|
||||
GL::UniformBuffer transparency_batch_ubo;
|
||||
|
||||
obj_shader_shader_data obj_shader;
|
||||
obj_scene_shader_data obj_scene;
|
||||
|
||||
@@ -456,7 +456,7 @@ namespace rndr {
|
||||
//}
|
||||
//else {
|
||||
// sss->textures[0].Bind();
|
||||
// glViewportDLL(0, 0, 640, 360);
|
||||
// gl_state_set_viewport(0, 0, 640, 360);
|
||||
//}
|
||||
|
||||
glClearColorDLL(sss->param.x, sss->param.y, sss->param.z, 0.0f);
|
||||
@@ -508,7 +508,7 @@ namespace rndr {
|
||||
|
||||
if (!sss->npr_contour) {
|
||||
sss->textures[0].Bind();
|
||||
glViewportDLL(0, 0, 640, 360);
|
||||
gl_state_set_viewport(0, 0, 640, 360);
|
||||
|
||||
filter_scene_shader_data filter_scene = {};
|
||||
filter_scene.g_transform = { 1.0f, 1.0f, 0.0f, 0.0f };
|
||||
@@ -618,7 +618,7 @@ namespace rndr {
|
||||
|| disp_manager->get_obj_count(mdl::OBJ_TYPE_REFRACT_TRANSPARENT)
|
||||
|| disp_manager->get_obj_count(mdl::OBJ_TYPE_REFRACT_TRANSLUCENT)) {
|
||||
texture* refr_tex = refract_texture.color_texture;
|
||||
glViewportDLL(0, 0, refr_tex->width, refr_tex->height);
|
||||
gl_state_set_viewport(0, 0, refr_tex->width, refr_tex->height);
|
||||
|
||||
draw_pass_set_camera();
|
||||
|
||||
@@ -971,7 +971,7 @@ namespace rndr {
|
||||
gl_state_begin_event("pass_sprite");
|
||||
if (sprite_manager_get_reqlist_count(0)) {
|
||||
rndr::Render* rend = render;
|
||||
glViewportDLL(0, 0, rend->screen_width, rend->screen_height);
|
||||
gl_state_set_viewport(0, 0, rend->screen_width, rend->screen_height);
|
||||
|
||||
if (multisample && multisample_framebuffer) {
|
||||
gl_state_bind_framebuffer(multisample_framebuffer);
|
||||
@@ -1078,7 +1078,7 @@ void image_filter_scale(RenderTexture* dst, texture* src, const vec4& scale) {
|
||||
return;
|
||||
|
||||
gl_state_begin_event("`anonymous-namespace'::Impl::apply_no_filter_sub");
|
||||
glViewportDLL(0, 0, dst->color_texture->width, dst->color_texture->height);
|
||||
gl_state_set_viewport(0, 0, dst->color_texture->width, dst->color_texture->height);
|
||||
|
||||
dst->Bind();
|
||||
|
||||
@@ -1245,7 +1245,7 @@ static void draw_pass_shadow_begin_make_shadowmap(Shadow* shad, int32_t index, i
|
||||
shad->curr_render_textures[0]->Bind();
|
||||
shad->curr_render_textures[0]->SetViewport();
|
||||
texture* tex = shad->curr_render_textures[0]->color_texture;
|
||||
glScissorDLL(0, 0, tex->width, tex->height);
|
||||
gl_state_set_scissor(0, 0, tex->width, tex->height);
|
||||
gl_state_enable_depth_test();
|
||||
gl_state_enable_scissor_test();
|
||||
glClearColorDLL(1.0, 1.0, 1.0, 1.0);
|
||||
@@ -1253,7 +1253,7 @@ static void draw_pass_shadow_begin_make_shadowmap(Shadow* shad, int32_t index, i
|
||||
glClearDLL(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
else if (shad->separate)
|
||||
glClearDLL(GL_COLOR_BUFFER_BIT);
|
||||
glScissorDLL(1, 1, tex->width - 2, tex->height - 2);
|
||||
gl_state_set_scissor(1, 1, tex->width - 2, tex->height - 2);
|
||||
|
||||
float_t shadow_range = shad->get_shadow_range();
|
||||
float_t offset;
|
||||
@@ -1350,7 +1350,7 @@ static void draw_pass_shadow_filter(RenderTexture* a1, RenderTexture* a2,
|
||||
rctx->filter_scene_ubo.Bind(0);
|
||||
rctx->esm_filter_batch_ubo.Bind(1);
|
||||
|
||||
glViewportDLL(0, 0, v7->width, v7->height);
|
||||
gl_state_set_viewport(0, 0, v7->width, v7->height);
|
||||
|
||||
a2->Bind();
|
||||
esm_filter_batch.g_params = { 1.0f / (float_t)v7->width, 0.0f, far_texel_offset, far_texel_offset };
|
||||
@@ -1405,7 +1405,7 @@ static void draw_pass_shadow_esm_filter(RenderTexture* dst, RenderTexture* buf,
|
||||
rctx->filter_scene_ubo.Bind(0);
|
||||
rctx->esm_filter_batch_ubo.Bind(1);
|
||||
|
||||
glViewportDLL(0, 0, dst_tex->width, dst_tex->height);
|
||||
gl_state_set_viewport(0, 0, dst_tex->width, dst_tex->height);
|
||||
|
||||
buf->Bind();
|
||||
esm_filter_batch.g_params = { 1.0f / (float_t)src_tex->width,
|
||||
@@ -1473,7 +1473,7 @@ static bool draw_pass_shadow_litproj_set() {
|
||||
static const GLfloat depth_clear = 1.0f;
|
||||
|
||||
litproj_shadow[0].Bind();
|
||||
glViewportDLL(0, 0, 2048, 512);
|
||||
gl_state_set_viewport(0, 0, 2048, 512);
|
||||
gl_state_enable_depth_test();
|
||||
gl_state_set_depth_mask(GL_TRUE);
|
||||
glClearBufferfv(GL_COLOR, 0, (float_t*)&color_clear);
|
||||
@@ -1546,7 +1546,7 @@ static void draw_pass_sss_contour(rndr::Render* rend) {
|
||||
gl_state_enable_depth_test();
|
||||
gl_state_set_depth_func(GL_ALWAYS);
|
||||
gl_state_set_depth_mask(GL_TRUE);
|
||||
glViewportDLL(0, 0, rend->render_width[0], rend->render_height[0]);
|
||||
gl_state_set_viewport(0, 0, rend->render_width[0], rend->render_height[0]);
|
||||
gl_state_active_bind_texture_2d(0, rend->rend_texture[0].GetColorTex());
|
||||
gl_state_bind_sampler(0, rctx->render_samplers[1]);
|
||||
gl_state_active_bind_texture_2d(1, rend->rend_texture[0].GetDepthTex());
|
||||
@@ -1660,7 +1660,7 @@ static void draw_pass_sss_filter(sss_data* sss) {
|
||||
gl_state_active_texture(0);
|
||||
if (sss->npr_contour) {
|
||||
sss->textures[0].Bind();
|
||||
glViewportDLL(0, 0, 640, 360);
|
||||
gl_state_set_viewport(0, 0, 640, 360);
|
||||
rndr::Render* rend = render_get();
|
||||
uniform->arr[U_REDUCE] = 0;
|
||||
shaders_ft.set(SHADER_FT_REDUCE);
|
||||
@@ -1670,7 +1670,7 @@ static void draw_pass_sss_filter(sss_data* sss) {
|
||||
0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f);
|
||||
}
|
||||
sss->textures[2].Bind();
|
||||
glViewportDLL(0, 0, 320, 180);
|
||||
gl_state_set_viewport(0, 0, 320, 180);
|
||||
uniform->arr[U_SSS_FILTER] = 0;
|
||||
shaders_ft.set(SHADER_FT_SSS_FILT);
|
||||
gl_state_bind_texture_2d(sss->textures[0].GetColorTex());
|
||||
@@ -1689,7 +1689,7 @@ static void draw_pass_sss_filter(sss_data* sss) {
|
||||
|
||||
rctx->sss_filter_gaussian_coef_ubo.WriteMemory(shader_data);
|
||||
sss->textures[1].Bind();
|
||||
glViewportDLL(0, 0, 320, 180);
|
||||
gl_state_set_viewport(0, 0, 320, 180);
|
||||
uniform->arr[U_SSS_FILTER] = 3;
|
||||
shaders_ft.set(SHADER_FT_SSS_FILT);
|
||||
gl_state_bind_texture_2d(sss->textures[2].GetColorTex());
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "shared.hpp"
|
||||
#include "gl_state.hpp"
|
||||
#include "texture.hpp"
|
||||
|
||||
struct RenderTexture {
|
||||
@@ -46,7 +47,7 @@ struct RenderTexture {
|
||||
};
|
||||
|
||||
inline void SetViewport() {
|
||||
glViewportDLL(0, 0, GetWidth(), GetHeight());
|
||||
gl_state_set_viewport(0, 0, GetWidth(), GetHeight());
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
+24
-521
@@ -8,6 +8,7 @@
|
||||
#include "../camera.hpp"
|
||||
#include "../gl_state.hpp"
|
||||
#include "../render_context.hpp"
|
||||
#include "../shader_ft.hpp"
|
||||
#include <streambuf>
|
||||
|
||||
struct dof_common_shader_data {
|
||||
@@ -24,12 +25,12 @@ dof_debug* dof_debug_data = (dof_debug*)0x00000001411AB650;
|
||||
dof_pv* dof_pv_data = (dof_pv*)0x0000001411AB630;
|
||||
|
||||
namespace renderer {
|
||||
DOF3::DOF3(int32_t width, int32_t height) : textures(), fbo(), samplers(), vao(), program() {
|
||||
DOF3::DOF3(int32_t width, int32_t height)
|
||||
: textures(), samplers(), vao(), program() {
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
|
||||
init(width, height);
|
||||
load_shaders();
|
||||
}
|
||||
|
||||
DOF3::~DOF3() {
|
||||
@@ -146,519 +147,12 @@ namespace renderer {
|
||||
common_ubo.Create(sizeof(dof_common_shader_data));
|
||||
|
||||
vec2 data[50] = {};
|
||||
renderer::DOF3::calculate_texcoords(data, 3.0);
|
||||
renderer::DOF3::calculate_texcoords(data, 3.0f);
|
||||
texcoords_ubo.Create(sizeof(data), data);
|
||||
|
||||
glGenVertexArrays(1, &vao);
|
||||
}
|
||||
|
||||
void renderer::DOF3::load_shaders() {
|
||||
const size_t buf_len = 0x8000;
|
||||
char* buf = (char*)_operator_new(buf_len);
|
||||
if (!buf)
|
||||
return;
|
||||
|
||||
GLProgram::ShaderData shader_data[2];
|
||||
shader_data[0].type = GL_VERTEX_SHADER;
|
||||
shader_data[0].string =
|
||||
u8"#version 430\n"
|
||||
u8"out VertexData{\n"
|
||||
u8" vec2 texcoord;\n"
|
||||
u8"}result;\n"
|
||||
u8"void main(){\n"
|
||||
u8" gl_Position.x = -1.f + (gl_VertexID / 2) * 4;\n"
|
||||
u8" gl_Position.y = 1.f - (gl_VertexID % 2) * 4;\n"
|
||||
u8" gl_Position.z = 0.f;\n"
|
||||
u8" gl_Position.w = 1.f;\n"
|
||||
u8" result.texcoord = gl_Position.xy * 0.5f + 0.5f;\n"
|
||||
u8"}\n";
|
||||
shader_data[0].length = 273;
|
||||
|
||||
shader_data[1].type = GL_FRAGMENT_SHADER;
|
||||
shader_data[1].string =
|
||||
u8"#version 430\n"
|
||||
u8"layout(binding = 0) uniform sampler2D g_tile;//r=min_depth_m, g=max_coc_pixel\n"
|
||||
u8"layout(location = 0) out vec2 result;//r=min_depth_m, g=max_coc_pixel\n"
|
||||
u8"in VertexData{\n"
|
||||
u8" vec2 texcoord;\n"
|
||||
u8"}frg;\n"
|
||||
u8"void main(){\n"
|
||||
u8" //3x3サンプル。\n"
|
||||
u8" vec2 texture_size = textureSize(g_tile, 0);\n"
|
||||
u8" vec2 texel_size = vec2(1.f / texture_size.x, 1.f / texture_size.y);\n"
|
||||
u8" vec2 uv = frg.texcoord;\n"
|
||||
u8" const vec2 v00 = textureLod(g_tile, uv + vec2(-texel_size.x, -texel_size.y), 0).rg;\n"
|
||||
u8" const vec2 v01 = textureLod(g_tile, uv + vec2(0.f, -texel_size.y), 0).rg;\n"
|
||||
u8" const vec2 v02 = textureLod(g_tile, uv + vec2(texel_size.x, -texel_size.y), 0).rg;\n"
|
||||
u8" const vec2 v10 = textureLod(g_tile, uv + vec2(-texel_size.x, 0.f), 0).rg;\n"
|
||||
u8" const vec2 v11 = textureLod(g_tile, uv + vec2(0.f, 0.f), 0).rg;\n"
|
||||
u8" const vec2 v12 = textureLod(g_tile, uv + vec2(texel_size.x, 0.f), 0).rg;\n"
|
||||
u8" const vec2 v20 = textureLod(g_tile, uv + vec2(-texel_size.x, texel_size.y), 0).rg;\n"
|
||||
u8" const vec2 v21 = textureLod(g_tile, uv + vec2(0.f, texel_size.y), 0).rg;\n"
|
||||
u8" const vec2 v22 = textureLod(g_tile, uv + vec2(texel_size.x, texel_size.y), 0).rg;\n"
|
||||
u8" //depthはmin。\n"
|
||||
u8" result.r = min(v00.r, v01.r);\n"
|
||||
u8" result.r = min(result.r, v02.r);\n"
|
||||
u8" result.r = min(result.r, v10.r);\n"
|
||||
u8" result.r = min(result.r, v11.r);\n"
|
||||
u8" result.r = min(result.r, v12.r);\n"
|
||||
u8" result.r = min(result.r, v20.r);\n"
|
||||
u8" result.r = min(result.r, v21.r);\n"
|
||||
u8" result.r = min(result.r, v22.r);\n"
|
||||
u8" //cocはmax。\n"
|
||||
u8" result.g = max(v00.g, v01.g);\n"
|
||||
u8" result.g = max(result.g, v02.g);\n"
|
||||
u8" result.g = max(result.g, v10.g);\n"
|
||||
u8" result.g = max(result.g, v11.g);\n"
|
||||
u8" result.g = max(result.g, v12.g);\n"
|
||||
u8" result.g = max(result.g, v20.g);\n"
|
||||
u8" result.g = max(result.g, v21.g);\n"
|
||||
u8" result.g = max(result.g, v22.g);\n"
|
||||
u8"}\n";
|
||||
shader_data[1].length = 1741;
|
||||
|
||||
program[0].compile_program(shader_data, 2);
|
||||
|
||||
GLProgram* program = &this->program[1];
|
||||
for (int32_t i = 0; i < 2; i++) {
|
||||
int32_t common_length = 0;
|
||||
int32_t shader_length = 0;
|
||||
|
||||
memcpy_s(buf, buf_len, "#version 430\n", 13);
|
||||
common_length += 13;
|
||||
|
||||
memcpy_s(buf + common_length, buf_len - common_length, "#define USE_F2_COC (", 20);
|
||||
common_length += 20;
|
||||
|
||||
buf[common_length++] = (char)('0' + i);
|
||||
|
||||
memcpy_s(buf + common_length, buf_len - common_length, ")\n", 2);
|
||||
common_length += 2;
|
||||
|
||||
memcpy_s(buf + common_length, buf_len - common_length,
|
||||
u8"layout(binding = 0) uniform Common{\n"
|
||||
u8" uniform vec4 g_depth_params;//x=(n-f)/(nf), y=1/n, z=coc_from_z_scale, w=coc_from_z_offset\n"
|
||||
u8" uniform vec4 g_spread_scale;//x=scale_from_meter_to_pixel, y=scale_from_meter_to_sample, z=scale_from_pi"
|
||||
u8"xel_to_sample, w=scale_from_sample_to_pixel\n"
|
||||
u8" uniform vec4 g_depth_params2;//x=distance_to_focus_m, y=focus_range, z=k/(fuzzing_range*fuzzing_range), "
|
||||
u8"w=max_coc_radius_in_pixel //yzw=for_f2\n"
|
||||
u8"};\n"
|
||||
u8"#define SCALE_FROM_METER_TO_PIXEL g_spread_scale.x\n"
|
||||
u8"#define SCALE_FROM_METER_TO_SAMPLE g_spread_scale.y\n"
|
||||
u8"#define SCALE_FROM_PIXEL_TO_SAMPLE g_spread_scale.z\n"
|
||||
u8"#define SCALE_FROM_SAMPLE_TO_PIXEL g_spread_scale.w\n"
|
||||
u8"#define SAMPLE_DIVISION (7)\n"
|
||||
u8"#define SAMPLE_COUNT (SAMPLE_DIVISION * SAMPLE_DIVISION)\n"
|
||||
u8"#define PI 3.1415926535f\n"
|
||||
u8"#define DOF_SINGLE_PIXEL_RADIUS (0.5f * 1.414213562f)\n"
|
||||
u8"#define DOF_DEPTH_SCALE_FOREGROUND 0.f//0で前ボケをあきらめる//0.05f//小さいと前景よりに。\n"
|
||||
u8"#define MAX_COC_RADIUS_PIXEL (8)\n"
|
||||
u8"float calculate_depth_m_from_value_in_zbuffer(const float value_in_zbuffer){\n"
|
||||
u8" return 1.f / (value_in_zbuffer * g_depth_params.x + g_depth_params.y);//線形化。\n"
|
||||
u8"}\n"
|
||||
u8"vec4 calculate_depth_m_from_value_in_zbuffer(const vec4 value_in_zbuffer){\n"
|
||||
u8" return vec4(1.f) / (value_in_zbuffer * g_depth_params.xxxx + g_depth_params.yyyy);\n"
|
||||
u8"}\n"
|
||||
u8"float clamp_coc_pixel(const float radius_pixel){\n"
|
||||
u8" return min(radius_pixel, MAX_COC_RADIUS_PIXEL);\n"
|
||||
u8" //return clamp(radius_pixel, -MAX_COC_RADIUS_PIXEL, MAX_COC_RADIUS_PIXEL);\n"
|
||||
u8"}\n"
|
||||
u8"#if USE_F2_COC\n"
|
||||
u8"float calculate_coc_pixel_from_depth(const float linear_depth){\n"
|
||||
u8" float depth_dist = max(abs(g_depth_params2.x - linear_depth) - g_depth_params2.y, 0.f);\n"
|
||||
u8" float dof_ratio = 1.f - exp(depth_dist * depth_dist * g_depth_params2.z);\n"
|
||||
u8" return dof_ratio * g_depth_params2.w;\n"
|
||||
u8"}\n"
|
||||
u8"float calculate_coc_pixel_from_value_in_zbuffer(const float value_in_zbuffer){\n"
|
||||
u8" float d = calculate_depth_m_from_value_in_zbuffer(value_in_zbuffer);\n"
|
||||
u8" return calculate_coc_pixel_from_depth(d);\n"
|
||||
u8"}\n"
|
||||
u8"#else\n"
|
||||
u8"const float TEST_SCALE = 10.f;\n"
|
||||
u8"float calculate_coc_pixel_from_value_in_zbuffer(const float value_in_zbuffer){\n"
|
||||
u8" return clamp_coc_pixel(abs(value_in_zbuffer * g_depth_params.z + g_depth_params.w) * 1000.f * TEST_SCALE"
|
||||
u8");//適当。1[m]=100[pixel]と換算。@todo 適正化。\n"
|
||||
u8"}\n"
|
||||
u8"float calculate_coc_pixel_from_depth(const float linear_depth){\n"
|
||||
u8" float z = (1.f / linear_depth - g_depth_params.y) / g_depth_params.x;//0割りあり得るなぁ。@todo 事前に計算をまとめる。\n"
|
||||
u8" return calculate_coc_pixel_from_value_in_zbuffer(z);\n"
|
||||
u8"}\n"
|
||||
u8"#endif\n"
|
||||
u8"float calculate_sample_alpha(const float sample_coc_in_pixel){\n"
|
||||
u8" return\n"
|
||||
u8" 1.f / (PI * max(DOF_SINGLE_PIXEL_RADIUS * DOF_SINGLE_PIXEL_RADIUS, sample_coc_in_pixel * sample_coc_"
|
||||
u8"in_pixel));//CoCの面積の逆数。面積で割ることでエネルギーが保存される。\n"
|
||||
u8"}\n"
|
||||
u8"float calculate_background_depth_weight(const float depth, const float tile_min_depth){//1で背景。0で前景。\n"
|
||||
u8" float d = DOF_DEPTH_SCALE_FOREGROUND * (depth - tile_min_depth);\n"
|
||||
u8" return smoothstep(0.f, 1.f, d);\n"
|
||||
u8"}\n", 3025);
|
||||
common_length += 3024;
|
||||
|
||||
memcpy_s(buf + common_length, buf_len - common_length,
|
||||
u8"layout(binding = 0) uniform sampler2D g_depth;\n"
|
||||
u8"layout(location = 0) out vec2 result;//r=min_depth_m, g=max_coc_pixel\n"
|
||||
u8"in VertexData{\n"
|
||||
u8" vec2 texcoord;\n"
|
||||
u8"}frg;\n"
|
||||
u8"void main(){\n"
|
||||
u8" //タイル化。r=最小深度, g=最大CoC。\n"
|
||||
u8"#define N (20)\n"
|
||||
u8" ivec2 texture_size = textureSize(g_depth, 0);\n"
|
||||
u8" const vec2 step = vec2(1.f / float(texture_size.x), 1.f / float(texture_size.y));\n"
|
||||
u8" vec2 lt_uv = frg.texcoord + (-N / 2.f + 0.5f) * step;\n"
|
||||
u8" vec2 uv = lt_uv;\n"
|
||||
u8" float min_z = 1.f;\n"
|
||||
u8" float max_coc = 0.f;\n"
|
||||
u8" for(int i = 0; i < N; ++ i){\n"
|
||||
u8" uv.x = lt_uv.x;\n"
|
||||
u8" for(int j = 0; j < N; ++ j){//@todo tehxtureGatherOffsetsでループ回数を減らしてみよ。\n"
|
||||
u8" const float z = textureLod(g_depth, uv, 0).r;\n"
|
||||
u8" if(z < min_z){\n"
|
||||
u8" min_z = z;\n"
|
||||
u8" }\n"
|
||||
u8" const float coc = calculate_coc_pixel_from_value_in_zbuffer(z);\n"
|
||||
u8" if(max_coc < coc){\n"
|
||||
u8" max_coc = coc;\n"
|
||||
u8" }\n"
|
||||
u8" uv.x += step.x;\n"
|
||||
u8" }\n"
|
||||
u8" uv.y += step.y;\n"
|
||||
u8" }\n"
|
||||
u8" result.r = calculate_depth_m_from_value_in_zbuffer(min_z);//線形化。\n"
|
||||
u8" result.g = max_coc;\n"
|
||||
u8" //result.g = 8.f<=max_coc?1.f:0.f;\n"
|
||||
u8"}\n", 1154);
|
||||
shader_length = 1153;
|
||||
|
||||
shader_data[1].type = GL_FRAGMENT_SHADER;
|
||||
shader_data[1].string = buf;
|
||||
shader_data[1].length = common_length + shader_length;
|
||||
|
||||
program[0].compile_program(shader_data, 2);
|
||||
|
||||
memcpy_s(buf + common_length, buf_len - common_length,
|
||||
u8"layout(binding = 0) uniform sampler2D g_depth_point_sampler;\n"
|
||||
u8"layout(binding = 1) uniform sampler2D g_color_linear_sampler;\n"
|
||||
u8"layout(binding = 2) uniform sampler2D g_tile_sampler;\n"
|
||||
u8"layout(location = 0) out vec3 result_prefilter;\n"
|
||||
u8"layout(location = 1) out vec3 result_presort;\n"
|
||||
u8"in VertexData{\n"
|
||||
u8" vec2 texcoord;\n"
|
||||
u8"}frg;\n"
|
||||
u8"float fetch_max_depth(in const vec2 texcoord){\n"
|
||||
u8" vec4 z = textureGather(g_depth_point_sampler, texcoord, 0);//bilinearのフットプリントで、4点をサンプル。\n"
|
||||
u8" return max(max(z.x, z.y), max(z.z, z.w));//最も遠い深度を選択。\n"
|
||||
u8"}\n"
|
||||
u8"float calculate_min_bilateral_weight(\n"
|
||||
u8" in const vec2 texcoord,\n"
|
||||
u8" in const float depth_center,\n"
|
||||
u8" in const float side_center){//ここでdepth_centerが前景なら、前景サンプルのみを使うように。depth_centerが背景なら背景サンプルのみを使うように。\n"
|
||||
u8" const float depth_scale = 1.f;\n"
|
||||
u8"#if 1\n"
|
||||
u8" vec4 z = calculate_depth_m_from_value_in_zbuffer(textureGather(g_depth_point_sampler, texcoord, 0));//非線形のまま、差が最大のものを選択した方が良いかも。\n"
|
||||
u8" z -= vec4(depth_center);\n"
|
||||
u8" z = abs(z);\n"
|
||||
u8" float d = max(max(z.x, z.y), max(z.z, z.w));//最も離れた深度を選択。\n"
|
||||
u8" return 1.f / (d * depth_scale + 1.f);\n"
|
||||
u8"#elif 0//おもいぞ!\n"
|
||||
u8" vec4 z = textureGather(g_depth_point_sampler, texcoord, 0);\n"
|
||||
u8" float max_z = calculate_depth_m_from_value_in_zbuffer(max(max(z.x, z.y), max(z.z, z.w)));//最も遠い深度を選択。\n"
|
||||
u8" if(0.f < side_center * (max_z - g_depth_params2.x)){//中央タップと同じ側(前景,背景)にある。\n"
|
||||
u8" z = calculate_depth_m_from_value_in_zbuffer(z);\n"
|
||||
u8" z -= vec4(depth_center);\n"
|
||||
u8" z = abs(z);\n"
|
||||
u8" float d = max(max(z.x, z.y), max(z.z, z.w));//最も離れた深度を選択。\n"
|
||||
u8" return 1.f / (d * depth_scale + 1.f);\n"
|
||||
u8" }else{\n"
|
||||
u8" return 0.f;\n"
|
||||
u8" }\n"
|
||||
u8"#else//おもいぞ!\n"
|
||||
u8" vec4 z = calculate_depth_m_from_value_in_zbuffer(textureGather(g_depth_point_sampler, texcoord, 0));\n"
|
||||
u8" vec4 d = z - vec4(depth_center);\n"
|
||||
u8" d = abs(d);//最大の成分を選ぶ。\n"
|
||||
u8" float rz, rd;\n"
|
||||
u8" if(d.x < d.y){//y, z, w\n"
|
||||
u8" if(d.y < d.z){//z, w\n"
|
||||
u8" if(d.z < d.w){//w\n"
|
||||
u8" rz = z.w;\n"
|
||||
u8" rd = d.w;\n"
|
||||
u8" }else{//z\n"
|
||||
u8" rz = z.z;\n"
|
||||
u8" rd = d.z;\n"
|
||||
u8" }\n"
|
||||
u8" }else if(d.y < d.w){//w\n"
|
||||
u8" rz = z.w;\n"
|
||||
u8" rd = d.w;\n"
|
||||
u8" }else{//y\n"
|
||||
u8" rz = z.y;\n"
|
||||
u8" rd = d.y;\n"
|
||||
u8" }\n"
|
||||
u8" }else if(d.x < d.z){//z, w\n"
|
||||
u8" if(d.z < d.w){//w\n"
|
||||
u8" rz = z.w;\n"
|
||||
u8" rd = d.w;\n"
|
||||
u8" }else{//z\n"
|
||||
u8" rz = z.z;\n"
|
||||
u8" rd = d.z;\n"
|
||||
u8" }\n"
|
||||
u8" }else if(d.x < d.w){//w\n"
|
||||
u8" rz = z.w;\n"
|
||||
u8" rd = d.w;\n"
|
||||
u8" }else{//x\n"
|
||||
u8" rz = z.x;\n"
|
||||
u8" rd = d.x;\n"
|
||||
u8" }\n"
|
||||
u8" return (0.f <= (rz - g_depth_params2.x) * side_center) ? (1.f / (rd * depth_scale + 1.f)) : 0.f;//中央タップと側(前景, 背景)が異なる場合は重み0。\n"
|
||||
u8"#endif\n"
|
||||
u8"}\n"
|
||||
u8"float luminace_from_rgb(in const vec3 rgb){\n"
|
||||
u8" return dot(vec3(0.3f, 0.59f, 0.11f), rgb);\n"
|
||||
u8"}\n"
|
||||
u8"vec3 calculate_karis_average(in const vec3 color, const float sharpness){\n"
|
||||
u8" return color * 1.f / (1.f + (1.f - sharpness) * luminace_from_rgb(color));\n"
|
||||
u8"}\n"
|
||||
u8"//9点サンプルして深度を重みにしたバイラテラルフィルタで合成。\n"
|
||||
u8"vec3 prefilter(in const float coc_center_pixel, in const float depth_center){\n"
|
||||
u8" const float side_center = depth_center - g_depth_params2.x;//前景->side_center<0, 背景->0<side_center。\n"
|
||||
u8" //concentric_mapping\n"
|
||||
u8" const float tw = 1280.f;\n"
|
||||
u8" const float th = 720.f;\n"
|
||||
u8" const vec2 offsets[8] = {//半径1[pixel]。中央タップは別計算。\n"
|
||||
u8" vec2(-0.7071066f / tw, -0.7071068f / th),\n"
|
||||
u8" vec2( 0.f / tw, -1.f / th),\n"
|
||||
u8" vec2( 0.707107f / tw, -0.7071065f / th),\n"
|
||||
u8" vec2( -1.f / tw, 0.f / th),\n"
|
||||
u8" vec2( 1.f / tw, 0.f / th),\n"
|
||||
u8" vec2(-0.7071067f / tw, 0.7071067f / th),\n"
|
||||
u8" vec2( 0.f / tw, 1.f / th),\n"
|
||||
u8" vec2( 0.7071067f / tw, 0.7071067f / th),\n"
|
||||
u8" };\n"
|
||||
u8" const float radius_in_pixel = coc_center_pixel / 3.f;//3で割るの理由は、cocは49タップでの広さでこのタップ間の広さは1/3だからだ。ここではタップ間を9タップで補間する。\n"
|
||||
u8" //中央タップ。\n"
|
||||
u8" vec3 c_t = textureLod(g_color_linear_sampler, frg.texcoord, 0.f).rgb;\n"
|
||||
u8" float w_t = 1.f;//中央タップは重み1。深度差0のため。\n"
|
||||
u8" //近傍タップ。\n"
|
||||
u8" for(int i = 0; i < 8; ++ i){\n"
|
||||
u8" const vec2 uv = frg.texcoord + offsets[i] * radius_in_pixel;\n"
|
||||
u8" float w = calculate_min_bilateral_weight(uv, depth_center, side_center);//depth, gather4, 最小のバイラテラル重みを算出。\n"
|
||||
u8" //c_t += calculate_karis_average(textureLod(g_color_linear_sampler, uv, 0.f).rgb, 0.5f) * w;//それを重みとしてカラーを累積。\n"
|
||||
u8" c_t += textureLod(g_color_linear_sampler, uv, 0.f).rgb * w;//それを重みとしてカラーを累積。\n"
|
||||
u8" w_t += w;//重みを累積。\n"
|
||||
u8" }\n"
|
||||
u8" c_t *= 1.f / w_t;\n"
|
||||
u8" c_t = pow(c_t, vec3(2.2f));\n"
|
||||
u8" return c_t;\n"
|
||||
u8"}\n"
|
||||
u8"vec3 presort(const float coc_center_pixel, const float depth_center){\n"
|
||||
u8" const vec2 tile = textureLod(g_tile_sampler, frg.texcoord, 0).rg;\n"
|
||||
u8" const float tile_min_depth = tile.r;\n"
|
||||
u8" const float sample_alpha = calculate_sample_alpha(coc_center_pixel);\n"
|
||||
u8" const float background_depth_weight = calculate_background_depth_weight(depth_center, tile_min_depth);\n"
|
||||
u8" const float foreground_depth_weight = 1.f - background_depth_weight;\n"
|
||||
u8" return vec3(\n"
|
||||
u8" coc_center_pixel * SCALE_FROM_PIXEL_TO_SAMPLE,\n"
|
||||
u8" sample_alpha * background_depth_weight,\n"
|
||||
u8" sample_alpha * foreground_depth_weight);\n"
|
||||
u8"}\n"
|
||||
u8"void main(){\n"
|
||||
u8" //中央タップのzを求める。\n"
|
||||
u8" const float z_center = fetch_max_depth(frg.texcoord);//バイリニアのフットプリント上で、最も遠い深度を選択。//value_in_zbuffer\n"
|
||||
u8" const float depth_center = calculate_depth_m_from_value_in_zbuffer(z_center);\n"
|
||||
u8" const float coc_center_pixel = calculate_coc_pixel_from_value_in_zbuffer(z_center);\n"
|
||||
u8" //prefilter.\n"
|
||||
u8" result_prefilter = prefilter(coc_center_pixel, depth_center);\n"
|
||||
u8" //presort.\n"
|
||||
u8" result_presort = presort(coc_center_pixel, depth_center);\n"
|
||||
u8"}\n", 6219);
|
||||
shader_length = 6218;
|
||||
|
||||
shader_data[1].type = GL_FRAGMENT_SHADER;
|
||||
shader_data[1].string = buf;
|
||||
shader_data[1].length = common_length + shader_length;
|
||||
|
||||
program[1].compile_program(shader_data, 2);
|
||||
|
||||
memcpy_s(buf + common_length, buf_len - common_length,
|
||||
u8"layout(binding = 0) uniform sampler2D g_presort;//r=coc[sample], g=background_weight(=depth_cmp*sample_alpha"
|
||||
u8"), b=foreground_weight(=depth_cmp*sample_alpha)\n"
|
||||
u8"layout(binding = 1) uniform sampler2D g_color;\n"
|
||||
u8"layout(binding = 2) uniform sampler2D g_tile;//r=min_depth_m, g=max_coc_pixel\n"
|
||||
u8"layout(binding = 1) uniform Texcoords{\n"
|
||||
u8" vec2 g_offsets[SAMPLE_COUNT];\n"
|
||||
u8"};\n"
|
||||
u8"layout(location = 0) out vec3 result_color;\n"
|
||||
u8"layout(location = 1) out float result_alpha;\n"
|
||||
u8"in VertexData{\n"
|
||||
u8" vec2 texcoord;\n"
|
||||
u8"}frg;\n"
|
||||
u8"#define DOF_SPREAD_TOW_POWER (4.f)\n"
|
||||
u8"void main(){\n"
|
||||
u8" vec4 background = vec4(0.f);\n"
|
||||
u8" vec4 foreground = vec4(0.f);\n"
|
||||
u8" float v = 0.f;\n"
|
||||
u8" const vec2 tile = textureLod(g_tile, frg.texcoord, 0).rg;\n"
|
||||
u8" const float tile_max_coc_pixel = tile.g;\n"
|
||||
u8" const float tile_min_depth = tile.r;\n"
|
||||
u8" float coc_pixel_sum = 0.f;\n"
|
||||
u8" for(int i = 0; i < SAMPLE_COUNT; ++ i){\n"
|
||||
u8" vec2 offset_coc_pixel = g_offsets[i].xy;//[pixel]\n"
|
||||
u8" float offset_max_radius_pixel = (SAMPLE_DIVISION - 1) / 2 * SCALE_FROM_SAMPLE_TO_PIXEL;\n"
|
||||
u8" offset_coc_pixel /= offset_max_radius_pixel;//正規化。\n"
|
||||
u8" offset_coc_pixel *= clamp_coc_pixel(tile_max_coc_pixel);\n"
|
||||
u8" vec2 uv_offset;\n"
|
||||
u8" uv_offset.x = offset_coc_pixel.x / 1280.f;\n"
|
||||
u8" uv_offset.y = offset_coc_pixel.y / 720.f;\n"
|
||||
u8" vec2 uv = frg.texcoord + uv_offset;\n"
|
||||
u8" const vec3 color = textureLod(g_color, uv, 0).rgb;\n"
|
||||
u8" const vec3 presort = textureLod(g_presort, uv, 0).rgb;\n"
|
||||
u8" const float sample_coc_sample = clamp_coc_pixel(presort.r * SCALE_FROM_SAMPLE_TO_PIXEL) * SCALE_FROM"
|
||||
u8"_PIXEL_TO_SAMPLE;\n"
|
||||
u8" const float offset_coc_sample = length(offset_coc_pixel * SCALE_FROM_PIXEL_TO_SAMPLE);//[sample]\n"
|
||||
u8" const float spread_cmp = clamp(sample_coc_sample - offset_coc_sample + 1.f, 0.f, 1.f);\n"
|
||||
u8" const float spread_toe = (offset_coc_sample <= 1.f) ? pow(spread_cmp, DOF_SPREAD_TOW_POWER) : spread"
|
||||
u8"_cmp;//toeの適用は先頭サンプル(=中央タップ)だけで良い。\n"
|
||||
u8" const float sample_back_weight = spread_toe * presort.g;\n"
|
||||
u8" const float sample_fore_weight = spread_toe * presort.b;\n"
|
||||
u8" background.rgb += color * sample_back_weight;\n"
|
||||
u8" background.a += sample_back_weight;\n"
|
||||
u8" foreground.rgb += color * sample_fore_weight;\n"
|
||||
u8" foreground.a += sample_fore_weight;\n"
|
||||
u8" coc_pixel_sum += presort.r;\n"
|
||||
u8" }\n"
|
||||
u8" //スライドではこう↓だが、↓↓のようにtile_min_depthから求めたsample_alpha()で割るべきだろう。\n"
|
||||
u8" const float alpha = clamp(2.f * (1.f / SAMPLE_COUNT) * (1.f / calculate_sample_alpha(tile_max_coc_pixel)"
|
||||
u8") * foreground.a, 0.f, 1.f);\n"
|
||||
u8" //const float alpha = clamp(2.f * (1.f / SAMPLE_COUNT) * (1.f / calculate_sample_alpha(calculate_coc_pix"
|
||||
u8"el_from_depth(tile_min_depth))) * foreground.a, 0.f, 1.f);\n"
|
||||
u8" const float epsilon = 0.0001f;\n"
|
||||
u8" result_color = mix(\n"
|
||||
u8" background.rgb / max(background.a, epsilon),\n"
|
||||
u8" foreground.rgb / max(foreground.a, epsilon),\n"
|
||||
u8" alpha);\n"
|
||||
u8" result_alpha = alpha;\n"
|
||||
u8" //result_alpha = coc_pixel_sum / SAMPLE_COUNT / tile_max_coc_pixel;\n"
|
||||
u8"}\n", 3015);
|
||||
shader_length = 3014;
|
||||
|
||||
shader_data[1].type = GL_FRAGMENT_SHADER;
|
||||
shader_data[1].string = buf;
|
||||
shader_data[1].length = common_length + shader_length;
|
||||
|
||||
program[2].compile_program(shader_data, 2);
|
||||
|
||||
memcpy_s(buf + common_length, buf_len - common_length,
|
||||
u8"layout(binding = 0) uniform sampler2D g_filtered_rgb_sampler;\n"
|
||||
u8"layout(binding = 1) uniform sampler2D g_filtered_a_sampler;\n"
|
||||
u8"layout(binding = 2) uniform sampler2D g_tile_sampler;\n"
|
||||
u8"layout(binding = 3) uniform sampler2D g_full_res_color_sampler;\n"
|
||||
u8"layout(binding = 4) uniform sampler2D g_full_res_depth_sampler;\n"
|
||||
u8"layout(location = 0) out vec4 result;\n"
|
||||
u8"in VertexData{\n"
|
||||
u8" vec2 texcoord;\n"
|
||||
u8"}frg;\n"
|
||||
u8"void sort3(\n"
|
||||
u8" out vec4 out_min,\n"
|
||||
u8" out vec4 out_mid,\n"
|
||||
u8" out vec4 out_max,\n"
|
||||
u8" const in vec4 p0,\n"
|
||||
u8" const in vec4 p1,\n"
|
||||
u8" const in vec4 p2){\n"
|
||||
u8" vec4 a = min(p1, p2);\n"
|
||||
u8" vec4 b = max(p1, p2);\n"
|
||||
u8" vec4 c = max(p0, a);\n"
|
||||
u8" out_min = min(p0, a);\n"
|
||||
u8" out_mid = min(b, c);\n"
|
||||
u8" out_max = max(b, c);\n"
|
||||
u8"}\n"
|
||||
u8"vec4 median9(\n"
|
||||
u8" const in vec4 p0,\n"
|
||||
u8" const in vec4 p1,\n"
|
||||
u8" const in vec4 p2,\n"
|
||||
u8" const in vec4 p3,\n"
|
||||
u8" const in vec4 p4,\n"
|
||||
u8" const in vec4 p5,\n"
|
||||
u8" const in vec4 p6,\n"
|
||||
u8" const in vec4 p7,\n"
|
||||
u8" const in vec4 p8){\n"
|
||||
u8" vec4 min012, mid012, max012;\n"
|
||||
u8" sort3(min012, mid012, max012, p0, p1, p2);\n"
|
||||
u8" vec4 min345, mid345, max345;\n"
|
||||
u8" sort3(min345, mid345, max345, p3, p4, p5);\n"
|
||||
u8" vec4 min678, mid678, max678;\n"
|
||||
u8" sort3(min678, mid678, max678, p6, p7, p8);\n"
|
||||
u8" vec4 a = max(max(min012, min345), min678);\n"
|
||||
u8" vec4 c = min(min(max678, max345), max012);\n"
|
||||
u8" vec4 t0, b, t1;\n"
|
||||
u8" sort3(t0, b, t1, mid012, mid345, mid678);\n"
|
||||
u8" vec4 m;\n"
|
||||
u8" sort3(t0, m, t1, a, b, c);\n"
|
||||
u8" return m;\n"
|
||||
u8"}\n"
|
||||
u8"vec3 tone_map(in const vec3 color, const float exposure){\n"
|
||||
u8" return pow(color, vec3(1.f / 2.2f));\n"
|
||||
u8"}\n"
|
||||
u8"vec4 fetch_half(in const vec2 texcoord){\n"
|
||||
u8" return vec4(\n"
|
||||
u8" textureLod(g_filtered_rgb_sampler, texcoord, 0.f).rgb,\n"
|
||||
u8" textureLod(g_filtered_a_sampler, texcoord, 0.f).r);\n"
|
||||
u8"}\n"
|
||||
u8"vec4 upsample(){\n"
|
||||
u8" //3x3タップのメディアンフィルタを適用。\n"
|
||||
u8" vec2 offset = vec2(1.f / 1280.f, 1.f / 720.f);\n"
|
||||
u8" vec4 p0 = fetch_half(frg.texcoord + vec2(-offset.x, -offset.y));\n"
|
||||
u8" vec4 p1 = fetch_half(frg.texcoord + vec2( 0.f, -offset.y));\n"
|
||||
u8" vec4 p2 = fetch_half(frg.texcoord + vec2( offset.x, -offset.y));\n"
|
||||
u8" vec4 p3 = fetch_half(frg.texcoord + vec2(-offset.x, 0.f));\n"
|
||||
u8" vec4 p4 = fetch_half(frg.texcoord + vec2( 0.f, 0.f));\n"
|
||||
u8" vec4 p5 = fetch_half(frg.texcoord + vec2( offset.x, 0.f));\n"
|
||||
u8" vec4 p6 = fetch_half(frg.texcoord + vec2(-offset.x, offset.y));\n"
|
||||
u8" vec4 p7 = fetch_half(frg.texcoord + vec2( 0.f, offset.y));\n"
|
||||
u8" vec4 p8 = fetch_half(frg.texcoord + vec2( offset.x, offset.y));\n"
|
||||
u8" return median9(p0, p1, p2, p3, p4, p5, p6, p7, p8);\n"
|
||||
u8"}\n"
|
||||
u8"void main(){\n"
|
||||
u8" vec4 full_res = textureLod(g_full_res_color_sampler, frg.texcoord, 0.f);\n"
|
||||
u8" full_res.rgb = pow(full_res.rgb, vec3(2.2f));\n"
|
||||
u8" vec4 half_res = upsample();\n"
|
||||
u8" half_res.a = textureLod(g_filtered_a_sampler, frg.texcoord, 0.f).r;//test\n"
|
||||
u8" float full_z = textureLod(g_full_res_depth_sampler, frg.texcoord, 0.f).r;\n"
|
||||
u8" float full_depth = calculate_depth_m_from_value_in_zbuffer(full_z);\n"
|
||||
u8" float full_coc_pixel = calculate_coc_pixel_from_value_in_zbuffer(full_z);\n"
|
||||
u8" vec2 tile = textureLod(g_tile_sampler, frg.texcoord, 0.f).rg;\n"
|
||||
u8" float tile_min_depth = tile.r;\n"
|
||||
u8" float tile_max_coc = tile.g;\n"
|
||||
u8" float background_factor = calculate_sample_alpha(full_coc_pixel);\n"
|
||||
u8" float foreground_factor = calculate_sample_alpha(tile_max_coc);\n"
|
||||
u8" //float foreground_factor = calculate_sample_alpha(calculate_coc_pixel_from_depth(tile_min_depth));\n"
|
||||
u8" float combined_factor = mix(background_factor, foreground_factor, half_res.a);\n"
|
||||
u8" combined_factor += background_factor;\n"
|
||||
u8"#if 1\n"
|
||||
u8" //enahance\n"
|
||||
u8" combined_factor=1.f-combined_factor;\n"
|
||||
u8" combined_factor*=combined_factor;\n"
|
||||
u8" combined_factor=1.f-combined_factor;\n"
|
||||
u8" combined_factor *= 4.f;//適当。\n"
|
||||
u8" combined_factor -= 0.2f;//実解像度に半解像度が薄く合成される個所を捨てる。みっともないので。\n"
|
||||
u8" combined_factor = clamp(combined_factor, 0.f, 1.f);\n"
|
||||
u8"#endif\n"
|
||||
u8" result.rgb = mix(half_res.rgb, full_res.rgb, combined_factor);\n"
|
||||
u8" result.rgb = max(tone_map(result.rgb, 1.f), vec3(0.f));\n"
|
||||
u8" result.a = 1.f;\n"
|
||||
u8"}\n", 3927);
|
||||
shader_length = 3926;
|
||||
|
||||
shader_data[1].type = GL_FRAGMENT_SHADER;
|
||||
shader_data[1].string = buf;
|
||||
shader_data[1].length = common_length + shader_length;
|
||||
|
||||
program[3].compile_program(shader_data, 2);
|
||||
program += 4;
|
||||
}
|
||||
|
||||
_operator_delete(buf);
|
||||
}
|
||||
|
||||
void DOF3::apply_f2(RenderTexture* rt, 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) {
|
||||
@@ -669,6 +163,8 @@ namespace renderer {
|
||||
update_data(min_distance, max_distance,
|
||||
fov, focus, 0.0f, 1.0f, focus_range, fuzzing_range, ratio);
|
||||
|
||||
uniform->arr[U_DOF] = 1;
|
||||
|
||||
gl_state_bind_vertex_array(vao);
|
||||
render_tiles(depth_texture, true);
|
||||
downsample(color_texture, depth_texture, true);
|
||||
@@ -694,13 +190,15 @@ namespace renderer {
|
||||
update_data(min_distance, max_distance,
|
||||
fov, focus, focal_length, f_number, 0.0f, 0.1f, 0.0f);
|
||||
|
||||
uniform->arr[U_DOF] = 0;
|
||||
|
||||
gl_state_bind_vertex_array(vao);
|
||||
render_tiles(depth_texture, false);
|
||||
downsample(color_texture, depth_texture, false);
|
||||
apply_main_filter(false);
|
||||
upsample(rt, color_texture, depth_texture, false);
|
||||
|
||||
gl_state_use_program(0);
|
||||
shader::unbind();
|
||||
for (int32_t i = 0; i < 8; i++) {
|
||||
gl_state_bind_sampler(i, 0);
|
||||
gl_state_active_bind_texture_2d(i, 0);
|
||||
@@ -712,16 +210,18 @@ namespace renderer {
|
||||
void DOF3::render_tiles(GLuint depth_texture, bool f2) {
|
||||
gl_state_begin_event("renderer::DOF3::render_tiles");
|
||||
fbo[0].bind_buffer();
|
||||
glViewportDLL(0, 0, fbo[0].width, fbo[0].height);
|
||||
program[f2 ? 5 : 1].use_program();
|
||||
gl_state_set_viewport(0, 0, fbo[0].width, fbo[0].height);
|
||||
uniform->arr[U_DOF_STAGE] = 0;
|
||||
shaders_ft.set(SHADER_FT_DOF);
|
||||
common_ubo.Bind(0);
|
||||
gl_state_active_bind_texture_2d(0, depth_texture);
|
||||
gl_state_bind_sampler(0, samplers[1]);
|
||||
glDrawArraysDLL(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
fbo[1].bind_buffer();
|
||||
glViewportDLL(0, 0, fbo[1].width, fbo[1].height);
|
||||
program[0].use_program();
|
||||
gl_state_set_viewport(0, 0, fbo[1].width, fbo[1].height);
|
||||
uniform->arr[U_DOF_STAGE] = 1;
|
||||
shaders_ft.set(SHADER_FT_DOF);
|
||||
gl_state_active_bind_texture_2d(0, textures[0]);
|
||||
gl_state_bind_sampler(0, samplers[1]);
|
||||
glDrawArraysDLL(GL_TRIANGLE_STRIP, 0, 4);
|
||||
@@ -732,8 +232,9 @@ namespace renderer {
|
||||
void DOF3::downsample(GLuint color_texture, GLuint depth_texture, bool f2) {
|
||||
gl_state_begin_event("renderer::DOF3::downsample");
|
||||
fbo[2].bind_buffer();
|
||||
glViewportDLL(0, 0, fbo[2].width, fbo[2].height);
|
||||
program[f2 ? 6 : 2].use_program();
|
||||
gl_state_set_viewport(0, 0, fbo[2].width, fbo[2].height);
|
||||
uniform->arr[U_DOF_STAGE] = 2;
|
||||
shaders_ft.set(SHADER_FT_DOF);
|
||||
common_ubo.Bind(0);
|
||||
gl_state_active_bind_texture_2d(0, depth_texture);
|
||||
gl_state_bind_sampler(0, samplers[1]);
|
||||
@@ -748,8 +249,9 @@ namespace renderer {
|
||||
void DOF3::apply_main_filter(bool f2) {
|
||||
gl_state_begin_event("renderer::DOF3::apply_main_filter");
|
||||
fbo[3].bind_buffer();
|
||||
glViewportDLL(0, 0, fbo[3].width, fbo[3].height);
|
||||
program[f2 ? 7 : 3].use_program();
|
||||
gl_state_set_viewport(0, 0, fbo[3].width, fbo[3].height);
|
||||
uniform->arr[U_DOF_STAGE] = 3;
|
||||
shaders_ft.set(SHADER_FT_DOF);
|
||||
common_ubo.Bind(0);
|
||||
texcoords_ubo.Bind(1);
|
||||
gl_state_active_bind_texture_2d(0, textures[3]);
|
||||
@@ -765,8 +267,9 @@ namespace renderer {
|
||||
void DOF3::upsample(RenderTexture* rt, GLuint color_texture, GLuint depth_texture, bool f2) {
|
||||
gl_state_begin_event("renderer::DOF3::upsample");
|
||||
rctx->render_buffer.Bind();
|
||||
glViewportDLL(0, 0, width, height);
|
||||
program[f2 ? 8 : 4].use_program();
|
||||
gl_state_set_viewport(0, 0, width, height);
|
||||
uniform->arr[U_DOF_STAGE] = 4;
|
||||
shaders_ft.set(SHADER_FT_DOF);
|
||||
common_ubo.Bind(0);
|
||||
gl_state_active_bind_texture_2d(0, textures[4]);
|
||||
gl_state_bind_sampler(0, samplers[1]);
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "../GL/uniform_buffer.hpp"
|
||||
#include "../render_texture.hpp"
|
||||
#include "fbo.hpp"
|
||||
#include "gl_program.hpp"
|
||||
|
||||
enum dof_debug_flags {
|
||||
DOF_DEBUG_USE_UI_PARAMS = 0x01,
|
||||
@@ -52,7 +51,7 @@ namespace renderer {
|
||||
FBO fbo[4];
|
||||
GLuint samplers[2];
|
||||
GLuint vao;
|
||||
GLProgram program[9];
|
||||
GLuint program[9]; // Unused
|
||||
GL::UniformBuffer common_ubo;
|
||||
GL::UniformBuffer texcoords_ubo;
|
||||
|
||||
@@ -65,7 +64,6 @@ namespace renderer {
|
||||
private:
|
||||
void free();
|
||||
void init(int32_t width, int32_t height);
|
||||
void load_shaders();
|
||||
|
||||
void apply_f2(RenderTexture* rt, GLuint color_texture,
|
||||
GLuint depth_texture, float_t min_distance, float_t max_distance, float_t fov,
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "gl_program.hpp"
|
||||
#include "../gl_state.hpp"
|
||||
|
||||
namespace renderer {
|
||||
bool GLProgram::compile_program(GLProgram::ShaderData* shader_data, int32_t count) {
|
||||
if (program) {
|
||||
glDeleteProgram(program);
|
||||
program = 0;
|
||||
}
|
||||
|
||||
program = glCreateProgram();
|
||||
|
||||
for (int32_t i = 0; i < count; i++, shader_data++) {
|
||||
GLuint shader = glCreateShader(shader_data->type);
|
||||
if (!renderer::GLProgram::compile_shader(shader, shader_data->string, shader_data->length))
|
||||
return false;
|
||||
|
||||
glAttachShader(program, shader);
|
||||
glDeleteShader(shader);
|
||||
}
|
||||
|
||||
glLinkProgram(program);
|
||||
return !glGetErrorDLL();
|
||||
}
|
||||
|
||||
bool GLProgram::compile_shader(GLuint shader, const char* string, int32_t length) {
|
||||
const char* strings[] = { string };
|
||||
int32_t lengths[] = { length };
|
||||
|
||||
glShaderSource(shader, 1, strings, lengths);
|
||||
glCompileShader(shader);
|
||||
|
||||
int32_t info_log_length;
|
||||
char info_log[0x400];
|
||||
glGetShaderInfoLog(shader, sizeof(info_log), &info_log_length, info_log);
|
||||
|
||||
int32_t compile_status;
|
||||
glGetShaderiv(shader, GL_COMPILE_STATUS, &compile_status);
|
||||
return compile_status == GL_TRUE;
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../KKdLib/default.hpp"
|
||||
#include "../../KKdLib/vec.hpp"
|
||||
#include "../gl_state.hpp"
|
||||
#include "../shared.hpp"
|
||||
|
||||
namespace renderer {
|
||||
struct GLProgram {
|
||||
struct ShaderData {
|
||||
GLenum type;
|
||||
const char* string;
|
||||
int32_t length;
|
||||
};
|
||||
|
||||
GLuint program;
|
||||
|
||||
bool compile_program(GLProgram::ShaderData* shader_data, int32_t count);
|
||||
|
||||
static bool compile_shader(GLuint shader, const char* string, int32_t length);
|
||||
|
||||
inline void use_program() {
|
||||
gl_state_use_program(program);
|
||||
}
|
||||
};
|
||||
|
||||
static_assert(sizeof(renderer::GLProgram) == 0x04, "\"renderer::GLProgram\" struct should have a size of 0x04");
|
||||
};
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "transparency.hpp"
|
||||
#include "../../KKdLib/str_utils.hpp"
|
||||
#include "../render_context.hpp"
|
||||
#include "../gl_state.hpp"
|
||||
#include "../shader_ft.hpp"
|
||||
|
||||
extern render_context* rctx;
|
||||
|
||||
@@ -16,8 +18,6 @@ namespace renderer {
|
||||
color_textures[0] = color_texture;
|
||||
fbo.init(width, height, color_textures, 1, depth_texture);
|
||||
|
||||
load_shaders();
|
||||
|
||||
glGenSamplers(1, &sampler);
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
|
||||
@@ -40,30 +40,30 @@ namespace renderer {
|
||||
}
|
||||
|
||||
void Transparency::combine(RenderTexture* rt, float_t alpha) {
|
||||
vec4 g_opacity = { alpha, 0.0f, 0.0f, 0.0f };
|
||||
transparency_batch_shader_data shader_data = {};
|
||||
shader_data.g_opacity = { alpha, 0.0f, 0.0f, 0.0f };
|
||||
rctx->transparency_batch_ubo.WriteMemory(shader_data);
|
||||
|
||||
gl_state_disable_blend();
|
||||
gl_state_disable_depth_test();
|
||||
rctx->render_buffer.Bind();
|
||||
program.use_program();
|
||||
glUniform4fv(0, 1, (GLfloat*)&g_opacity.x);
|
||||
shaders_ft.set(SHADER_FT_TRANSPARENCY);
|
||||
rctx->transparency_batch_ubo.Bind(0);
|
||||
gl_state_active_bind_texture_2d(0, fbo.textures[0]);
|
||||
gl_state_active_bind_texture_2d(1, rt->GetColorTex());
|
||||
gl_state_bind_vertex_array(vao);
|
||||
glDrawArraysDLL(GL_TRIANGLE_STRIP, 0, 4);
|
||||
shaders_ft.draw_arrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
gl_state_enable_depth_test();
|
||||
|
||||
glCopyImageSubData(
|
||||
rctx->render_buffer.GetColorTex(), GL_TEXTURE_2D, 0, 0, 0, 0,
|
||||
glCopyImageSubData(rctx->render_buffer.GetColorTex(), GL_TEXTURE_2D, 0, 0, 0, 0,
|
||||
rt->GetColorTex(), GL_TEXTURE_2D, 0, 0, 0, 0, fbo.width, fbo.height, 1);
|
||||
}
|
||||
|
||||
void Transparency::copy(GLuint texture) {
|
||||
glCopyImageSubData(
|
||||
texture, GL_TEXTURE_2D, 0, 0, 0, 0,
|
||||
glCopyImageSubData(texture, GL_TEXTURE_2D, 0, 0, 0, 0,
|
||||
fbo.textures[0], GL_TEXTURE_2D, 0, 0, 0, 0, fbo.width, fbo.height, 1);
|
||||
fbo.bind_buffer();
|
||||
glViewportDLL(0, 0, fbo.width, fbo.height);
|
||||
gl_state_set_viewport(0, 0, fbo.width, fbo.height);
|
||||
}
|
||||
|
||||
void Transparency::resize(GLuint color_texture, GLuint depth_texture, int32_t width, int32_t height) {
|
||||
@@ -71,41 +71,4 @@ namespace renderer {
|
||||
color_textures[0] = color_texture;
|
||||
fbo.init(width, height, color_textures, 1, depth_texture);
|
||||
}
|
||||
|
||||
void renderer::Transparency::load_shaders() {
|
||||
GLProgram::ShaderData shader_data[2];
|
||||
|
||||
shader_data[0].type = GL_VERTEX_SHADER;
|
||||
shader_data[0].string =
|
||||
u8"#version 430\n"
|
||||
u8"out VertexData{\n"
|
||||
u8" vec2 texcoord;\n"
|
||||
u8"}result;\n"
|
||||
u8"void main(){\n"
|
||||
u8" gl_Position.x = -1.f + (gl_VertexID / 2) * 4;\n"
|
||||
u8" gl_Position.y = 1.f - (gl_VertexID % 2) * 4;\n"
|
||||
u8" gl_Position.z = 0.f;\n"
|
||||
u8" gl_Position.w = 1.f;\n"
|
||||
u8" result.texcoord = gl_Position.xy * 0.5f + 0.5f;\n"
|
||||
u8"}\n";
|
||||
shader_data[0].length = 273;
|
||||
|
||||
shader_data[1].type = GL_FRAGMENT_SHADER;
|
||||
shader_data[1].string =
|
||||
u8"#version 430\n"
|
||||
u8"layout(binding = 0) uniform sampler2D g_layerd_color;\n"
|
||||
u8"layout(binding = 1) uniform sampler2D g_base_color;\n"
|
||||
u8"layout(location = 0) uniform vec4 g_opacity;//x=opacity, yzw=unused\n"
|
||||
u8"in VertexData{\n"
|
||||
u8" vec2 texcoord;\n"
|
||||
u8"}frg;\n"
|
||||
u8"layout(location = 0) out vec4 result;\n"
|
||||
u8"void main(){\n"
|
||||
u8" vec4 cl = textureLod(g_layerd_color, frg.texcoord, 0.f);\n"
|
||||
u8" vec4 cb = textureLod(g_base_color, frg.texcoord, 0.f);\n"
|
||||
u8" result.rgba = mix(cb, cl, g_opacity.x);\n"
|
||||
u8"};\n";
|
||||
shader_data[1].length = 445;
|
||||
program.compile_program(shader_data, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,13 +9,12 @@
|
||||
#include "../../KKdLib/vec.hpp"
|
||||
#include "../render_texture.hpp"
|
||||
#include "fbo.hpp"
|
||||
#include "gl_program.hpp"
|
||||
|
||||
namespace renderer {
|
||||
struct Transparency {
|
||||
private:
|
||||
FBO fbo;
|
||||
GLProgram program;
|
||||
GLuint program; // Unused
|
||||
GLuint sampler;
|
||||
GLuint vao;
|
||||
|
||||
@@ -27,9 +26,6 @@ namespace renderer {
|
||||
void copy(GLuint texture);
|
||||
|
||||
void resize(GLuint color_texture, GLuint depth_texture, int32_t width, int32_t height);
|
||||
|
||||
private:
|
||||
void load_shaders();
|
||||
};
|
||||
|
||||
static_assert(sizeof(renderer::Transparency) == 0x30, "\"renderer::Transparency\" struct should have a size of 0x30");
|
||||
|
||||
@@ -101,7 +101,7 @@ HOOK(void, FASTCALL, ScreenShotImpl__get_data, 0x0000000140557F50, ScreenShotImp
|
||||
gl_state_disable_depth_test();
|
||||
gl_state_disable_blend();
|
||||
gl_state_disable_cull_face();
|
||||
glViewportDLL(0, 0, impl->curr_width, impl->curr_height);
|
||||
gl_state_set_viewport(0, 0, impl->curr_width, impl->curr_height);
|
||||
|
||||
shaders_ft.set(SHADER_FT_REDUCE);
|
||||
gl_state_bind_vertex_array(rctx->common_vao);
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
#include "gl.hpp"
|
||||
#include "uniform.hpp"
|
||||
|
||||
#define SHADER_MAX_UNIFORM_VALUES 16
|
||||
|
||||
struct shader_sub_table {
|
||||
uint32_t sub_index;
|
||||
const int32_t* vp_unival_max;
|
||||
|
||||
+181
-522
@@ -85,22 +85,28 @@ enum shader_ft_sub_enum {
|
||||
SHADER_FT_SUB_BOX8,
|
||||
SHADER_FT_SUB_COPY,
|
||||
SHADER_FT_SUB_SPRITE,
|
||||
SHADER_FT_SUB_DOF_RENDER_TILE,
|
||||
SHADER_FT_SUB_DOF_GATHER_TILE,
|
||||
SHADER_FT_SUB_DOF_DOWNSAMPLE,
|
||||
SHADER_FT_SUB_DOF_MAIN_FILTER,
|
||||
SHADER_FT_SUB_DOF_UPSAMPLE,
|
||||
SHADER_FT_SUB_TRANSPARENCY,
|
||||
SHADER_FT_SUB_SHADER_END,
|
||||
};
|
||||
|
||||
static const int32_t blinn_vert_vpt_unival_max[] = {
|
||||
static const int32_t blinn_per_vert_vpt_unival_max[] = {
|
||||
1, 1, 0,
|
||||
};
|
||||
|
||||
static const int32_t blinn_vert_fpt_unival_max[] = {
|
||||
static const int32_t blinn_per_vert_fpt_unival_max[] = {
|
||||
0, 0, 1,
|
||||
};
|
||||
|
||||
static const int32_t blinn_frag_vpt_unival_max[] = {
|
||||
static const int32_t blinn_per_frag_vpt_unival_max[] = {
|
||||
1, 1, 0,
|
||||
};
|
||||
|
||||
static const int32_t blinn_frag_fpt_unival_max[] = {
|
||||
static const int32_t blinn_per_frag_fpt_unival_max[] = {
|
||||
0, 0, 1,
|
||||
};
|
||||
|
||||
@@ -664,662 +670,280 @@ static const int32_t sprite_fpt_unival_max[] = {
|
||||
3, 3, 2,
|
||||
};
|
||||
|
||||
static const int32_t dof_common_vpt_unival_max[] = {
|
||||
0,
|
||||
};
|
||||
|
||||
static const int32_t dof_render_tile_fpt_unival_max[] = {
|
||||
1,
|
||||
};
|
||||
|
||||
static const int32_t dof_gather_tile_fpt_unival_max[] = {
|
||||
0,
|
||||
};
|
||||
|
||||
static const int32_t dof_downsample_fpt_unival_max[] = {
|
||||
1,
|
||||
};
|
||||
|
||||
static const int32_t dof_main_filter_fpt_unival_max[] = {
|
||||
1,
|
||||
};
|
||||
|
||||
static const int32_t dof_upsample_fpt_unival_max[] = {
|
||||
1,
|
||||
};
|
||||
|
||||
static const int32_t transparency_vpt_unival_max[] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
static const int32_t transparency_fpt_unival_max[] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
#define shader_sub_table_struct(sub_index, vp, fp) \
|
||||
{ \
|
||||
SHADER_FT_SUB_##sub_index, \
|
||||
vp##_vpt_unival_max, \
|
||||
fp##_fpt_unival_max, \
|
||||
#vp, \
|
||||
#fp, \
|
||||
}
|
||||
|
||||
static const shader_sub_table BLINN_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_BLINN_VERT,
|
||||
blinn_vert_vpt_unival_max,
|
||||
blinn_vert_fpt_unival_max,
|
||||
"blinn_per_vert",
|
||||
"blinn_per_vert",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_BLINN_FRAG,
|
||||
blinn_frag_vpt_unival_max,
|
||||
blinn_frag_fpt_unival_max,
|
||||
"blinn_per_frag",
|
||||
"blinn_per_frag",
|
||||
},
|
||||
shader_sub_table_struct(BLINN_VERT, blinn_per_vert, blinn_per_vert),
|
||||
shader_sub_table_struct(BLINN_FRAG, blinn_per_frag, blinn_per_frag),
|
||||
};
|
||||
|
||||
static const shader_sub_table ITEM_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_ITEM_BLINN,
|
||||
item_blinn_vpt_unival_max,
|
||||
item_blinn_fpt_unival_max,
|
||||
"item_blinn",
|
||||
"item_blinn",
|
||||
},
|
||||
shader_sub_table_struct(BLINN_VERT, item_blinn, item_blinn),
|
||||
};
|
||||
|
||||
static const shader_sub_table STAGE_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_STAGE_BLINN,
|
||||
stage_blinn_vpt_unival_max,
|
||||
stage_blinn_fpt_unival_max,
|
||||
"stage_blinn",
|
||||
"stage_blinn",
|
||||
},
|
||||
shader_sub_table_struct(STAGE_BLINN, stage_blinn, stage_blinn),
|
||||
};
|
||||
|
||||
static const shader_sub_table SKIN_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_SKIN_DEFAULT,
|
||||
skin_default_vpt_unival_max,
|
||||
skin_default_fpt_unival_max,
|
||||
"skin_default",
|
||||
"skin_default",
|
||||
},
|
||||
shader_sub_table_struct(SKIN_DEFAULT, skin_default, skin_default),
|
||||
};
|
||||
|
||||
static const shader_sub_table SSS_SKIN_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_SSS_SKIN,
|
||||
sss_skin_vpt_unival_max,
|
||||
sss_skin_fpt_unival_max,
|
||||
"sss_skin",
|
||||
"sss_skin",
|
||||
},
|
||||
shader_sub_table_struct(SSS_SKIN, sss_skin, sss_skin),
|
||||
};
|
||||
|
||||
static const shader_sub_table SSS_FILT_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_SSS_FILTER_MIN,
|
||||
sss_filter_min_vpt_unival_max,
|
||||
sss_filter_min_fpt_unival_max,
|
||||
"sss_filter_min",
|
||||
"sss_filter_min",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_SSS_FILTER_MIN_NPR,
|
||||
sss_filter_min_vpt_unival_max,
|
||||
sss_filter_min_npr_fpt_unival_max,
|
||||
"sss_filter_min",
|
||||
"sss_filter_min_npr",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_SSS_FILTER_GAUSS_2D,
|
||||
sss_filter_gauss_2d_vpt_unival_max,
|
||||
sss_filter_gauss_2d_fpt_unival_max,
|
||||
"sss_filter_gauss_2d",
|
||||
"sss_filter_gauss_2d",
|
||||
},
|
||||
shader_sub_table_struct(SSS_FILTER_MIN, sss_filter_min, sss_filter_min),
|
||||
shader_sub_table_struct(SSS_FILTER_MIN_NPR, sss_filter_min, sss_filter_min_npr),
|
||||
shader_sub_table_struct(SSS_FILTER_GAUSS_2D, sss_filter_gauss_2d, sss_filter_gauss_2d),
|
||||
};
|
||||
|
||||
static const shader_sub_table HAIR_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_HAIR_DEFAULT,
|
||||
hair_default_vpt_unival_max,
|
||||
hair_default_fpt_unival_max,
|
||||
"hair_default",
|
||||
"hair_default",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_HAIR_NPR1,
|
||||
hair_default_vpt_unival_max,
|
||||
hair_npr1_fpt_unival_max,
|
||||
"hair_default",
|
||||
"hair_npr1",
|
||||
},
|
||||
shader_sub_table_struct(HAIR_DEFAULT, hair_default, hair_default),
|
||||
shader_sub_table_struct(HAIR_NPR1, hair_default, hair_npr1),
|
||||
};
|
||||
|
||||
static const shader_sub_table CLOTH_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_CLOTH_DEFAULT,
|
||||
cloth_default_vpt_unival_max,
|
||||
cloth_default_fpt_unival_max,
|
||||
"cloth_default",
|
||||
"cloth_default",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_CLOTH_ANISO,
|
||||
cloth_default_vpt_unival_max,
|
||||
cloth_aniso_fpt_unival_max,
|
||||
"cloth_default",
|
||||
"cloth_aniso",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_CLOTH_NPR1,
|
||||
cloth_default_vpt_unival_max,
|
||||
cloth_npr1_fpt_unival_max,
|
||||
"cloth_default",
|
||||
"cloth_npr1",
|
||||
},
|
||||
shader_sub_table_struct(CLOTH_DEFAULT, cloth_default, cloth_default),
|
||||
shader_sub_table_struct(CLOTH_ANISO, cloth_default, cloth_aniso),
|
||||
shader_sub_table_struct(CLOTH_NPR1, cloth_default, cloth_npr1),
|
||||
};
|
||||
|
||||
static const shader_sub_table TIGHTS_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_TIGHTS,
|
||||
tights_vpt_unival_max,
|
||||
tights_fpt_unival_max,
|
||||
"tights",
|
||||
"tights",
|
||||
},
|
||||
shader_sub_table_struct(TIGHTS, tights, tights),
|
||||
};
|
||||
|
||||
static const shader_sub_table SKY_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_SKY_DEFAULT,
|
||||
sky_default_vpt_unival_max,
|
||||
sky_default_fpt_unival_max,
|
||||
"sky_default",
|
||||
"sky_default",
|
||||
},
|
||||
shader_sub_table_struct(SKY_DEFAULT, sky_default, sky_default),
|
||||
};
|
||||
|
||||
static const shader_sub_table GLASEYE_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_GLASS_EYE,
|
||||
glass_eye_vpt_unival_max,
|
||||
glass_eye_fpt_unival_max,
|
||||
"glass_eye",
|
||||
"glass_eye",
|
||||
},
|
||||
shader_sub_table_struct(GLASS_EYE, glass_eye, glass_eye),
|
||||
};
|
||||
|
||||
static const shader_sub_table ESMGAUSS_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_ESM_GAUSS,
|
||||
esm_gauss_vpt_unival_max,
|
||||
esm_gauss_fpt_unival_max,
|
||||
"esm_gauss",
|
||||
"esm_gauss",
|
||||
},
|
||||
shader_sub_table_struct(ESM_GAUSS, esm_gauss, esm_gauss),
|
||||
};
|
||||
|
||||
static const shader_sub_table ESMFILT_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_ESM_FILTER_MIN,
|
||||
esm_filter_min_vpt_unival_max,
|
||||
esm_filter_min_fpt_unival_max,
|
||||
"esm_filter_min",
|
||||
"esm_filter_min",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_ESM_FILTER_EROSION,
|
||||
esm_filter_erosion_vpt_unival_max,
|
||||
esm_filter_erosion_fpt_unival_max,
|
||||
"esm_filter_erosion",
|
||||
"esm_filter_erosion",
|
||||
},
|
||||
shader_sub_table_struct(ESM_FILTER_MIN, esm_filter_min, esm_filter_min),
|
||||
shader_sub_table_struct(ESM_FILTER_EROSION, esm_filter_erosion, esm_filter_erosion),
|
||||
};
|
||||
|
||||
static const shader_sub_table LITPROJ_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_LIT_PROJ,
|
||||
lit_proj_vpt_unival_max,
|
||||
lit_proj_fpt_unival_max,
|
||||
"lit_proj",
|
||||
"lit_proj",
|
||||
},
|
||||
shader_sub_table_struct(LIT_PROJ, lit_proj, lit_proj),
|
||||
};
|
||||
|
||||
static const shader_sub_table SIMPLE_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_SIMPLE,
|
||||
simple_vpt_unival_max,
|
||||
simple_fpt_unival_max,
|
||||
"simple",
|
||||
"simple",
|
||||
},
|
||||
shader_sub_table_struct(SIMPLE, simple, simple),
|
||||
};
|
||||
|
||||
static const shader_sub_table SIL_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_SILHOUETTE,
|
||||
silhouette_vpt_unival_max,
|
||||
silhouette_fpt_unival_max,
|
||||
"silhouette",
|
||||
"silhouette",
|
||||
},
|
||||
shader_sub_table_struct(SILHOUETTE, silhouette, silhouette),
|
||||
};
|
||||
|
||||
static const shader_sub_table LAMBERT_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_LAMBERT,
|
||||
lambert_vpt_unival_max,
|
||||
lambert_fpt_unival_max,
|
||||
"lambert",
|
||||
"lambert",
|
||||
},
|
||||
shader_sub_table_struct(LAMBERT, lambert, lambert),
|
||||
};
|
||||
|
||||
static const shader_sub_table CONSTANT_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_CONSTANT,
|
||||
constant_vpt_unival_max,
|
||||
constant_fpt_unival_max,
|
||||
"constant",
|
||||
"constant",
|
||||
},
|
||||
shader_sub_table_struct(CONSTANT, constant, constant),
|
||||
};
|
||||
|
||||
static const shader_sub_table TONEMAP_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_TONEMAP,
|
||||
tone_map_vpt_unival_max,
|
||||
tone_map_fpt_unival_max,
|
||||
"tone_map",
|
||||
"tone_map",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_TONEMAP_NPR1,
|
||||
tone_map_npr1_vpt_unival_max,
|
||||
tone_map_npr1_fpt_unival_max,
|
||||
"tone_map_npr1",
|
||||
"tone_map_npr1",
|
||||
},
|
||||
shader_sub_table_struct(TONEMAP, tone_map, tone_map),
|
||||
shader_sub_table_struct(TONEMAP_NPR1, tone_map_npr1, tone_map_npr1),
|
||||
};
|
||||
|
||||
static const shader_sub_table REDUCE_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_REDUCE_TEX_REDUCE_2,
|
||||
reduce_tex_reduce_2_vpt_unival_max,
|
||||
reduce_tex_reduce_2_fpt_unival_max,
|
||||
"reduce_tex_reduce_2",
|
||||
"reduce_tex_reduce_2",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_REDUCE_TEX_REDUCE_2_ALPHAMASK,
|
||||
reduce_tex_reduce_2_alphamask_vpt_unival_max,
|
||||
reduce_tex_reduce_2_alphamask_fpt_unival_max,
|
||||
"reduce_tex_reduce_2_alphamask",
|
||||
"reduce_tex_reduce_2_alphamask",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_REDUCE_TEX_REDUCE_4,
|
||||
reduce_tex_reduce_4_vpt_unival_max,
|
||||
reduce_tex_reduce_4_fpt_unival_max,
|
||||
"reduce_tex_reduce_4",
|
||||
"reduce_tex_reduce_4",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_REDUCE_TEX_REDUCE_4_EXTRACT,
|
||||
reduce_tex_reduce_4_extract_vpt_unival_max,
|
||||
reduce_tex_reduce_4_extract_fpt_unival_max,
|
||||
"reduce_tex_reduce_4_extract",
|
||||
"reduce_tex_reduce_4_extract",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_GHOST,
|
||||
ghost_vpt_unival_max,
|
||||
ghost_fpt_unival_max,
|
||||
"ghost",
|
||||
"ghost",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_REDUCE_TEX_REDUCE_COMPOSITE_2,
|
||||
reduce_tex_reduce_composite_2_vpt_unival_max,
|
||||
reduce_tex_reduce_composite_2_fpt_unival_max,
|
||||
"reduce_tex_reduce_composite_2",
|
||||
"reduce_tex_reduce_composite_2",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_REDUCE_TEX_REDUCE_COMPOSITE_BLUR,
|
||||
reduce_tex_reduce_composite_blur_vpt_unival_max,
|
||||
reduce_tex_reduce_composite_blur_fpt_unival_max,
|
||||
"reduce_tex_reduce_composite_blur",
|
||||
"reduce_tex_reduce_composite_blur",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_REDUCE_TEX_REDUCE_COMPOSITE_4,
|
||||
reduce_tex_reduce_composite_4_vpt_unival_max,
|
||||
reduce_tex_reduce_composite_4_fpt_unival_max,
|
||||
"reduce_tex_reduce_composite_4",
|
||||
"reduce_tex_reduce_composite_4",
|
||||
},
|
||||
shader_sub_table_struct(REDUCE_TEX_REDUCE_2,
|
||||
reduce_tex_reduce_2, reduce_tex_reduce_2),
|
||||
shader_sub_table_struct(REDUCE_TEX_REDUCE_2_ALPHAMASK,
|
||||
reduce_tex_reduce_2_alphamask, reduce_tex_reduce_2_alphamask),
|
||||
shader_sub_table_struct(REDUCE_TEX_REDUCE_4,
|
||||
reduce_tex_reduce_4, reduce_tex_reduce_4),
|
||||
shader_sub_table_struct(REDUCE_TEX_REDUCE_4_EXTRACT,
|
||||
reduce_tex_reduce_4_extract, reduce_tex_reduce_4_extract),
|
||||
shader_sub_table_struct(GHOST, ghost, ghost),
|
||||
shader_sub_table_struct(REDUCE_TEX_REDUCE_COMPOSITE_2,
|
||||
reduce_tex_reduce_composite_2, reduce_tex_reduce_composite_2),
|
||||
shader_sub_table_struct(REDUCE_TEX_REDUCE_COMPOSITE_BLUR,
|
||||
reduce_tex_reduce_composite_blur, reduce_tex_reduce_composite_blur),
|
||||
shader_sub_table_struct(REDUCE_TEX_REDUCE_COMPOSITE_4,
|
||||
reduce_tex_reduce_composite_4, reduce_tex_reduce_composite_4),
|
||||
};
|
||||
|
||||
static const shader_sub_table MAGNIFY_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_MAGNIFY_LINEAR,
|
||||
magnify_linear_vpt_unival_max,
|
||||
magnify_linear_fpt_unival_max,
|
||||
"magnify_linear",
|
||||
"magnify_linear",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_MAGNIFY_DIFF,
|
||||
magnify_diff_vpt_unival_max,
|
||||
magnify_diff_fpt_unival_max,
|
||||
"magnify_diff",
|
||||
"magnify_diff",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_MAGNIFY_DIFF2,
|
||||
magnify_diff2_vpt_unival_max,
|
||||
magnify_diff2_fpt_unival_max,
|
||||
"magnify_diff2",
|
||||
"magnify_diff2",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_MAGNIFY_CONE,
|
||||
magnify_cone_vpt_unival_max,
|
||||
magnify_cone_fpt_unival_max,
|
||||
"magnify_cone",
|
||||
"magnify_cone",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_MAGNIFY_CONE2,
|
||||
magnify_cone2_vpt_unival_max,
|
||||
magnify_cone2_fpt_unival_max,
|
||||
"magnify_cone2",
|
||||
"magnify_cone2",
|
||||
},
|
||||
shader_sub_table_struct(MAGNIFY_LINEAR, magnify_linear, magnify_linear),
|
||||
shader_sub_table_struct(MAGNIFY_DIFF, magnify_diff, magnify_diff),
|
||||
shader_sub_table_struct(MAGNIFY_DIFF2, magnify_diff2, magnify_diff2),
|
||||
shader_sub_table_struct(MAGNIFY_CONE, magnify_cone, magnify_cone),
|
||||
shader_sub_table_struct(MAGNIFY_CONE2, magnify_cone2, magnify_cone2),
|
||||
};
|
||||
|
||||
static const shader_sub_table MLAA_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_MLAA_EDGE,
|
||||
mlaa_edge_vpt_unival_max,
|
||||
mlaa_edge_fpt_unival_max,
|
||||
"mlaa_edge",
|
||||
"mlaa_edge",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_MLAA_AREA,
|
||||
mlaa_area_vpt_unival_max,
|
||||
mlaa_area_fpt_unival_max,
|
||||
"mlaa_area",
|
||||
"mlaa_area",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_MLAA_BLEND,
|
||||
mlaa_blend_vpt_unival_max,
|
||||
mlaa_blend_fpt_unival_max,
|
||||
"mlaa_blend",
|
||||
"mlaa_blend",
|
||||
},
|
||||
shader_sub_table_struct(MLAA_EDGE, mlaa_edge, mlaa_edge),
|
||||
shader_sub_table_struct(MLAA_AREA, mlaa_area, mlaa_area),
|
||||
shader_sub_table_struct(MLAA_BLEND, mlaa_blend, mlaa_blend),
|
||||
};
|
||||
|
||||
static const shader_sub_table CONTOUR_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_CONTOUR,
|
||||
contour_vpt_unival_max,
|
||||
contour_fpt_unival_max,
|
||||
"contour",
|
||||
"contour",
|
||||
},
|
||||
shader_sub_table_struct(CONTOUR, contour, contour),
|
||||
};
|
||||
|
||||
static const shader_sub_table CONTOUR_NPR_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_CONTOUR_NPR,
|
||||
contour_npr_vpt_unival_max,
|
||||
contour_npr_fpt_unival_max,
|
||||
"contour_npr",
|
||||
"contour_npr",
|
||||
},
|
||||
shader_sub_table_struct(CONTOUR_NPR, contour_npr, contour_npr),
|
||||
};
|
||||
|
||||
static const shader_sub_table EXPOSURE_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_EXPOSURE_MINIFY,
|
||||
exposure_minify_vpt_unival_max,
|
||||
exposure_minify_fpt_unival_max,
|
||||
"exposure_minify",
|
||||
"exposure_minify",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_EXPOSURE_MEASURE,
|
||||
exposure_measure_vpt_unival_max,
|
||||
exposure_measure_fpt_unival_max,
|
||||
"exposure_measure",
|
||||
"exposure_measure",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_EXPOSURE_AVERAGE,
|
||||
exposure_average_vpt_unival_max,
|
||||
exposure_average_fpt_unival_max,
|
||||
"exposure_average",
|
||||
"exposure_average",
|
||||
},
|
||||
shader_sub_table_struct(EXPOSURE_MINIFY, exposure_minify, exposure_minify),
|
||||
shader_sub_table_struct(EXPOSURE_MEASURE, exposure_measure, exposure_measure),
|
||||
shader_sub_table_struct(EXPOSURE_AVERAGE, exposure_average, exposure_average),
|
||||
};
|
||||
|
||||
static const shader_sub_table GAUSS_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_PP_GAUSS_USUAL,
|
||||
pp_gauss_usual_vpt_unival_max,
|
||||
pp_gauss_usual_fpt_unival_max,
|
||||
"pp_gauss_usual",
|
||||
"pp_gauss_usual",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_PP_GAUSS_CONE,
|
||||
pp_gauss_cone_vpt_unival_max,
|
||||
pp_gauss_cone_fpt_unival_max,
|
||||
"pp_gauss_cone",
|
||||
"pp_gauss_cone",
|
||||
},
|
||||
shader_sub_table_struct(PP_GAUSS_USUAL, pp_gauss_usual, pp_gauss_usual),
|
||||
shader_sub_table_struct(PP_GAUSS_CONE, pp_gauss_cone, pp_gauss_cone),
|
||||
};
|
||||
|
||||
static const shader_sub_table SUN_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_SUN,
|
||||
sun_vpt_unival_max,
|
||||
sun_fpt_unival_max,
|
||||
"sun",
|
||||
"sun",
|
||||
},
|
||||
shader_sub_table_struct(SUN, sun, sun),
|
||||
};
|
||||
|
||||
static const shader_sub_table SUN_NO_TEXTURED_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_SUN_NO_TEXTURED,
|
||||
sun_no_textured_vpt_unival_max,
|
||||
sun_no_textured_fpt_unival_max,
|
||||
"sun_no_textured",
|
||||
"sun_no_textured",
|
||||
},
|
||||
shader_sub_table_struct(SUN_NO_TEXTURED, sun_no_textured, sun_no_textured),
|
||||
};
|
||||
|
||||
static const shader_sub_table WATER01_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_WATER01,
|
||||
water01_vpt_unival_max,
|
||||
water01_fpt_unival_max,
|
||||
"water01",
|
||||
"water01",
|
||||
},
|
||||
shader_sub_table_struct(WATER01, water01, water01),
|
||||
};
|
||||
|
||||
static const shader_sub_table W_PTCL_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_WATER_PARTICLE,
|
||||
water_particle_vpt_unival_max,
|
||||
water_particle_fpt_unival_max,
|
||||
"water_particle",
|
||||
"water_particle",
|
||||
},
|
||||
shader_sub_table_struct(WATER_PARTICLE, water_particle, water_particle),
|
||||
};
|
||||
|
||||
static const shader_sub_table SNOW_PT_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_SNOW_PARTICLE,
|
||||
snow_particle_vpt_unival_max,
|
||||
snow_particle_fpt_unival_max,
|
||||
"snow_particle",
|
||||
"snow_particle",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_SNOW_PARTICLE_CPU,
|
||||
snow_particle_cpu_vpt_unival_max,
|
||||
snow_particle_cpu_fpt_unival_max,
|
||||
"snow_particle_cpu",
|
||||
"snow_particle_cpu",
|
||||
},
|
||||
shader_sub_table_struct(SNOW_PARTICLE, snow_particle, snow_particle),
|
||||
shader_sub_table_struct(SNOW_PARTICLE_CPU, snow_particle_cpu, snow_particle_cpu),
|
||||
};
|
||||
|
||||
static const shader_sub_table LEAF_PT_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_LEAF_PARTICLE,
|
||||
leaf_particle_vpt_unival_max,
|
||||
leaf_particle_fpt_unival_max,
|
||||
"leaf_particle",
|
||||
"leaf_particle",
|
||||
},
|
||||
shader_sub_table_struct(LEAF_PARTICLE, leaf_particle, leaf_particle),
|
||||
};
|
||||
|
||||
static const shader_sub_table STAR_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_STAR,
|
||||
star_vpt_unival_max,
|
||||
star_fpt_unival_max,
|
||||
"star",
|
||||
"star",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_STAR_MILKY_WAY,
|
||||
star_milky_way_vpt_unival_max,
|
||||
star_milky_way_fpt_unival_max,
|
||||
"star_milky_way",
|
||||
"star_milky_way",
|
||||
},
|
||||
shader_sub_table_struct(STAR, star, star),
|
||||
shader_sub_table_struct(STAR_MILKY_WAY, star_milky_way, star_milky_way),
|
||||
};
|
||||
|
||||
static const shader_sub_table FLOOR_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_FLOOR,
|
||||
floor_vpt_unival_max,
|
||||
floor_fpt_unival_max,
|
||||
"floor",
|
||||
"floor",
|
||||
},
|
||||
shader_sub_table_struct(FLOOR, floor, floor),
|
||||
};
|
||||
|
||||
static const shader_sub_table PUDDLE_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_PUDDLE,
|
||||
puddle_vpt_unival_max,
|
||||
puddle_fpt_unival_max,
|
||||
"puddle",
|
||||
"puddle",
|
||||
},
|
||||
shader_sub_table_struct(PUDDLE, puddle, puddle),
|
||||
};
|
||||
|
||||
static const shader_sub_table S_REFL_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_SIMPLE_REFLECT,
|
||||
simple_reflect_vpt_unival_max,
|
||||
simple_reflect_fpt_unival_max,
|
||||
"simple_reflect",
|
||||
"simple_reflect",
|
||||
},
|
||||
shader_sub_table_struct(SIMPLE_REFLECT, simple_reflect, simple_reflect),
|
||||
};
|
||||
|
||||
static const shader_sub_table S_REFR_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_SIMPLE_REFRACT,
|
||||
simple_refract_vpt_unival_max,
|
||||
simple_refract_fpt_unival_max,
|
||||
"simple_refract",
|
||||
"simple_refract",
|
||||
},
|
||||
shader_sub_table_struct(SIMPLE_REFRACT, simple_refract, simple_refract),
|
||||
};
|
||||
|
||||
static const shader_sub_table RIPEMIT_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_RIPPLE_EMIT,
|
||||
ripple_emit_vpt_unival_max,
|
||||
ripple_emit_fpt_unival_max,
|
||||
"ripple_emit",
|
||||
"ripple_emit",
|
||||
},
|
||||
shader_sub_table_struct(RIPPLE_EMIT, ripple_emit, ripple_emit),
|
||||
};
|
||||
|
||||
static const shader_sub_table RAIN_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_RAIN,
|
||||
rain_vpt_unival_max,
|
||||
rain_fpt_unival_max,
|
||||
"rain",
|
||||
"rain",
|
||||
},
|
||||
shader_sub_table_struct(RAIN, rain, rain),
|
||||
};
|
||||
|
||||
static const shader_sub_table RIPPLE_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_RIPPLE,
|
||||
ripple_vpt_unival_max,
|
||||
ripple_fpt_unival_max,
|
||||
"ripple",
|
||||
"ripple",
|
||||
},
|
||||
shader_sub_table_struct(RIPPLE, ripple, ripple),
|
||||
};
|
||||
|
||||
static const shader_sub_table FOGPTCL_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_FOG_PTCL,
|
||||
fog_ptcl_vpt_unival_max,
|
||||
fog_ptcl_fpt_unival_max,
|
||||
"fog_ptcl",
|
||||
"fog_ptcl",
|
||||
},
|
||||
shader_sub_table_struct(FOG_PTCL, fog_ptcl, fog_ptcl),
|
||||
};
|
||||
|
||||
static const shader_sub_table PARTICL_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_PARTICLE,
|
||||
particle_vpt_unival_max,
|
||||
particle_fpt_unival_max,
|
||||
"particle",
|
||||
"particle",
|
||||
},
|
||||
shader_sub_table_struct(PARTICLE, particle, particle),
|
||||
};
|
||||
|
||||
static const shader_sub_table GLITTER_PT_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_GLITTER_PARTICLE,
|
||||
glitter_particle_vpt_unival_max,
|
||||
glitter_particle_fpt_unival_max,
|
||||
"glitter_particle",
|
||||
"glitter_particle",
|
||||
},
|
||||
shader_sub_table_struct(GLITTER_PARTICLE, glitter_particle, glitter_particle),
|
||||
};
|
||||
|
||||
static const shader_sub_table FONT_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_FONT,
|
||||
font_vpt_unival_max,
|
||||
font_fpt_unival_max,
|
||||
"font",
|
||||
"font",
|
||||
},
|
||||
shader_sub_table_struct(FONT, font, font),
|
||||
};
|
||||
|
||||
static const shader_sub_table IMGFILT_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_BOX4,
|
||||
box4_vpt_unival_max,
|
||||
box4_fpt_unival_max,
|
||||
"box4",
|
||||
"box4",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_BOX8,
|
||||
box8_vpt_unival_max,
|
||||
box8_fpt_unival_max,
|
||||
"box8",
|
||||
"box8",
|
||||
},
|
||||
{
|
||||
SHADER_FT_SUB_COPY,
|
||||
copy_vpt_unival_max,
|
||||
copy_fpt_unival_max,
|
||||
"copy",
|
||||
"copy",
|
||||
},
|
||||
shader_sub_table_struct(BOX4, box4, box4),
|
||||
shader_sub_table_struct(BOX8, box8, box8),
|
||||
shader_sub_table_struct(COPY, copy, copy),
|
||||
};
|
||||
|
||||
static const shader_sub_table SPRITE_table[] = {
|
||||
{
|
||||
SHADER_FT_SUB_SPRITE,
|
||||
sprite_vpt_unival_max,
|
||||
sprite_fpt_unival_max,
|
||||
"sprite",
|
||||
"sprite",
|
||||
},
|
||||
shader_sub_table_struct(SPRITE, sprite, sprite),
|
||||
};
|
||||
|
||||
static const shader_sub_table DOF_table[] = {
|
||||
shader_sub_table_struct(DOF_RENDER_TILE, dof_common, dof_render_tile),
|
||||
shader_sub_table_struct(DOF_GATHER_TILE, dof_common, dof_gather_tile),
|
||||
shader_sub_table_struct(DOF_DOWNSAMPLE, dof_common, dof_downsample),
|
||||
shader_sub_table_struct(DOF_MAIN_FILTER, dof_common, dof_main_filter),
|
||||
shader_sub_table_struct(DOF_UPSAMPLE, dof_common, dof_upsample),
|
||||
};
|
||||
|
||||
static const shader_sub_table TRANSPARENCY_table[] = {
|
||||
shader_sub_table_struct(TRANSPARENCY, transparency, transparency),
|
||||
};
|
||||
|
||||
#undef shader_sub_table_struct
|
||||
|
||||
static const uniform_name BLINN_uniform[] = {
|
||||
U_SKINNING,
|
||||
U_MORPH,
|
||||
@@ -1530,6 +1154,14 @@ static const uniform_name SPRITE_uniform[] = {
|
||||
U_COMBINER,
|
||||
};
|
||||
|
||||
static const uniform_name DOF_uniform[] = {
|
||||
U_DOF,
|
||||
};
|
||||
|
||||
static const uniform_name TRANSPARENCY_uniform[] = {
|
||||
U_INVALID,
|
||||
};
|
||||
|
||||
struct glass_eye_struct {
|
||||
vec4 field_0;
|
||||
vec4 field_10;
|
||||
@@ -1624,6 +1256,8 @@ const shader_table shader_ft_table[] = {
|
||||
shader_table_struct(FONT),
|
||||
shader_table_struct(IMGFILT),
|
||||
shader_table_struct(SPRITE),
|
||||
shader_table_struct(DOF),
|
||||
shader_table_struct(TRANSPARENCY),
|
||||
};
|
||||
|
||||
#undef shader_table_struct
|
||||
@@ -1648,6 +1282,7 @@ static void shader_bind_gauss(shader_set_data* set, shader* shad);
|
||||
static void shader_bind_snow_particle(shader_set_data* set, shader* shad);
|
||||
static void shader_bind_star(shader_set_data* set, shader* shad);
|
||||
static void shader_bind_imgfilter(shader_set_data* set, shader* shad);
|
||||
static void shader_bind_dof(shader_set_data* set, shader* shad);
|
||||
|
||||
const shader_bind_func shader_ft_bind_func_table[] = {
|
||||
{
|
||||
@@ -1710,6 +1345,10 @@ const shader_bind_func shader_ft_bind_func_table[] = {
|
||||
SHADER_FT_IMGFILT,
|
||||
shader_bind_imgfilter,
|
||||
},
|
||||
{
|
||||
SHADER_FT_DOF,
|
||||
shader_bind_dof,
|
||||
},
|
||||
};
|
||||
|
||||
const size_t shader_ft_bind_func_table_size =
|
||||
@@ -2044,3 +1683,23 @@ static void shader_bind_imgfilter(shader_set_data* set, shader* shad) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void shader_bind_dof(shader_set_data* set, shader* shad) {
|
||||
switch (uniform->arr[U_DOF_STAGE]) {
|
||||
case 0:
|
||||
shad->bind(set, SHADER_FT_SUB_DOF_RENDER_TILE);
|
||||
break;
|
||||
case 1:
|
||||
shad->bind(set, SHADER_FT_SUB_DOF_GATHER_TILE);
|
||||
break;
|
||||
case 2:
|
||||
shad->bind(set, SHADER_FT_SUB_DOF_DOWNSAMPLE);
|
||||
break;
|
||||
case 3:
|
||||
shad->bind(set, SHADER_FT_SUB_DOF_MAIN_FILTER);
|
||||
break;
|
||||
case 4:
|
||||
shad->bind(set, SHADER_FT_SUB_DOF_UPSAMPLE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,8 @@ enum shader_ft_enum {
|
||||
SHADER_FT_FONT,
|
||||
SHADER_FT_IMGFILT,
|
||||
SHADER_FT_SPRITE,
|
||||
SHADER_FT_DOF,
|
||||
SHADER_FT_TRANSPARENCY,
|
||||
SHADER_FT_END,
|
||||
SHADER_FT_MAX,
|
||||
};
|
||||
|
||||
@@ -472,8 +472,7 @@ namespace spr {
|
||||
if (index == 2 && resolution_mode != RESOLUTION_MODE_MAX)
|
||||
res_window_get()->resolution_mode = resolution_mode;
|
||||
|
||||
GLint v43[4];
|
||||
glGetIntegervDLL(GL_VIEWPORT, v43);
|
||||
gl_state_rect viewport_rect = gl_state_get_viewport();
|
||||
|
||||
for (int32_t i = 0; i < 2; i++) {
|
||||
auto reqlist = this->reqlist[index][i];
|
||||
@@ -520,15 +519,15 @@ namespace spr {
|
||||
y_min = (int32_t)min.y;
|
||||
x_max = (int32_t)(max.x - min.x);
|
||||
y_max = (int32_t)(max.y - min.y);
|
||||
glViewportDLL(x_min, y_min, x_max, y_max);
|
||||
gl_state_set_viewport(x_min, y_min, x_max, y_max);
|
||||
}
|
||||
else {
|
||||
view_projection = view_projection_aet;
|
||||
|
||||
x_min = v43[0];
|
||||
y_min = v43[1];
|
||||
x_max = v43[2];
|
||||
y_max = v43[3];
|
||||
x_min = viewport_rect.x;
|
||||
y_min = viewport_rect.y;
|
||||
x_max = viewport_rect.width;
|
||||
y_max = viewport_rect.height;
|
||||
}
|
||||
|
||||
float_t v23 = (float_t)x_max * 0.5f;
|
||||
|
||||
@@ -80,6 +80,9 @@ enum uniform_name {
|
||||
U45 = 0x45,
|
||||
U_MAX = 0x46,
|
||||
U_INVALID = 0xFFFFFFFF,
|
||||
|
||||
U_DOF = U_TEX_0_TYPE,
|
||||
U_DOF_STAGE = U_TEX_1_TYPE,
|
||||
};
|
||||
|
||||
struct uniform_value {
|
||||
|
||||
Reference in New Issue
Block a user