mirror of
https://github.com/korenkonder/ReDIVA.git
synced 2026-10-08 22:50:08 +03:00
Fixed issues with transparent chara draw
This commit is contained in:
+16
-14
@@ -923,8 +923,10 @@ namespace rndr {
|
||||
|
||||
dof = new renderer::DOF3(render_post_width[0], render_post_height[0]);
|
||||
|
||||
transparency_tex[0] = texture_load_tex_2d(texture_id(0x25, texture_counter++),
|
||||
GL_RGBA16F, render_post_width[0], render_post_height[0], 0, 0, 0);
|
||||
for (int32_t i = 0; i < 1; i++)
|
||||
transparency_tex[i] = texture_load_tex_2d(texture_id(0x25, texture_counter++),
|
||||
GL_RGBA16F, render_post_width[0], render_post_height[0], 0, 0, 0);
|
||||
|
||||
transparency = new renderer::Transparency(transparency_tex[0]->tex,
|
||||
rend_texture[0].GetDepthTex(), render_post_width[0], render_post_height[0]);
|
||||
}
|
||||
@@ -1105,15 +1107,17 @@ namespace rndr {
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
|
||||
|
||||
for (int32_t i = 0; i < 3; i++) {
|
||||
texture_id id = taa_tex[i]->id;
|
||||
texture_free(taa_tex[i]);
|
||||
taa_tex[i] = texture_load_tex_2d(texture_id(0x25, texture_counter++),
|
||||
GL_RGBA8, render_post_width[0], render_post_height[0], 0, 0, 0);
|
||||
taa_tex[i] = texture_load_tex_2d(id, GL_RGBA8,
|
||||
render_post_width[0], render_post_height[0], 0, 0, 0);
|
||||
taa_buffer[i].SetColorDepthTextures(taa_tex[i]->tex, 0, rend_texture[0].GetDepthTex());
|
||||
}
|
||||
|
||||
texture_id aet_back_tex_id = aet_back_tex->id;
|
||||
texture_free(aet_back_tex);
|
||||
aet_back_tex = texture_load_tex_2d(texture_id(0x25, texture_counter++),
|
||||
GL_RGBA8, render_post_width[0], render_post_height[0], 0, 0, 0);
|
||||
aet_back_tex = texture_load_tex_2d(aet_back_tex_id, GL_RGBA8,
|
||||
render_post_width[0], render_post_height[0], 0, 0, 0);
|
||||
aet_back_texture.SetColorDepthTextures(aet_back_tex->tex, 0, rend_texture[0].GetDepthTex());
|
||||
|
||||
mlaa_buffer.Init(render_post_width[0], render_post_height[0], 0, GL_RGBA8, GL_DEPTH_COMPONENT24);
|
||||
@@ -1132,15 +1136,13 @@ namespace rndr {
|
||||
|
||||
dof->resize(render_post_width[0], render_post_height[0]);
|
||||
|
||||
for (int32_t i = 0; i < 1; i++)
|
||||
if (transparency_tex[i]) {
|
||||
texture_free(transparency_tex[i]);
|
||||
transparency_tex[i] = 0;
|
||||
texture_counter--;
|
||||
}
|
||||
for (int32_t i = 0; i < 1; i++) {
|
||||
texture_id id = transparency_tex[i]->id;
|
||||
texture_free(transparency_tex[i]);
|
||||
transparency_tex[i] = texture_load_tex_2d(id, GL_RGBA16F,
|
||||
render_post_width[0], render_post_height[0], 0, 0, 0);
|
||||
}
|
||||
|
||||
transparency_tex[0] = texture_load_tex_2d(texture_id(0x25, texture_counter++),
|
||||
GL_RGBA16F, render_post_width[0], render_post_height[0], 0, 0, 0);
|
||||
transparency->resize(transparency_tex[0]->tex, rend_texture[0].GetDepthTex(),
|
||||
render_post_width[0], render_post_height[0]);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace renderer {
|
||||
textures[count] = depth_texture;
|
||||
|
||||
glGenFramebuffers(1, &buffer);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, buffer);
|
||||
gl_state_bind_framebuffer(buffer, true);
|
||||
for (int32_t i = 0; i < count; i++)
|
||||
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, textures[i], 0);
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace renderer {
|
||||
color_attachments[i] = GL_COLOR_ATTACHMENT0 + i;
|
||||
glDrawBuffers(count, color_attachments);
|
||||
glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
gl_state_bind_framebuffer(0);
|
||||
}
|
||||
#pragma warning(pop)
|
||||
|
||||
|
||||
+36
-49
@@ -25,7 +25,7 @@ static texture* texture_load_tex(texture_id id, GLenum target,
|
||||
int32_t max_mipmap_level, void** data_ptr, bool use_high_anisotropy);
|
||||
static GLenum texture_txp_get_gl_internal_format(txp* t);
|
||||
|
||||
std::vector<texture*> texture_storage;
|
||||
std::map<texture_id, texture> texture_storage;
|
||||
|
||||
texture::texture() : init_count(), flags(), width(), height(),
|
||||
tex(), target(), internal_format(), max_mipmap_level(), size() {
|
||||
@@ -366,72 +366,59 @@ bool texture_txp_set_load(txp_set* t, texture*** texs, texture_id* ids) {
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void texture_storage_init() {
|
||||
void texture_storage_init() {
|
||||
texture_storage = {};
|
||||
}
|
||||
|
||||
inline texture* texture_storage_create_texture(texture_id id) {
|
||||
for (texture*& i : texture_storage)
|
||||
if (i && i->id == id) {
|
||||
i->init_count++;
|
||||
return i;
|
||||
}
|
||||
texture* texture_storage_create_texture(texture_id id) {
|
||||
auto elem = texture_storage.find(id);
|
||||
if (elem != texture_storage.end()) {
|
||||
elem->second.init_count++;
|
||||
return &elem->second;
|
||||
}
|
||||
|
||||
texture* tex = new texture();
|
||||
tex->init_count = 1;
|
||||
tex->id = id;
|
||||
texture_storage.push_back(tex);
|
||||
return tex;
|
||||
texture tex;
|
||||
tex.init_count = 1;
|
||||
tex.id = id;
|
||||
return &texture_storage.insert({ id, tex }).first->second;
|
||||
}
|
||||
|
||||
inline texture* texture_storage_get_texture(uint32_t id) {
|
||||
for (texture*& i : texture_storage)
|
||||
if (i && i->id.index == id)
|
||||
return i;
|
||||
texture* texture_storage_get_texture(uint32_t id) {
|
||||
auto elem = texture_storage.find(texture_id(0x00, id));
|
||||
if (elem != texture_storage.end())
|
||||
return &elem->second;
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline texture* texture_storage_get_texture(texture_id id) {
|
||||
for (texture*& i : texture_storage)
|
||||
if (i && i->id == id)
|
||||
return i;
|
||||
texture* texture_storage_get_texture(texture_id id) {
|
||||
auto elem = texture_storage.find(id);
|
||||
if (elem != texture_storage.end())
|
||||
return &elem->second;
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline size_t texture_storage_get_texture_count() {
|
||||
size_t texture_storage_get_texture_count() {
|
||||
return texture_storage.size();
|
||||
}
|
||||
|
||||
inline texture* texture_storage_get_texture_by_index(size_t index) {
|
||||
if (index >= 0 && index < texture_storage.size())
|
||||
return texture_storage[index];
|
||||
return 0;
|
||||
}
|
||||
void texture_storage_delete_texture(texture_id id) {
|
||||
auto elem = texture_storage.find(id);
|
||||
if (elem == texture_storage.end())
|
||||
return;
|
||||
|
||||
inline void texture_storage_delete_texture(texture_id id) {
|
||||
for (std::vector<texture*>::iterator i = texture_storage.begin(); i != texture_storage.end(); i++)
|
||||
if (*i && (*i)->id == id) {
|
||||
texture* tex = *i;
|
||||
if (tex->init_count > 1) {
|
||||
tex->init_count--;
|
||||
break;
|
||||
}
|
||||
|
||||
glDeleteTextures(1, &tex->tex);
|
||||
delete tex;
|
||||
i = texture_storage.erase(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
inline void texture_storage_free() {
|
||||
for (texture*& i : texture_storage) {
|
||||
if (i)
|
||||
glDeleteTextures(1, &i->tex);
|
||||
delete i;
|
||||
texture* tex = &elem->second;
|
||||
if (tex->init_count > 1) {
|
||||
tex->init_count--;
|
||||
return;
|
||||
}
|
||||
|
||||
texture_storage.erase(elem);
|
||||
}
|
||||
|
||||
void texture_storage_free() {
|
||||
for (auto& i : texture_storage)
|
||||
glDeleteTextures(1, &i.second.tex);
|
||||
texture_storage.clear();
|
||||
texture_storage.shrink_to_fit();
|
||||
}
|
||||
|
||||
inline static void texture_bind(GLenum target, GLuint texture) {
|
||||
|
||||
+6
-7
@@ -31,27 +31,27 @@ struct texture_id {
|
||||
};
|
||||
|
||||
inline bool operator >(const texture_id& left, const texture_id& right) {
|
||||
return left.id > right.id && left.index > right.index;
|
||||
return (((uint64_t)left.id << 32) | left.index) > (((uint64_t)right.id << 32) | right.index);
|
||||
}
|
||||
|
||||
inline bool operator <(const texture_id& left, const texture_id& right) {
|
||||
return left.id < right.id && left.index < right.index;
|
||||
return (((uint64_t)left.id << 32) | left.index) < (((uint64_t)right.id << 32) | right.index);
|
||||
}
|
||||
|
||||
inline bool operator >=(const texture_id& left, const texture_id& right) {
|
||||
return left.id >= right.id && left.index >= right.index;
|
||||
return (((uint64_t)left.id << 32) | left.index) >= (((uint64_t)right.id << 32) | right.index);
|
||||
}
|
||||
|
||||
inline bool operator <=(const texture_id& left, const texture_id& right) {
|
||||
return left.id <= right.id && left.index <= right.index;
|
||||
return (((uint64_t)left.id << 32) | left.index) <= (((uint64_t)right.id << 32) | right.index);
|
||||
}
|
||||
|
||||
inline bool operator ==(const texture_id& left, const texture_id& right) {
|
||||
return left.id == right.id && left.index == right.index;
|
||||
return (((uint64_t)left.id << 32) | left.index) == (((uint64_t)right.id << 32) | right.index);
|
||||
}
|
||||
|
||||
inline bool operator !=(const texture_id& left, const texture_id& right) {
|
||||
return left.id != right.id || left.index != right.index;
|
||||
return (((uint64_t)left.id << 32) | left.index) != (((uint64_t)right.id << 32) | right.index);
|
||||
}
|
||||
|
||||
struct texture {
|
||||
@@ -106,6 +106,5 @@ extern texture* texture_storage_create_texture(texture_id id);
|
||||
extern texture* texture_storage_get_texture(uint32_t id);
|
||||
extern texture* texture_storage_get_texture(texture_id id);
|
||||
extern size_t texture_storage_get_texture_count();
|
||||
extern texture* texture_storage_get_texture_by_index(size_t index);
|
||||
extern void texture_storage_delete_texture(texture_id id);
|
||||
extern void texture_storage_free();
|
||||
|
||||
@@ -47,9 +47,9 @@ void data_view_texture_imgui(class_data* data) {
|
||||
return;
|
||||
}
|
||||
|
||||
size_t count = texture_storage_get_texture_count();
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
texture* tex = texture_storage_get_texture_by_index(i);
|
||||
extern std::map<texture_id, texture> texture_storage;
|
||||
for (auto& i : texture_storage) {
|
||||
texture* tex = &i.second;
|
||||
if (tex->id.id)
|
||||
continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user