Finally fixed incorrect alpha on Glitter (and other stuff here too)

This commit is contained in:
korenkonder
2023-12-27 14:57:38 +03:00
parent 02638f6e80
commit b41dd4cafa
4 changed files with 120 additions and 31 deletions
+2 -3
View File
@@ -72,7 +72,7 @@ namespace Glitter {
gl_state_bind_array_buffer(0);
gl_state_bind_vertex_array(0);
if (is_quad)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
gl_state_bind_element_array_buffer(0);
}
void DeleteBuffer(GLuint& vao, GLArrayBuffer& vbo, GLElementArrayBuffer& ebo) {
@@ -101,8 +101,7 @@ namespace Glitter {
uint8_t buf[0x100];
// Particle
inject_uint32_t((void*)0x000000014039A396,
0x1B0 + sizeof(GLuint) * 2 + sizeof(DrawListData*));
inject_uint32_t((void*)0x000000014039A396, sizeof(Particle));
memcpy(buf, _000000014039BC78_patch_data, 0x11);
*(uint64_t*)&buf[0x05] = (uint64_t)Particle::CreateBuffer;
+108 -9
View File
@@ -7,6 +7,7 @@
#include "../../KKdLib/mat.hpp"
#include "../../KKdLib/vec.hpp"
#include "../color.hpp"
#include "../gl.hpp"
#include "../gl_array_buffer.hpp"
#include "../gl_element_array_buffer.hpp"
@@ -30,8 +31,8 @@ namespace Glitter {
};
enum DispType {
DISP_NORMAL = 0,
DISP_OPAQUE = 1,
DISP_OPAQUE = 0,
DISP_NORMAL = 1,
DISP_ALPHA = 2,
};
@@ -71,6 +72,12 @@ namespace Glitter {
PARTICLE_MANAGER_RESET_SCENE_COUNTER = 0x04,
PARTICLE_MANAGER_READ_FILES = 0x08,
};
enum ParticleSubFlag {
PARTICLE_SUB_NONE = 0x00000000,
PARTICLE_SUB_UV_2ND_ADD = 0x00400000,
PARTICLE_SUB_USE_CURVE = 0x40000000,
};
enum ParticleType {
PARTICLE_QUAD = 0,
@@ -97,6 +104,17 @@ namespace Glitter {
SCENE_FLAG_3 = 0x04,
};
enum UVIndexType {
UV_INDEX_FIXED = 0,
UV_INDEX_INITIAL_RANDOM_FIXED = 1,
UV_INDEX_RANDOM = 2,
UV_INDEX_FORWARD = 3,
UV_INDEX_REVERSE = 4,
UV_INDEX_INITIAL_RANDOM_FORWARD = 5,
UV_INDEX_INITIAL_RANDOM_REVERSE = 6,
UV_INDEX_USER = 7,
};
struct Animation;
struct Buffer;
struct Camera;
@@ -104,9 +122,9 @@ namespace Glitter {
struct Effect;
struct Emitter;
struct EmitterInst;
struct ItemBase;
class ItemBase;
struct Node;
struct Particle;
class Particle;
struct ParticleInst;
struct Random;
struct RenderElement;
@@ -120,11 +138,22 @@ namespace Glitter {
#define GPM Glitter::GltParticleManager* glt_particle_manager
#define GPM_VAL (glt_particle_manager)
struct Animation {
prj::vector<Curve*> curves;
};
struct Buffer {
vec3 position;
vec2 uv[2];
vec4 color;
};
class ItemBase {
public:
void* __vftable;
prj::string name;
Animation animation;\
};
struct LocusHistory {
struct Data {
@@ -142,9 +171,80 @@ namespace Glitter {
Sub sub;
};
struct Particle {
static void CreateBuffer(size_t data);
static void DeleteBuffer(size_t data);
typedef prj::vector<prj::pair<GLint, GLsizei>> DrawListData;
class Particle : ItemBase {
public:
struct Data {
ParticleFlag flags;
float_t life_time;
ParticleType type;
Pivot pivot;
Direction draw_type;
float_t z_offset;
vec3 rotation;
vec3 rotation_random;
vec3 rotation_add;
vec3 rotation_add_random;
vec3 position_offset;
vec3 position_offset_random;
vec3 base_direction;
vec3 direction_random;
float_t speed;
float_t speed_random;
float_t deceleration;
float_t deceleration_random;
vec3 gravitational_acceleration;
vec3 external_acceleration;
vec3 external_acceleration_random;
float_t reflection_coeff;
float_t reflection_coeff_random;
float_t dwordB4;
color4u8_bgra color_int;
vec4 color;
UVIndexType uv_index_type;
int32_t uv_index;
float_t frame_step_uv;
int32_t uv_index_start;
int32_t uv_index_end;
int32_t uv_index_count;
vec2 uv_scroll_add;
float_t uv_scroll_add_scale;
vec2 split_uv;
uint8_t split_u;
uint8_t split_v;
ParticleBlend blend_mode;
ParticleBlend mask_blend_mode;
int32_t dword104;
ParticleSubFlag sub_flags;
int32_t count;
int32_t locus_history_size;
int32_t locus_history_size_random;
int32_t dword118;
float_t emission;
uint64_t tex_hash;
uint64_t mask_tex_hash;
int32_t texture;
int32_t mask_texture;
char dword138[32];
};
struct Sub {
Glitter::Particle::Data data;
Glitter::Buffer* buffer;
GLArrayBuffer vbo;
int32_t max_count;
bool field_168;
int32_t dword16C;
GLuint vao;
GLElementArrayBuffer ebo;
DrawListData* draw_list;
};
Glitter::Particle::Sub sub;
static void CreateBuffer(Particle* ptcl);
static void DeleteBuffer(Particle* ptcl);
};
struct RenderElement {
@@ -188,8 +288,6 @@ namespace Glitter {
bool buffer_init;
};
typedef prj::vector<prj::pair<GLint, GLsizei>> DrawListData;
struct RenderGroup {
void* __vftable;
ParticleFlag flags;
@@ -224,6 +322,7 @@ namespace Glitter {
GLArrayBuffer vbo;
float_t emission;
bool use_own_buffer;
int32_t dword12C;
GLuint vao;
GLElementArrayBuffer ebo;
size_t disp;
+9 -18
View File
@@ -6,28 +6,19 @@
#include "glitter.hpp"
namespace Glitter {
void Particle::CreateBuffer(size_t data) {
ParticleType type = (ParticleType) * (int32_t*)(data + 0x40 + 0x00 + 0x08);
GLArrayBuffer& vbo = *(GLArrayBuffer*)(data + 0x40 + 0x160);
int32_t max_count = *(int32_t*)(data + 0x40 + 0x164);
GLuint& vao = *(GLuint*)(data + 0x40 + 0x170);
GLElementArrayBuffer& ebo = *(GLElementArrayBuffer*)(data + 0x40 + 0x174);
Glitter::CreateBuffer(max_count, type == PARTICLE_QUAD, vao, vbo, ebo);
void Particle::CreateBuffer(Particle* ptcl) {
Glitter::CreateBuffer(ptcl->sub.max_count,
ptcl->sub.data.type == PARTICLE_QUAD, ptcl->sub.vao, ptcl->sub.vbo, ptcl->sub.ebo);
DrawListData*& draw_list = *(DrawListData**)(data + 0x40 + 0x178);
draw_list = new DrawListData;
ptcl->sub.draw_list = new DrawListData;
}
void Particle::DeleteBuffer(size_t data) {
DrawListData*& draw_list = *(DrawListData**)(data + 0x40 + 0x178);
if (draw_list) {
delete draw_list;
draw_list = 0;
void Particle::DeleteBuffer(Particle* ptcl) {
if (ptcl->sub.draw_list) {
delete ptcl->sub.draw_list;
ptcl->sub.draw_list = 0;
}
GLArrayBuffer& vbo = *(GLArrayBuffer*)(data + 0x40 + 0x160);
GLuint& vao = *(GLuint*)(data + 0x40 + 0x170);
GLElementArrayBuffer& ebo = *(GLElementArrayBuffer*)(data + 0x40 + 0x174);
Glitter::DeleteBuffer(vao, vbo, ebo);
Glitter::DeleteBuffer(ptcl->sub.vao, ptcl->sub.vbo, ptcl->sub.ebo);
}
}
+1 -1
View File
@@ -66,7 +66,7 @@ namespace Glitter {
continue;
RenderGroup* rend_group = i;
if (RenderGroup_CannotDisp(rend_group) && rend_group->disp_type != disp_type)
if (RenderGroup_CannotDisp(rend_group) || rend_group->disp_type != disp_type)
continue;
Disp(rend_group);