gl_rend_state massive overhaul. Created render_data_context
This commit is contained in:
@@ -294,7 +294,7 @@ namespace prj {
|
||||
this->begin = str;
|
||||
this->end = str + utf16_length(str);
|
||||
}
|
||||
|
||||
|
||||
inline wstring_range(const wchar_t* str, size_t length) {
|
||||
this->begin = str;
|
||||
this->end = str + length;
|
||||
|
||||
@@ -4,7 +4,3 @@
|
||||
*/
|
||||
|
||||
#include "uniform.hpp"
|
||||
|
||||
uniform_value* uniform = (uniform_value*)0x000000014CC57AF0;
|
||||
|
||||
void(FASTCALL* uniform_value_reset)() = (void(FASTCALL*)())0x0000000140443400;
|
||||
|
||||
@@ -88,7 +88,3 @@ enum uniform_name {
|
||||
struct uniform_value {
|
||||
int32_t arr[U_MAX];
|
||||
};
|
||||
|
||||
extern uniform_value* uniform;
|
||||
|
||||
extern void(FASTCALL* uniform_value_reset)();
|
||||
|
||||
@@ -148,6 +148,7 @@
|
||||
<ClCompile Include="Glitter\render_scene.cpp" />
|
||||
<ClCompile Include="Glitter\scene.cpp" />
|
||||
<ClCompile Include="data_test\rob_osage_test.cpp" />
|
||||
<ClCompile Include="gl_state.cpp" />
|
||||
<ClCompile Include="graphics\color_change_dw.cpp" />
|
||||
<ClCompile Include="mdl\disp_manager.cpp" />
|
||||
<ClCompile Include="mdl\draw_object.cpp" />
|
||||
@@ -196,6 +197,7 @@
|
||||
<ClInclude Include="GL\uniform_buffer.hpp" />
|
||||
<ClInclude Include="Glitter\glitter.hpp" />
|
||||
<ClInclude Include="data_test\rob_osage_test.hpp" />
|
||||
<ClInclude Include="gl_state.hpp" />
|
||||
<ClInclude Include="graphics\color_change_dw.hpp" />
|
||||
<ClInclude Include="mdl\disp_manager.hpp" />
|
||||
<ClInclude Include="mdl\draw_object.hpp" />
|
||||
|
||||
@@ -5,13 +5,10 @@
|
||||
|
||||
#include "array_buffer.hpp"
|
||||
#include "../gl_rend_state.hpp"
|
||||
#include "../gl_state.hpp"
|
||||
|
||||
namespace GL {
|
||||
void ArrayBuffer::Bind(bool force) {
|
||||
gl_rend_state.bind_array_buffer(buffer, force);
|
||||
}
|
||||
|
||||
void ArrayBuffer::Create(size_t size) {
|
||||
void ArrayBuffer::Create(gl_state_struct& gl_st, size_t size) {
|
||||
if (buffer)
|
||||
return;
|
||||
|
||||
@@ -21,7 +18,7 @@ namespace GL {
|
||||
}
|
||||
else {
|
||||
glGenBuffers(1, &buffer);
|
||||
gl_rend_state.bind_array_buffer(buffer, true);
|
||||
gl_st.bind_array_buffer(buffer);
|
||||
if (DIVA_GL_VERSION_4_4)
|
||||
glBufferStorage(GL_ARRAY_BUFFER, (GLsizeiptr)size,
|
||||
0, GL_DYNAMIC_STORAGE_BIT | GL_MAP_WRITE_BIT);
|
||||
@@ -30,7 +27,7 @@ namespace GL {
|
||||
}
|
||||
}
|
||||
|
||||
void ArrayBuffer::Create(size_t size, const void* data, bool dynamic) {
|
||||
void ArrayBuffer::Create(gl_state_struct& gl_st, size_t size, const void* data, bool dynamic) {
|
||||
if (buffer)
|
||||
return;
|
||||
|
||||
@@ -41,7 +38,7 @@ namespace GL {
|
||||
}
|
||||
else {
|
||||
glGenBuffers(1, &buffer);
|
||||
gl_rend_state.bind_array_buffer(buffer, true);
|
||||
gl_st.bind_array_buffer(buffer);
|
||||
if (DIVA_GL_VERSION_4_4)
|
||||
glBufferStorage(GL_ARRAY_BUFFER, (GLsizeiptr)size, data,
|
||||
dynamic ? GL_DYNAMIC_STORAGE_BIT | GL_MAP_WRITE_BIT : 0);
|
||||
@@ -58,7 +55,7 @@ namespace GL {
|
||||
}
|
||||
}
|
||||
|
||||
void* ArrayBuffer::MapMemory() {
|
||||
void* ArrayBuffer::MapMemory(gl_state_struct& gl_st) {
|
||||
if (!buffer)
|
||||
return 0;
|
||||
|
||||
@@ -66,7 +63,7 @@ namespace GL {
|
||||
if (DIVA_GL_VERSION_4_5)
|
||||
data = glMapNamedBuffer(buffer, GL_WRITE_ONLY);
|
||||
else {
|
||||
gl_rend_state.bind_array_buffer(buffer);
|
||||
gl_st.bind_array_buffer(buffer);
|
||||
data = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
|
||||
}
|
||||
|
||||
@@ -77,12 +74,36 @@ namespace GL {
|
||||
glUnmapNamedBuffer(buffer);
|
||||
else {
|
||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||
gl_rend_state.bind_array_buffer(0);
|
||||
gl_st.bind_array_buffer(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ArrayBuffer::UnmapMemory() {
|
||||
void* ArrayBuffer::MapMemory(p_gl_rend_state& p_gl_rend_st) {
|
||||
if (!buffer)
|
||||
return 0;
|
||||
|
||||
void* data;
|
||||
if (DIVA_GL_VERSION_4_5)
|
||||
data = glMapNamedBuffer(buffer, GL_WRITE_ONLY);
|
||||
else {
|
||||
p_gl_rend_st.bind_array_buffer(buffer);
|
||||
data = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
|
||||
}
|
||||
|
||||
if (data)
|
||||
return data;
|
||||
|
||||
if (DIVA_GL_VERSION_4_5)
|
||||
glUnmapNamedBuffer(buffer);
|
||||
else {
|
||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||
p_gl_rend_st.bind_array_buffer(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ArrayBuffer::UnmapMemory(gl_state_struct& gl_st) {
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
@@ -90,18 +111,42 @@ namespace GL {
|
||||
glUnmapNamedBuffer(buffer);
|
||||
else {
|
||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||
gl_rend_state.bind_array_buffer(0);
|
||||
gl_st.bind_array_buffer(0);
|
||||
}
|
||||
}
|
||||
|
||||
void ArrayBuffer::WriteMemory(size_t offset, size_t size, const void* data) {
|
||||
void ArrayBuffer::UnmapMemory(p_gl_rend_state& p_gl_rend_st) {
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
if (DIVA_GL_VERSION_4_5)
|
||||
glUnmapNamedBuffer(buffer);
|
||||
else {
|
||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||
p_gl_rend_st.bind_array_buffer(0);
|
||||
}
|
||||
}
|
||||
|
||||
void ArrayBuffer::WriteMemory(gl_state_struct& gl_st, size_t offset, size_t size, const void* data) {
|
||||
if (!buffer || !size)
|
||||
return;
|
||||
|
||||
if (DIVA_GL_VERSION_4_5)
|
||||
glNamedBufferSubData(buffer, (GLsizeiptr)offset, (GLsizeiptr)size, data);
|
||||
else {
|
||||
gl_rend_state.bind_array_buffer(buffer);
|
||||
gl_st.bind_array_buffer(buffer);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, (GLsizeiptr)offset, (GLsizeiptr)size, data);
|
||||
}
|
||||
}
|
||||
|
||||
void ArrayBuffer::WriteMemory(p_gl_rend_state& p_gl_rend_st, size_t offset, size_t size, const void* data) {
|
||||
if (!buffer || !size)
|
||||
return;
|
||||
|
||||
if (DIVA_GL_VERSION_4_5)
|
||||
glNamedBufferSubData(buffer, (GLsizeiptr)offset, (GLsizeiptr)size, data);
|
||||
else {
|
||||
p_gl_rend_st.bind_array_buffer(buffer);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, (GLsizeiptr)offset, (GLsizeiptr)size, data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
#include "../../KKdLib/default.hpp"
|
||||
#include "../wrap.hpp"
|
||||
|
||||
struct gl_state_struct;
|
||||
struct p_gl_rend_state;
|
||||
|
||||
namespace GL {
|
||||
struct ArrayBuffer {
|
||||
private:
|
||||
@@ -26,13 +29,15 @@ namespace GL {
|
||||
|
||||
}
|
||||
|
||||
void Bind(bool force = false);
|
||||
void Create(size_t size);
|
||||
void Create(size_t size, const void* data, bool dynamic = false);
|
||||
void Create(gl_state_struct& gl_st, size_t size);
|
||||
void Create(gl_state_struct& gl_st, size_t size, const void* data, bool dynamic = false);
|
||||
void Destroy();
|
||||
void* MapMemory();
|
||||
void UnmapMemory();
|
||||
void WriteMemory(size_t offset, size_t size, const void* data);
|
||||
void* MapMemory(gl_state_struct& gl_st);
|
||||
void* MapMemory(p_gl_rend_state& p_gl_rend_st);
|
||||
void UnmapMemory(gl_state_struct& gl_st);
|
||||
void UnmapMemory(p_gl_rend_state& p_gl_rend_st);
|
||||
void WriteMemory(gl_state_struct& gl_st, size_t offset, size_t size, const void* data);
|
||||
void WriteMemory(p_gl_rend_state& p_gl_rend_st, size_t offset, size_t size, const void* data);
|
||||
|
||||
inline bool IsNull() {
|
||||
return !buffer;
|
||||
@@ -43,8 +48,13 @@ namespace GL {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void WriteMemory(T& data) {
|
||||
WriteMemory(0, sizeof(T), &data);
|
||||
inline void WriteMemory(gl_state_struct& gl_st, T& data) {
|
||||
WriteMemory(gl_st, 0, sizeof(T), &data);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void WriteMemory(p_gl_rend_state& p_gl_rend_st, T& data) {
|
||||
WriteMemory(p_gl_rend_st, 0, sizeof(T), &data);
|
||||
}
|
||||
|
||||
inline operator GLuint() const {
|
||||
|
||||
@@ -5,13 +5,10 @@
|
||||
|
||||
#include "element_array_buffer.hpp"
|
||||
#include "../gl_rend_state.hpp"
|
||||
#include "../gl_state.hpp"
|
||||
|
||||
namespace GL {
|
||||
void ElementArrayBuffer::Bind(bool force) {
|
||||
gl_rend_state.bind_element_array_buffer(buffer, force);
|
||||
}
|
||||
|
||||
void ElementArrayBuffer::Create(size_t size) {
|
||||
void ElementArrayBuffer::Create(gl_state_struct& gl_st, size_t size) {
|
||||
if (buffer)
|
||||
return;
|
||||
|
||||
@@ -21,7 +18,7 @@ namespace GL {
|
||||
}
|
||||
else {
|
||||
glGenBuffers(1, &buffer);
|
||||
gl_rend_state.bind_element_array_buffer(buffer, true);
|
||||
gl_st.bind_element_array_buffer(buffer, true);
|
||||
if (DIVA_GL_VERSION_4_4)
|
||||
glBufferStorage(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)size,
|
||||
0, GL_DYNAMIC_STORAGE_BIT | GL_MAP_WRITE_BIT);
|
||||
@@ -30,7 +27,7 @@ namespace GL {
|
||||
}
|
||||
}
|
||||
|
||||
void ElementArrayBuffer::Create(size_t size, const void* data, bool dynamic) {
|
||||
void ElementArrayBuffer::Create(gl_state_struct& gl_st, size_t size, const void* data, bool dynamic) {
|
||||
if (buffer)
|
||||
return;
|
||||
|
||||
@@ -41,7 +38,7 @@ namespace GL {
|
||||
}
|
||||
else {
|
||||
glGenBuffers(1, &buffer);
|
||||
gl_rend_state.bind_element_array_buffer(buffer, true);
|
||||
gl_st.bind_element_array_buffer(buffer, true);
|
||||
if (DIVA_GL_VERSION_4_4)
|
||||
glBufferStorage(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)size, data,
|
||||
dynamic ? GL_DYNAMIC_STORAGE_BIT | GL_MAP_WRITE_BIT : 0);
|
||||
@@ -58,7 +55,7 @@ namespace GL {
|
||||
}
|
||||
}
|
||||
|
||||
void* ElementArrayBuffer::MapMemory() {
|
||||
void* ElementArrayBuffer::MapMemory(gl_state_struct& gl_st) {
|
||||
if (!buffer)
|
||||
return 0;
|
||||
|
||||
@@ -66,7 +63,7 @@ namespace GL {
|
||||
if (DIVA_GL_VERSION_4_5)
|
||||
data = glMapNamedBuffer(buffer, GL_WRITE_ONLY);
|
||||
else {
|
||||
gl_rend_state.bind_element_array_buffer(buffer);
|
||||
gl_st.bind_element_array_buffer(buffer);
|
||||
data = glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY);
|
||||
}
|
||||
|
||||
@@ -77,12 +74,36 @@ namespace GL {
|
||||
glUnmapNamedBuffer(buffer);
|
||||
else {
|
||||
glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER);
|
||||
gl_rend_state.bind_element_array_buffer(0);
|
||||
gl_st.bind_element_array_buffer(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ElementArrayBuffer::UnmapMemory() {
|
||||
void* ElementArrayBuffer::MapMemory(p_gl_rend_state& p_gl_rend_st) {
|
||||
if (!buffer)
|
||||
return 0;
|
||||
|
||||
void* data;
|
||||
if (DIVA_GL_VERSION_4_5)
|
||||
data = glMapNamedBuffer(buffer, GL_WRITE_ONLY);
|
||||
else {
|
||||
p_gl_rend_st.bind_element_array_buffer(buffer);
|
||||
data = glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY);
|
||||
}
|
||||
|
||||
if (data)
|
||||
return data;
|
||||
|
||||
if (DIVA_GL_VERSION_4_5)
|
||||
glUnmapNamedBuffer(buffer);
|
||||
else {
|
||||
glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER);
|
||||
p_gl_rend_st.bind_element_array_buffer(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ElementArrayBuffer::UnmapMemory(gl_state_struct& gl_st) {
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
@@ -90,18 +111,42 @@ namespace GL {
|
||||
glUnmapNamedBuffer(buffer);
|
||||
else {
|
||||
glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER);
|
||||
gl_rend_state.bind_element_array_buffer(0);
|
||||
gl_st.bind_element_array_buffer(0);
|
||||
}
|
||||
}
|
||||
|
||||
void ElementArrayBuffer::WriteMemory(size_t offset, size_t size, const void* data) {
|
||||
void ElementArrayBuffer::UnmapMemory(p_gl_rend_state& p_gl_rend_st) {
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
if (DIVA_GL_VERSION_4_5)
|
||||
glUnmapNamedBuffer(buffer);
|
||||
else {
|
||||
glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER);
|
||||
p_gl_rend_st.bind_element_array_buffer(0);
|
||||
}
|
||||
}
|
||||
|
||||
void ElementArrayBuffer::WriteMemory(gl_state_struct& gl_st, size_t offset, size_t size, const void* data) {
|
||||
if (!buffer || !size)
|
||||
return;
|
||||
|
||||
if (DIVA_GL_VERSION_4_5)
|
||||
glNamedBufferSubData(buffer, (GLsizeiptr)offset, (GLsizeiptr)size, data);
|
||||
else {
|
||||
gl_rend_state.bind_element_array_buffer(buffer);
|
||||
gl_st.bind_element_array_buffer(buffer);
|
||||
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)offset, (GLsizeiptr)size, data);
|
||||
}
|
||||
}
|
||||
|
||||
void ElementArrayBuffer::WriteMemory(p_gl_rend_state& p_gl_rend_st, size_t offset, size_t size, const void* data) {
|
||||
if (!buffer || !size)
|
||||
return;
|
||||
|
||||
if (DIVA_GL_VERSION_4_5)
|
||||
glNamedBufferSubData(buffer, (GLsizeiptr)offset, (GLsizeiptr)size, data);
|
||||
else {
|
||||
p_gl_rend_st.bind_element_array_buffer(buffer);
|
||||
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)offset, (GLsizeiptr)size, data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
#include "../../KKdLib/default.hpp"
|
||||
#include "../wrap.hpp"
|
||||
|
||||
struct gl_state_struct;
|
||||
struct p_gl_rend_state;
|
||||
|
||||
namespace GL {
|
||||
struct ElementArrayBuffer {
|
||||
private:
|
||||
@@ -26,13 +29,15 @@ namespace GL {
|
||||
|
||||
}
|
||||
|
||||
void Bind(bool force = false);
|
||||
void Create(size_t size);
|
||||
void Create(size_t size, const void* data, bool dynamic = false);
|
||||
void Create(gl_state_struct& gl_st, size_t size);
|
||||
void Create(gl_state_struct& gl_st, size_t size, const void* data, bool dynamic = false);
|
||||
void Destroy();
|
||||
void* MapMemory();
|
||||
void UnmapMemory();
|
||||
void WriteMemory(size_t offset, size_t size, const void* data);
|
||||
void* MapMemory(gl_state_struct& gl_st);
|
||||
void* MapMemory(p_gl_rend_state& p_gl_rend_st);
|
||||
void UnmapMemory(gl_state_struct& gl_st);
|
||||
void UnmapMemory(p_gl_rend_state& p_gl_rend_st);
|
||||
void WriteMemory(gl_state_struct& gl_st, size_t offset, size_t size, const void* data);
|
||||
void WriteMemory(p_gl_rend_state& p_gl_rend_st, size_t offset, size_t size, const void* data);
|
||||
|
||||
inline bool IsNull() {
|
||||
return !buffer;
|
||||
@@ -43,8 +48,13 @@ namespace GL {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void WriteMemory(T& data) {
|
||||
WriteMemory(0, sizeof(T), &data);
|
||||
inline void WriteMemory(gl_state_struct& gl_st, T& data) {
|
||||
WriteMemory(gl_st, 0, sizeof(T), &data);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void WriteMemory(p_gl_rend_state& p_gl_rend_st, T& data) {
|
||||
WriteMemory(p_gl_rend_st, 0, sizeof(T), &data);
|
||||
}
|
||||
|
||||
inline operator GLuint() const {
|
||||
|
||||
@@ -5,14 +5,11 @@
|
||||
|
||||
#include "shader_storage_buffer.hpp"
|
||||
#include "../gl_rend_state.hpp"
|
||||
#include "../gl_state.hpp"
|
||||
|
||||
namespace GL {
|
||||
void ShaderStorageBuffer::Bind(int32_t index, bool force) {
|
||||
gl_rend_state.bind_shader_storage_buffer_base(index, buffer, force);
|
||||
}
|
||||
|
||||
void ShaderStorageBuffer::Create(size_t size) {
|
||||
if (!DIVA_GL_VERSION_4_3 || buffer)
|
||||
void ShaderStorageBuffer::Create(gl_state_struct& gl_st, size_t size) {
|
||||
if (buffer)
|
||||
return;
|
||||
|
||||
if (DIVA_GL_VERSION_4_5) {
|
||||
@@ -21,7 +18,7 @@ namespace GL {
|
||||
}
|
||||
else {
|
||||
glGenBuffers(1, &buffer);
|
||||
gl_rend_state.bind_shader_storage_buffer(buffer, true);
|
||||
gl_st.bind_shader_storage_buffer(buffer, true);
|
||||
if (DIVA_GL_VERSION_4_4)
|
||||
glBufferStorage(GL_SHADER_STORAGE_BUFFER, (GLsizeiptr)size,
|
||||
0, GL_DYNAMIC_STORAGE_BIT | GL_MAP_WRITE_BIT);
|
||||
@@ -30,8 +27,8 @@ namespace GL {
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderStorageBuffer::Create(size_t size, const void* data, bool dynamic) {
|
||||
if (!DIVA_GL_VERSION_4_3 || buffer)
|
||||
void ShaderStorageBuffer::Create(gl_state_struct& gl_st, size_t size, const void* data, bool dynamic) {
|
||||
if (buffer)
|
||||
return;
|
||||
|
||||
if (DIVA_GL_VERSION_4_5) {
|
||||
@@ -41,7 +38,7 @@ namespace GL {
|
||||
}
|
||||
else {
|
||||
glGenBuffers(1, &buffer);
|
||||
gl_rend_state.bind_shader_storage_buffer(buffer, true);
|
||||
gl_st.bind_shader_storage_buffer(buffer, true);
|
||||
if (DIVA_GL_VERSION_4_4)
|
||||
glBufferStorage(GL_SHADER_STORAGE_BUFFER, (GLsizeiptr)size, data,
|
||||
dynamic ? GL_DYNAMIC_STORAGE_BIT | GL_MAP_WRITE_BIT : 0);
|
||||
@@ -58,15 +55,15 @@ namespace GL {
|
||||
}
|
||||
}
|
||||
|
||||
void* ShaderStorageBuffer::MapMemory() {
|
||||
if (!DIVA_GL_VERSION_4_3 || !buffer)
|
||||
void* ShaderStorageBuffer::MapMemory(gl_state_struct& gl_st) {
|
||||
if (!buffer)
|
||||
return 0;
|
||||
|
||||
void* data;
|
||||
if (DIVA_GL_VERSION_4_5)
|
||||
data = glMapNamedBuffer(buffer, GL_WRITE_ONLY);
|
||||
else {
|
||||
gl_rend_state.bind_shader_storage_buffer(buffer);
|
||||
gl_st.bind_shader_storage_buffer(buffer);
|
||||
data = glMapBuffer(GL_SHADER_STORAGE_BUFFER, GL_WRITE_ONLY);
|
||||
}
|
||||
|
||||
@@ -77,31 +74,79 @@ namespace GL {
|
||||
glUnmapNamedBuffer(buffer);
|
||||
else {
|
||||
glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);
|
||||
gl_rend_state.bind_shader_storage_buffer(0);
|
||||
gl_st.bind_shader_storage_buffer(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ShaderStorageBuffer::UnmapMemory() {
|
||||
if (!DIVA_GL_VERSION_4_3 || !buffer)
|
||||
void* ShaderStorageBuffer::MapMemory(p_gl_rend_state& p_gl_rend_st) {
|
||||
if (!buffer)
|
||||
return 0;
|
||||
|
||||
void* data;
|
||||
if (DIVA_GL_VERSION_4_5)
|
||||
data = glMapNamedBuffer(buffer, GL_WRITE_ONLY);
|
||||
else {
|
||||
p_gl_rend_st.bind_shader_storage_buffer(buffer);
|
||||
data = glMapBuffer(GL_SHADER_STORAGE_BUFFER, GL_WRITE_ONLY);
|
||||
}
|
||||
|
||||
if (data)
|
||||
return data;
|
||||
|
||||
if (DIVA_GL_VERSION_4_5)
|
||||
glUnmapNamedBuffer(buffer);
|
||||
else {
|
||||
glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);
|
||||
p_gl_rend_st.bind_shader_storage_buffer(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ShaderStorageBuffer::UnmapMemory(gl_state_struct& gl_st) {
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
if (DIVA_GL_VERSION_4_5)
|
||||
glUnmapNamedBuffer(buffer);
|
||||
else {
|
||||
glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);
|
||||
gl_rend_state.bind_shader_storage_buffer(0);
|
||||
gl_st.bind_shader_storage_buffer(0);
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderStorageBuffer::WriteMemory(size_t offset, size_t size, const void* data) {
|
||||
if (!DIVA_GL_VERSION_4_3 || !buffer || !size)
|
||||
void ShaderStorageBuffer::UnmapMemory(p_gl_rend_state& p_gl_rend_st) {
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
if (DIVA_GL_VERSION_4_5)
|
||||
glUnmapNamedBuffer(buffer);
|
||||
else {
|
||||
glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);
|
||||
p_gl_rend_st.bind_shader_storage_buffer(0);
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderStorageBuffer::WriteMemory(gl_state_struct& gl_st, size_t offset, size_t size, const void* data) {
|
||||
if (!buffer || !size)
|
||||
return;
|
||||
|
||||
if (DIVA_GL_VERSION_4_5)
|
||||
glNamedBufferSubData(buffer, (GLsizeiptr)offset, (GLsizeiptr)size, data);
|
||||
else {
|
||||
gl_rend_state.bind_shader_storage_buffer(buffer);
|
||||
gl_st.bind_shader_storage_buffer(buffer);
|
||||
glBufferSubData(GL_SHADER_STORAGE_BUFFER, (GLsizeiptr)offset, (GLsizeiptr)size, data);
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderStorageBuffer::WriteMemory(p_gl_rend_state& p_gl_rend_st, size_t offset, size_t size, const void* data) {
|
||||
if (!buffer || !size)
|
||||
return;
|
||||
|
||||
if (DIVA_GL_VERSION_4_5)
|
||||
glNamedBufferSubData(buffer, (GLsizeiptr)offset, (GLsizeiptr)size, data);
|
||||
else {
|
||||
p_gl_rend_st.bind_shader_storage_buffer(buffer);
|
||||
glBufferSubData(GL_SHADER_STORAGE_BUFFER, (GLsizeiptr)offset, (GLsizeiptr)size, data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
#include "../../KKdLib/default.hpp"
|
||||
#include "../wrap.hpp"
|
||||
|
||||
struct gl_state_struct;
|
||||
struct p_gl_rend_state;
|
||||
|
||||
namespace GL {
|
||||
struct ShaderStorageBuffer {
|
||||
private:
|
||||
@@ -26,13 +29,15 @@ namespace GL {
|
||||
|
||||
}
|
||||
|
||||
void Bind(int32_t index, bool force = false);
|
||||
void Create(size_t size);
|
||||
void Create(size_t size, const void* data, bool dynamic = false);
|
||||
void Create(gl_state_struct& gl_st, size_t size);
|
||||
void Create(gl_state_struct& gl_st, size_t size, const void* data, bool dynamic = false);
|
||||
void Destroy();
|
||||
void* MapMemory();
|
||||
void UnmapMemory();
|
||||
void WriteMemory(size_t offset, size_t size, const void* data);
|
||||
void* MapMemory(gl_state_struct& gl_st);
|
||||
void* MapMemory(p_gl_rend_state& p_gl_rend_st);
|
||||
void UnmapMemory(gl_state_struct& gl_st);
|
||||
void UnmapMemory(p_gl_rend_state& p_gl_rend_st);
|
||||
void WriteMemory(gl_state_struct& gl_st, size_t offset, size_t size, const void* data);
|
||||
void WriteMemory(p_gl_rend_state& p_gl_rend_st, size_t offset, size_t size, const void* data);
|
||||
|
||||
inline bool IsNull() {
|
||||
return !buffer;
|
||||
@@ -43,8 +48,13 @@ namespace GL {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void WriteMemory(T& data) {
|
||||
WriteMemory(0, sizeof(T), &data);
|
||||
inline void WriteMemory(gl_state_struct& gl_st, T& data) {
|
||||
WriteMemory(gl_st, 0, sizeof(T), &data);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void WriteMemory(p_gl_rend_state& p_gl_rend_st, T& data) {
|
||||
WriteMemory(p_gl_rend_st, 0, sizeof(T), &data);
|
||||
}
|
||||
|
||||
inline operator GLuint() const {
|
||||
|
||||
@@ -5,13 +5,10 @@
|
||||
|
||||
#include "uniform_buffer.hpp"
|
||||
#include "../gl_rend_state.hpp"
|
||||
#include "../gl_state.hpp"
|
||||
|
||||
namespace GL {
|
||||
void UniformBuffer::Bind(int32_t index, bool force) {
|
||||
gl_rend_state.bind_uniform_buffer_base(index, buffer, force);
|
||||
}
|
||||
|
||||
void UniformBuffer::Create(size_t size) {
|
||||
void UniformBuffer::Create(gl_state_struct& gl_st, size_t size) {
|
||||
if (buffer)
|
||||
return;
|
||||
|
||||
@@ -21,7 +18,7 @@ namespace GL {
|
||||
}
|
||||
else {
|
||||
glGenBuffers(1, &buffer);
|
||||
gl_rend_state.bind_uniform_buffer(buffer, true);
|
||||
gl_st.bind_uniform_buffer(buffer, true);
|
||||
if (DIVA_GL_VERSION_4_4)
|
||||
glBufferStorage(GL_UNIFORM_BUFFER, (GLsizeiptr)size,
|
||||
0, GL_DYNAMIC_STORAGE_BIT | GL_MAP_WRITE_BIT);
|
||||
@@ -30,7 +27,7 @@ namespace GL {
|
||||
}
|
||||
}
|
||||
|
||||
void UniformBuffer::Create(size_t size, const void* data, bool dynamic) {
|
||||
void UniformBuffer::Create(gl_state_struct& gl_st, size_t size, const void* data, bool dynamic) {
|
||||
if (buffer)
|
||||
return;
|
||||
|
||||
@@ -41,7 +38,7 @@ namespace GL {
|
||||
}
|
||||
else {
|
||||
glGenBuffers(1, &buffer);
|
||||
gl_rend_state.bind_uniform_buffer(buffer, true);
|
||||
gl_st.bind_uniform_buffer(buffer, true);
|
||||
if (DIVA_GL_VERSION_4_4)
|
||||
glBufferStorage(GL_UNIFORM_BUFFER, (GLsizeiptr)size, data,
|
||||
dynamic ? GL_DYNAMIC_STORAGE_BIT | GL_MAP_WRITE_BIT : 0);
|
||||
@@ -58,7 +55,7 @@ namespace GL {
|
||||
}
|
||||
}
|
||||
|
||||
void* UniformBuffer::MapMemory() {
|
||||
void* UniformBuffer::MapMemory(gl_state_struct& gl_st) {
|
||||
if (!buffer)
|
||||
return 0;
|
||||
|
||||
@@ -66,7 +63,7 @@ namespace GL {
|
||||
if (DIVA_GL_VERSION_4_5)
|
||||
data = glMapNamedBuffer(buffer, GL_WRITE_ONLY);
|
||||
else {
|
||||
gl_rend_state.bind_uniform_buffer(buffer);
|
||||
gl_st.bind_uniform_buffer(buffer);
|
||||
data = glMapBuffer(GL_UNIFORM_BUFFER, GL_WRITE_ONLY);
|
||||
}
|
||||
|
||||
@@ -77,12 +74,36 @@ namespace GL {
|
||||
glUnmapNamedBuffer(buffer);
|
||||
else {
|
||||
glUnmapBuffer(GL_UNIFORM_BUFFER);
|
||||
gl_rend_state.bind_uniform_buffer(0);
|
||||
gl_st.bind_uniform_buffer(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void UniformBuffer::UnmapMemory() {
|
||||
void* UniformBuffer::MapMemory(p_gl_rend_state& p_gl_rend_st) {
|
||||
if (!buffer)
|
||||
return 0;
|
||||
|
||||
void* data;
|
||||
if (DIVA_GL_VERSION_4_5)
|
||||
data = glMapNamedBuffer(buffer, GL_WRITE_ONLY);
|
||||
else {
|
||||
p_gl_rend_st.bind_uniform_buffer(buffer);
|
||||
data = glMapBuffer(GL_UNIFORM_BUFFER, GL_WRITE_ONLY);
|
||||
}
|
||||
|
||||
if (data)
|
||||
return data;
|
||||
|
||||
if (DIVA_GL_VERSION_4_5)
|
||||
glUnmapNamedBuffer(buffer);
|
||||
else {
|
||||
glUnmapBuffer(GL_UNIFORM_BUFFER);
|
||||
p_gl_rend_st.bind_uniform_buffer(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void UniformBuffer::UnmapMemory(gl_state_struct& gl_st) {
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
@@ -90,18 +111,42 @@ namespace GL {
|
||||
glUnmapNamedBuffer(buffer);
|
||||
else {
|
||||
glUnmapBuffer(GL_UNIFORM_BUFFER);
|
||||
gl_rend_state.bind_uniform_buffer(0);
|
||||
gl_st.bind_uniform_buffer(0);
|
||||
}
|
||||
}
|
||||
|
||||
void UniformBuffer::WriteMemory(size_t offset, size_t size, const void* data) {
|
||||
void UniformBuffer::UnmapMemory(p_gl_rend_state& p_gl_rend_st) {
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
if (DIVA_GL_VERSION_4_5)
|
||||
glUnmapNamedBuffer(buffer);
|
||||
else {
|
||||
glUnmapBuffer(GL_UNIFORM_BUFFER);
|
||||
p_gl_rend_st.bind_uniform_buffer(0);
|
||||
}
|
||||
}
|
||||
|
||||
void UniformBuffer::WriteMemory(gl_state_struct& gl_st, size_t offset, size_t size, const void* data) {
|
||||
if (!buffer || !size)
|
||||
return;
|
||||
|
||||
if (DIVA_GL_VERSION_4_5)
|
||||
glNamedBufferSubData(buffer, (GLsizeiptr)offset, (GLsizeiptr)size, data);
|
||||
else {
|
||||
gl_rend_state.bind_uniform_buffer(buffer);
|
||||
gl_st.bind_uniform_buffer(buffer);
|
||||
glBufferSubData(GL_UNIFORM_BUFFER, (GLsizeiptr)offset, (GLsizeiptr)size, data);
|
||||
}
|
||||
}
|
||||
|
||||
void UniformBuffer::WriteMemory(p_gl_rend_state& p_gl_rend_st, size_t offset, size_t size, const void* data) {
|
||||
if (!buffer || !size)
|
||||
return;
|
||||
|
||||
if (DIVA_GL_VERSION_4_5)
|
||||
glNamedBufferSubData(buffer, (GLsizeiptr)offset, (GLsizeiptr)size, data);
|
||||
else {
|
||||
p_gl_rend_st.bind_uniform_buffer(buffer);
|
||||
glBufferSubData(GL_UNIFORM_BUFFER, (GLsizeiptr)offset, (GLsizeiptr)size, data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
#include "../../KKdLib/default.hpp"
|
||||
#include "../wrap.hpp"
|
||||
|
||||
struct gl_state_struct;
|
||||
struct p_gl_rend_state;
|
||||
|
||||
namespace GL {
|
||||
struct UniformBuffer {
|
||||
private:
|
||||
@@ -26,13 +29,15 @@ namespace GL {
|
||||
|
||||
}
|
||||
|
||||
void Bind(int32_t index, bool force = false);
|
||||
void Create(size_t size);
|
||||
void Create(size_t size, const void* data, bool dynamic = false);
|
||||
void Create(gl_state_struct& gl_st, size_t size);
|
||||
void Create(gl_state_struct& gl_st, size_t size, const void* data, bool dynamic = false);
|
||||
void Destroy();
|
||||
void* MapMemory();
|
||||
void UnmapMemory();
|
||||
void WriteMemory(size_t offset, size_t size, const void* data);
|
||||
void* MapMemory(gl_state_struct& gl_st);
|
||||
void* MapMemory(p_gl_rend_state& p_gl_rend_st);
|
||||
void UnmapMemory(gl_state_struct& gl_st);
|
||||
void UnmapMemory(p_gl_rend_state& p_gl_rend_st);
|
||||
void WriteMemory(gl_state_struct& gl_st, size_t offset, size_t size, const void* data);
|
||||
void WriteMemory(p_gl_rend_state& p_gl_rend_st, size_t offset, size_t size, const void* data);
|
||||
|
||||
inline bool IsNull() {
|
||||
return !buffer;
|
||||
@@ -43,8 +48,13 @@ namespace GL {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void WriteMemory(T& data) {
|
||||
WriteMemory(0, sizeof(T), &data);
|
||||
inline void WriteMemory(gl_state_struct& gl_st, T& data) {
|
||||
WriteMemory(gl_st, 0, sizeof(T), &data);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void WriteMemory(p_gl_rend_state& p_gl_rend_st, T& data) {
|
||||
WriteMemory(p_gl_rend_st, 0, sizeof(T), &data);
|
||||
}
|
||||
|
||||
inline operator GLuint() const {
|
||||
|
||||
@@ -277,8 +277,8 @@ namespace Glitter {
|
||||
i->CtrlInit(this, delta_frame);
|
||||
}
|
||||
|
||||
void EffectInstX::Disp(DispType disp_type) {
|
||||
render_scene.Disp(disp_type);
|
||||
void EffectInstX::Disp(render_data_context& rend_data_ctx, DispType disp_type, const cam_data& cam) {
|
||||
render_scene.Disp(rend_data_ctx, disp_type, cam);
|
||||
}
|
||||
|
||||
void EffectInstX::DispMesh() {
|
||||
@@ -501,7 +501,7 @@ namespace Glitter {
|
||||
void EffectInstX::GetExtAnim() {
|
||||
if (!ext_anim)
|
||||
return;
|
||||
|
||||
|
||||
if (!(flags & EFFECT_INST_EXT_ANIM) && !(flags & EFFECT_INST_EXT_ANIM_MAT)
|
||||
|| (flags & EFFECT_INST_EXT_ANIM_END)
|
||||
|| (flags & EFFECT_INST_EXT_ANIM_SET_ONCE) && (flags & EFFECT_INST_EXT_ANIM_TRANS))
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "../../KKdLib/farc.hpp"
|
||||
#include "../rob/rob.hpp"
|
||||
#if SHARED_GLITTER_BUFFER
|
||||
#include "../gl_rend_state.hpp"
|
||||
#include "../gl_state.hpp"
|
||||
#endif
|
||||
|
||||
namespace Glitter {
|
||||
@@ -110,7 +110,7 @@ namespace Glitter {
|
||||
|
||||
static const GLsizei buffer_size = sizeof(Buffer);
|
||||
|
||||
effect_group->vbo.Create(buffer_size * max_count);
|
||||
effect_group->vbo.Create(gl_state, buffer_size * max_count);
|
||||
|
||||
if (max_count_quad) {
|
||||
size_t count = max_count_quad / 4 * 5;
|
||||
@@ -123,7 +123,7 @@ namespace Glitter {
|
||||
ebo_data[i + 4] = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
effect_group->ebo.Create(sizeof(uint32_t) * count, ebo_data);
|
||||
effect_group->ebo.Create(gl_state, sizeof(uint32_t) * count, ebo_data);
|
||||
free_def(ebo_data);
|
||||
}
|
||||
else
|
||||
@@ -151,10 +151,10 @@ namespace Glitter {
|
||||
k->buffer = buffer;
|
||||
|
||||
glGenVertexArrays(1, &k->vao);
|
||||
gl_rend_state.bind_vertex_array(k->vao, true);
|
||||
gl_rend_state.bind_array_buffer(vbo, true);
|
||||
gl_state.bind_vertex_array(k->vao, true);
|
||||
gl_state.bind_array_buffer(vbo, true);
|
||||
if (k->data.type == PARTICLE_QUAD)
|
||||
gl_rend_state.bind_element_array_buffer(ebo, true);
|
||||
gl_state.bind_element_array_buffer(ebo, true);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, buffer_size,
|
||||
@@ -174,9 +174,11 @@ namespace Glitter {
|
||||
}
|
||||
}
|
||||
|
||||
gl_rend_state.bind_array_buffer(0);
|
||||
gl_rend_state.bind_vertex_array(0);
|
||||
gl_rend_state.bind_element_array_buffer(0);
|
||||
if (offset) {
|
||||
gl_state.bind_array_buffer(0);
|
||||
gl_state.bind_vertex_array(0);
|
||||
gl_state.bind_element_array_buffer(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
free_def(effect_group->buffer);
|
||||
@@ -888,7 +890,7 @@ namespace Glitter {
|
||||
emit->data.rotation_add_random = *(vec3*)(d + 48);
|
||||
d += 60;
|
||||
|
||||
|
||||
|
||||
switch (emit->data.type) {
|
||||
case EMITTER_BOX:
|
||||
emit->data.box.size = *(vec3*)d;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
#include "glitter.hpp"
|
||||
#include "../gl_rend_state.hpp"
|
||||
#include "../gl_state.hpp"
|
||||
#include "../wrap.hpp"
|
||||
#include <Helpers.h>
|
||||
|
||||
@@ -21,12 +21,12 @@ namespace Glitter {
|
||||
buffer = (Buffer*)_operator_new(sizeof(Buffer) * max_count);
|
||||
|
||||
glGenVertexArrays(1, &vao);
|
||||
gl_rend_state.bind_vertex_array(vao, true);
|
||||
gl_state.bind_vertex_array(vao, true);
|
||||
|
||||
static const GLsizei buffer_size = sizeof(Buffer);
|
||||
|
||||
vbo.Create(buffer_size * max_count);
|
||||
vbo.Bind(true);
|
||||
vbo.Create(gl_state, buffer_size * max_count);
|
||||
gl_state.bind_array_buffer(vbo, true);
|
||||
|
||||
if (is_quad) {
|
||||
size_t count = max_count / 4 * 5;
|
||||
@@ -39,8 +39,8 @@ namespace Glitter {
|
||||
ebo_data[i + 4] = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
ebo.Create(sizeof(uint32_t) * count, ebo_data);
|
||||
ebo.Bind(true);
|
||||
ebo.Create(gl_state, sizeof(uint32_t) * count, ebo_data);
|
||||
gl_state.bind_array_buffer(ebo, true);
|
||||
_operator_delete(ebo_data);
|
||||
}
|
||||
|
||||
@@ -54,10 +54,10 @@ namespace Glitter {
|
||||
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, buffer_size,
|
||||
(void*)offsetof(Buffer, color));
|
||||
|
||||
gl_rend_state.bind_array_buffer(0);
|
||||
gl_rend_state.bind_vertex_array(0);
|
||||
gl_state.bind_array_buffer(0);
|
||||
gl_state.bind_vertex_array(0);
|
||||
if (is_quad)
|
||||
gl_rend_state.bind_element_array_buffer(0);
|
||||
gl_state.bind_element_array_buffer(0);
|
||||
}
|
||||
|
||||
void DeleteBuffer(Buffer*& buffer, GLuint& vao, GL::ArrayBuffer& vbo, GL::ElementArrayBuffer& ebo) {
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
|
||||
#define SHARED_GLITTER_BUFFER (1)
|
||||
|
||||
struct cam_data;
|
||||
struct render_data_context;
|
||||
|
||||
namespace Glitter {
|
||||
enum CurveFlag {
|
||||
CURVE_RANDOM_RANGE = 0x01,
|
||||
@@ -32,7 +35,7 @@ namespace Glitter {
|
||||
CURVE_BAKED = 0x40,
|
||||
CURVE_BAKED_FULL = 0x80,
|
||||
};
|
||||
|
||||
|
||||
enum CurveType {
|
||||
CURVE_TRANSLATION_X = 0,
|
||||
CURVE_TRANSLATION_Y = 1,
|
||||
@@ -259,7 +262,7 @@ namespace Glitter {
|
||||
PARTICLE_LOCAL = 0x10000,
|
||||
PARTICLE_EMISSION = 0x20000,
|
||||
};
|
||||
|
||||
|
||||
enum ParticleInstFlag {
|
||||
PARTICLE_INST_NONE = 0x00,
|
||||
PARTICLE_INST_ENDED = 0x01,
|
||||
@@ -273,7 +276,7 @@ namespace Glitter {
|
||||
PARTICLE_MANAGER_READ_FILES = 0x08,
|
||||
PARTICLE_MANAGER_LOCAL = 0x20,
|
||||
};
|
||||
|
||||
|
||||
enum ParticleSubFlag {
|
||||
PARTICLE_SUB_NONE = 0x00000000,
|
||||
PARTICLE_SUB_UV_2ND_ADD = 0x00400000,
|
||||
@@ -298,7 +301,7 @@ namespace Glitter {
|
||||
PIVOT_BOTTOM_CENTER = 7,
|
||||
PIVOT_BOTTOM_RIGHT = 8,
|
||||
};
|
||||
|
||||
|
||||
enum SceneFlag {
|
||||
SCENE_NONE = 0x00,
|
||||
SCENE_FLAG_1 = 0x01,
|
||||
@@ -455,7 +458,7 @@ namespace Glitter {
|
||||
prj::string name;
|
||||
Animation animation;
|
||||
};
|
||||
|
||||
|
||||
class ItemBaseX {
|
||||
public:
|
||||
AnimationX animation;
|
||||
@@ -494,7 +497,7 @@ namespace Glitter {
|
||||
|
||||
NodeX& operator=(const NodeX& node);
|
||||
};
|
||||
|
||||
|
||||
class EffectX : public NodeX {
|
||||
public:
|
||||
struct ExtAnim {
|
||||
@@ -537,7 +540,7 @@ namespace Glitter {
|
||||
|
||||
EffectX& operator=(const EffectX& eff);
|
||||
};
|
||||
|
||||
|
||||
struct EffectGroup {
|
||||
void* __vftable;
|
||||
prj::vector<Effect*> effects;
|
||||
@@ -610,8 +613,8 @@ namespace Glitter {
|
||||
|
||||
void CalcDisp();
|
||||
void CalcDisp(RenderGroup* rend_group);
|
||||
void Disp(Glitter::DispType disp_type);
|
||||
void Disp(RenderGroup* rend_group);
|
||||
void Disp(render_data_context& rend_data_ctx, DispType disp_type, const cam_data& cam);
|
||||
void Disp(render_data_context& rend_data_ctx, RenderGroup* rend_group, const cam_data& cam);
|
||||
|
||||
static void CalcDispLine(RenderGroup* rend_group);
|
||||
static void CalcDispLocus(RenderGroup* rend_group);
|
||||
@@ -652,8 +655,8 @@ namespace Glitter {
|
||||
bool CanDisp(DispType disp_type, bool a3);
|
||||
void CheckUseCamera();
|
||||
void Ctrl(float_t delta_frame, bool copy_mats);
|
||||
void Disp(DispType disp_type);
|
||||
void Disp(RenderGroupX* rend_group);
|
||||
void Disp(render_data_context& rend_data_ctx, DispType disp_type, const cam_data& cam);
|
||||
void Disp(render_data_context& rend_data_ctx, RenderGroupX* rend_group, const cam_data& cam);
|
||||
void DispMesh();
|
||||
void DispMesh(RenderGroupX* rend_group);
|
||||
size_t GetCtrlCount(ParticleType type);
|
||||
@@ -664,7 +667,7 @@ namespace Glitter {
|
||||
static void CalcDispQuadSetPivot(Pivot pivot,
|
||||
float_t w, float_t h, float_t& v00, float_t& v01, float_t& v10, float_t& v11);
|
||||
};
|
||||
|
||||
|
||||
struct EffectInstX {
|
||||
bool init;
|
||||
EffectX* effect;
|
||||
@@ -729,7 +732,7 @@ namespace Glitter {
|
||||
void CtrlFlags(float_t delta_frame);
|
||||
void CtrlInit(float_t delta_frame);
|
||||
void CtrlMat();
|
||||
void Disp(DispType disp_type);
|
||||
void Disp(render_data_context& rend_data_ctx, DispType disp_type, const cam_data& cam);
|
||||
void DispMesh();
|
||||
void Emit(float_t delta_frame, float_t emission);
|
||||
void EmitInit(float_t delta_frame, float_t emission);
|
||||
@@ -910,7 +913,7 @@ namespace Glitter {
|
||||
bool UnpackParticle(void* data, ParticleX* ptcl,
|
||||
uint32_t ptcl_version, EffectX* eff, EffectGroupX* eff_group);
|
||||
};
|
||||
|
||||
|
||||
struct LocusHistory {
|
||||
struct Data {
|
||||
vec3 translation;
|
||||
@@ -943,9 +946,9 @@ namespace Glitter {
|
||||
|
||||
void Append(RenderElementX* rend_elem, ParticleInstX* ptcl_inst);
|
||||
};
|
||||
|
||||
|
||||
typedef prj::vector<prj::pair<GLint, GLsizei>> DrawListData;
|
||||
|
||||
|
||||
class Particle : ItemBase {
|
||||
public:
|
||||
struct Data {
|
||||
@@ -1266,7 +1269,7 @@ namespace Glitter {
|
||||
static mat4 RotateToPrevPosition(RenderGroupX* rend_group,
|
||||
RenderElementX* rend_elem, vec3* vec);
|
||||
};
|
||||
|
||||
|
||||
struct RenderElement {
|
||||
bool alive;
|
||||
uint8_t uv_counter;
|
||||
@@ -1353,7 +1356,7 @@ namespace Glitter {
|
||||
|
||||
operator uint32_t() const { return (counter << 8) || index; }
|
||||
};
|
||||
|
||||
|
||||
struct Scene {
|
||||
void* __vftable;
|
||||
prj::vector<SceneEffect*> effects;
|
||||
@@ -1365,7 +1368,7 @@ namespace Glitter {
|
||||
RenderScene render_scene;
|
||||
|
||||
void CalcDisp();
|
||||
void Disp(DispType disp_type);
|
||||
void Disp(render_data_context& rend_data_ctx, DispType disp_type, const cam_data& cam);
|
||||
};
|
||||
|
||||
struct SceneEffectX {
|
||||
@@ -1392,7 +1395,7 @@ namespace Glitter {
|
||||
void CheckUpdate(float_t delta_frame);
|
||||
bool Copy(EffectInstX* eff_inst, SceneX* dst);
|
||||
void Ctrl(float_t delta_frame);
|
||||
void Disp(DispType disp_type);
|
||||
void Disp(render_data_context& rend_data_ctx, DispType disp_type, const cam_data& cam);
|
||||
void DispMesh();
|
||||
size_t GetCtrlCount(ParticleType ptcl_type);
|
||||
size_t GetDispCount(ParticleType ptcl_type);
|
||||
@@ -1433,7 +1436,7 @@ namespace Glitter {
|
||||
uint32_t texture_counter;
|
||||
|
||||
void CalcDisp();
|
||||
void DispScenes(DispType disp_type);
|
||||
void DispScenes(render_data_context& rend_data_ctx, DispType disp_type, const cam_data& cam);
|
||||
};
|
||||
|
||||
class GltParticleManagerX : app::Task {
|
||||
@@ -1469,7 +1472,7 @@ namespace Glitter {
|
||||
void CheckSceneHasLocalEffect(SceneX* sc);
|
||||
void CtrlScenes();
|
||||
void DecrementInitBuffersByCount(int32_t count = 1);
|
||||
void DispScenes(DispType disp_type);
|
||||
void DispScenes(render_data_context& rend_data_ctx, DispType disp_type, const cam_data& cam);
|
||||
void FreeEffects();
|
||||
void FreeSceneEffect(SceneCounter scene_counter, bool force_kill = true);
|
||||
void FreeSceneEffect(uint32_t effect_group_hash, uint32_t effect_hash, bool force_kill = true);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
#include "glitter.hpp"
|
||||
#include "../gl_rend_state.hpp"
|
||||
#include "../render_context.hpp"
|
||||
#include <Helpers.h>
|
||||
|
||||
namespace Glitter {
|
||||
@@ -20,18 +20,18 @@ namespace Glitter {
|
||||
i->CalcDisp();
|
||||
}
|
||||
|
||||
void GltParticleManager::DispScenes(DispType disp_type) {
|
||||
void GltParticleManager::DispScenes(render_data_context& rend_data_ctx, DispType disp_type, const cam_data& cam) {
|
||||
if (flags & PARTICLE_MANAGER_NOT_DISP)
|
||||
return;
|
||||
|
||||
for (Scene*& i : scenes)
|
||||
if (i)
|
||||
i->Disp(disp_type);
|
||||
i->Disp(rend_data_ctx, disp_type, cam);
|
||||
|
||||
gl_rend_state.bind_vertex_array(0);
|
||||
gl_rend_state.disable_blend();
|
||||
gl_rend_state.enable_cull_face();
|
||||
gl_rend_state.disable_depth_test();
|
||||
rend_data_ctx.state.bind_vertex_array(0);
|
||||
rend_data_ctx.state.disable_blend();
|
||||
rend_data_ctx.state.enable_cull_face();
|
||||
rend_data_ctx.state.disable_depth_test();
|
||||
}
|
||||
|
||||
GltParticleManagerX::GltParticleManagerX() : frame_rate(),
|
||||
@@ -262,18 +262,18 @@ namespace Glitter {
|
||||
init_buffers = max_def(init_buffers - count, 0);
|
||||
}
|
||||
|
||||
void GltParticleManagerX::DispScenes(DispType disp_type) {
|
||||
void GltParticleManagerX::DispScenes(render_data_context& rend_data_ctx, DispType disp_type, const cam_data& cam) {
|
||||
if (flags & PARTICLE_MANAGER_NOT_DISP)
|
||||
return;
|
||||
|
||||
for (SceneX*& i : scenes)
|
||||
if (i)
|
||||
i->Disp(disp_type);
|
||||
i->Disp(rend_data_ctx, disp_type, cam);
|
||||
|
||||
gl_rend_state.bind_vertex_array(0);
|
||||
gl_rend_state.disable_blend();
|
||||
gl_rend_state.enable_cull_face();
|
||||
gl_rend_state.disable_depth_test();
|
||||
rend_data_ctx.state.bind_vertex_array(0);
|
||||
rend_data_ctx.state.disable_blend();
|
||||
rend_data_ctx.state.enable_cull_face();
|
||||
rend_data_ctx.state.disable_depth_test();
|
||||
}
|
||||
|
||||
void GltParticleManagerX::FreeEffects() {
|
||||
|
||||
+121
-134
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "glitter.hpp"
|
||||
#include "../gl_rend_state.hpp"
|
||||
#include "../gl_state.hpp"
|
||||
#include "../render_context.hpp"
|
||||
#include "../shader_ft.hpp"
|
||||
#include "../wrap.hpp"
|
||||
@@ -60,7 +61,7 @@ namespace Glitter {
|
||||
}
|
||||
}
|
||||
|
||||
void RenderScene::Disp(Glitter::DispType disp_type) {
|
||||
void RenderScene::Disp(render_data_context& rend_data_ctx, DispType disp_type, const cam_data& cam) {
|
||||
bool (FASTCALL * RenderGroup_CannotDisp)(RenderGroup * rend_group)
|
||||
= (bool(FASTCALL*)(RenderGroup * rend_group))0x00000001403A7120;
|
||||
|
||||
@@ -72,11 +73,11 @@ namespace Glitter {
|
||||
if (RenderGroup_CannotDisp(rend_group) || rend_group->disp_type != disp_type)
|
||||
continue;
|
||||
|
||||
Disp(rend_group);
|
||||
Disp(rend_data_ctx, rend_group, cam);
|
||||
}
|
||||
}
|
||||
|
||||
void RenderScene::Disp(RenderGroup* rend_group) {
|
||||
void RenderScene::Disp(render_data_context& rend_data_ctx, RenderGroup* rend_group, const cam_data& cam) {
|
||||
switch (rend_group->type) {
|
||||
case PARTICLE_QUAD:
|
||||
case PARTICLE_LINE:
|
||||
@@ -89,15 +90,10 @@ namespace Glitter {
|
||||
if (!rend_group->vao || rend_group->disp < 1)
|
||||
return;
|
||||
|
||||
mat4 cam_view;
|
||||
mat4 cam_projection;
|
||||
mat4_transpose(&camera_data.view, &cam_view);
|
||||
mat4_transpose(&camera_data.projection, &cam_projection);
|
||||
|
||||
mat4 mat;
|
||||
mat4_transpose(&rend_group->mat_draw, &mat);
|
||||
mat4_mul(&mat, &cam_view, &mat);
|
||||
mat4_mul(&mat, &cam_projection, &mat);
|
||||
mat4_mul(&mat, &cam.get_view_mat(), &mat);
|
||||
mat4_mul(&mat, &cam.get_proj_mat(), &mat);
|
||||
|
||||
float_t emission = 1.0f;
|
||||
if (rend_group->flags & PARTICLE_EMISSION || rend_group->blend_mode == PARTICLE_BLEND_TYPICAL)
|
||||
@@ -112,7 +108,7 @@ namespace Glitter {
|
||||
shader_data.g_glitter_blend_color = 1.0f;
|
||||
shader_data.g_state_material_diffuse = 0.0f;
|
||||
shader_data.g_state_material_emission = { emission, emission, emission, 1.0f };
|
||||
rctx->glitter_batch_ubo.WriteMemory(shader_data);
|
||||
rctx->glitter_batch_ubo.WriteMemory(rend_data_ctx.state, shader_data);
|
||||
|
||||
GLenum blend_src;
|
||||
GLenum blend_dst;
|
||||
@@ -137,8 +133,8 @@ namespace Glitter {
|
||||
break;
|
||||
}
|
||||
|
||||
gl_rend_state.set_blend_func(blend_src, blend_dst);
|
||||
gl_rend_state.set_blend_equation(GL_FUNC_ADD);
|
||||
rend_data_ctx.state.set_blend_func(blend_src, blend_dst);
|
||||
rend_data_ctx.state.set_blend_equation(GL_FUNC_ADD);
|
||||
|
||||
GLuint texture = rctx->empty_texture_2d->glid;
|
||||
GLuint mask_texture = rctx->empty_texture_2d->glid;
|
||||
@@ -147,117 +143,116 @@ namespace Glitter {
|
||||
if (rend_group->mask_texture) {
|
||||
mask_texture = rend_group->mask_texture;
|
||||
|
||||
uniform->arr[U_TEXTURE_COUNT] = 2;
|
||||
rend_data_ctx.shader_flags.arr[U_TEXTURE_COUNT] = 2;
|
||||
switch (rend_group->mask_blend_mode) {
|
||||
default:
|
||||
uniform->arr[U_TEXTURE_BLEND] = 0;
|
||||
rend_data_ctx.shader_flags.arr[U_TEXTURE_BLEND] = 0;
|
||||
break;
|
||||
case PARTICLE_BLEND_MULTIPLY:
|
||||
uniform->arr[U_TEXTURE_BLEND] = 1;
|
||||
rend_data_ctx.shader_flags.arr[U_TEXTURE_BLEND] = 1;
|
||||
break;
|
||||
case PARTICLE_BLEND_ADD:
|
||||
uniform->arr[U_TEXTURE_BLEND] = 2;
|
||||
rend_data_ctx.shader_flags.arr[U_TEXTURE_BLEND] = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
uniform->arr[U_TEXTURE_COUNT] = 1;
|
||||
uniform->arr[U_TEXTURE_BLEND] = 0;
|
||||
rend_data_ctx.shader_flags.arr[U_TEXTURE_COUNT] = 1;
|
||||
rend_data_ctx.shader_flags.arr[U_TEXTURE_BLEND] = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
uniform->arr[U_TEXTURE_COUNT] = 0;
|
||||
uniform->arr[U_TEXTURE_BLEND] = 0;
|
||||
rend_data_ctx.shader_flags.arr[U_TEXTURE_COUNT] = 0;
|
||||
rend_data_ctx.shader_flags.arr[U_TEXTURE_BLEND] = 0;
|
||||
}
|
||||
|
||||
gl_rend_state.active_bind_texture_2d(0, texture);
|
||||
gl_rend_state.active_bind_texture_2d(1, mask_texture);
|
||||
rend_data_ctx.state.active_bind_texture_2d(0, texture);
|
||||
rend_data_ctx.state.active_bind_texture_2d(1, mask_texture);
|
||||
|
||||
switch (rend_group->type) {
|
||||
case PARTICLE_QUAD:
|
||||
switch (rend_group->fog_type) {
|
||||
default:
|
||||
uniform->arr[U_FOG_STAGE] = 0;
|
||||
rend_data_ctx.shader_flags.arr[U_FOG_STAGE] = 0;
|
||||
break;
|
||||
case Glitter::FOG_DEPTH:
|
||||
uniform->arr[U_FOG_STAGE] = 1;
|
||||
rend_data_ctx.shader_flags.arr[U_FOG_STAGE] = 1;
|
||||
break;
|
||||
case Glitter::FOG_HEIGHT:
|
||||
uniform->arr[U_FOG_STAGE] = 2;
|
||||
rend_data_ctx.shader_flags.arr[U_FOG_STAGE] = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
gl_rend_state.enable_depth_test();
|
||||
rend_data_ctx.state.enable_depth_test();
|
||||
|
||||
if (alpha_test) {
|
||||
uniform->arr[U_ALPHA_TEST] = 1;
|
||||
rctx->set_batch_alpha_threshold(0.5f);
|
||||
uniform->arr[U_ALPHA_BLEND] = 1;
|
||||
gl_rend_state.set_depth_mask(GL_TRUE);
|
||||
gl_rend_state.disable_blend();
|
||||
rend_data_ctx.shader_flags.arr[U_ALPHA_TEST] = 1;
|
||||
rend_data_ctx.set_batch_alpha_threshold(0.5f);
|
||||
rend_data_ctx.shader_flags.arr[U_ALPHA_BLEND] = 1;
|
||||
rend_data_ctx.state.set_depth_mask(GL_TRUE);
|
||||
rend_data_ctx.state.disable_blend();
|
||||
}
|
||||
else if (rend_group->disp_type) {
|
||||
uniform->arr[U_ALPHA_TEST] = 0;
|
||||
uniform->arr[U_ALPHA_BLEND] = 2;
|
||||
gl_rend_state.set_depth_mask(GL_FALSE);
|
||||
gl_rend_state.enable_blend();
|
||||
rend_data_ctx.shader_flags.arr[U_ALPHA_TEST] = 0;
|
||||
rend_data_ctx.shader_flags.arr[U_ALPHA_BLEND] = 2;
|
||||
rend_data_ctx.state.set_depth_mask(GL_FALSE);
|
||||
rend_data_ctx.state.enable_blend();
|
||||
}
|
||||
else {
|
||||
uniform->arr[U_ALPHA_TEST] = 0;
|
||||
uniform->arr[U_ALPHA_BLEND] = 0;
|
||||
gl_rend_state.set_depth_mask(GL_TRUE);
|
||||
gl_rend_state.disable_blend();
|
||||
rend_data_ctx.shader_flags.arr[U_ALPHA_TEST] = 0;
|
||||
rend_data_ctx.shader_flags.arr[U_ALPHA_BLEND] = 0;
|
||||
rend_data_ctx.state.set_depth_mask(GL_TRUE);
|
||||
rend_data_ctx.state.disable_blend();
|
||||
}
|
||||
|
||||
if (rend_group->draw_type == DIRECTION_BILLBOARD) {
|
||||
gl_rend_state.enable_cull_face();
|
||||
gl_rend_state.set_cull_face_mode(GL_BACK);
|
||||
rend_data_ctx.state.enable_cull_face();
|
||||
rend_data_ctx.state.set_cull_face_mode(GL_BACK);
|
||||
}
|
||||
else
|
||||
gl_rend_state.disable_cull_face();
|
||||
rend_data_ctx.state.disable_cull_face();
|
||||
break;
|
||||
case PARTICLE_LINE:
|
||||
uniform->arr[U_ALPHA_TEST] = 0;
|
||||
uniform->arr[U_ALPHA_BLEND] = 2;
|
||||
uniform->arr[U_FOG_STAGE] = 0;
|
||||
rend_data_ctx.shader_flags.arr[U_ALPHA_TEST] = 0;
|
||||
rend_data_ctx.shader_flags.arr[U_ALPHA_BLEND] = 2;
|
||||
rend_data_ctx.shader_flags.arr[U_FOG_STAGE] = 0;
|
||||
|
||||
gl_rend_state.enable_depth_test();
|
||||
gl_rend_state.set_depth_mask(GL_FALSE);
|
||||
gl_rend_state.enable_blend();
|
||||
gl_rend_state.enable_cull_face();
|
||||
gl_rend_state.set_cull_face_mode(GL_BACK);
|
||||
rend_data_ctx.state.enable_depth_test();
|
||||
rend_data_ctx.state.set_depth_mask(GL_FALSE);
|
||||
rend_data_ctx.state.enable_blend();
|
||||
rend_data_ctx.state.enable_cull_face();
|
||||
rend_data_ctx.state.set_cull_face_mode(GL_BACK);
|
||||
break;
|
||||
case PARTICLE_LOCUS:
|
||||
uniform->arr[U_ALPHA_TEST] = 0;
|
||||
uniform->arr[U_ALPHA_BLEND] = 2;
|
||||
uniform->arr[U_FOG_STAGE] = 0;
|
||||
rend_data_ctx.shader_flags.arr[U_ALPHA_TEST] = 0;
|
||||
rend_data_ctx.shader_flags.arr[U_ALPHA_BLEND] = 2;
|
||||
rend_data_ctx.shader_flags.arr[U_FOG_STAGE] = 0;
|
||||
|
||||
gl_rend_state.enable_depth_test();
|
||||
gl_rend_state.set_depth_mask(GL_FALSE);
|
||||
gl_rend_state.enable_blend();
|
||||
gl_rend_state.disable_cull_face();
|
||||
rend_data_ctx.state.enable_depth_test();
|
||||
rend_data_ctx.state.set_depth_mask(GL_FALSE);
|
||||
rend_data_ctx.state.enable_blend();
|
||||
rend_data_ctx.state.disable_cull_face();
|
||||
break;
|
||||
}
|
||||
|
||||
shaders_ft.set(SHADER_FT_GLITTER_PT);
|
||||
rctx->set_glitter_render_data();
|
||||
rctx->glitter_batch_ubo.Bind(3);
|
||||
shaders_ft.set(rend_data_ctx.state, rend_data_ctx.shader_flags, SHADER_FT_GLITTER_PT);
|
||||
rend_data_ctx.set_glitter_render_data_state();
|
||||
rend_data_ctx.state.bind_uniform_buffer_base(3, rctx->glitter_batch_ubo);
|
||||
switch (rend_group->type) {
|
||||
case PARTICLE_QUAD:
|
||||
gl_rend_state.bind_vertex_array(rend_group->vao);
|
||||
shaders_ft.enable_primitive_restart();
|
||||
shaders_ft.draw_elements(GL_TRIANGLE_STRIP, (GLsizei)(5 * rend_group->disp - 1), GL_UNSIGNED_INT, 0);
|
||||
shaders_ft.disable_primitive_restart();
|
||||
rend_data_ctx.state.bind_vertex_array(rend_group->vao);
|
||||
rend_data_ctx.state.draw_elements(GL_TRIANGLE_STRIP,
|
||||
(GLsizei)(5 * rend_group->disp - 1), GL_UNSIGNED_INT, 0);
|
||||
break;
|
||||
case PARTICLE_LINE:
|
||||
gl_rend_state.bind_vertex_array(rend_group->vao);
|
||||
rend_data_ctx.state.bind_vertex_array(rend_group->vao);
|
||||
for (std::pair<GLint, GLsizei>& i : *rend_group->draw_list)
|
||||
shaders_ft.draw_arrays(GL_LINE_STRIP, i.first, i.second);
|
||||
rend_data_ctx.state.draw_arrays(GL_LINE_STRIP, i.first, i.second);
|
||||
break;
|
||||
case PARTICLE_LOCUS:
|
||||
gl_rend_state.bind_vertex_array(rend_group->vao);
|
||||
rend_data_ctx.state.bind_vertex_array(rend_group->vao);
|
||||
for (std::pair<GLint, GLsizei>& i : *rend_group->draw_list)
|
||||
shaders_ft.draw_arrays(GL_TRIANGLE_STRIP, i.first, i.second);
|
||||
rend_data_ctx.state.draw_arrays(GL_TRIANGLE_STRIP, i.first, i.second);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -345,7 +340,7 @@ namespace Glitter {
|
||||
}
|
||||
rend_group->disp = disp;
|
||||
|
||||
rend_group->vbo.WriteMemory(0, (buf - rend_group->buffer) * sizeof(Buffer), rend_group->buffer);
|
||||
rend_group->vbo.WriteMemory(gl_state, 0, (buf - rend_group->buffer) * sizeof(Buffer), rend_group->buffer);
|
||||
}
|
||||
|
||||
void RenderScene::CalcDispLocus(RenderGroup* rend_group) {
|
||||
@@ -505,7 +500,7 @@ namespace Glitter {
|
||||
}
|
||||
rend_group->disp = disp;
|
||||
|
||||
rend_group->vbo.WriteMemory(0, (buf - rend_group->buffer) * sizeof(Buffer), rend_group->buffer);
|
||||
rend_group->vbo.WriteMemory(gl_state, 0, (buf - rend_group->buffer) * sizeof(Buffer), rend_group->buffer);
|
||||
}
|
||||
|
||||
void RenderScene::CalcDispQuad(RenderGroup* rend_group) {
|
||||
@@ -703,7 +698,7 @@ namespace Glitter {
|
||||
}
|
||||
rend_group->disp = disp;
|
||||
|
||||
rend_group->vbo.WriteMemory(0, (buf - rend_group->buffer) * sizeof(Buffer), rend_group->buffer);
|
||||
rend_group->vbo.WriteMemory(gl_state, 0, (buf - rend_group->buffer) * sizeof(Buffer), rend_group->buffer);
|
||||
}
|
||||
|
||||
void RenderScene::CalcDispQuadNormal(
|
||||
@@ -930,7 +925,7 @@ namespace Glitter {
|
||||
}
|
||||
rend_group->disp = disp;
|
||||
|
||||
rend_group->vbo.WriteMemory(0, (buf - rend_group->buffer) * sizeof(Buffer), rend_group->buffer);
|
||||
rend_group->vbo.WriteMemory(gl_state, 0, (buf - rend_group->buffer) * sizeof(Buffer), rend_group->buffer);
|
||||
}
|
||||
|
||||
void RenderScene::CalcDispLocusSetPivot(Pivot pivot,
|
||||
@@ -1169,7 +1164,7 @@ namespace Glitter {
|
||||
rend_group->disp = disp;
|
||||
|
||||
#if !SHARED_GLITTER_BUFFER
|
||||
rend_group->vbo.WriteMemory(0, (buf - rend_group->buffer) * sizeof(Buffer), rend_group->buffer);
|
||||
rend_group->vbo.WriteMemory(gl_state, 0, (buf - rend_group->buffer) * sizeof(Buffer), rend_group->buffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1326,7 +1321,7 @@ namespace Glitter {
|
||||
rend_group->disp = disp;
|
||||
|
||||
#if !SHARED_GLITTER_BUFFER
|
||||
rend_group->vbo.WriteMemory(0, (buf - rend_group->buffer) * sizeof(Buffer), rend_group->buffer);
|
||||
rend_group->vbo.WriteMemory(gl_state, 0, (buf - rend_group->buffer) * sizeof(Buffer), rend_group->buffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1518,7 +1513,7 @@ namespace Glitter {
|
||||
rend_group->disp = disp;
|
||||
|
||||
#if !SHARED_GLITTER_BUFFER
|
||||
rend_group->vbo.WriteMemory(0, (buf - rend_group->buffer) * sizeof(Buffer), rend_group->buffer);
|
||||
rend_group->vbo.WriteMemory(gl_state, 0, (buf - rend_group->buffer) * sizeof(Buffer), rend_group->buffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1732,7 +1727,7 @@ namespace Glitter {
|
||||
rend_group->disp = disp;
|
||||
|
||||
#if !SHARED_GLITTER_BUFFER
|
||||
rend_group->vbo.WriteMemory(0, (buf - rend_group->buffer) * sizeof(Buffer), rend_group->buffer);
|
||||
rend_group->vbo.WriteMemory(gl_state, 0, (buf - rend_group->buffer) * sizeof(Buffer), rend_group->buffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1778,7 +1773,7 @@ namespace Glitter {
|
||||
}
|
||||
}
|
||||
|
||||
void RenderSceneX::Disp(DispType disp_type) {
|
||||
void RenderSceneX::Disp(render_data_context& rend_data_ctx, DispType disp_type, const cam_data& cam) {
|
||||
for (RenderGroupX* i : groups) {
|
||||
if (!i)
|
||||
continue;
|
||||
@@ -1787,11 +1782,11 @@ namespace Glitter {
|
||||
if ((rend_group)->disp_type != disp_type || rend_group->CannotDisp())
|
||||
continue;
|
||||
|
||||
Disp(rend_group);
|
||||
Disp(rend_data_ctx, rend_group, cam);
|
||||
}
|
||||
}
|
||||
|
||||
void RenderSceneX::Disp(RenderGroupX* rend_group) {
|
||||
void RenderSceneX::Disp(render_data_context& rend_data_ctx, RenderGroupX* rend_group, const cam_data& cam) {
|
||||
switch (rend_group->type) {
|
||||
case PARTICLE_QUAD:
|
||||
case PARTICLE_LINE:
|
||||
@@ -1805,16 +1800,9 @@ namespace Glitter {
|
||||
if (!rend_group->vao || rend_group->disp < 1)
|
||||
return;
|
||||
|
||||
mat4 cam_view;
|
||||
mat4 cam_projection;
|
||||
mat4_transpose(&camera_data.view, &cam_view);
|
||||
if (reflect_draw)
|
||||
mat4_mul(&reflect_mat, &cam_view, &cam_view);
|
||||
mat4_transpose(&camera_data.projection, &cam_projection);
|
||||
|
||||
mat4 mat;
|
||||
mat4_mul(&rend_group->mat_draw, &cam_view, &mat);
|
||||
mat4_mul(&mat, &cam_projection, &mat);
|
||||
mat4_mul(&rend_group->mat_draw, &cam.get_view_mat(), &mat);
|
||||
mat4_mul(&mat, &cam.get_proj_mat(), &mat);
|
||||
|
||||
float_t emission = 1.0f;
|
||||
if (rend_group->flags & PARTICLE_EMISSION || rend_group->blend_mode == PARTICLE_BLEND_TYPICAL)
|
||||
@@ -1829,7 +1817,7 @@ namespace Glitter {
|
||||
shader_data.g_glitter_blend_color = 1.0f;
|
||||
shader_data.g_state_material_diffuse = 0.0f;
|
||||
shader_data.g_state_material_emission = { emission, emission, emission, 1.0f };
|
||||
rctx->glitter_batch_ubo.WriteMemory(shader_data);
|
||||
rctx->glitter_batch_ubo.WriteMemory(rend_data_ctx.state, shader_data);
|
||||
|
||||
GLenum blend_src;
|
||||
GLenum blend_dst;
|
||||
@@ -1854,8 +1842,8 @@ namespace Glitter {
|
||||
break;
|
||||
}
|
||||
|
||||
gl_rend_state.set_blend_func(blend_src, blend_dst);
|
||||
gl_rend_state.set_blend_equation(GL_FUNC_ADD);
|
||||
rend_data_ctx.state.set_blend_func(blend_src, blend_dst);
|
||||
rend_data_ctx.state.set_blend_equation(GL_FUNC_ADD);
|
||||
|
||||
GLuint texture = rctx->empty_texture_2d->glid;
|
||||
GLuint mask_texture = rctx->empty_texture_2d->glid;
|
||||
@@ -1864,95 +1852,94 @@ namespace Glitter {
|
||||
if (rend_group->mask_texture) {
|
||||
mask_texture = rend_group->mask_texture;
|
||||
|
||||
uniform->arr[U_TEXTURE_COUNT] = 2;
|
||||
rend_data_ctx.shader_flags.arr[U_TEXTURE_COUNT] = 2;
|
||||
switch (rend_group->mask_blend_mode) {
|
||||
default:
|
||||
uniform->arr[U_TEXTURE_BLEND] = 0;
|
||||
rend_data_ctx.shader_flags.arr[U_TEXTURE_BLEND] = 0;
|
||||
break;
|
||||
case PARTICLE_BLEND_MULTIPLY:
|
||||
uniform->arr[U_TEXTURE_BLEND] = 1;
|
||||
rend_data_ctx.shader_flags.arr[U_TEXTURE_BLEND] = 1;
|
||||
break;
|
||||
case PARTICLE_BLEND_ADD:
|
||||
uniform->arr[U_TEXTURE_BLEND] = 2;
|
||||
rend_data_ctx.shader_flags.arr[U_TEXTURE_BLEND] = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
uniform->arr[U_TEXTURE_COUNT] = 1;
|
||||
uniform->arr[U_TEXTURE_BLEND] = 0;
|
||||
rend_data_ctx.shader_flags.arr[U_TEXTURE_COUNT] = 1;
|
||||
rend_data_ctx.shader_flags.arr[U_TEXTURE_BLEND] = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
uniform->arr[U_TEXTURE_COUNT] = 0;
|
||||
uniform->arr[U_TEXTURE_BLEND] = 0;
|
||||
rend_data_ctx.shader_flags.arr[U_TEXTURE_COUNT] = 0;
|
||||
rend_data_ctx.shader_flags.arr[U_TEXTURE_BLEND] = 0;
|
||||
}
|
||||
|
||||
gl_rend_state.active_bind_texture_2d(0, texture);
|
||||
gl_rend_state.active_bind_texture_2d(1, mask_texture);
|
||||
rend_data_ctx.state.active_bind_texture_2d(0, texture);
|
||||
rend_data_ctx.state.active_bind_texture_2d(1, mask_texture);
|
||||
|
||||
switch (rend_group->fog_type) {
|
||||
default:
|
||||
uniform->arr[U_FOG_STAGE] = 0;
|
||||
rend_data_ctx.shader_flags.arr[U_FOG_STAGE] = 0;
|
||||
break;
|
||||
case Glitter::FOG_DEPTH:
|
||||
uniform->arr[U_FOG_STAGE] = 1;
|
||||
rend_data_ctx.shader_flags.arr[U_FOG_STAGE] = 1;
|
||||
break;
|
||||
case Glitter::FOG_HEIGHT:
|
||||
uniform->arr[U_FOG_STAGE] = 2;
|
||||
rend_data_ctx.shader_flags.arr[U_FOG_STAGE] = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!(rend_group->flags & PARTICLE_DEPTH_TEST))
|
||||
gl_rend_state.enable_depth_test();
|
||||
rend_data_ctx.state.enable_depth_test();
|
||||
else
|
||||
gl_rend_state.disable_depth_test();
|
||||
rend_data_ctx.state.disable_depth_test();
|
||||
|
||||
if (alpha_test) {
|
||||
uniform->arr[U_ALPHA_TEST] = 1;
|
||||
rctx->set_batch_alpha_threshold(0.5f);
|
||||
uniform->arr[U_ALPHA_BLEND] = rend_group->disp_type ? 3 : 1;
|
||||
gl_rend_state.set_depth_mask(GL_TRUE);
|
||||
gl_rend_state.disable_blend();
|
||||
rend_data_ctx.shader_flags.arr[U_ALPHA_TEST] = 1;
|
||||
rend_data_ctx.set_batch_alpha_threshold(0.5f);
|
||||
rend_data_ctx.shader_flags.arr[U_ALPHA_BLEND] = rend_group->disp_type ? 3 : 1;
|
||||
rend_data_ctx.state.set_depth_mask(GL_TRUE);
|
||||
rend_data_ctx.state.disable_blend();
|
||||
}
|
||||
else if (rend_group->disp_type) {
|
||||
uniform->arr[U_ALPHA_TEST] = 0;
|
||||
uniform->arr[U_ALPHA_BLEND] = 2;
|
||||
gl_rend_state.set_depth_mask(GL_FALSE);
|
||||
gl_rend_state.enable_blend();
|
||||
rend_data_ctx.shader_flags.arr[U_ALPHA_TEST] = 0;
|
||||
rend_data_ctx.shader_flags.arr[U_ALPHA_BLEND] = 2;
|
||||
rend_data_ctx.state.set_depth_mask(GL_FALSE);
|
||||
rend_data_ctx.state.enable_blend();
|
||||
}
|
||||
else {
|
||||
uniform->arr[U_ALPHA_TEST] = 0;
|
||||
uniform->arr[U_ALPHA_BLEND] = 0;
|
||||
gl_rend_state.set_depth_mask(GL_TRUE);
|
||||
gl_rend_state.disable_blend();
|
||||
rend_data_ctx.shader_flags.arr[U_ALPHA_TEST] = 0;
|
||||
rend_data_ctx.shader_flags.arr[U_ALPHA_BLEND] = 0;
|
||||
rend_data_ctx.state.set_depth_mask(GL_TRUE);
|
||||
rend_data_ctx.state.disable_blend();
|
||||
}
|
||||
|
||||
if (rend_group->draw_type == DIRECTION_BILLBOARD && !rend_group->use_culling) {
|
||||
gl_rend_state.enable_cull_face();
|
||||
gl_rend_state.set_cull_face_mode(GL_BACK);
|
||||
rend_data_ctx.state.enable_cull_face();
|
||||
rend_data_ctx.state.set_cull_face_mode(GL_BACK);
|
||||
}
|
||||
else
|
||||
gl_rend_state.disable_cull_face();
|
||||
rend_data_ctx.state.disable_cull_face();
|
||||
|
||||
shaders_ft.set(SHADER_FT_GLITTER_PT);
|
||||
rctx->set_glitter_render_data();
|
||||
rctx->glitter_batch_ubo.Bind(3);
|
||||
shaders_ft.set(rend_data_ctx.state, rend_data_ctx.shader_flags, SHADER_FT_GLITTER_PT);
|
||||
rend_data_ctx.set_glitter_render_data_state();
|
||||
rend_data_ctx.state.bind_uniform_buffer_base(3, rctx->glitter_batch_ubo);
|
||||
switch (rend_group->type) {
|
||||
case PARTICLE_QUAD:
|
||||
gl_rend_state.bind_vertex_array(rend_group->vao);
|
||||
shaders_ft.enable_primitive_restart();
|
||||
shaders_ft.draw_elements(GL_TRIANGLE_STRIP, (GLsizei)(5 * rend_group->disp - 1), GL_UNSIGNED_INT, 0);
|
||||
shaders_ft.disable_primitive_restart();
|
||||
rend_data_ctx.state.bind_vertex_array(rend_group->vao);
|
||||
rend_data_ctx.state.draw_elements(GL_TRIANGLE_STRIP,
|
||||
(GLsizei)(5 * rend_group->disp - 1), GL_UNSIGNED_INT, 0);
|
||||
break;
|
||||
case PARTICLE_LINE:
|
||||
gl_rend_state.bind_vertex_array(rend_group->vao);
|
||||
rend_data_ctx.state.bind_vertex_array(rend_group->vao);
|
||||
for (std::pair<GLint, GLsizei>& i : rend_group->draw_list)
|
||||
shaders_ft.draw_arrays(GL_LINE_STRIP, i.first, i.second);
|
||||
rend_data_ctx.state.draw_arrays(GL_LINE_STRIP, i.first, i.second);
|
||||
break;
|
||||
case PARTICLE_LOCUS:
|
||||
gl_rend_state.bind_vertex_array(rend_group->vao);
|
||||
rend_data_ctx.state.bind_vertex_array(rend_group->vao);
|
||||
for (std::pair<GLint, GLsizei>& i : rend_group->draw_list)
|
||||
shaders_ft.draw_arrays(GL_TRIANGLE_STRIP, i.first, i.second);
|
||||
rend_data_ctx.state.draw_arrays(GL_TRIANGLE_STRIP, i.first, i.second);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
*/
|
||||
|
||||
#include "glitter.hpp"
|
||||
#include "../gl_state.hpp"
|
||||
|
||||
namespace Glitter {
|
||||
void Scene::Disp(DispType disp_type) {
|
||||
void Scene::Disp(render_data_context& rend_data_ctx, DispType disp_type, const cam_data& cam) {
|
||||
if (!(flags & SCENE_NOT_DISP))
|
||||
render_scene.Disp(disp_type);
|
||||
render_scene.Disp(rend_data_ctx, disp_type, cam);
|
||||
}
|
||||
|
||||
void Scene::CalcDisp() {
|
||||
@@ -60,7 +61,7 @@ namespace Glitter {
|
||||
}
|
||||
|
||||
if (disp)
|
||||
effect_group->vbo.WriteMemory(0, effect_group->max_count * sizeof(Buffer), effect_group->buffer);
|
||||
effect_group->vbo.WriteMemory(gl_state, 0, effect_group->max_count * sizeof(Buffer), effect_group->buffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -137,13 +138,13 @@ namespace Glitter {
|
||||
}
|
||||
}
|
||||
|
||||
void SceneX::Disp(DispType disp_type) {
|
||||
void SceneX::Disp(render_data_context& rend_data_ctx, DispType disp_type, const cam_data& cam) {
|
||||
if (flags & SCENE_NOT_DISP)
|
||||
return;
|
||||
|
||||
for (SceneEffectX& i : effects)
|
||||
if (i.ptr && i.disp)
|
||||
i.ptr->Disp(disp_type);
|
||||
i.ptr->Disp(rend_data_ctx, disp_type, cam);
|
||||
}
|
||||
|
||||
void SceneX::DispMesh() {
|
||||
|
||||
+122
-5
@@ -4,10 +4,121 @@
|
||||
*/
|
||||
|
||||
#include "camera.hpp"
|
||||
#include "render.hpp"
|
||||
#include "../AFTModsShared/resolution_mode.hpp"
|
||||
#include "render.hpp"
|
||||
#include "render_context.hpp"
|
||||
#include <Helpers.h>
|
||||
|
||||
cam_data::cam_data() : view_point(0.0f, 0.0f, 1.0f), interest(), up(0.0f, 1.0f, 0.0f),
|
||||
fov(30.0f * DEG_TO_RAD_FLOAT), aspect(4.0f / 3.0f), min_distance(1.0f), max_distance(200.0f),
|
||||
view_mat(), proj_mat(), view_proj_mat(), persp_scale(), persp_offset() {
|
||||
|
||||
}
|
||||
|
||||
void cam_data::calc_ortho_proj_mat(float_t left, float_t right,
|
||||
float_t bottom, float_t top, const vec2& scale, const vec2& offset) {
|
||||
mat4_ortho_offset(left, right, bottom, top, min_distance, max_distance, &scale, &offset, &proj_mat);
|
||||
}
|
||||
|
||||
void cam_data::calc_persp_proj_mat() {
|
||||
mat4_persp(fov, aspect, min_distance, max_distance, &proj_mat);
|
||||
persp_scale = 1.0f;
|
||||
persp_offset = 0.0f;
|
||||
}
|
||||
|
||||
void cam_data::calc_persp_proj_mat_offset(const vec2& persp_scale, const vec2& persp_offset) {
|
||||
mat4_persp_offset(fov, aspect, min_distance, max_distance, &persp_scale, &persp_offset, &proj_mat);
|
||||
this->persp_scale = persp_scale;
|
||||
this->persp_offset = persp_offset;
|
||||
}
|
||||
|
||||
void cam_data::calc_view_mat() {
|
||||
mat4_look_at(&view_point, &interest, &up, &view_mat);
|
||||
}
|
||||
|
||||
void cam_data::calc_view_proj_mat() {
|
||||
mat4_mul(&view_mat, &proj_mat, &view_proj_mat);
|
||||
}
|
||||
|
||||
void cam_data::get() {
|
||||
view_point = camera_data.view_point;
|
||||
interest = camera_data.interest;
|
||||
up = camera_data.up;
|
||||
fov = camera_data.fov * DEG_TO_RAD_FLOAT;
|
||||
aspect = (float_t)camera_data.aspect;
|
||||
min_distance = camera_data.min_distance;
|
||||
max_distance = camera_data.max_distance;
|
||||
mat4_transpose(&camera_data.view, &view_mat);
|
||||
mat4_transpose(&camera_data.projection, &proj_mat);
|
||||
mat4_transpose(&camera_data.view_projection, &view_proj_mat);
|
||||
persp_scale = 1.0f;
|
||||
persp_offset = 0.0f;
|
||||
}
|
||||
|
||||
float_t cam_data::get_aspect() const {
|
||||
return aspect;
|
||||
}
|
||||
|
||||
float_t cam_data::get_fov() const {
|
||||
return fov;
|
||||
}
|
||||
|
||||
const vec3& cam_data::get_interest() const {
|
||||
return interest;
|
||||
}
|
||||
|
||||
float_t cam_data::get_min_distance() const {
|
||||
return min_distance;
|
||||
}
|
||||
|
||||
float_t cam_data::get_max_distance() const {
|
||||
return max_distance;
|
||||
}
|
||||
|
||||
const mat4& cam_data::get_proj_mat() const {
|
||||
return proj_mat;
|
||||
}
|
||||
|
||||
const mat4& cam_data::get_view_mat() const {
|
||||
return view_mat;
|
||||
}
|
||||
|
||||
const vec3& cam_data::get_view_point() const {
|
||||
return view_point;
|
||||
}
|
||||
|
||||
const mat4& cam_data::get_view_proj_mat() const {
|
||||
return view_proj_mat;
|
||||
}
|
||||
|
||||
void cam_data::set_aspect(float_t value) {
|
||||
aspect = value;
|
||||
}
|
||||
|
||||
void cam_data::set_fov(float_t value) {
|
||||
fov = value;
|
||||
}
|
||||
|
||||
void cam_data::set_interest(const vec3& value) {
|
||||
interest = value;
|
||||
}
|
||||
|
||||
void cam_data::set_min_distance(float_t value) {
|
||||
min_distance = value;
|
||||
}
|
||||
|
||||
void cam_data::set_max_distance(float_t value) {
|
||||
max_distance = value;
|
||||
}
|
||||
|
||||
void cam_data::set_up(const vec3& value) {
|
||||
up = value;
|
||||
}
|
||||
|
||||
void cam_data::set_view_point(const vec3& value) {
|
||||
view_point = value;
|
||||
}
|
||||
|
||||
static void (FASTCALL* camera_struct__update_view)(camera_struct& cam)
|
||||
= (void (FASTCALL*)(camera_struct & cam))0x00000001401F7690;
|
||||
|
||||
@@ -58,10 +169,13 @@ HOOK(void, FASTCALL, camera_data_update_projection, 0x00000001401F8E90) {
|
||||
mat4_mul(&spr_3d_view, &spr_3d_proj, &spr_3d_proj);
|
||||
mat4_transpose(&spr_3d_proj, &camera_data.view_projection_aet_3d);
|
||||
|
||||
render_get()->calc_projection_matrix(&camera_data.projection, camera_data.fov,
|
||||
(float_t)camera_data.aspect, camera_data.min_distance, camera_data.max_distance,
|
||||
camera_data.proj_left_offset, camera_data.proj_right_offset,
|
||||
camera_data.proj_bottom_offset, camera_data.proj_top_offset);
|
||||
vec2 persp_scale = 1.0f;
|
||||
vec2 persp_offset = render_get()->get_taa_offset();
|
||||
mat4 proj;
|
||||
mat4_persp_offset(camera_data.fov * DEG_TO_RAD_FLOAT, (float_t)camera_data.aspect,
|
||||
camera_data.min_distance, camera_data.max_distance, &persp_scale, &persp_offset, &proj);
|
||||
mat4_transpose(&proj, &camera_data.projection);
|
||||
|
||||
camera_data.fov_horizontal_rad = tanf(camera_data.fov * 0.5f * DEG_TO_RAD_FLOAT);
|
||||
}
|
||||
|
||||
@@ -71,6 +185,9 @@ HOOK(void, FASTCALL, camera_update, 0x00000001401F8970) {
|
||||
camera_data.fast_change_hist1 = camera_data.fast_change_hist0;
|
||||
camera_data.fast_change_hist0 = camera_data.fast_change;
|
||||
camera_data.fast_change = false;
|
||||
|
||||
extern render_context* rctx;
|
||||
rctx->render_manager_cam.get();
|
||||
}
|
||||
|
||||
void camera_patch() {
|
||||
|
||||
@@ -8,4 +8,45 @@
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "../AFTModsShared/camera.hpp"
|
||||
|
||||
struct cam_data {
|
||||
vec3 view_point;
|
||||
vec3 interest;
|
||||
vec3 up;
|
||||
float_t fov;
|
||||
float_t aspect;
|
||||
float_t min_distance;
|
||||
float_t max_distance;
|
||||
mat4 view_mat;
|
||||
mat4 proj_mat;
|
||||
mat4 view_proj_mat;
|
||||
vec2 persp_scale;
|
||||
vec2 persp_offset;
|
||||
|
||||
cam_data();
|
||||
|
||||
void calc_ortho_proj_mat(float_t left, float_t right,
|
||||
float_t bottom, float_t top, const vec2& scale, const vec2& offset);
|
||||
void calc_persp_proj_mat();
|
||||
void calc_persp_proj_mat_offset(const vec2& persp_scale, const vec2& persp_offset);
|
||||
void calc_view_mat();
|
||||
void calc_view_proj_mat();
|
||||
void get();
|
||||
float_t get_aspect() const;
|
||||
float_t get_fov() const;
|
||||
const vec3& get_interest() const;
|
||||
float_t get_min_distance() const;
|
||||
float_t get_max_distance() const;
|
||||
const mat4& get_proj_mat() const;
|
||||
const mat4& get_view_mat() const;
|
||||
const vec3& get_view_point() const;
|
||||
const mat4& get_view_proj_mat() const;
|
||||
void set_aspect(float_t value);
|
||||
void set_fov(float_t value);
|
||||
void set_interest(const vec3& value);
|
||||
void set_min_distance(float_t value);
|
||||
void set_max_distance(float_t value);
|
||||
void set_up(const vec3& value);
|
||||
void set_view_point(const vec3& value);
|
||||
};
|
||||
|
||||
extern void camera_patch();
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
*/
|
||||
|
||||
#include "clear_color.hpp"
|
||||
#include "wrap.hpp"
|
||||
#include "gl_rend_state.hpp"
|
||||
|
||||
color4u8& clear_color = *(color4u8*)0x0000000140EC57C8;
|
||||
|
||||
void clear_color_set_gl() {
|
||||
void clear_color_set_gl(p_gl_rend_state& p_gl_rend_st) {
|
||||
vec4 color = clear_color;
|
||||
glClearColorDLL(color.x, color.y, color.z, color.w);
|
||||
p_gl_rend_st.clear_color(color.x, color.y, color.z, color.w);
|
||||
}
|
||||
|
||||
@@ -10,4 +10,4 @@
|
||||
|
||||
extern color4u8& clear_color;
|
||||
|
||||
extern void clear_color_set_gl();
|
||||
extern void clear_color_set_gl(struct p_gl_rend_state& p_gl_rend_st);
|
||||
|
||||
@@ -981,7 +981,7 @@ void RobOsageTest::disp_coli() {
|
||||
return;
|
||||
|
||||
disp_coli_cls_list(ex_node, cls_param);
|
||||
|
||||
|
||||
if (osg && osg->rob.nodes.size() >= 1) {
|
||||
RobOsageNode* j_begin = osg->rob.nodes.data() + 1;
|
||||
RobOsageNode* j_end = osg->rob.nodes.data() + osg->rob.nodes.size();
|
||||
|
||||
+342
-309
File diff suppressed because it is too large
Load Diff
@@ -43,10 +43,10 @@ struct particle_init_data {
|
||||
float_t scale_y;
|
||||
};
|
||||
|
||||
extern void leaf_particle_draw();
|
||||
extern void rain_particle_draw();
|
||||
extern void particle_draw();
|
||||
extern void snow_particle_draw();
|
||||
extern void star_catalog_draw();
|
||||
extern void leaf_particle_draw(struct render_data_context& rend_data_ctx, const struct cam_data& cam);
|
||||
extern void rain_particle_draw(struct render_data_context& rend_data_ctx, const struct cam_data& cam);
|
||||
extern void particle_draw(struct render_data_context& rend_data_ctx, const struct cam_data& cam);
|
||||
extern void snow_particle_draw(struct render_data_context& rend_data_ctx, const struct cam_data& cam);
|
||||
extern void star_catalog_draw(struct render_data_context& rend_data_ctx, const struct cam_data& cam);
|
||||
|
||||
extern void effect_patch();
|
||||
|
||||
+1605
-380
File diff suppressed because it is too large
Load Diff
+88
-117
@@ -6,7 +6,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "wrap.hpp"
|
||||
#include "gl.hpp"
|
||||
|
||||
enum gl_rend_state_index {
|
||||
GL_REND_STATE_PRE_3D = 0,
|
||||
GL_REND_STATE_3D,
|
||||
GL_REND_STATE_2D,
|
||||
GL_REND_STATE_POST_2D,
|
||||
GL_REND_STATE_COUNT,
|
||||
};
|
||||
|
||||
struct gl_rend_state_rect {
|
||||
GLint x;
|
||||
@@ -15,135 +23,98 @@ struct gl_rend_state_rect {
|
||||
GLsizei height;
|
||||
};
|
||||
|
||||
struct gl_rend_state_struct {
|
||||
GLint program;
|
||||
GLuint active_texture_index;
|
||||
GLint texture_binding_2d[32];
|
||||
GLint texture_binding_cube_map[32];
|
||||
GLint sampler_binding[32];
|
||||
GLboolean blend;
|
||||
GLenum blend_src_rgb;
|
||||
GLenum blend_src_alpha;
|
||||
GLenum blend_dst_rgb;
|
||||
GLenum blend_dst_alpha;
|
||||
GLenum blend_mode_rgb;
|
||||
GLenum blend_mode_alpha;
|
||||
GLuint framebuffer_binding;
|
||||
GLuint read_framebuffer_binding;
|
||||
GLuint draw_framebuffer_binding;
|
||||
GLuint vertex_array_binding;
|
||||
GLuint array_buffer_binding;
|
||||
GLuint element_array_buffer_binding;
|
||||
GLuint uniform_buffer_binding;
|
||||
GLuint uniform_buffer_bindings[14];
|
||||
GLintptr uniform_buffer_offsets[14];
|
||||
GLsizeiptr uniform_buffer_sizes[14];
|
||||
GLuint shader_storage_buffer_binding;
|
||||
GLuint shader_storage_buffer_bindings[14];
|
||||
GLintptr shader_storage_buffer_offsets[14];
|
||||
GLsizeiptr shader_storage_buffer_sizes[14];
|
||||
GLboolean color_mask[4];
|
||||
GLboolean cull_face;
|
||||
GLenum cull_face_mode;
|
||||
GLboolean depth_test;
|
||||
GLenum depth_func;
|
||||
GLboolean depth_mask;
|
||||
GLfloat line_width;
|
||||
GLenum polygon_mode;
|
||||
GLboolean multisample;
|
||||
GLboolean primitive_restart;
|
||||
GLuint primitive_restart_index;
|
||||
gl_rend_state_rect scissor_box;
|
||||
GLboolean scissor_test;
|
||||
GLboolean stencil_test;
|
||||
GLenum stencil_func;
|
||||
GLenum stencil_fail;
|
||||
GLenum stencil_dpfail;
|
||||
GLenum stencil_dppass;
|
||||
GLuint stencil_mask;
|
||||
GLint stencil_ref;
|
||||
GLuint stencil_value_mask;
|
||||
gl_rend_state_rect viewport;
|
||||
struct p_gl_rend_state {
|
||||
struct gl_rend_state& ptr;
|
||||
|
||||
void active_bind_texture_2d(int32_t index, GLuint texture, bool force = false);
|
||||
void active_bind_texture_cube_map(int32_t index, GLuint texture, bool force = false);
|
||||
void active_texture(size_t index, bool force = false);
|
||||
void bind_framebuffer(GLuint framebuffer, bool force = false);
|
||||
void bind_read_framebuffer(GLuint framebuffer, bool force = false);
|
||||
void bind_draw_framebuffer(GLuint framebuffer, bool force = false);
|
||||
void bind_vertex_array(GLuint array, bool force = false);
|
||||
void bind_array_buffer(GLuint buffer, bool force = false);
|
||||
void bind_element_array_buffer(GLuint buffer, bool force = false);
|
||||
void bind_uniform_buffer(GLuint buffer, bool force = false);
|
||||
void bind_uniform_buffer_base(GLuint index, GLuint buffer, bool force = false);
|
||||
p_gl_rend_state(gl_rend_state_index index);
|
||||
|
||||
void active_bind_texture_2d(int32_t index, GLuint texture);
|
||||
void active_bind_texture_cube_map(int32_t index, GLuint texture);
|
||||
void active_texture(int32_t index);
|
||||
void begin_event(const char* message, int32_t length);
|
||||
void bind_framebuffer(GLuint framebuffer);
|
||||
void bind_read_framebuffer(GLuint framebuffer);
|
||||
void bind_draw_framebuffer(GLuint framebuffer);
|
||||
void bind_vertex_array(GLuint array);
|
||||
void bind_array_buffer(GLuint buffer);
|
||||
void bind_element_array_buffer(GLuint buffer);
|
||||
void bind_uniform_buffer(GLuint buffer);
|
||||
void bind_uniform_buffer_base(GLuint index, GLuint buffer);
|
||||
void bind_uniform_buffer_range(GLuint index,
|
||||
GLuint buffer, GLintptr offset, GLsizeiptr size, bool force = false);
|
||||
void bind_shader_storage_buffer(GLuint buffer, bool force = false);
|
||||
void bind_shader_storage_buffer_base(GLuint index, GLuint buffer, bool force = false);
|
||||
GLuint buffer, GLintptr offset, GLsizeiptr size);
|
||||
void bind_shader_storage_buffer(GLuint buffer);
|
||||
void bind_shader_storage_buffer_base(GLuint index, GLuint buffer);
|
||||
void bind_shader_storage_buffer_range(GLuint index,
|
||||
GLuint buffer, GLintptr offset, GLsizeiptr size, bool force = false);
|
||||
void bind_texture_2d(GLuint texture, bool force = false);
|
||||
void bind_texture_cube_map(GLuint texture, bool force = false);
|
||||
void bind_sampler(int32_t index, GLuint sampler, bool force = false);
|
||||
bool check_uniform_buffer_binding();
|
||||
bool check_uniform_buffer_binding_base(size_t index);
|
||||
bool check_shader_storage_buffer_binding();
|
||||
bool check_shader_storage_buffer_binding_base(size_t index);
|
||||
bool check_texture_binding_2d(size_t index);
|
||||
bool check_texture_binding_cube_map(size_t index);
|
||||
bool check_sampler_binding(int32_t index, GLuint sampler);
|
||||
void disable_blend(bool force = false);
|
||||
void disable_cull_face(bool force = false);
|
||||
void disable_depth_test(bool force = false);
|
||||
void disable_multisample(bool force = false);
|
||||
void disable_primitive_restart(bool force = false);
|
||||
void disable_scissor_test(bool force = false);
|
||||
void disable_stencil_test(bool force = false);
|
||||
void enable_blend(bool force = false);
|
||||
void enable_cull_face(bool force = false);
|
||||
void enable_depth_test(bool force = false);
|
||||
void enable_multisample(bool force = false);
|
||||
void enable_primitive_restart(bool force = false);
|
||||
void enable_scissor_test(bool force = false);
|
||||
void enable_stencil_test(bool force = false);
|
||||
GLuint buffer, GLintptr offset, GLsizeiptr size);
|
||||
void bind_texture_2d(GLuint texture);
|
||||
void bind_texture_cube_map(GLuint texture);
|
||||
void bind_sampler(int32_t index, GLuint sampler);
|
||||
void blit_framebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
|
||||
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
|
||||
GLenum check_framebuffer_status(GLenum target);
|
||||
void clear(GLbitfield mask);
|
||||
void clear_buffer(GLenum buffer, GLint drawbuffer, const GLfloat* value);
|
||||
void clear_color(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
|
||||
void clear_depth(GLfloat depth);
|
||||
void clear_stencil(GLint stencil);
|
||||
void copy_image_sub_data(GLuint srcName, GLenum srcTarget, GLint srcLevel,
|
||||
GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel,
|
||||
GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);
|
||||
void copy_tex_sub_image_2d(GLenum target, GLint level,
|
||||
GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
void disable_blend();
|
||||
void disable_cull_face();
|
||||
void disable_depth_test();
|
||||
void disable_multisample();
|
||||
void disable_primitive_restart();
|
||||
void disable_scissor_test();
|
||||
void disable_stencil_test();
|
||||
void draw_arrays(GLenum mode, GLint first, GLsizei count);
|
||||
void draw_elements(GLenum mode,
|
||||
GLsizei count, GLenum type, const void* indices);
|
||||
void draw_range_elements(GLenum mode,
|
||||
GLuint start, GLuint end, GLsizei count, GLenum type, const void* indices);
|
||||
void enable_blend();
|
||||
void enable_cull_face();
|
||||
void enable_depth_test();
|
||||
void enable_multisample();
|
||||
void enable_primitive_restart();
|
||||
void enable_scissor_test();
|
||||
void enable_stencil_test();
|
||||
void end_event();
|
||||
void generate_mipmap(GLenum target);
|
||||
void generate_texture_mipmap(GLuint texture);
|
||||
void get();
|
||||
void get_clear_color(GLfloat& red, GLfloat& green, GLfloat& blue, GLfloat& alpha);
|
||||
GLuint get_program();
|
||||
gl_rend_state_rect get_scissor();
|
||||
void get_scissor(GLint& x, GLint& y, GLsizei& width, GLsizei& height);
|
||||
gl_rend_state_rect get_viewport();
|
||||
void get_viewport(GLint& x, GLint& y, GLsizei& width, GLsizei& height);
|
||||
void set_blend_func(GLenum src, GLenum dst, bool force = false);
|
||||
void set_blend_func(GLenum src, GLenum dst);
|
||||
void set_blend_func_separate(GLenum src_rgb, GLenum dst_rgb,
|
||||
GLenum src_alpha, GLenum dst_alpha, bool force = false);
|
||||
void set_blend_equation(GLenum mode, bool force = false);
|
||||
GLenum src_alpha, GLenum dst_alpha);
|
||||
void set_blend_equation(GLenum mode);
|
||||
void set_blend_equation_separate(
|
||||
GLenum mode_rgb, GLenum mode_alpha, bool force = false);
|
||||
void set_color_mask(GLboolean red, GLboolean green,
|
||||
GLboolean blue, GLboolean alpha, bool force = false);
|
||||
void set_cull_face_mode(GLenum mode, bool force = false);
|
||||
void set_depth_func(GLenum func, bool force = false);
|
||||
void set_depth_mask(GLboolean flag, bool force = false);
|
||||
void set_line_width(GLfloat width, bool force = false);
|
||||
void set_polygon_mode(GLenum face, GLenum mode, bool force = false);
|
||||
void set_primitive_restart_index(GLuint index, bool force = false);
|
||||
void set_scissor(const gl_rend_state_rect& rect, bool force = false);
|
||||
void set_scissor(GLint x, GLint y, GLsizei width, GLsizei height, bool force = false);
|
||||
void set_stencil_func(GLenum func, GLint ref, GLuint mask, bool force = false);
|
||||
void set_stencil_mask(GLuint mask, bool force = false);
|
||||
void set_stencil_op(GLenum sfail, GLenum dpfail, GLenum dppass, bool force = false);
|
||||
void set_viewport(const gl_rend_state_rect& rect, bool force = false);
|
||||
void set_viewport(GLint x, GLint y, GLsizei width, GLsizei height, bool force = false);
|
||||
void use_program(GLuint program, bool force = false);
|
||||
GLenum mode_rgb, GLenum mode_alpha);
|
||||
void set_color_mask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
|
||||
void set_cull_face_mode(GLenum mode);
|
||||
void set_depth_func(GLenum func);
|
||||
void set_depth_mask(GLboolean flag);
|
||||
void set_line_width(GLfloat width);
|
||||
void set_primitive_restart_index(GLuint index);
|
||||
void set_scissor(const gl_rend_state_rect& rect);
|
||||
void set_scissor(GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
void set_stencil_func(GLenum func, GLint ref, GLuint mask);
|
||||
void set_stencil_mask(GLuint mask);
|
||||
void set_stencil_op(GLenum sfail, GLenum dpfail, GLenum dppass);
|
||||
void set_viewport(const gl_rend_state_rect& rect);
|
||||
void set_viewport(GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
void update();
|
||||
void use_program(GLuint program);
|
||||
|
||||
template <size_t size>
|
||||
inline void begin_event(const char(&str)[size]) {
|
||||
glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, (GLsizei)(size - 1), str);
|
||||
begin_event(str, (GLsizei)(size - 1));
|
||||
}
|
||||
|
||||
inline void end_event() {
|
||||
glPopDebugGroup();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
extern gl_rend_state_struct gl_rend_state;
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "gl_state.hpp"
|
||||
|
||||
gl_state_struct gl_state;
|
||||
|
||||
void gl_state_struct::bind_framebuffer(GLuint framebuffer, bool force) {
|
||||
if (force || read_framebuffer_binding != framebuffer
|
||||
|| draw_framebuffer_binding != framebuffer) {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
|
||||
read_framebuffer_binding = framebuffer;
|
||||
draw_framebuffer_binding = framebuffer;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_struct::bind_read_framebuffer(GLuint framebuffer, bool force) {
|
||||
if (force || read_framebuffer_binding != framebuffer) {
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer);
|
||||
read_framebuffer_binding = framebuffer;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_struct::bind_draw_framebuffer(GLuint framebuffer, bool force) {
|
||||
if (force || draw_framebuffer_binding != framebuffer) {
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer);
|
||||
draw_framebuffer_binding = framebuffer;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_struct::bind_vertex_array(GLuint array, bool force) {
|
||||
if (force || vertex_array_binding != array) {
|
||||
glBindVertexArray(array);
|
||||
vertex_array_binding = array;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_struct::bind_array_buffer(GLuint buffer, bool force) {
|
||||
if (force || array_buffer_binding != buffer) {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
||||
array_buffer_binding = buffer;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_struct::bind_element_array_buffer(GLuint buffer, bool force) {
|
||||
if (force || element_array_buffer_binding != buffer) {
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer);
|
||||
element_array_buffer_binding = buffer;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_struct::bind_uniform_buffer(GLuint buffer, bool force) {
|
||||
if (force || uniform_buffer_binding != buffer) {
|
||||
glBindBuffer(GL_UNIFORM_BUFFER, buffer);
|
||||
uniform_buffer_binding = buffer;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_struct::bind_shader_storage_buffer(GLuint buffer, bool force) {
|
||||
if (force || shader_storage_buffer_binding != buffer) {
|
||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, buffer);
|
||||
shader_storage_buffer_binding = buffer;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_struct::bind_texture_2d(GLuint texture, bool force) {
|
||||
if (texture_binding_2d != texture) {
|
||||
glBindTextureDLL(GL_TEXTURE_2D, texture);
|
||||
texture_binding_2d = texture;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_struct::bind_texture_cube_map(GLuint texture, bool force) {
|
||||
if (force || texture_binding_cube_map != texture) {
|
||||
glBindTextureDLL(GL_TEXTURE_CUBE_MAP, texture);
|
||||
texture_binding_cube_map = texture;
|
||||
}
|
||||
}
|
||||
|
||||
bool gl_state_struct::check_uniform_buffer_binding() {
|
||||
return uniform_buffer_binding != 0;
|
||||
}
|
||||
|
||||
bool gl_state_struct::check_shader_storage_buffer_binding() {
|
||||
return shader_storage_buffer_binding != 0;
|
||||
}
|
||||
|
||||
bool gl_state_struct::check_texture_binding_2d() {
|
||||
return texture_binding_2d != 0;
|
||||
}
|
||||
|
||||
bool gl_state_struct::check_texture_binding_cube_map() {
|
||||
return texture_binding_cube_map != 0;
|
||||
}
|
||||
|
||||
void gl_state_struct::get() {
|
||||
glGetIntegervDLL(GL_TEXTURE_BINDING_2D, (GLint*)&texture_binding_2d);
|
||||
glGetIntegervDLL(GL_TEXTURE_BINDING_CUBE_MAP, (GLint*)&texture_binding_cube_map);
|
||||
|
||||
glGetIntegervDLL(GL_READ_FRAMEBUFFER_BINDING, (GLint*)&read_framebuffer_binding);
|
||||
glGetIntegervDLL(GL_DRAW_FRAMEBUFFER_BINDING, (GLint*)&draw_framebuffer_binding);
|
||||
glGetIntegervDLL(GL_VERTEX_ARRAY_BINDING, (GLint*)&vertex_array_binding);
|
||||
glGetIntegervDLL(GL_ARRAY_BUFFER_BINDING, (GLint*)&array_buffer_binding);
|
||||
glGetIntegervDLL(GL_ELEMENT_ARRAY_BUFFER_BINDING, (GLint*)&element_array_buffer_binding);
|
||||
|
||||
glGetIntegervDLL(GL_UNIFORM_BUFFER_BINDING, (GLint*)&uniform_buffer_binding);
|
||||
glGetIntegervDLL(GL_SHADER_STORAGE_BUFFER_BINDING, (GLint*)&shader_storage_buffer_binding);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "wrap.hpp"
|
||||
|
||||
struct gl_state_struct {
|
||||
GLuint texture_binding_2d;
|
||||
GLuint texture_binding_cube_map;
|
||||
GLuint read_framebuffer_binding;
|
||||
GLuint draw_framebuffer_binding;
|
||||
GLuint vertex_array_binding;
|
||||
GLuint array_buffer_binding;
|
||||
GLuint element_array_buffer_binding;
|
||||
GLuint uniform_buffer_binding;
|
||||
GLuint shader_storage_buffer_binding;
|
||||
|
||||
void bind_framebuffer(GLuint framebuffer, bool force = false);
|
||||
void bind_read_framebuffer(GLuint framebuffer, bool force = false);
|
||||
void bind_draw_framebuffer(GLuint framebuffer, bool force = false);
|
||||
void bind_vertex_array(GLuint array, bool force = false);
|
||||
void bind_array_buffer(GLuint buffer, bool force = false);
|
||||
void bind_element_array_buffer(GLuint buffer, bool force = false);
|
||||
void bind_uniform_buffer(GLuint buffer, bool force = false);
|
||||
void bind_shader_storage_buffer(GLuint buffer, bool force = false);
|
||||
void bind_texture_2d(GLuint texture, bool force = false);
|
||||
void bind_texture_cube_map(GLuint texture, bool force = false);
|
||||
bool check_uniform_buffer_binding();
|
||||
bool check_shader_storage_buffer_binding();
|
||||
bool check_texture_binding_2d();
|
||||
bool check_texture_binding_cube_map();
|
||||
void get();
|
||||
};
|
||||
|
||||
extern gl_state_struct gl_state;
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "color_change_dw.hpp"
|
||||
#include "../../AFTModsShared/dw.hpp"
|
||||
#include "../rob/rob.hpp"
|
||||
#include "../gl_rend_state.hpp"
|
||||
#include "../gl_state.hpp"
|
||||
#include "../shared.hpp"
|
||||
#include "../texture.hpp"
|
||||
#include <Helpers.h>
|
||||
@@ -121,7 +121,7 @@ HOOK(void, FASTCALL, ColorChangeDw__Draw, 0x00000001402C2170, ColorChangeDw* Thi
|
||||
else
|
||||
dxt5_image_apply_color_tone(width_align, height_align, size, (dxt5_block*)data, col_tone);
|
||||
|
||||
gl_rend_state.bind_texture_2d(org_tex->glid);
|
||||
gl_state.bind_texture_2d(org_tex->glid);
|
||||
int32_t width = chg_tex->get_width_mip_level(i);
|
||||
int32_t height = chg_tex->get_height_mip_level(i);
|
||||
glCompressedTexSubImage2D(org_tex->target, i, 0, 0, width, height,
|
||||
@@ -130,7 +130,7 @@ HOOK(void, FASTCALL, ColorChangeDw__Draw, 0x00000001402C2170, ColorChangeDw* Thi
|
||||
else if (chg_tex->internal_format == GL_RGB5) {
|
||||
rgb565_image_apply_color_tone(width_align, height_align, size, (rgb565*)data, col_tone);
|
||||
|
||||
gl_rend_state.bind_texture_2d(org_tex->glid);
|
||||
gl_state.bind_texture_2d(org_tex->glid);
|
||||
int32_t width = chg_tex->get_width_mip_level(i);
|
||||
int32_t height = chg_tex->get_height_mip_level(i);
|
||||
glTexSubImage2DDLL(org_tex->target, i, 0, 0, width, height,
|
||||
@@ -139,7 +139,7 @@ HOOK(void, FASTCALL, ColorChangeDw__Draw, 0x00000001402C2170, ColorChangeDw* Thi
|
||||
gl_get_error_print();
|
||||
prj::HeapCMallocFree(prj::HeapCMallocTemp, data);
|
||||
}
|
||||
gl_rend_state.bind_texture_2d(0);
|
||||
gl_state.bind_texture_2d(0);
|
||||
}
|
||||
|
||||
if (This->show) {
|
||||
@@ -249,7 +249,7 @@ bool ColorChangeDw::LoadTexture() {
|
||||
return false;
|
||||
|
||||
int32_t tex_num = objset_info_storage_get_set_tex_num(obj_set_id);
|
||||
|
||||
|
||||
/*for (int32_t i = 0; i < tex_num; i++) {
|
||||
::texture* chg_tex = 0;
|
||||
::texture* org_tex = textures[i];
|
||||
@@ -281,7 +281,7 @@ bool ColorChangeDw::LoadTexture() {
|
||||
|
||||
int32_t width_align = org_tex->get_width_align_mip_level(i);
|
||||
int32_t height_align = org_tex->get_height_align_mip_level(i);
|
||||
gl_rend_state.bind_texture_2d(org_tex->glid);
|
||||
gl_state.bind_texture_2d(org_tex->glid);
|
||||
if (org_tex->flags & TEXTURE_BLOCK_COMPRESSION)
|
||||
glGetCompressedTexImage(org_tex->target, i, data);
|
||||
else
|
||||
|
||||
+21
-42
@@ -13,6 +13,7 @@
|
||||
#include "auth_3d.hpp"
|
||||
#include "camera.hpp"
|
||||
#include "effect.hpp"
|
||||
#include "gl_state.hpp"
|
||||
#include "light_param.hpp"
|
||||
#include "object.hpp"
|
||||
#include "print.hpp"
|
||||
@@ -113,13 +114,15 @@ HOOK(int32_t, FASTCALL, data_free, 0x000000140192490) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
HOOK(void, FASTCALL, sub_140194CD0, 0x000000140194CD0) {
|
||||
HOOK(void, FASTCALL, display_callback, 0x000000140194CD0) {
|
||||
rctx->ctrl();
|
||||
originalsub_140194CD0();
|
||||
originaldisplay_callback();
|
||||
render_data_context rend_data_ctx(GL_REND_STATE_POST_2D);
|
||||
rend_data_ctx.state.update();
|
||||
}
|
||||
|
||||
HOOK(void, FASTCALL, gl_rend_state__get, 0x0000000140442DF0) {
|
||||
gl_rend_state.get();
|
||||
|
||||
}
|
||||
|
||||
HOOK(void, FASTCALL, rndr__Render__update_res, 0x00000001404A9480, rndr::Render* rend, bool set, int32_t base_downsample) {
|
||||
@@ -128,11 +131,12 @@ HOOK(void, FASTCALL, rndr__Render__update_res, 0x00000001404A9480, rndr::Render*
|
||||
|
||||
HOOK(void, FASTCALL, rndr__Render__take_ss, 0x00000001404A9CD0,
|
||||
rndr::Render* rend, texture* tex, bool vertical, float_t horizontal_offset) {
|
||||
rend->take_ss(tex, vertical, horizontal_offset);
|
||||
render_data_context rend_data_ctx(GL_REND_STATE_POST_2D);
|
||||
rend->take_ss(rend_data_ctx, tex, vertical, horizontal_offset);
|
||||
}
|
||||
|
||||
HOOK(void, FASTCALL, rndr__Render__init_tone_map_buffers, 0x00000001404A9FF0, rndr::Render* rend) {
|
||||
rend->init_tone_map_buffers();
|
||||
HOOK(void, FASTCALL, rndr__Render__init_post_process_buffers, 0x00000001404A9FF0, rndr::Render* rend) {
|
||||
rend->init_post_process_buffers();
|
||||
}
|
||||
|
||||
HOOK(void, FASTCALL, rndr__Render__init_render_buffers, 0x00000001404AB0C0, rndr::Render* rend,
|
||||
@@ -165,12 +169,13 @@ HOOK(void, FASTCALL, rndr__Render__movie_texture_free, 0x00000001404B18F0,
|
||||
}
|
||||
|
||||
HOOK(void, FASTCALL, rndr__RenderManager__rndpass_pre_proc, 0x0000000140502C90) {
|
||||
gl_rend_state.begin_event("rndpass_pre_proc");
|
||||
render_manager.render->pre_proc();
|
||||
render_data_context rend_data_ctx(GL_REND_STATE_PRE_3D);
|
||||
rend_data_ctx.state.begin_event("rndpass_pre_proc");
|
||||
render_manager.render->pre_proc(rend_data_ctx);
|
||||
Glitter::glt_particle_manager->CalcDisp();
|
||||
Glitter::glt_particle_manager_x->CalcDisp();
|
||||
rctx->pre_proc();
|
||||
gl_rend_state.end_event();
|
||||
rend_data_ctx.state.end_event();
|
||||
}
|
||||
|
||||
HOOK(void, FASTCALL, rndr__RenderManager__render_all, 0x0000000140502CA0) {
|
||||
@@ -178,40 +183,14 @@ HOOK(void, FASTCALL, rndr__RenderManager__render_all, 0x0000000140502CA0) {
|
||||
}
|
||||
|
||||
HOOK(void, FASTCALL, rndr__RenderManager__rndpass_post_proc, 0x0000000140502C70) {
|
||||
gl_rend_state.begin_event("rndpass_post_proc");
|
||||
render_data_context rend_data_ctx(GL_REND_STATE_POST_2D);
|
||||
rend_data_ctx.state.begin_event("rndpass_post_proc");
|
||||
rctx->post_proc();
|
||||
render_manager.render->post_proc();
|
||||
render_manager.field_31C = false;
|
||||
gl_rend_state.end_event();
|
||||
rend_data_ctx.state.end_event();
|
||||
}
|
||||
|
||||
struct ScreenShotData {
|
||||
prj::string path;
|
||||
int32_t format;
|
||||
bool screen_shot_4x;
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
GLuint buffer;
|
||||
const void* tex_data;
|
||||
};
|
||||
|
||||
struct ScreenShotImpl {
|
||||
void* __vftable;
|
||||
prj::string path;
|
||||
int32_t format;
|
||||
bool screen_shot_4x;
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
int32_t curr_width;
|
||||
int32_t curr_height;
|
||||
bool capture;
|
||||
texture* tex;
|
||||
GLuint data_buffers[2];
|
||||
ScreenShotData ss_data[2];
|
||||
int32_t data_buffer_index;
|
||||
void* thread; // Thrd_t
|
||||
};
|
||||
|
||||
HOOK(void, FASTCALL, shader_free, 0x00000001405E4DB0) {
|
||||
shaders_ft.unload();
|
||||
}
|
||||
@@ -236,11 +215,11 @@ HOOK(int32_t, FASTCALL, shader_get_index_by_name, 0x00000001405E4ED0, const char
|
||||
}
|
||||
|
||||
HOOK(void, FASTCALL, env_set_blend_color, 0x00000001405E5600, float_t r, float_t g, float_t b, float_t a) {
|
||||
rctx->set_batch_blend_color({ r, g, b, a });
|
||||
|
||||
}
|
||||
|
||||
HOOK(void, FASTCALL, env_set_offset_color, 0x00000001405E5630, float_t r, float_t g, float_t b, float_t a) {
|
||||
rctx->set_batch_offset_color({ r, g, b, a });
|
||||
|
||||
}
|
||||
|
||||
HOOK(void, FASTCALL, set_render_defaults, 0x00000001401948B0) {
|
||||
@@ -277,13 +256,13 @@ void hook_funcs() {
|
||||
INSTALL_HOOK(data_init);
|
||||
INSTALL_HOOK(data_free);
|
||||
|
||||
INSTALL_HOOK(sub_140194CD0);
|
||||
INSTALL_HOOK(display_callback);
|
||||
|
||||
INSTALL_HOOK(gl_rend_state__get);
|
||||
|
||||
INSTALL_HOOK(rndr__Render__update_res);
|
||||
INSTALL_HOOK(rndr__Render__take_ss);
|
||||
INSTALL_HOOK(rndr__Render__init_tone_map_buffers);
|
||||
INSTALL_HOOK(rndr__Render__init_post_process_buffers);
|
||||
INSTALL_HOOK(rndr__Render__init_render_buffers);
|
||||
INSTALL_HOOK(rndr__Render__free);
|
||||
INSTALL_HOOK(rndr__Render__render_texture_set);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "../KKdLib/hash.hpp"
|
||||
#include "../KKdLib/str_utils.hpp"
|
||||
#include "../AFTModsShared/file_handler.hpp"
|
||||
#include "gl_state.hpp"
|
||||
#include "render_context.hpp"
|
||||
#include <Helpers.h>
|
||||
|
||||
@@ -241,19 +242,13 @@ void light_param_patch() {
|
||||
INSTALL_HOOK(light_param_data_storage__delete_textures);
|
||||
}
|
||||
|
||||
void light_param_data_storage_data_set_ibl() {
|
||||
static const int32_t ibl_texture_index[] = {
|
||||
9, 10, 11, 12, 13
|
||||
};
|
||||
|
||||
for (int32_t i = 0; i < 5; i++)
|
||||
gl_rend_state.active_bind_texture_cube_map(ibl_texture_index[i],
|
||||
light_param_data_storage_data->textures[i]);
|
||||
const GLuint* light_param_data_storage_data_get_ibl_textures() {
|
||||
return light_param_data_storage_data->textures;
|
||||
}
|
||||
|
||||
void light_param_data::set_ibl(const light_param_data_ibl* ibl, const light_param_data_storage* storage) {
|
||||
for (int32_t i = 0, j = -1; i < 5; i++, j++) {
|
||||
gl_rend_state.bind_texture_cube_map(storage->textures[i]);
|
||||
gl_state.bind_texture_cube_map(storage->textures[i]);
|
||||
glTexParameteriDLL(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteriDLL(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteriDLL(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
||||
@@ -279,7 +274,7 @@ void light_param_data::set_ibl(const light_param_data_ibl* ibl, const light_para
|
||||
light_param_data::set_ibl_specular(&ibl->specular[j]);
|
||||
}
|
||||
}
|
||||
gl_rend_state.bind_texture_cube_map(0);
|
||||
gl_state.bind_texture_cube_map(0);
|
||||
|
||||
::light_set* set = &light_set_data[LIGHT_SET_MAIN];
|
||||
set->set_irradiance(ibl->diff_coef[1][0], ibl->diff_coef[1][1], ibl->diff_coef[1][2]);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../AFTModsShared/types.hpp"
|
||||
#include "wrap.hpp"
|
||||
|
||||
extern void light_param_patch();
|
||||
extern void light_param_data_storage_data_set_ibl();
|
||||
extern const GLuint* light_param_data_storage_data_get_ibl_textures();
|
||||
|
||||
+179
-166
@@ -10,6 +10,7 @@
|
||||
#include "../Glitter/glitter.hpp"
|
||||
#include "../rob/rob.hpp"
|
||||
#include "../gl_rend_state.hpp"
|
||||
#include "../gl_state.hpp"
|
||||
#include "../object.hpp"
|
||||
#include "../render_manager.hpp"
|
||||
#include "../shader_ft.hpp"
|
||||
@@ -49,7 +50,7 @@ static void rob_chara_item_cos_data_disp_item_object(rob_chara_item_cos_data* it
|
||||
object_info obj_info, const mat4& mat, int32_t item_no);
|
||||
static void rob_chara_item_cos_data_set_chara_index(rob_chara_item_cos_data* item_cos_data, ::chara_index chara_index);
|
||||
|
||||
static void sub_140436760(mat4* view);
|
||||
static void sub_140436760(const cam_data& cam);
|
||||
|
||||
extern bool reflect_draw;
|
||||
extern mat4 reflect_mat;
|
||||
@@ -293,17 +294,19 @@ namespace mdl {
|
||||
void DispManager::vertex_array::reset_vertex_attrib() {
|
||||
alive_time = 0;
|
||||
vertex_buffer = 0;
|
||||
vertex_buffer_offset = 0;
|
||||
morph_vertex_buffer = 0;
|
||||
morph_vertex_buffer_offset = 0;
|
||||
|
||||
gl_rend_state.bind_vertex_array(vertex_array);
|
||||
gl_state.bind_vertex_array(vertex_array);
|
||||
for (int32_t i = 0; i < 16; i++)
|
||||
if (vertex_attrib_array[i]) {
|
||||
glDisableVertexAttribArray(i);
|
||||
vertex_attrib_array[i] = false;
|
||||
}
|
||||
gl_rend_state.bind_array_buffer(0, true);
|
||||
gl_rend_state.bind_element_array_buffer(0, true);
|
||||
gl_rend_state.bind_vertex_array(0);
|
||||
gl_state.bind_array_buffer(0, true);
|
||||
gl_state.bind_element_array_buffer(0, true);
|
||||
gl_state.bind_vertex_array(0);
|
||||
}
|
||||
|
||||
void DispManager::add_vertex_array(ObjSubMeshArgs* args) {
|
||||
@@ -374,10 +377,11 @@ namespace mdl {
|
||||
vertex_array = &vertex_array_cache.back();
|
||||
}
|
||||
|
||||
bool new_vertex_array = false;
|
||||
if (!vertex_array->vertex_array) {
|
||||
glGenVertexArrays(1, &vertex_array->vertex_array);
|
||||
|
||||
gl_rend_state.bind_vertex_array(vertex_array->vertex_array);
|
||||
gl_state.bind_vertex_array(vertex_array->vertex_array);
|
||||
glVertexAttrib4f( POSITION_INDEX, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glVertexAttrib4f( BONE_WEIGHT_INDEX, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glVertexAttrib4f( NORMAL_INDEX, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
@@ -394,6 +398,7 @@ namespace mdl {
|
||||
glVertexAttrib4f(MORPH_TEXCOORD0_INDEX, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glVertexAttrib4f(MORPH_TEXCOORD1_INDEX, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glVertexAttrib4f( BONE_INDEX_INDEX, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
new_vertex_array = true;
|
||||
}
|
||||
|
||||
vertex_array->vertex_buffer = vertex_buffer;
|
||||
@@ -409,10 +414,11 @@ namespace mdl {
|
||||
memcpy(&vertex_array->vertex_attrib_buffer_binding,
|
||||
vertex_attrib_buffer_binding, sizeof(vertex_attrib_buffer_binding));
|
||||
|
||||
gl_rend_state.bind_vertex_array(vertex_array->vertex_array);
|
||||
gl_rend_state.bind_array_buffer(vertex_buffer, true);
|
||||
if (!new_vertex_array)
|
||||
gl_state.bind_vertex_array(vertex_array->vertex_array);
|
||||
gl_state.bind_array_buffer(vertex_buffer, true);
|
||||
if (index_buffer)
|
||||
gl_rend_state.bind_element_array_buffer(index_buffer, true);
|
||||
gl_state.bind_element_array_buffer(index_buffer, true);
|
||||
|
||||
size_t offset = vertex_buffer_offset;
|
||||
if (vertex_format & OBJ_VERTEX_POSITION) {
|
||||
@@ -424,7 +430,7 @@ namespace mdl {
|
||||
glVertexAttribPointer(POSITION_INDEX,
|
||||
3, GL_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 12;
|
||||
}
|
||||
}
|
||||
else if (vertex_array->vertex_attrib_array[POSITION_INDEX]) {
|
||||
glDisableVertexAttribArray(POSITION_INDEX);
|
||||
vertex_array->vertex_attrib_array[POSITION_INDEX] = false;
|
||||
@@ -651,7 +657,7 @@ namespace mdl {
|
||||
}
|
||||
|
||||
if (morph_vertex_buffer) {
|
||||
gl_rend_state.bind_array_buffer(morph_vertex_buffer, true);
|
||||
gl_state.bind_array_buffer(morph_vertex_buffer, true);
|
||||
|
||||
size_t offset = morph_vertex_buffer_offset;
|
||||
if (vertex_format & OBJ_VERTEX_POSITION) {
|
||||
@@ -802,8 +808,6 @@ namespace mdl {
|
||||
}
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_COLOR0) {
|
||||
uniform->arr[U_MORPH_COLOR] = 1;
|
||||
|
||||
if (!vertex_array->vertex_attrib_array[MORPH_COLOR_INDEX]) {
|
||||
glEnableVertexAttribArray(MORPH_COLOR_INDEX);
|
||||
vertex_array->vertex_attrib_array[MORPH_COLOR_INDEX] = true;
|
||||
@@ -883,10 +887,10 @@ namespace mdl {
|
||||
}
|
||||
}
|
||||
|
||||
gl_rend_state.bind_array_buffer(0);
|
||||
gl_rend_state.bind_vertex_array(0);
|
||||
gl_state.bind_array_buffer(0);
|
||||
gl_state.bind_vertex_array(0);
|
||||
if (index_buffer)
|
||||
gl_rend_state.bind_element_array_buffer(0);
|
||||
gl_state.bind_element_array_buffer(0);
|
||||
}
|
||||
|
||||
static size_t gen_grid_vertices(prj::vector<prj::pair<vec3, vec3>>& data,
|
||||
@@ -1647,10 +1651,11 @@ namespace mdl {
|
||||
etc_vertex_array = &etc_vertex_array_cache.back();
|
||||
}
|
||||
|
||||
bool new_vertex_array = false;
|
||||
if (!etc_vertex_array->vertex_array) {
|
||||
glGenVertexArrays(1, &etc_vertex_array->vertex_array);
|
||||
|
||||
gl_rend_state.bind_vertex_array(etc_vertex_array->vertex_array);
|
||||
gl_state.bind_vertex_array(etc_vertex_array->vertex_array);
|
||||
glVertexAttrib4f( POSITION_INDEX, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glVertexAttrib4f( BONE_WEIGHT_INDEX, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glVertexAttrib4f( NORMAL_INDEX, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
@@ -1667,11 +1672,13 @@ namespace mdl {
|
||||
glVertexAttrib4f(MORPH_TEXCOORD0_INDEX, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glVertexAttrib4f(MORPH_TEXCOORD1_INDEX, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glVertexAttrib4f( BONE_INDEX_INDEX, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
new_vertex_array = true;
|
||||
}
|
||||
|
||||
etc_vertex_array->alive_time = 2;
|
||||
etc_vertex_array->data = etc->data;
|
||||
etc_vertex_array->type = type;
|
||||
etc_vertex_array->indexed = indexed;
|
||||
|
||||
prj::vector<prj::pair<vec3, vec3>> vtx_data;
|
||||
prj::vector<uint32_t> vtx_indices;
|
||||
@@ -1787,20 +1794,21 @@ namespace mdl {
|
||||
|
||||
GLsizei size_vertex = sizeof(vec3) * 2;
|
||||
|
||||
gl_rend_state.bind_vertex_array(etc_vertex_array->vertex_array);
|
||||
if (!new_vertex_array)
|
||||
gl_state.bind_vertex_array(etc_vertex_array->vertex_array);
|
||||
|
||||
if (etc_vertex_array->vertex_buffer.IsNull())
|
||||
etc_vertex_array->vertex_buffer.Create(sizeof(vec3) * 2 * vtx_data.size());
|
||||
etc_vertex_array->vertex_buffer.Create(gl_state, sizeof(vec3) * 2 * vtx_data.size());
|
||||
|
||||
etc_vertex_array->vertex_buffer.Bind(true);
|
||||
gl_state.bind_array_buffer(etc_vertex_array->vertex_buffer, true);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vec3) * 2
|
||||
* vtx_data.size(), vtx_data.data());
|
||||
|
||||
if (indexed) {
|
||||
if (etc_vertex_array->index_buffer.IsNull())
|
||||
etc_vertex_array->index_buffer.Create(sizeof(uint32_t) * vtx_indices.size());
|
||||
etc_vertex_array->index_buffer.Create(gl_state, sizeof(uint32_t) * vtx_indices.size());
|
||||
|
||||
etc_vertex_array->index_buffer.Bind(true);
|
||||
gl_state.bind_element_array_buffer(etc_vertex_array->index_buffer, true);
|
||||
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(uint32_t)
|
||||
* vtx_indices.size(), vtx_indices.data());
|
||||
}
|
||||
@@ -1813,10 +1821,10 @@ namespace mdl {
|
||||
glVertexAttribPointer(NORMAL_INDEX,
|
||||
3, GL_FLOAT, GL_FALSE, size_vertex, (void*)sizeof(vec3));
|
||||
|
||||
gl_rend_state.bind_array_buffer(0);
|
||||
gl_rend_state.bind_vertex_array(0);
|
||||
gl_state.bind_array_buffer(0);
|
||||
gl_state.bind_vertex_array(0);
|
||||
if (indexed)
|
||||
gl_rend_state.bind_element_array_buffer(0);
|
||||
gl_state.bind_element_array_buffer(0);
|
||||
}
|
||||
|
||||
void* DispManager::alloc_data(int32_t size) {
|
||||
@@ -1853,7 +1861,7 @@ namespace mdl {
|
||||
buff_offset = 0;
|
||||
}
|
||||
|
||||
void DispManager::calc_obj_radius(mat4* view, ObjType type) {
|
||||
void DispManager::calc_obj_radius(const cam_data& cam, ObjType type) {
|
||||
prj::vector<vec3> alpha_center;
|
||||
prj::vector<vec3> mat_center;
|
||||
|
||||
@@ -1864,9 +1872,9 @@ namespace mdl {
|
||||
case OBJ_KIND_NORMAL: {
|
||||
mat4 mat = i->mat;
|
||||
if (i->args.sub_mesh.mesh->attrib.m.billboard)
|
||||
model_mat_face_camera_view(view, &mat, &mat);
|
||||
model_mat_face_camera_view(cam, &mat, &mat);
|
||||
else if (i->args.sub_mesh.mesh->attrib.m.billboard_y_axis)
|
||||
model_mat_face_camera_position(view, &mat, &mat);
|
||||
model_mat_face_camera_position(cam, &mat, &mat);
|
||||
|
||||
get_obj_center(mat, &i->args.sub_mesh, center);
|
||||
|
||||
@@ -1900,7 +1908,7 @@ namespace mdl {
|
||||
if (show_mat_center && type == OBJ_TYPE_TRANSLUCENT && v50)
|
||||
mat_center.push_back(center);
|
||||
|
||||
mat4_transform_point(view, ¢er, ¢er);
|
||||
mat4_transform_point(&cam.get_view_mat(), ¢er, ¢er);
|
||||
i->view_z = center.z;
|
||||
}
|
||||
|
||||
@@ -1935,7 +1943,7 @@ namespace mdl {
|
||||
}
|
||||
}
|
||||
|
||||
void DispManager::calc_obj_radius(mat4* view, ObjTypeLocal type) {
|
||||
void DispManager::calc_obj_radius(const cam_data& cam, ObjTypeLocal type) {
|
||||
for (ObjData*& i : get_obj_list(type)) {
|
||||
vec3 center = 0.0f;
|
||||
bool v50 = false;
|
||||
@@ -1943,9 +1951,9 @@ namespace mdl {
|
||||
case OBJ_KIND_NORMAL: {
|
||||
mat4 mat = i->mat;
|
||||
if (i->args.sub_mesh.mesh->attrib.m.billboard)
|
||||
model_mat_face_camera_view(view, &mat, &mat);
|
||||
model_mat_face_camera_view(cam, &mat, &mat);
|
||||
else if (i->args.sub_mesh.mesh->attrib.m.billboard_y_axis)
|
||||
model_mat_face_camera_position(view, &mat, &mat);
|
||||
model_mat_face_camera_position(cam, &mat, &mat);
|
||||
|
||||
get_obj_center(mat, &i->args.sub_mesh, center);
|
||||
|
||||
@@ -1970,13 +1978,12 @@ namespace mdl {
|
||||
break;
|
||||
}
|
||||
|
||||
mat4_transform_point(view, ¢er, ¢er);
|
||||
mat4_transform_point(&cam.get_view_mat(), ¢er, ¢er);
|
||||
i->view_z = center.z;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void DispManager::calc_obj_radius(mat4* view, ObjTypeReflect type) {
|
||||
void DispManager::calc_obj_radius(const cam_data& cam, ObjTypeReflect type) {
|
||||
for (ObjData*& i : get_obj_list(type)) {
|
||||
vec3 center = 0.0f;
|
||||
bool v50 = false;
|
||||
@@ -1984,9 +1991,9 @@ namespace mdl {
|
||||
case OBJ_KIND_NORMAL: {
|
||||
mat4 mat = i->mat;
|
||||
if (i->args.sub_mesh.mesh->attrib.m.billboard)
|
||||
model_mat_face_camera_view(view, &mat, &mat);
|
||||
model_mat_face_camera_view(cam, &mat, &mat);
|
||||
else if (i->args.sub_mesh.mesh->attrib.m.billboard_y_axis)
|
||||
model_mat_face_camera_position(view, &mat, &mat);
|
||||
model_mat_face_camera_position(cam, &mat, &mat);
|
||||
|
||||
get_obj_center(mat, &i->args.sub_mesh, center);
|
||||
|
||||
@@ -2011,10 +2018,9 @@ namespace mdl {
|
||||
break;
|
||||
}
|
||||
|
||||
mat4_transform_point(view, ¢er, ¢er);
|
||||
mat4_transform_point(&cam.get_view_mat(), ¢er, ¢er);
|
||||
i->view_z = center.z;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void DispManager::check_index_buffer(GLuint buffer) {
|
||||
@@ -2030,12 +2036,13 @@ namespace mdl {
|
||||
|
||||
for (DispManager::etc_vertex_array& i : etc_vertex_array_cache)
|
||||
if (i.alive_time > 0 && --i.alive_time <= 0) {
|
||||
gl_rend_state.bind_vertex_array(i.vertex_array);
|
||||
gl_state.bind_vertex_array(i.vertex_array);
|
||||
glDisableVertexAttribArray(POSITION_INDEX);
|
||||
glDisableVertexAttribArray(NORMAL_INDEX);
|
||||
gl_rend_state.bind_array_buffer(0, true);
|
||||
gl_rend_state.bind_element_array_buffer(0, true);
|
||||
gl_rend_state.bind_vertex_array(0);
|
||||
gl_state.bind_array_buffer(0);
|
||||
if (i.indexed)
|
||||
gl_state.bind_element_array_buffer(0);
|
||||
gl_state.bind_vertex_array(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2046,31 +2053,32 @@ namespace mdl {
|
||||
i.reset_vertex_attrib();
|
||||
}
|
||||
|
||||
void DispManager::draw(ObjType type, int32_t depth_mask, bool reflect_texture_mask, int32_t alpha) {
|
||||
void DispManager::draw(render_data_context& rend_data_ctx, ObjType type,
|
||||
const cam_data& cam, int32_t depth_mask, bool reflect_texture_mask, int32_t alpha) {
|
||||
if (type < 0 || type >= OBJ_TYPE_MAX || get_obj_count(type) < 1)
|
||||
return;
|
||||
|
||||
int32_t alpha_test = 0;
|
||||
float_t min_alpha = 1.0f;
|
||||
float_t alpha_threshold = 0.0f;
|
||||
bool reflect = uniform->arr[U_REFLECT] == 1;
|
||||
void(*func)(const ObjSubMeshArgs * args) = draw_sub_mesh_default;
|
||||
bool reflect = rend_data_ctx.shader_flags.arr[U_REFLECT] == 1;
|
||||
void(*func)(render_data_context & rend_data_ctx, const ObjSubMeshArgs * args,
|
||||
const cam_data & cam, const mat4 * mat) = draw_sub_mesh_default;
|
||||
|
||||
for (int32_t i = 0; i < 5; i++)
|
||||
gl_rend_state.active_bind_texture_2d(i, rctx->empty_texture_2d->glid);
|
||||
gl_rend_state.active_bind_texture_cube_map(5, rctx->empty_texture_cube_map->glid);
|
||||
gl_rend_state.active_texture(0);
|
||||
gl_rend_state.set_blend_func(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
uniform_value_reset();
|
||||
gl_rend_state.get();
|
||||
rend_data_ctx.state.active_bind_texture_2d(i, rctx->empty_texture_2d->glid);
|
||||
rend_data_ctx.state.active_bind_texture_cube_map(5, rctx->empty_texture_cube_map->glid);
|
||||
rend_data_ctx.state.active_texture(0);
|
||||
rend_data_ctx.state.set_blend_func(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
rend_data_ctx.reset_shader_flags();
|
||||
|
||||
switch (type) {
|
||||
case OBJ_TYPE_TRANSLUCENT:
|
||||
case OBJ_TYPE_TRANSLUCENT_SORT_BY_RADIUS:
|
||||
if (depth_mask)
|
||||
func = draw_sub_mesh_translucent;
|
||||
func = draw_sub_mesh_no_mat;
|
||||
else
|
||||
gl_rend_state.set_depth_mask(GL_FALSE);
|
||||
rend_data_ctx.state.set_depth_mask(GL_FALSE);
|
||||
|
||||
alpha_test = 1;
|
||||
min_alpha = 0.0f;
|
||||
@@ -2088,43 +2096,43 @@ namespace mdl {
|
||||
func = draw_sub_mesh_shadow;
|
||||
break;
|
||||
case OBJ_TYPE_TYPE_6:
|
||||
func = draw_sub_mesh_translucent;
|
||||
gl_rend_state.set_color_mask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
draw_state.shader_index = SHADER_FT_SIL;
|
||||
func = draw_sub_mesh_no_mat;
|
||||
rend_data_ctx.state.set_color_mask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
rctx->draw_state_rend_data[rend_data_ctx.index].shader_index = SHADER_FT_SIL;
|
||||
break;
|
||||
case OBJ_TYPE_TYPE_7:
|
||||
func = draw_sub_mesh_translucent;
|
||||
gl_rend_state.set_color_mask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
draw_state.shader_index = SHADER_FT_SIL;
|
||||
func = draw_sub_mesh_no_mat;
|
||||
rend_data_ctx.state.set_color_mask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
rctx->draw_state_rend_data[rend_data_ctx.index].shader_index = SHADER_FT_SIL;
|
||||
|
||||
alpha_test = 1;
|
||||
min_alpha = 0.0f;
|
||||
alpha_threshold = 0.99999994f;
|
||||
break;
|
||||
case OBJ_TYPE_REFLECT_CHARA_OPAQUE:
|
||||
gl_rend_state.set_cull_face_mode(GL_FRONT);
|
||||
rend_data_ctx.state.set_cull_face_mode(GL_FRONT);
|
||||
|
||||
if (!reflect_draw) {
|
||||
if (reflect)
|
||||
func = draw_sub_mesh_reflect;
|
||||
func = draw_sub_mesh_cheap;
|
||||
else if (render_manager.reflect_type == STAGE_DATA_REFLECT_REFLECT_MAP)
|
||||
func = draw_sub_mesh_reflect_reflect_map;
|
||||
func = draw_sub_mesh_cheap_reflect_map;
|
||||
}
|
||||
break;
|
||||
case OBJ_TYPE_REFLECT_CHARA_TRANSLUCENT:
|
||||
gl_rend_state.set_cull_face_mode(GL_FRONT);
|
||||
rend_data_ctx.state.set_cull_face_mode(GL_FRONT);
|
||||
|
||||
min_alpha = 0.0f;
|
||||
|
||||
if (!reflect_draw) {
|
||||
if (reflect)
|
||||
func = draw_sub_mesh_reflect;
|
||||
func = draw_sub_mesh_cheap;
|
||||
else if (render_manager.reflect_type == STAGE_DATA_REFLECT_REFLECT_MAP)
|
||||
func = draw_sub_mesh_reflect_reflect_map;
|
||||
func = draw_sub_mesh_cheap_reflect_map;
|
||||
}
|
||||
break;
|
||||
case OBJ_TYPE_REFLECT_CHARA_TRANSPARENT:
|
||||
gl_rend_state.set_cull_face_mode(GL_FRONT);
|
||||
rend_data_ctx.state.set_cull_face_mode(GL_FRONT);
|
||||
|
||||
alpha_test = 1;
|
||||
min_alpha = 0.1f;
|
||||
@@ -2132,9 +2140,9 @@ namespace mdl {
|
||||
|
||||
if (!reflect_draw) {
|
||||
if (reflect)
|
||||
func = draw_sub_mesh_reflect;
|
||||
func = draw_sub_mesh_cheap;
|
||||
else if (render_manager.reflect_type == STAGE_DATA_REFLECT_REFLECT_MAP)
|
||||
func = draw_sub_mesh_reflect_reflect_map;
|
||||
func = draw_sub_mesh_cheap_reflect_map;
|
||||
}
|
||||
break;
|
||||
case OBJ_TYPE_REFLECT_OPAQUE:
|
||||
@@ -2142,18 +2150,18 @@ namespace mdl {
|
||||
alpha_threshold = 0.5f;
|
||||
|
||||
if (reflect_draw)
|
||||
gl_rend_state.set_cull_face_mode(GL_FRONT);
|
||||
rend_data_ctx.state.set_cull_face_mode(GL_FRONT);
|
||||
else if (!reflect_texture_mask)
|
||||
func = draw_sub_mesh_reflect_reflect_map;
|
||||
func = draw_sub_mesh_cheap_reflect_map;
|
||||
break;
|
||||
case OBJ_TYPE_REFLECT_TRANSLUCENT:
|
||||
gl_rend_state.set_depth_mask(GL_FALSE);
|
||||
rend_data_ctx.state.set_depth_mask(GL_FALSE);
|
||||
|
||||
min_alpha = 0.0f;
|
||||
alpha_threshold = 0.0f;
|
||||
|
||||
if (reflect_draw)
|
||||
gl_rend_state.set_cull_face_mode(GL_FRONT);
|
||||
rend_data_ctx.state.set_cull_face_mode(GL_FRONT);
|
||||
break;
|
||||
case OBJ_TYPE_REFLECT_TRANSPARENT:
|
||||
alpha_test = 1;
|
||||
@@ -2161,10 +2169,10 @@ namespace mdl {
|
||||
alpha_threshold = 0.5f;
|
||||
|
||||
if (reflect_draw)
|
||||
gl_rend_state.set_cull_face_mode(GL_FRONT);
|
||||
rend_data_ctx.state.set_cull_face_mode(GL_FRONT);
|
||||
break;
|
||||
case OBJ_TYPE_REFRACT_TRANSLUCENT:
|
||||
gl_rend_state.set_depth_mask(GL_FALSE);
|
||||
rend_data_ctx.state.set_depth_mask(GL_FALSE);
|
||||
|
||||
min_alpha = 0.0f;
|
||||
alpha_threshold = 0.0f;
|
||||
@@ -2178,7 +2186,7 @@ namespace mdl {
|
||||
func = draw_sub_mesh_sss;
|
||||
|
||||
if (reflect_draw)
|
||||
gl_rend_state.set_cull_face_mode(GL_FRONT);
|
||||
rend_data_ctx.state.set_cull_face_mode(GL_FRONT);
|
||||
break;
|
||||
case OBJ_TYPE_TRANSPARENT_ALPHA_ORDER_1:
|
||||
case OBJ_TYPE_TRANSPARENT_ALPHA_ORDER_2:
|
||||
@@ -2190,35 +2198,35 @@ namespace mdl {
|
||||
case OBJ_TYPE_TRANSLUCENT_ALPHA_ORDER_1:
|
||||
case OBJ_TYPE_TRANSLUCENT_ALPHA_ORDER_2:
|
||||
case OBJ_TYPE_TRANSLUCENT_ALPHA_ORDER_3:
|
||||
gl_rend_state.set_depth_mask(GL_FALSE);
|
||||
rend_data_ctx.state.set_depth_mask(GL_FALSE);
|
||||
|
||||
alpha_test = 1;
|
||||
min_alpha = 0.0f;
|
||||
alpha_threshold = 0.0f;
|
||||
break;
|
||||
case OBJ_TYPE_USER:
|
||||
func = draw_sub_mesh_translucent;
|
||||
func = draw_sub_mesh_no_mat;
|
||||
break;
|
||||
}
|
||||
rctx->set_batch_alpha_threshold(alpha_threshold);
|
||||
rctx->set_batch_min_alpha(min_alpha);
|
||||
uniform->arr[U_ALPHA_TEST] = alpha_test;
|
||||
rend_data_ctx.set_batch_alpha_threshold(alpha_threshold);
|
||||
rend_data_ctx.set_batch_min_alpha(min_alpha);
|
||||
rend_data_ctx.shader_flags.arr[U_ALPHA_TEST] = alpha_test;
|
||||
|
||||
if (alpha < 0)
|
||||
for (ObjData*& i : get_obj_list(type)) {
|
||||
switch (i->kind) {
|
||||
case OBJ_KIND_NORMAL: {
|
||||
draw_sub_mesh(&i->args.sub_mesh, &i->mat, func);
|
||||
draw_sub_mesh(rend_data_ctx, &i->args.sub_mesh, &i->mat, func, cam);
|
||||
} break;
|
||||
case OBJ_KIND_ETC: {
|
||||
draw_etc_obj(&i->args.etc, &i->mat);
|
||||
draw_etc_obj(rend_data_ctx, &i->args.etc, &i->mat);
|
||||
} break;
|
||||
case OBJ_KIND_USER: {
|
||||
i->args.user.func(i->args.user.data, &i->mat);
|
||||
i->args.user.func(rend_data_ctx, i->args.user.data, cam, &i->mat);
|
||||
} break;
|
||||
case OBJ_KIND_TRANSLUCENT: {
|
||||
for (int32_t j = 0; j < i->args.translucent.count; j++)
|
||||
draw_sub_mesh(i->args.translucent.sub_mesh[j], &i->mat, func);
|
||||
draw_sub_mesh(rend_data_ctx, i->args.translucent.sub_mesh[j], &i->mat, func, cam);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
@@ -2229,7 +2237,7 @@ namespace mdl {
|
||||
int32_t a = (int32_t)(i->args.sub_mesh.blend_color.w * 255.0f);
|
||||
a = clamp_def(a, 0, 255);
|
||||
if (a == alpha)
|
||||
draw_sub_mesh(&i->args.sub_mesh, &i->mat, func);
|
||||
draw_sub_mesh(rend_data_ctx, &i->args.sub_mesh, &i->mat, func, cam);
|
||||
} break;
|
||||
case OBJ_KIND_TRANSLUCENT: {
|
||||
for (int32_t j = 0; j < i->args.translucent.count; j++) {
|
||||
@@ -2237,7 +2245,7 @@ namespace mdl {
|
||||
int32_t a = (int32_t)(args->blend_color.w * 255.0f);
|
||||
a = clamp_def(a, 0, 255);
|
||||
if (a == alpha)
|
||||
draw_sub_mesh(args, &i->mat, func);
|
||||
draw_sub_mesh(rend_data_ctx, args, &i->mat, func, cam);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
@@ -2247,78 +2255,79 @@ namespace mdl {
|
||||
case OBJ_TYPE_TRANSLUCENT:
|
||||
case OBJ_TYPE_TRANSLUCENT_SORT_BY_RADIUS:
|
||||
if (!depth_mask)
|
||||
gl_rend_state.set_depth_mask(GL_TRUE);
|
||||
rend_data_ctx.state.set_depth_mask(GL_TRUE);
|
||||
break;
|
||||
case OBJ_TYPE_TYPE_6:
|
||||
case OBJ_TYPE_TYPE_7:
|
||||
draw_state.shader_index = -1;
|
||||
gl_rend_state.set_color_mask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
rctx->draw_state_rend_data[rend_data_ctx.index].shader_index = -1;
|
||||
rend_data_ctx.state.set_color_mask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
break;
|
||||
case OBJ_TYPE_REFLECT_CHARA_OPAQUE:
|
||||
case OBJ_TYPE_REFLECT_CHARA_TRANSLUCENT:
|
||||
case OBJ_TYPE_REFLECT_CHARA_TRANSPARENT:
|
||||
gl_rend_state.set_cull_face_mode(GL_BACK);
|
||||
rend_data_ctx.state.set_cull_face_mode(GL_BACK);
|
||||
break;
|
||||
case OBJ_TYPE_REFLECT_OPAQUE:
|
||||
if (reflect_draw)
|
||||
gl_rend_state.set_cull_face_mode(GL_FRONT);
|
||||
rend_data_ctx.state.set_cull_face_mode(GL_FRONT);
|
||||
break;
|
||||
case OBJ_TYPE_REFLECT_TRANSLUCENT:
|
||||
if (reflect_draw)
|
||||
gl_rend_state.set_cull_face_mode(GL_FRONT);
|
||||
gl_rend_state.set_depth_mask(GL_TRUE);
|
||||
rend_data_ctx.state.set_cull_face_mode(GL_FRONT);
|
||||
rend_data_ctx.state.set_depth_mask(GL_TRUE);
|
||||
break;
|
||||
case OBJ_TYPE_REFLECT_TRANSPARENT:
|
||||
if (reflect_draw)
|
||||
gl_rend_state.set_cull_face_mode(GL_FRONT);
|
||||
rend_data_ctx.state.set_cull_face_mode(GL_FRONT);
|
||||
break;
|
||||
case OBJ_TYPE_REFRACT_TRANSLUCENT:
|
||||
if (reflect_draw)
|
||||
gl_rend_state.set_cull_face_mode(GL_FRONT);
|
||||
gl_rend_state.set_depth_mask(GL_TRUE);
|
||||
rend_data_ctx.state.set_cull_face_mode(GL_FRONT);
|
||||
rend_data_ctx.state.set_depth_mask(GL_TRUE);
|
||||
break;
|
||||
case OBJ_TYPE_SSS:
|
||||
if (reflect_draw)
|
||||
gl_rend_state.set_cull_face_mode(GL_BACK);
|
||||
rend_data_ctx.state.set_cull_face_mode(GL_BACK);
|
||||
break;
|
||||
case OBJ_TYPE_TRANSLUCENT_ALPHA_ORDER_1:
|
||||
case OBJ_TYPE_TRANSLUCENT_ALPHA_ORDER_2:
|
||||
case OBJ_TYPE_TRANSLUCENT_ALPHA_ORDER_3:
|
||||
gl_rend_state.set_depth_mask(GL_TRUE);
|
||||
rend_data_ctx.state.set_depth_mask(GL_TRUE);
|
||||
break;
|
||||
}
|
||||
|
||||
uniform_value_reset();
|
||||
gl_rend_state.bind_vertex_array(0);
|
||||
shader::unbind();
|
||||
gl_rend_state.set_blend_func(GL_ONE, GL_ZERO);
|
||||
rend_data_ctx.reset_shader_flags();
|
||||
rend_data_ctx.state.bind_vertex_array(0);
|
||||
shader::unbind(rend_data_ctx.state);
|
||||
rend_data_ctx.state.set_blend_func(GL_ONE, GL_ZERO);
|
||||
for (int32_t i = 0; i < 5; i++)
|
||||
gl_rend_state.bind_sampler(i, 0);
|
||||
rend_data_ctx.state.bind_sampler(i, 0);
|
||||
}
|
||||
|
||||
void DispManager::draw(mdl::ObjTypeLocal type, int32_t depth_mask) {
|
||||
void DispManager::draw(render_data_context& rend_data_ctx, mdl::ObjTypeLocal type,
|
||||
const cam_data& cam, int32_t depth_mask, bool reflect_texture_mask) {
|
||||
if (type < 0 || type >= OBJ_TYPE_LOCAL_MAX || get_obj_count(type) < 1)
|
||||
return;
|
||||
|
||||
int32_t alpha_test = 0;
|
||||
float_t min_alpha = 1.0f;
|
||||
float_t alpha_threshold = 0.0f;
|
||||
void(*func)(const ObjSubMeshArgs * args) = draw_sub_mesh_default;
|
||||
void(*func)(render_data_context & rend_data_ctx, const ObjSubMeshArgs * args,
|
||||
const cam_data & cam, const mat4 * mat) = draw_sub_mesh_default;
|
||||
|
||||
for (int32_t i = 0; i < 5; i++)
|
||||
gl_rend_state.active_bind_texture_2d(i, rctx->empty_texture_2d->glid);
|
||||
gl_rend_state.active_bind_texture_cube_map(5, rctx->empty_texture_cube_map->glid);
|
||||
gl_rend_state.active_texture(0);
|
||||
gl_rend_state.set_blend_func(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
uniform_value_reset();
|
||||
gl_rend_state.get();
|
||||
rend_data_ctx.state.active_bind_texture_2d(i, rctx->empty_texture_2d->glid);
|
||||
rend_data_ctx.state.active_bind_texture_cube_map(5, rctx->empty_texture_cube_map->glid);
|
||||
rend_data_ctx.state.active_texture(0);
|
||||
rend_data_ctx.state.set_blend_func(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
rend_data_ctx.reset_shader_flags();
|
||||
|
||||
switch (type) {
|
||||
case OBJ_TYPE_LOCAL_TRANSLUCENT:
|
||||
if (depth_mask)
|
||||
func = draw_sub_mesh_translucent;
|
||||
func = draw_sub_mesh_no_mat;
|
||||
else
|
||||
gl_rend_state.set_depth_mask(GL_FALSE);
|
||||
rend_data_ctx.state.set_depth_mask(GL_FALSE);
|
||||
|
||||
alpha_test = 1;
|
||||
min_alpha = 0.0f;
|
||||
@@ -2330,18 +2339,18 @@ namespace mdl {
|
||||
alpha_threshold = 0.5f;
|
||||
break;
|
||||
}
|
||||
rctx->set_batch_alpha_threshold(alpha_threshold);
|
||||
rctx->set_batch_min_alpha(min_alpha);
|
||||
uniform->arr[U_ALPHA_TEST] = alpha_test;
|
||||
rend_data_ctx.set_batch_alpha_threshold(alpha_threshold);
|
||||
rend_data_ctx.set_batch_min_alpha(min_alpha);
|
||||
rend_data_ctx.shader_flags.arr[U_ALPHA_TEST] = alpha_test;
|
||||
|
||||
for (ObjData*& i : get_obj_list(type)) {
|
||||
switch (i->kind) {
|
||||
case OBJ_KIND_NORMAL: {
|
||||
draw_sub_mesh(&i->args.sub_mesh, &i->mat, func);
|
||||
draw_sub_mesh(rend_data_ctx, &i->args.sub_mesh, &i->mat, func, cam);
|
||||
} break;
|
||||
case OBJ_KIND_TRANSLUCENT: {
|
||||
for (int32_t j = 0; j < i->args.translucent.count; j++)
|
||||
draw_sub_mesh(i->args.translucent.sub_mesh[j], &i->mat, func);
|
||||
draw_sub_mesh(rend_data_ctx, i->args.translucent.sub_mesh[j], &i->mat, func, cam);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
@@ -2349,62 +2358,63 @@ namespace mdl {
|
||||
switch (type) {
|
||||
case OBJ_TYPE_LOCAL_TRANSLUCENT:
|
||||
if (!depth_mask)
|
||||
gl_rend_state.set_depth_mask(GL_TRUE);
|
||||
rend_data_ctx.state.set_depth_mask(GL_TRUE);
|
||||
break;
|
||||
}
|
||||
|
||||
uniform_value_reset();
|
||||
gl_rend_state.bind_vertex_array(0);
|
||||
shader::unbind();
|
||||
gl_rend_state.set_blend_func(GL_ONE, GL_ZERO);
|
||||
rend_data_ctx.reset_shader_flags();
|
||||
rend_data_ctx.state.bind_vertex_array(0);
|
||||
shader::unbind(rend_data_ctx.state);
|
||||
rend_data_ctx.state.set_blend_func(GL_ONE, GL_ZERO);
|
||||
for (int32_t i = 0; i < 5; i++)
|
||||
gl_rend_state.bind_sampler(i, 0);
|
||||
rend_data_ctx.state.bind_sampler(i, 0);
|
||||
}
|
||||
|
||||
void DispManager::draw(mdl::ObjTypeReflect type, int32_t depth_mask) {
|
||||
void DispManager::draw(render_data_context& rend_data_ctx, mdl::ObjTypeReflect type,
|
||||
const cam_data& cam, int32_t depth_mask, bool reflect_texture_mask) {
|
||||
if (type < 0 || type >= OBJ_TYPE_REFLECT_MAX || get_obj_count(type) < 1)
|
||||
return;
|
||||
|
||||
int32_t alpha_test = 0;
|
||||
float_t min_alpha = 1.0f;
|
||||
float_t alpha_threshold = 0.0f;
|
||||
bool reflect = uniform->arr[U_REFLECT] == 1;
|
||||
void(*func)(const ObjSubMeshArgs * args) = draw_sub_mesh_default;
|
||||
bool reflect = rend_data_ctx.shader_flags.arr[U_REFLECT] == 1;
|
||||
void(*func)(render_data_context & rend_data_ctx, const ObjSubMeshArgs * args,
|
||||
const cam_data & cam, const mat4 * mat) = draw_sub_mesh_default;
|
||||
|
||||
for (int32_t i = 0; i < 5; i++)
|
||||
gl_rend_state.active_bind_texture_2d(i, rctx->empty_texture_2d->glid);
|
||||
gl_rend_state.active_bind_texture_cube_map(5, rctx->empty_texture_cube_map->glid);
|
||||
gl_rend_state.active_texture(0);
|
||||
gl_rend_state.set_blend_func(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
uniform_value_reset();
|
||||
gl_rend_state.get();
|
||||
rend_data_ctx.state.active_bind_texture_2d(i, rctx->empty_texture_2d->glid);
|
||||
rend_data_ctx.state.active_bind_texture_cube_map(5, rctx->empty_texture_cube_map->glid);
|
||||
rend_data_ctx.state.active_texture(0);
|
||||
rend_data_ctx.state.set_blend_func(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
rend_data_ctx.reset_shader_flags();
|
||||
|
||||
switch (type) {
|
||||
case OBJ_TYPE_REFLECT_TRANSLUCENT_SORT_BY_RADIUS:
|
||||
if (depth_mask)
|
||||
func = draw_sub_mesh_translucent;
|
||||
func = draw_sub_mesh_no_mat;
|
||||
else
|
||||
gl_rend_state.set_depth_mask(GL_FALSE);
|
||||
rend_data_ctx.state.set_depth_mask(GL_FALSE);
|
||||
|
||||
alpha_test = 1;
|
||||
min_alpha = 0.0f;
|
||||
alpha_threshold = 0.0f;
|
||||
|
||||
gl_rend_state.set_cull_face_mode(GL_FRONT);
|
||||
rend_data_ctx.state.set_cull_face_mode(GL_FRONT);
|
||||
break;
|
||||
}
|
||||
rctx->set_batch_alpha_threshold(alpha_threshold);
|
||||
rctx->set_batch_min_alpha(min_alpha);
|
||||
uniform->arr[U_ALPHA_TEST] = alpha_test;
|
||||
rend_data_ctx.set_batch_alpha_threshold(alpha_threshold);
|
||||
rend_data_ctx.set_batch_min_alpha(min_alpha);
|
||||
rend_data_ctx.shader_flags.arr[U_ALPHA_TEST] = alpha_test;
|
||||
|
||||
for (ObjData*& i : get_obj_list(type)) {
|
||||
switch (i->kind) {
|
||||
case OBJ_KIND_NORMAL: {
|
||||
draw_sub_mesh(&i->args.sub_mesh, &i->mat, func);
|
||||
draw_sub_mesh(rend_data_ctx, &i->args.sub_mesh, &i->mat, func, cam);
|
||||
} break;
|
||||
case OBJ_KIND_TRANSLUCENT: {
|
||||
for (int32_t j = 0; j < i->args.translucent.count; j++)
|
||||
draw_sub_mesh(i->args.translucent.sub_mesh[j], &i->mat, func);
|
||||
draw_sub_mesh(rend_data_ctx, i->args.translucent.sub_mesh[j], &i->mat, func, cam);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
@@ -2412,16 +2422,16 @@ namespace mdl {
|
||||
switch (type) {
|
||||
case OBJ_TYPE_REFLECT_TRANSLUCENT_SORT_BY_RADIUS:
|
||||
if (!depth_mask)
|
||||
gl_rend_state.set_cull_face_mode(GL_BACK);
|
||||
rend_data_ctx.state.set_cull_face_mode(GL_BACK);
|
||||
break;
|
||||
}
|
||||
|
||||
uniform_value_reset();
|
||||
gl_rend_state.bind_vertex_array(0);
|
||||
shader::unbind();
|
||||
gl_rend_state.set_blend_func(GL_ONE, GL_ZERO);
|
||||
rend_data_ctx.reset_shader_flags();
|
||||
rend_data_ctx.state.bind_vertex_array(0);
|
||||
shader::unbind(rend_data_ctx.state);
|
||||
rend_data_ctx.state.set_blend_func(GL_ONE, GL_ZERO);
|
||||
for (int32_t i = 0; i < 5; i++)
|
||||
gl_rend_state.bind_sampler(i, 0);
|
||||
rend_data_ctx.state.bind_sampler(i, 0);
|
||||
}
|
||||
|
||||
/*void DispManager::draw_show_vector(ObjType type, int32_t show_vector) {
|
||||
@@ -2431,12 +2441,12 @@ namespace mdl {
|
||||
render_context* rctx = rctx_ptr;
|
||||
|
||||
for (int32_t i = 0; i < 5; i++)
|
||||
gl_rend_state.active_bind_texture_2d(i, rctx->empty_texture_2d->glid);
|
||||
gl_rend_state.active_bind_texture_cube_map(5, rctx->empty_texture_cube_map->glid);
|
||||
gl_rend_state.active_texture(0);
|
||||
gl_rend_state.set_blend_func(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
uniform_value_reset();
|
||||
gl_rend_state.get();
|
||||
rend_data_ctx.state.active_bind_texture_2d(i, rctx->empty_texture_2d->glid);
|
||||
rend_data_ctx.state.active_bind_texture_cube_map(5, rctx->empty_texture_cube_map->glid);
|
||||
rend_data_ctx.state.active_texture(0);
|
||||
rend_data_ctx.state.set_blend_func(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
rend_data_ctx.reset_shader_flags();
|
||||
rend_data_ctx.state.get();
|
||||
|
||||
for (ObjData*& i : get_obj_list(type)) {
|
||||
switch (i->type) {
|
||||
@@ -2451,7 +2461,7 @@ namespace mdl {
|
||||
} break;
|
||||
}
|
||||
}
|
||||
gl_rend_state.set_blend_func(GL_ONE, GL_ZERO);
|
||||
rend_data_ctx.state.set_blend_func(GL_ONE, GL_ZERO);
|
||||
}*/
|
||||
|
||||
void DispManager::entry_list(ObjType type, ObjData* data) {
|
||||
@@ -3654,11 +3664,11 @@ namespace mdl {
|
||||
int32_t DispManager::get_obj_count(ObjType type) {
|
||||
return (int32_t)get_obj_list(type).size();
|
||||
}
|
||||
|
||||
|
||||
int32_t DispManager::get_obj_count(ObjTypeLocal type) {
|
||||
return (int32_t)get_obj_list(type).size();
|
||||
}
|
||||
|
||||
|
||||
int32_t DispManager::get_obj_count(ObjTypeReflect type) {
|
||||
return (int32_t)get_obj_list(type).size();
|
||||
}
|
||||
@@ -3705,15 +3715,16 @@ namespace mdl {
|
||||
return wet_param;
|
||||
}
|
||||
|
||||
void DispManager::obj_sort(mat4* view, ObjType type, int32_t compare_func, bool a3) {
|
||||
void DispManager::obj_sort(render_data_context& rend_data_ctx,
|
||||
ObjType type, int32_t compare_func, const cam_data& cam, bool a3) {
|
||||
prj::list<ObjData*>& list = get_obj_list(type);
|
||||
if (list.size() < 1)
|
||||
return;
|
||||
|
||||
if (a3 && type == OBJ_TYPE_TRANSLUCENT)
|
||||
sub_140436760(view);
|
||||
sub_140436760(cam);
|
||||
|
||||
calc_obj_radius(view, type);
|
||||
calc_obj_radius(cam, type);
|
||||
|
||||
switch (compare_func) {
|
||||
case 0:
|
||||
@@ -3734,12 +3745,13 @@ namespace mdl {
|
||||
}
|
||||
}
|
||||
|
||||
void DispManager::obj_sort(mat4* view, ObjTypeLocal type, int32_t compare_func, bool a3) {
|
||||
void DispManager::obj_sort(render_data_context& rend_data_ctx,
|
||||
ObjTypeLocal type, int32_t compare_func, const cam_data& cam) {
|
||||
prj::list<ObjData*>& list = get_obj_list(type);
|
||||
if (list.size() < 1)
|
||||
return;
|
||||
|
||||
calc_obj_radius(view, type);
|
||||
calc_obj_radius(cam, type);
|
||||
|
||||
switch (compare_func) {
|
||||
case 0:
|
||||
@@ -3760,12 +3772,13 @@ namespace mdl {
|
||||
}
|
||||
}
|
||||
|
||||
void DispManager::obj_sort(mat4* view, ObjTypeReflect type, int32_t compare_func, bool a3) {
|
||||
void DispManager::obj_sort(render_data_context& rend_data_ctx,
|
||||
ObjTypeReflect type, int32_t compare_func, const cam_data& cam) {
|
||||
prj::list<ObjData*>& list = get_obj_list(type);
|
||||
if (list.size() < 1)
|
||||
return;
|
||||
|
||||
calc_obj_radius(view, type);
|
||||
calc_obj_radius(cam, type);
|
||||
|
||||
switch (compare_func) {
|
||||
case 0:
|
||||
@@ -4150,7 +4163,7 @@ static void rob_chara_item_cos_data_set_chara_index(rob_chara_item_cos_data* ite
|
||||
item_cos_data->chara_index = chara_index;
|
||||
}
|
||||
|
||||
static void sub_140436760(mat4* view) {
|
||||
static void sub_140436760(const cam_data& cam) {
|
||||
for (auto& i : disp_manager->obj[mdl::OBJ_TYPE_TRANSLUCENT]) {
|
||||
if (i->kind != mdl::OBJ_KIND_NORMAL)
|
||||
continue;
|
||||
@@ -4184,7 +4197,7 @@ static void sub_140436760(mat4* view) {
|
||||
mat4 mat;
|
||||
mat4_transpose(&i->mat, &mat);
|
||||
mat4_mul_translate(&mat, &aabb->center, &mat);
|
||||
mat4_mul(&mat, view, &mat);
|
||||
mat4_mul(&mat, &cam.get_view_mat(), &mat);
|
||||
mat4_transpose(&mat, &mat);
|
||||
|
||||
vec4 t;
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
#define TEXTURE_PATTERN_COUNT 24
|
||||
#define TEXTURE_TRANSFORM_COUNT 24
|
||||
|
||||
struct cam_data;
|
||||
struct render_data_context;
|
||||
|
||||
namespace mdl {
|
||||
enum EtcObjType {
|
||||
ETC_OBJ_TEAPOT = 0,
|
||||
@@ -101,6 +104,9 @@ struct material_list_struct {
|
||||
vec4u8& has_blend_color, vec4& emission, vec4u8& has_emission);
|
||||
};
|
||||
|
||||
struct cam_data;
|
||||
struct render_data_context;
|
||||
|
||||
namespace mdl {
|
||||
struct ObjSubMeshArgs;
|
||||
|
||||
@@ -202,7 +208,7 @@ namespace mdl {
|
||||
|
||||
EtcObjCross();
|
||||
};
|
||||
|
||||
|
||||
struct EtcObjCapsule { // Added
|
||||
float_t radius;
|
||||
int32_t slices;
|
||||
@@ -251,7 +257,7 @@ namespace mdl {
|
||||
~EtcObj();
|
||||
};
|
||||
|
||||
typedef void(*UserArgsFunc)(void* data, mat4* mat);
|
||||
typedef void(*UserArgsFunc)(render_data_context& rend_data_ctx, void* data, const cam_data& cam, mat4* mat);
|
||||
|
||||
struct UserArgs {
|
||||
UserArgsFunc func;
|
||||
@@ -283,7 +289,7 @@ namespace mdl {
|
||||
float_t view_z;
|
||||
float_t radius;
|
||||
Args args;
|
||||
|
||||
|
||||
ObjData();
|
||||
~ObjData();
|
||||
|
||||
@@ -342,6 +348,7 @@ namespace mdl {
|
||||
GLuint vertex_array;
|
||||
EtcObj::Data data;
|
||||
EtcObjType type;
|
||||
bool indexed;
|
||||
GLsizei count;
|
||||
size_t offset;
|
||||
GLsizei wire_count;
|
||||
@@ -384,16 +391,18 @@ namespace mdl {
|
||||
ObjData* alloc_obj_data(ObjKind kind);
|
||||
mat4* alloc_mat4_array(int32_t count);
|
||||
void buffer_reset();
|
||||
void calc_obj_radius(mat4* view, ObjType type);
|
||||
void calc_obj_radius(mat4* view, ObjTypeLocal type);
|
||||
void calc_obj_radius(mat4* view, ObjTypeReflect type);
|
||||
void calc_obj_radius(const cam_data& cam, ObjType type);
|
||||
void calc_obj_radius(const cam_data& cam, ObjTypeLocal type);
|
||||
void calc_obj_radius(const cam_data& cam, ObjTypeReflect type);
|
||||
void check_index_buffer(GLuint buffer);
|
||||
void check_vertex_arrays();
|
||||
void check_vertex_buffer(GLuint buffer);
|
||||
void draw(ObjType type, int32_t depth_mask = 0, bool reflect_texture_mask = true, int32_t alpha = -1);
|
||||
void draw(ObjTypeLocal type, int32_t depth_mask = 0);
|
||||
void draw(ObjTypeReflect type, int32_t depth_mask = 0);
|
||||
/*void draw_show_vector(mdl::ObjType type, int32_t show_vector);*/
|
||||
void draw(render_data_context& rend_data_ctx, ObjType type, const cam_data& cam,
|
||||
int32_t depth_mask = 0, bool reflect_texture_mask = true, int32_t alpha = -1);
|
||||
void draw(render_data_context& rend_data_ctx, ObjTypeLocal type, const cam_data& cam,
|
||||
int32_t depth_mask = 0, bool reflect_texture_mask = true);
|
||||
void draw(render_data_context& rend_data_ctx, ObjTypeReflect type, const cam_data& cam,
|
||||
int32_t depth_mask = 0, bool reflect_texture_mask = true);
|
||||
void entry_list(ObjType type, ObjData* data);
|
||||
void entry_list(ObjTypeLocal type, ObjData* data);
|
||||
void entry_list(ObjTypeReflect type, ObjData* data);
|
||||
@@ -446,9 +455,12 @@ namespace mdl {
|
||||
void get_texture_specular_offset(vec4& value);
|
||||
void get_texture_transform(int32_t& count, texture_transform_struct*& value);
|
||||
float_t get_wet_param();
|
||||
void obj_sort(mat4* view, ObjType type, int32_t compare_func, bool a3 = false);
|
||||
void obj_sort(mat4* view, ObjTypeLocal type, int32_t compare_func, bool a3 = false);
|
||||
void obj_sort(mat4* view, ObjTypeReflect type, int32_t compare_func, bool a3 = false);
|
||||
void obj_sort(render_data_context& rend_data_ctx,
|
||||
ObjType type, int32_t compare_func, const cam_data& cam, bool a3 = false);
|
||||
void obj_sort(render_data_context& rend_data_ctx,
|
||||
ObjTypeLocal type, int32_t compare_func, const cam_data& cam);
|
||||
void obj_sort(render_data_context& rend_data_ctx,
|
||||
ObjTypeReflect type, int32_t compare_func, const cam_data& cam);
|
||||
void refresh();
|
||||
void set_chara_color(bool value = false);
|
||||
void set_culling_func(bool(FASTCALL* func)(const obj_bounding_sphere*) = 0);
|
||||
|
||||
+456
-470
File diff suppressed because it is too large
Load Diff
@@ -12,20 +12,29 @@
|
||||
#include "../render_context.hpp"
|
||||
|
||||
namespace mdl {
|
||||
extern void draw(obj_primitive_type primitive_type, uint32_t count,
|
||||
extern void draw(
|
||||
render_data_context& rend_data_ctx, obj_primitive_type primitive_type, uint32_t count,
|
||||
uint16_t start, uint16_t end, obj_index_format index_format, size_t indices);
|
||||
extern void draw_etc_obj(const mdl::EtcObj* etc, const mat4* mat);
|
||||
extern void draw_sub_mesh(const ObjSubMeshArgs* args, const mat4* mat,
|
||||
void(*func)(const ObjSubMeshArgs* args));
|
||||
//extern void draw_sub_mesh_show_vector(const ObjSubMeshArgs* args, const mat4* model, int32_t show_vector);
|
||||
extern void draw_sub_mesh_default(const ObjSubMeshArgs* args);
|
||||
extern void draw_sub_mesh_default_instanced(const ObjSubMeshArgs* args, const mat4* mat);
|
||||
extern void draw_sub_mesh_sss(const ObjSubMeshArgs* args);
|
||||
extern void draw_sub_mesh_reflect(const ObjSubMeshArgs* args);
|
||||
extern void draw_sub_mesh_reflect_reflect_map(const ObjSubMeshArgs* args);
|
||||
extern void draw_sub_mesh_shadow(const ObjSubMeshArgs* args);
|
||||
extern void draw_sub_mesh_translucent(const ObjSubMeshArgs* args);
|
||||
extern void draw_etc_obj(
|
||||
render_data_context& rend_data_ctx, const mdl::EtcObj* etc, const mat4* mat);
|
||||
extern void draw_sub_mesh(render_data_context& rend_data_ctx, const ObjSubMeshArgs* args,
|
||||
const mat4* mat, void(*func)(render_data_context& rend_data_ctx,
|
||||
const ObjSubMeshArgs* args, const cam_data& cam, const mat4* mat), const cam_data& cam);
|
||||
extern void draw_sub_mesh_cheap(render_data_context& rend_data_ctx,
|
||||
const ObjSubMeshArgs* args, const cam_data& cam, const mat4* mat);
|
||||
extern void draw_sub_mesh_cheap_reflect_map(render_data_context& rend_data_ctx,
|
||||
const ObjSubMeshArgs* args, const cam_data& cam, const mat4* mat);
|
||||
extern void draw_sub_mesh_default(render_data_context& rend_data_ctx,
|
||||
const ObjSubMeshArgs* args, const cam_data& cam, const mat4* mat);
|
||||
extern void draw_sub_mesh_default_instanced(render_data_context& rend_data_ctx,
|
||||
const ObjSubMeshArgs* args, const cam_data& cam, const mat4* mat);
|
||||
extern void draw_sub_mesh_no_mat(render_data_context& rend_data_ctx,
|
||||
const ObjSubMeshArgs* args, const cam_data& cam, const mat4* mat);
|
||||
extern void draw_sub_mesh_shadow(render_data_context& rend_data_ctx,
|
||||
const ObjSubMeshArgs* args, const cam_data& cam, const mat4* mat);
|
||||
extern void draw_sub_mesh_sss(render_data_context& rend_data_ctx,
|
||||
const ObjSubMeshArgs* args, const cam_data& cam, const mat4* mat);
|
||||
};
|
||||
|
||||
extern void model_mat_face_camera_position(const mat4* view, const mat4* src, mat4* dst);
|
||||
extern void model_mat_face_camera_view(const mat4* view, const mat4* src, mat4* dst);
|
||||
extern void model_mat_face_camera_position(const cam_data& cam, const mat4* src, mat4* dst);
|
||||
extern void model_mat_face_camera_view(const cam_data& cam, const mat4* src, mat4* dst);
|
||||
|
||||
+11
-11
@@ -8,7 +8,7 @@
|
||||
#include "../AFTModsShared/file_handler.hpp"
|
||||
#include "mdl/disp_manager.hpp"
|
||||
#include "pv_game/firstread.hpp"
|
||||
#include "gl_rend_state.hpp"
|
||||
#include "gl_state.hpp"
|
||||
#include "wrap.hpp"
|
||||
#include <Helpers.h>
|
||||
|
||||
@@ -206,9 +206,9 @@ GLsizeiptr obj_mesh_vertex_buffer_divagl::get_size() {
|
||||
GLint buffer;
|
||||
GLint size;
|
||||
glGetIntegervDLL(GL_ARRAY_BUFFER_BINDING, &buffer);
|
||||
gl_rend_state.bind_element_array_buffer(buffers[0]);
|
||||
gl_state.bind_element_array_buffer(buffers[0]);
|
||||
glGetBufferParameteriv(target, GL_BUFFER_SIZE, &size);
|
||||
gl_rend_state.bind_element_array_buffer(buffer);
|
||||
gl_state.bind_element_array_buffer(buffer);
|
||||
return size;
|
||||
}
|
||||
#endif
|
||||
@@ -1163,12 +1163,12 @@ bool ObjsetInfo::vertex_buffer_load() {
|
||||
static GLuint create_index_buffer(size_t size, const void* data) {
|
||||
GLuint buffer = 0;
|
||||
glGenBuffers(1, &buffer);
|
||||
gl_rend_state.bind_element_array_buffer(buffer);
|
||||
gl_state.bind_element_array_buffer(buffer);
|
||||
if (DIVA_GL_VERSION_4_4)
|
||||
glBufferStorage(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)size, data, 0);
|
||||
else
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)size, data, GL_STATIC_DRAW);
|
||||
gl_rend_state.bind_element_array_buffer(0);
|
||||
gl_state.bind_element_array_buffer(0);
|
||||
|
||||
if (glGetErrorDLL()) {
|
||||
glDeleteBuffers(1, &buffer);
|
||||
@@ -1183,14 +1183,14 @@ static GLuint create_index_buffer(size_t size, const void* data) {
|
||||
static GLuint create_vertex_buffer(size_t size, const void* data, bool dynamic) {
|
||||
GLuint buffer = 0;
|
||||
glGenBuffers(1, &buffer);
|
||||
gl_rend_state.bind_array_buffer(buffer);
|
||||
gl_state.bind_array_buffer(buffer);
|
||||
if (DIVA_GL_VERSION_4_4)
|
||||
glBufferStorage(GL_ARRAY_BUFFER, (GLsizeiptr)size, data,
|
||||
dynamic ? GL_DYNAMIC_STORAGE_BIT | GL_MAP_WRITE_BIT : 0);
|
||||
else
|
||||
glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)size, data,
|
||||
dynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW);
|
||||
gl_rend_state.bind_array_buffer(0);
|
||||
gl_state.bind_array_buffer(0);
|
||||
|
||||
if (glGetErrorDLL()) {
|
||||
glDeleteBuffers(1, &buffer);
|
||||
@@ -1209,9 +1209,9 @@ static void free_index_buffer(GLuint buffer) {
|
||||
disp_manager->check_index_buffer(buffer);
|
||||
|
||||
GLint size;
|
||||
gl_rend_state.bind_element_array_buffer(buffer);
|
||||
gl_state.bind_element_array_buffer(buffer);
|
||||
glGetBufferParameteriv(GL_ELEMENT_ARRAY_BUFFER, GL_BUFFER_SIZE, &size);
|
||||
gl_rend_state.bind_element_array_buffer(0);
|
||||
gl_state.bind_element_array_buffer(0);
|
||||
bufobj_mgr.ib_all_size -= size;
|
||||
|
||||
glDeleteBuffers(1, &buffer);
|
||||
@@ -1225,9 +1225,9 @@ static void free_vertex_buffer(GLuint buffer) {
|
||||
disp_manager->check_vertex_buffer(buffer);
|
||||
|
||||
GLint size = 0;
|
||||
gl_rend_state.bind_array_buffer(buffer);
|
||||
gl_state.bind_array_buffer(buffer);
|
||||
glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &size);
|
||||
gl_rend_state.bind_array_buffer(0);
|
||||
gl_state.bind_array_buffer(0);
|
||||
bufobj_mgr.vb_all_size -= size;
|
||||
|
||||
glDeleteBuffers(1, &buffer);
|
||||
|
||||
+431
-440
File diff suppressed because it is too large
Load Diff
+29
-21
@@ -19,6 +19,10 @@ enum tone_map_method {
|
||||
TONE_MAP_MAX = 3,
|
||||
};
|
||||
|
||||
struct cam_data;
|
||||
struct p_gl_rend_state;
|
||||
struct render_data_context;
|
||||
|
||||
namespace rndr {
|
||||
struct Render {
|
||||
enum MagFilterType {
|
||||
@@ -173,44 +177,48 @@ namespace rndr {
|
||||
int32_t update;
|
||||
FrameTexture frame_texture[6];
|
||||
|
||||
void apply_post_process(texture* light_proj_tex, int32_t npr_param);
|
||||
void bind_render_texture(bool aet_back = false);
|
||||
void calc_exposure_chara_data();
|
||||
void calc_projection_matrix(mat4* mat, float_t fov, float_t aspect, float_t z_near, float_t z_far,
|
||||
float_t left_offset, float_t right_offset, float_t bottom_offset, float_t top_offset);
|
||||
void draw_quad(int32_t width, int32_t height, float_t s0, float_t t0, float_t s1, float_t t1,
|
||||
void apply_post_process(render_data_context& rend_data_ctx,
|
||||
const cam_data& cam, texture* light_proj_tex, int32_t npr_param);
|
||||
void bind_render_texture(p_gl_rend_state& p_gl_rend_st, bool aet_back = false);
|
||||
void calc_exposure_chara_data(render_data_context& rend_data_ctx, const cam_data& cam);
|
||||
void draw_quad(render_data_context& rend_data_ctx,
|
||||
int32_t width, int32_t height, float_t s0, float_t t0, float_t s1, float_t t1,
|
||||
float_t scale, float_t param_x, float_t param_y, float_t param_z, float_t param_w);
|
||||
void draw_lens_flare();
|
||||
void draw_lens_flare(render_data_context& rend_data_ctx, const cam_data& cam);
|
||||
void free();
|
||||
vec2 get_taa_offset();
|
||||
void init_render_buffers(int32_t width, int32_t height,
|
||||
int32_t ssaa, int32_t hd_res, int32_t ss_alpha_mask);
|
||||
void init_tone_map_buffers();
|
||||
void init_post_process_buffers();
|
||||
int32_t movie_texture_set(texture* movie_texture);
|
||||
void movie_texture_free(texture* movie_texture);
|
||||
void post_proc();
|
||||
void pre_proc();
|
||||
void pre_proc(render_data_context& rend_data_ctx);
|
||||
int32_t render_texture_set(texture* render_texture, bool task_photo);
|
||||
void render_texture_free(texture* render_texture, bool task_photo);
|
||||
void resize(int32_t width, int32_t height);
|
||||
void set_screen_res(int32_t x_offset, int32_t y_offset, int32_t width, int32_t height);
|
||||
void take_ss(texture* tex, bool vertical, float_t horizontal_offset);
|
||||
void transparency_combine(float_t alpha);
|
||||
void transparency_copy();
|
||||
void take_ss(render_data_context& rend_data_ctx,
|
||||
texture* tex, bool vertical, float_t horizontal_offset);
|
||||
void transparency_combine(render_data_context& rend_data_ctx, float_t alpha);
|
||||
void transparency_copy(render_data_context& rend_data_ctx);
|
||||
void update_res(bool set, int32_t base_downsample);
|
||||
|
||||
private:
|
||||
void apply_mlaa(int32_t destination, int32_t source, int32_t mlaa);
|
||||
void apply_tone_map(texture* light_proj_tex, int32_t npr_param);
|
||||
void calc_exposure();
|
||||
void calc_gaussian_blur(float_t start, float_t step,
|
||||
void apply_mlaa(render_data_context& rend_data_ctx,
|
||||
int32_t destination, int32_t source, int32_t mlaa);
|
||||
void apply_tone_map(render_data_context& rend_data_ctx, texture* light_proj_tex, int32_t npr_param);
|
||||
void calc_exposure(render_data_context& rend_data_ctx, const cam_data& cam);
|
||||
void calc_gaussian_blur(render_data_context& rend_data_ctx, float_t start, float_t step,
|
||||
int32_t kernel_size, float_t radius_scale, float_t intensity_scale);
|
||||
void calc_taa_blend();
|
||||
void copy_to_frame_texture(GLuint pre_pp_tex, int32_t wight, int32_t height, GLuint post_pp_tex);
|
||||
void draw_lens_ghost();
|
||||
void downsample();
|
||||
void copy_to_frame_texture(render_data_context& rend_data_ctx,
|
||||
GLuint pre_pp_tex, int32_t wight, int32_t height, GLuint post_pp_tex);
|
||||
void draw_lens_ghost(render_data_context& rend_data_ctx);
|
||||
void downsample(render_data_context& rend_data_ctx);
|
||||
void generate_mlaa_area_texture();
|
||||
void get_blur();
|
||||
void update_tone_map_lut();
|
||||
void get_blur(render_data_context& rend_data_ctx);
|
||||
void update_tone_map_lut(p_gl_rend_state& p_gl_rend_st);
|
||||
};
|
||||
|
||||
static_assert(sizeof(rndr::Render) == 0x1510, "\"rndr::Render\" struct should have a size of 0x1510");
|
||||
|
||||
+436
-384
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "render_context.hpp"
|
||||
#include "../AFTModsShared/uniform.hpp"
|
||||
#include "gl_rend_state.hpp"
|
||||
#include "gl_state.hpp"
|
||||
#include "render_manager.hpp"
|
||||
#include "shader_ft.hpp"
|
||||
#include "static_var.hpp"
|
||||
@@ -18,9 +20,9 @@ render_context* rctx;
|
||||
extern bool config_shared_storage_uniform_buffer;
|
||||
|
||||
void draw_state_stats::reset() {
|
||||
object_draw_count = 0;
|
||||
object_translucent_draw_count = 0;
|
||||
object_reflect_draw_count = 0;
|
||||
sub_mesh_count = 0;
|
||||
sub_mesh_no_mat_count = 0;
|
||||
sub_mesh_cheap_count = 0;
|
||||
field_C = 0;
|
||||
field_10 = 0;
|
||||
draw_count = 0;
|
||||
@@ -47,9 +49,13 @@ void sss_data::init() {
|
||||
init_data = true;
|
||||
}
|
||||
|
||||
void sss_data::set_texture(int32_t texture_index) {
|
||||
gl_rend_state.active_bind_texture_2d(16, textures[texture_index].GetColorTex());
|
||||
gl_rend_state.active_texture(0);
|
||||
void sss_data::set_texture(struct p_gl_rend_state& p_gl_rend_st, int32_t texture_index) {
|
||||
p_gl_rend_st.active_bind_texture_2d(16, textures[texture_index].GetColorTex());
|
||||
p_gl_rend_st.active_texture(0);
|
||||
}
|
||||
|
||||
draw_state_struct::render_data::render_data() : self_shadow(), shadow(), blend(), cull_front(), field_8() {
|
||||
shader_index = -1;
|
||||
}
|
||||
|
||||
void draw_state_struct::set_fog_height(bool value) {
|
||||
@@ -258,13 +264,13 @@ void render_data::obj_batch_data::reset() {
|
||||
}
|
||||
|
||||
void render_data::init() {
|
||||
buffer_shader.Create(sizeof(obj_shader_data));
|
||||
buffer_scene.Create(sizeof(obj_scene_data));
|
||||
buffer_batch.Create(sizeof(obj_batch_data));
|
||||
buffer_shader.Create(gl_state, sizeof(obj_shader_data));
|
||||
buffer_scene.Create(gl_state, sizeof(obj_scene_data));
|
||||
buffer_batch.Create(gl_state, sizeof(obj_batch_data));
|
||||
if (DIVA_GL_VERSION_4_3)
|
||||
buffer_skinning.Create(sizeof(obj_skinning_data));
|
||||
buffer_skinning.Create(gl_state, sizeof(obj_skinning_data));
|
||||
else
|
||||
buffer_skinning_ubo.Create(sizeof(obj_skinning_data));
|
||||
buffer_skinning_ubo.Create(gl_state, sizeof(obj_skinning_data));
|
||||
|
||||
buffer_shader_data.reset();
|
||||
enum_or(flags, RENDER_DATA_SHADER_UPDATE);
|
||||
@@ -272,6 +278,7 @@ void render_data::init() {
|
||||
enum_or(flags, RENDER_DATA_SCENE_UPDATE);
|
||||
buffer_batch_data.reset();
|
||||
enum_or(flags, RENDER_DATA_BATCH_UPDATE);
|
||||
inv_view_mat = mat4_identity;
|
||||
}
|
||||
|
||||
void render_data::free() {
|
||||
@@ -284,16 +291,61 @@ void render_data::free() {
|
||||
buffer_shader.Destroy();
|
||||
}
|
||||
|
||||
void render_data::set(render_context* rctx) {
|
||||
shaders_ft.set(shader_index);
|
||||
void render_data::set_skinning_data(p_gl_rend_state& p_gl_rend_st, const mat4* mats, int32_t count) {
|
||||
if (count == 2) {
|
||||
mat4 temp;
|
||||
mat4_transpose(&mats[0], &temp);
|
||||
if (buffer_batch_data.g_joint[0] != temp.row0
|
||||
|| buffer_batch_data.g_joint[1] != temp.row1
|
||||
|| buffer_batch_data.g_joint[2] != temp.row2) {
|
||||
buffer_batch_data.g_joint[0] = temp.row0;
|
||||
buffer_batch_data.g_joint[1] = temp.row1;
|
||||
buffer_batch_data.g_joint[2] = temp.row2;
|
||||
enum_or(flags, RENDER_DATA_BATCH_UPDATE);
|
||||
}
|
||||
}
|
||||
|
||||
if (config_shared_storage_uniform_buffer) {
|
||||
GLuint buffer = 0;
|
||||
size_t offset = 0;
|
||||
size_t size = 0;
|
||||
if (rctx->get_shared_storage_uniform_buffer_data(
|
||||
(size_t)mats, buffer, offset, size, !!DIVA_GL_VERSION_4_3))
|
||||
if (DIVA_GL_VERSION_4_3)
|
||||
p_gl_rend_st.bind_shader_storage_buffer_range(0, buffer, (GLintptr)offset, (GLsizeiptr)size);
|
||||
else
|
||||
p_gl_rend_st.bind_uniform_buffer_range(6, buffer, (GLintptr)offset, (GLsizeiptr)size);
|
||||
}
|
||||
else {
|
||||
vec4* g_joint_transforms = buffer_skinning_data.g_joint_transforms;
|
||||
|
||||
mat4 mat;
|
||||
for (int32_t i = 0; i < count; i++, mats++, g_joint_transforms += 3) {
|
||||
mat4_transpose(mats, &mat);
|
||||
g_joint_transforms[0] = mat.row0;
|
||||
g_joint_transforms[1] = mat.row1;
|
||||
g_joint_transforms[2] = mat.row2;
|
||||
}
|
||||
|
||||
if (DIVA_GL_VERSION_4_3)
|
||||
buffer_skinning.WriteMemory(p_gl_rend_st,
|
||||
0, sizeof(vec4) * 3 * count, &buffer_skinning_data);
|
||||
else
|
||||
buffer_skinning_ubo.WriteMemory(p_gl_rend_st,
|
||||
0, sizeof(vec4) * 3 * count, &buffer_skinning_data);
|
||||
}
|
||||
}
|
||||
|
||||
void render_data::set_state(p_gl_rend_state& p_gl_rend_st) {
|
||||
shaders_ft.set(p_gl_rend_st, shader_flags, shader_index);
|
||||
|
||||
if (flags & RENDER_DATA_SHADER_UPDATE) {
|
||||
buffer_shader.WriteMemory(buffer_shader_data);
|
||||
buffer_shader.WriteMemory(p_gl_rend_st, buffer_shader_data);
|
||||
enum_and(flags, ~RENDER_DATA_SHADER_UPDATE);
|
||||
}
|
||||
|
||||
if (flags & RENDER_DATA_SCENE_UPDATE) {
|
||||
buffer_scene.WriteMemory(buffer_scene_data);
|
||||
buffer_scene.WriteMemory(p_gl_rend_st, buffer_scene_data);
|
||||
enum_and(flags, ~RENDER_DATA_SCENE_UPDATE);
|
||||
}
|
||||
|
||||
@@ -306,7 +358,7 @@ void render_data::set(render_context* rctx) {
|
||||
mat4_transpose(&worlds, &worlds);
|
||||
|
||||
mat4 temp;
|
||||
mat4_mul(&worlds, &rctx->vp_mat, &temp);
|
||||
mat4_mul(&worlds, &cam.view_proj_mat, &temp);
|
||||
mat4_transpose(&temp, &temp);
|
||||
buffer_batch_data.g_transforms[0] = temp.row0;
|
||||
buffer_batch_data.g_transforms[1] = temp.row1;
|
||||
@@ -319,7 +371,7 @@ void render_data::set(render_context* rctx) {
|
||||
buffer_batch_data.g_worlds_invtrans[1] = temp.row1;
|
||||
buffer_batch_data.g_worlds_invtrans[2] = temp.row2;
|
||||
|
||||
mat4_mul(&worlds, &rctx->view_mat, &worlds);
|
||||
mat4_mul(&worlds, &cam.view_mat, &worlds);
|
||||
mat4_transpose(&worlds, &temp);
|
||||
buffer_batch_data.g_worldview[0] = temp.row0;
|
||||
buffer_batch_data.g_worldview[1] = temp.row1;
|
||||
@@ -340,28 +392,343 @@ void render_data::set(render_context* rctx) {
|
||||
buffer_batch_data.g_joint_inverse[1] = temp.row1;
|
||||
buffer_batch_data.g_joint_inverse[2] = temp.row2;
|
||||
|
||||
buffer_batch.WriteMemory(buffer_batch_data);
|
||||
buffer_batch.WriteMemory(p_gl_rend_st, buffer_batch_data);
|
||||
enum_and(flags, ~RENDER_DATA_BATCH_UPDATE);
|
||||
}
|
||||
|
||||
buffer_shader.Bind(0);
|
||||
buffer_scene.Bind(1);
|
||||
buffer_batch.Bind(2);
|
||||
p_gl_rend_st.bind_uniform_buffer_base(0, buffer_shader);
|
||||
p_gl_rend_st.bind_uniform_buffer_base(1, buffer_scene);
|
||||
p_gl_rend_st.bind_uniform_buffer_base(2, buffer_batch);
|
||||
|
||||
if (uniform->arr[U_SKINNING] && !config_shared_storage_uniform_buffer)
|
||||
if (shader_flags.arr[U_SKINNING] && !config_shared_storage_uniform_buffer)
|
||||
if (DIVA_GL_VERSION_4_3)
|
||||
buffer_skinning.Bind(0);
|
||||
p_gl_rend_st.bind_shader_storage_buffer_base(0, buffer_skinning);
|
||||
else
|
||||
buffer_skinning_ubo.Bind(6);
|
||||
p_gl_rend_st.bind_uniform_buffer_base(6, buffer_skinning_ubo);
|
||||
}
|
||||
|
||||
void render_data::set_shader(uint32_t index) {
|
||||
shader_index = index;
|
||||
|
||||
buffer_shader_data.set_shader_flags(uniform->arr);
|
||||
buffer_shader_data.set_shader_flags(shader_flags.arr);
|
||||
enum_or(flags, RENDER_DATA_SHADER_UPDATE);
|
||||
}
|
||||
|
||||
render_data_context::render_data_context(gl_rend_state_index index) : state(index), index(index),
|
||||
data(rctx->data[index]), shader_flags(rctx->data[index].shader_flags) {
|
||||
|
||||
}
|
||||
|
||||
void render_data_context::get_scene_fog_params(render_data_context::fog_params& value) {
|
||||
value.depth_color = data.buffer_scene_data.g_fog_depth_color;
|
||||
value.height_params = data.buffer_scene_data.g_fog_height_params;
|
||||
value.height_color = data.buffer_scene_data.g_fog_height_color;
|
||||
value.bump_params = data.buffer_scene_data.g_fog_bump_params;
|
||||
value.density = data.buffer_scene_data.g_fog_state_params.x;
|
||||
value.start = data.buffer_scene_data.g_fog_state_params.y;
|
||||
value.end = data.buffer_scene_data.g_fog_state_params.z;
|
||||
}
|
||||
|
||||
void render_data_context::get_scene_light(vec4* light_env_stage_diffuse,
|
||||
vec4* light_env_stage_specular, vec4* light_chara_dir, vec4* light_chara_luce,
|
||||
vec4* light_env_chara_diffuse, vec4* light_env_chara_specular) {
|
||||
if (light_env_stage_diffuse)
|
||||
*light_env_stage_diffuse = data.buffer_scene_data.g_light_env_stage_diffuse;
|
||||
if (light_env_stage_specular)
|
||||
*light_env_stage_specular = data.buffer_scene_data.g_light_env_stage_specular;
|
||||
if (light_chara_dir)
|
||||
*light_chara_dir = data.buffer_scene_data.g_light_chara_dir;
|
||||
if (light_chara_luce)
|
||||
*light_chara_luce = data.buffer_scene_data.g_light_chara_luce;
|
||||
if (light_env_chara_diffuse)
|
||||
*light_env_chara_diffuse = data.buffer_scene_data.g_light_env_chara_diffuse;
|
||||
if (light_env_chara_specular)
|
||||
*light_env_chara_specular = data.buffer_scene_data.g_light_env_chara_specular;
|
||||
}
|
||||
|
||||
void render_data_context::reset_shader_flags() {
|
||||
shader_flags.arr[U_TEXTURE_COUNT] = 0;
|
||||
shader_flags.arr[U_TEXTURE_BLEND] = 0;
|
||||
shader_flags.arr[U_NORMAL] = 0;
|
||||
shader_flags.arr[U_SPECULAR] = 0;
|
||||
shader_flags.arr[U_TRANSPARENCY] = 0;
|
||||
shader_flags.arr[U_TRANSLUCENCY] = 0;
|
||||
shader_flags.arr[U_ENV_MAP] = 0;
|
||||
shader_flags.arr[U0B] = 0;
|
||||
shader_flags.arr[U_SPECULAR_IBL] = 0;
|
||||
shader_flags.arr[U_FOG_STAGE] = 0;
|
||||
shader_flags.arr[U_FOG_CHARA] = 0;
|
||||
shader_flags.arr[U_ANISO] = 0;
|
||||
shader_flags.arr[U_STAGE_SHADOW] = 0;
|
||||
shader_flags.arr[U45] = 0;
|
||||
shader_flags.arr[U_TEX_0_TYPE] = 0;
|
||||
shader_flags.arr[U_TEX_1_TYPE] = 0;
|
||||
}
|
||||
|
||||
void render_data_context::set_batch_alpha_threshold(const float_t value) {
|
||||
data.buffer_batch_data.g_max_alpha.z = value;
|
||||
enum_or(data.flags, RENDER_DATA_BATCH_UPDATE);
|
||||
}
|
||||
|
||||
void render_data_context::set_batch_blend_color_offset_color(
|
||||
const vec4& blend_color, const vec4& offset_color) {
|
||||
data.buffer_batch_data.g_blend_color = blend_color;
|
||||
data.buffer_batch_data.g_offset_color = offset_color;
|
||||
enum_or(data.flags, RENDER_DATA_BATCH_UPDATE);
|
||||
}
|
||||
|
||||
void render_data_context::set_batch_material_color(const vec4& diffuse, const vec4& ambient,
|
||||
const vec4& emission, const float_t material_shininess, const vec4& specular,
|
||||
const vec4& fresnel_coefficients, const vec4& texture_color_coefficients,
|
||||
const vec4& texture_color_offset, const vec4& texture_specular_coefficients,
|
||||
const vec4& texture_specular_offset, const float_t shininess) {
|
||||
data.buffer_batch_data.g_material_state_diffuse = diffuse;
|
||||
data.buffer_batch_data.g_material_state_ambient = ambient;
|
||||
data.buffer_batch_data.g_material_state_emission = emission;
|
||||
data.buffer_batch_data.g_material_state_shininess = { material_shininess, 0.0f, 0.0f, 1.0f };
|
||||
data.buffer_batch_data.g_material_state_specular = specular;
|
||||
data.buffer_batch_data.g_fresnel_coefficients = fresnel_coefficients;
|
||||
data.buffer_batch_data.g_texture_color_coefficients = texture_color_coefficients;
|
||||
data.buffer_batch_data.g_texture_color_offset = texture_color_offset;
|
||||
data.buffer_batch_data.g_texture_specular_coefficients = texture_specular_coefficients;
|
||||
data.buffer_batch_data.g_shininess.x = shininess;
|
||||
data.buffer_batch_data.g_texture_specular_offset = texture_specular_offset;
|
||||
enum_or(data.flags, RENDER_DATA_BATCH_UPDATE);
|
||||
}
|
||||
|
||||
void render_data_context::set_batch_material_color_emission(const vec4& emission) {
|
||||
data.buffer_batch_data.g_material_state_emission = emission;
|
||||
enum_or(data.flags, RENDER_DATA_BATCH_UPDATE);
|
||||
}
|
||||
|
||||
void render_data_context::set_batch_material_parameter(const vec4* specular, const vec4& bump_depth,
|
||||
const vec4& intensity, const float_t reflect_uv_scale, const float_t refract_uv_scale) {
|
||||
if (specular)
|
||||
data.buffer_batch_data.g_material_state_specular = *specular;
|
||||
data.buffer_batch_data.g_bump_depth = bump_depth;
|
||||
data.buffer_batch_data.g_intensity = intensity;
|
||||
data.buffer_batch_data.g_reflect_uv_scale.x = reflect_uv_scale;
|
||||
data.buffer_batch_data.g_reflect_uv_scale.y = reflect_uv_scale;
|
||||
data.buffer_batch_data.g_reflect_uv_scale.z = refract_uv_scale;
|
||||
data.buffer_batch_data.g_reflect_uv_scale.w = refract_uv_scale;
|
||||
enum_or(data.flags, RENDER_DATA_BATCH_UPDATE);
|
||||
}
|
||||
|
||||
void render_data_context::set_batch_min_alpha(const float_t value) {
|
||||
data.buffer_batch_data.g_max_alpha.w = value;
|
||||
enum_or(data.flags, RENDER_DATA_BATCH_UPDATE);
|
||||
}
|
||||
|
||||
void render_data_context::set_batch_morph_weight(const float_t value) {
|
||||
data.buffer_batch_data.g_morph_weight.x = value;
|
||||
data.buffer_batch_data.g_morph_weight.y = 1.0f - value;
|
||||
data.buffer_batch_data.g_morph_weight.z = 0.0f;
|
||||
data.buffer_batch_data.g_morph_weight.w = 0.0f;
|
||||
enum_or(data.flags, RENDER_DATA_BATCH_UPDATE);
|
||||
}
|
||||
|
||||
void render_data_context::set_batch_scene_camera(const cam_data& cam) {
|
||||
data.cam = cam;
|
||||
|
||||
mat4_invert(&data.cam.get_view_mat(), &data.inv_view_mat);
|
||||
|
||||
mat4 temp;
|
||||
mat4_transpose(&data.cam.get_view_mat(), &temp);
|
||||
data.buffer_scene_data.g_view[0] = temp.row0;
|
||||
data.buffer_scene_data.g_view[1] = temp.row1;
|
||||
data.buffer_scene_data.g_view[2] = temp.row2;
|
||||
|
||||
mat4_invert(&data.cam.get_view_mat(), &temp);
|
||||
mat4_transpose(&temp, &temp);
|
||||
data.buffer_scene_data.g_view_inverse[0] = temp.row0;
|
||||
data.buffer_scene_data.g_view_inverse[1] = temp.row1;
|
||||
data.buffer_scene_data.g_view_inverse[2] = temp.row2;
|
||||
|
||||
mat4_transpose(&data.cam.get_view_proj_mat(), &temp);
|
||||
data.buffer_scene_data.g_projection_view[0] = temp.row0;
|
||||
data.buffer_scene_data.g_projection_view[1] = temp.row1;
|
||||
data.buffer_scene_data.g_projection_view[2] = temp.row2;
|
||||
data.buffer_scene_data.g_projection_view[3] = temp.row3;
|
||||
|
||||
*(vec3*)&data.buffer_scene_data.g_view_position = cam.get_view_point();
|
||||
data.buffer_scene_data.g_view_position.w = 0.0f;
|
||||
//enum_or(data.flags, RENDER_DATA_BATCH_UPDATE | RENDER_DATA_SCENE_UPDATE);
|
||||
enum_or(data.flags, RENDER_DATA_SCENE_UPDATE);
|
||||
}
|
||||
|
||||
void render_data_context::set_batch_sss_param(const vec4& sss_param) {
|
||||
data.buffer_batch_data.g_sss_param = sss_param;
|
||||
enum_or(data.flags, RENDER_DATA_BATCH_UPDATE);
|
||||
}
|
||||
|
||||
void render_data_context::set_batch_texcoord_transforms(const mat4 mats[2]) {
|
||||
mat4 temp;
|
||||
mat4_transpose(&mats[0], &temp);
|
||||
data.buffer_batch_data.g_texcoord_transforms[0] = temp.row0;
|
||||
data.buffer_batch_data.g_texcoord_transforms[1] = temp.row1;
|
||||
mat4_transpose(&mats[1], &temp);
|
||||
data.buffer_batch_data.g_texcoord_transforms[2] = temp.row0;
|
||||
data.buffer_batch_data.g_texcoord_transforms[3] = temp.row1;
|
||||
enum_or(data.flags, RENDER_DATA_BATCH_UPDATE);
|
||||
}
|
||||
|
||||
void render_data_context::set_batch_worlds(const mat4& mat) {
|
||||
mat4 temp;
|
||||
mat4_transpose(&mat, &temp);
|
||||
if (data.buffer_batch_data.g_worlds[0] != temp.row0
|
||||
|| data.buffer_batch_data.g_worlds[1] != temp.row1
|
||||
|| data.buffer_batch_data.g_worlds[2] != temp.row2) {
|
||||
data.buffer_batch_data.g_worlds[0] = temp.row0;
|
||||
data.buffer_batch_data.g_worlds[1] = temp.row1;
|
||||
data.buffer_batch_data.g_worlds[2] = temp.row2;
|
||||
enum_or(data.flags, RENDER_DATA_BATCH_UPDATE);
|
||||
}
|
||||
}
|
||||
|
||||
void render_data_context::set_glitter_render_data_state() {
|
||||
data.buffer_shader_data.set_shader_flags(data.shader_flags.arr);
|
||||
data.buffer_shader.WriteMemory(state, data.buffer_shader_data);
|
||||
state.bind_uniform_buffer_base(0, data.buffer_shader);
|
||||
|
||||
if (data.flags & RENDER_DATA_SCENE_UPDATE) {
|
||||
data.buffer_scene.WriteMemory(state, data.buffer_scene_data);
|
||||
enum_and(data.flags, ~RENDER_DATA_SCENE_UPDATE);
|
||||
}
|
||||
state.bind_uniform_buffer_base(1, data.buffer_scene);
|
||||
}
|
||||
|
||||
void render_data_context::set_render_data_state() {
|
||||
data.set_state(state);
|
||||
}
|
||||
|
||||
void render_data_context::set_scene_fog_params(const render_data_context::fog_params& value) {
|
||||
data.buffer_scene_data.g_fog_depth_color = value.depth_color;
|
||||
data.buffer_scene_data.g_fog_height_params = value.height_params;
|
||||
data.buffer_scene_data.g_fog_height_color = value.height_color;
|
||||
data.buffer_scene_data.g_fog_bump_params = value.bump_params;
|
||||
const float_t start = value.start;
|
||||
const float_t end = value.end;
|
||||
data.buffer_scene_data.g_fog_state_params.x = value.density;
|
||||
data.buffer_scene_data.g_fog_state_params.y = value.start;
|
||||
data.buffer_scene_data.g_fog_state_params.z = value.end;
|
||||
data.buffer_scene_data.g_fog_state_params.w = end - start > 0.0f ? 1.0f / (end - start) : 0.0f;
|
||||
enum_or(data.flags, RENDER_DATA_SCENE_UPDATE);
|
||||
}
|
||||
|
||||
void render_data_context::set_scene_framebuffer_size(const int32_t width, const int32_t height,
|
||||
const int32_t render_width, const int32_t render_height) {
|
||||
enum_or(data.flags, RENDER_DATA_SCENE_UPDATE);
|
||||
data.buffer_scene_data.g_framebuffer_size.x = 1.0f / (float_t)width;
|
||||
data.buffer_scene_data.g_framebuffer_size.y = 1.0f / (float_t)height;
|
||||
data.buffer_scene_data.g_framebuffer_size.w = 1.0f / (float_t)render_height;
|
||||
data.buffer_scene_data.g_framebuffer_size.z = 1.0f / (float_t)render_width;
|
||||
}
|
||||
|
||||
void render_data_context::set_scene_light(const mat4& irradiance_r_transforms, const mat4& irradiance_g_transforms,
|
||||
const mat4& irradiance_b_transforms, const vec4& light_env_stage_diffuse,
|
||||
const vec4& light_env_stage_specular, const vec4& light_env_chara_diffuse,
|
||||
const vec4& light_env_chara_ambient, const vec4& light_env_chara_specular,
|
||||
const vec4& light_env_reflect_diffuse, const vec4& light_env_reflect_ambient,
|
||||
const vec4& light_env_proj_diffuse, const vec4& light_env_proj_specular,
|
||||
const vec4& light_env_proj_position, const vec4& light_stage_dir, const vec4& light_stage_diff,
|
||||
const vec4& light_stage_spec, const vec4& light_chara_dir, const vec4& light_chara_spec,
|
||||
const vec4& light_chara_luce, const vec4& light_chara_back, const vec4& light_face_diff,
|
||||
const vec4& chara_color0, const vec4& chara_color1, const vec4& chara_f_dir, const vec4& chara_f_ambient,
|
||||
const vec4& chara_f_diffuse, const vec4& chara_tc_param, const mat4& normal_tangent_transforms,
|
||||
const vec4& light_reflect_dir, const vec4& clip_plane, const vec4& npr_cloth_spec_color) {
|
||||
mat4 temp;
|
||||
mat4_transpose(&irradiance_r_transforms, &temp);
|
||||
data.buffer_scene_data.g_irradiance_r_transforms[0] = temp.row0;
|
||||
data.buffer_scene_data.g_irradiance_r_transforms[1] = temp.row1;
|
||||
data.buffer_scene_data.g_irradiance_r_transforms[2] = temp.row2;
|
||||
data.buffer_scene_data.g_irradiance_r_transforms[3] = temp.row3;
|
||||
mat4_transpose(&irradiance_g_transforms, &temp);
|
||||
data.buffer_scene_data.g_irradiance_g_transforms[0] = temp.row0;
|
||||
data.buffer_scene_data.g_irradiance_g_transforms[1] = temp.row1;
|
||||
data.buffer_scene_data.g_irradiance_g_transforms[2] = temp.row2;
|
||||
data.buffer_scene_data.g_irradiance_g_transforms[3] = temp.row3;
|
||||
mat4_transpose(&irradiance_b_transforms, &temp);
|
||||
data.buffer_scene_data.g_irradiance_b_transforms[0] = temp.row0;
|
||||
data.buffer_scene_data.g_irradiance_b_transforms[1] = temp.row1;
|
||||
data.buffer_scene_data.g_irradiance_b_transforms[2] = temp.row2;
|
||||
data.buffer_scene_data.g_irradiance_b_transforms[3] = temp.row3;
|
||||
data.buffer_scene_data.g_light_env_stage_diffuse = light_env_stage_diffuse;
|
||||
data.buffer_scene_data.g_light_env_stage_specular = light_env_stage_specular;
|
||||
data.buffer_scene_data.g_light_env_chara_diffuse = light_env_chara_diffuse;
|
||||
data.buffer_scene_data.g_light_env_chara_ambient = light_env_chara_ambient;
|
||||
data.buffer_scene_data.g_light_env_chara_specular = light_env_chara_specular;
|
||||
data.buffer_scene_data.g_light_env_reflect_diffuse = light_env_reflect_diffuse;
|
||||
data.buffer_scene_data.g_light_env_reflect_ambient = light_env_reflect_ambient;
|
||||
data.buffer_scene_data.g_light_env_proj_diffuse = light_env_proj_diffuse;
|
||||
data.buffer_scene_data.g_light_env_proj_specular = light_env_proj_specular;
|
||||
data.buffer_scene_data.g_light_env_proj_position = light_env_proj_position;
|
||||
data.buffer_scene_data.g_light_stage_dir = light_stage_dir;
|
||||
data.buffer_scene_data.g_light_stage_diff = light_stage_diff;
|
||||
data.buffer_scene_data.g_light_stage_spec = light_stage_spec;
|
||||
data.buffer_scene_data.g_light_chara_dir = light_chara_dir;
|
||||
data.buffer_scene_data.g_light_chara_spec = light_chara_spec;
|
||||
data.buffer_scene_data.g_light_chara_luce = light_chara_luce;
|
||||
data.buffer_scene_data.g_light_chara_back = light_chara_back;
|
||||
data.buffer_scene_data.g_light_face_diff = light_face_diff;
|
||||
data.buffer_scene_data.g_chara_color0 = chara_color0;
|
||||
data.buffer_scene_data.g_chara_color1 = chara_color1;
|
||||
data.buffer_scene_data.g_chara_f_dir = chara_f_dir;
|
||||
data.buffer_scene_data.g_chara_f_ambient = chara_f_ambient;
|
||||
data.buffer_scene_data.g_chara_f_diffuse = chara_f_diffuse;
|
||||
data.buffer_scene_data.g_chara_tc_param = chara_tc_param;
|
||||
mat4_transpose(&normal_tangent_transforms, &temp);
|
||||
data.buffer_scene_data.g_normal_tangent_transforms[0] = temp.row0;
|
||||
data.buffer_scene_data.g_normal_tangent_transforms[1] = temp.row1;
|
||||
data.buffer_scene_data.g_normal_tangent_transforms[2] = temp.row2;
|
||||
data.buffer_scene_data.g_light_reflect_dir = light_reflect_dir;
|
||||
data.buffer_scene_data.g_clip_plane = clip_plane;
|
||||
data.buffer_scene_data.g_npr_cloth_spec_color = npr_cloth_spec_color;
|
||||
enum_or(data.flags, RENDER_DATA_SCENE_UPDATE);
|
||||
}
|
||||
|
||||
void render_data_context::set_scene_light_projection(const mat4& light_projection) {
|
||||
mat4 temp;
|
||||
mat4_transpose(&light_projection, &temp);
|
||||
data.buffer_scene_data.g_light_projection[0] = temp.row0;
|
||||
data.buffer_scene_data.g_light_projection[1] = temp.row1;
|
||||
data.buffer_scene_data.g_light_projection[2] = temp.row2;
|
||||
data.buffer_scene_data.g_light_projection[3] = temp.row3;
|
||||
enum_or(data.flags, RENDER_DATA_SCENE_UPDATE);
|
||||
}
|
||||
|
||||
void render_data_context::set_scene_shadow_params(const float_t esm_param,
|
||||
const mat4 mats[2], const vec4& shadow_ambient, const vec4& shadow_ambient1) {
|
||||
data.buffer_scene_data.g_esm_param = { esm_param, 0.0f, 0.0f, 0.0f };
|
||||
mat4 temp;
|
||||
mat4_transpose(&mats[0], &temp);
|
||||
data.buffer_scene_data.g_self_shadow_receivers[0] = temp.row0;
|
||||
data.buffer_scene_data.g_self_shadow_receivers[1] = temp.row1;
|
||||
data.buffer_scene_data.g_self_shadow_receivers[2] = temp.row2;
|
||||
mat4_transpose(&mats[1], &temp);
|
||||
data.buffer_scene_data.g_self_shadow_receivers[3] = temp.row0;
|
||||
data.buffer_scene_data.g_self_shadow_receivers[4] = temp.row1;
|
||||
data.buffer_scene_data.g_self_shadow_receivers[5] = temp.row2;
|
||||
data.buffer_scene_data.g_shadow_ambient = shadow_ambient;
|
||||
data.buffer_scene_data.g_shadow_ambient1 = shadow_ambient1;
|
||||
enum_or(data.flags, RENDER_DATA_SCENE_UPDATE);
|
||||
}
|
||||
|
||||
void render_data_context::set_self_shadow(bool value) {
|
||||
rctx->draw_state_rend_data[index].self_shadow = value;
|
||||
}
|
||||
|
||||
void render_data_context::set_shader(uint32_t index) {
|
||||
data.set_shader(index);
|
||||
}
|
||||
|
||||
void render_data_context::set_shadow(bool value) {
|
||||
rctx->draw_state_rend_data[index].shadow = value;
|
||||
}
|
||||
|
||||
void render_data_context::set_skinning_data(p_gl_rend_state& p_gl_rend_st, const mat4* mats, int32_t count) {
|
||||
data.set_skinning_data(p_gl_rend_st, mats, count);
|
||||
}
|
||||
|
||||
bool render_context::shared_storage_buffer::can_fill_data(size_t size) {
|
||||
return (size + align_val(offset, sv_min_storage_buffer_alignment)) <= this->size;
|
||||
}
|
||||
@@ -372,7 +739,7 @@ void render_context::shared_storage_buffer::create(size_t size) {
|
||||
|
||||
size = size / sv_min_storage_buffer_alignment * sv_min_storage_buffer_alignment;
|
||||
|
||||
buffer.Create(size);
|
||||
buffer.Create(gl_state, size);
|
||||
data = _operator_new(size);
|
||||
memset(data, 0, size);
|
||||
offset = 0;
|
||||
@@ -407,7 +774,7 @@ void render_context::shared_uniform_buffer::create(size_t size) {
|
||||
|
||||
size = size / sv_min_uniform_buffer_alignment * sv_min_uniform_buffer_alignment;
|
||||
|
||||
buffer.Create(size);
|
||||
buffer.Create(gl_state, size);
|
||||
data = _operator_new(size);
|
||||
memset(data, 0, size);
|
||||
offset = 0;
|
||||
@@ -435,6 +802,8 @@ size_t render_context::shared_uniform_buffer::fill_data(const void* data, size_t
|
||||
render_context::render_context() : box_vao(), lens_ghost_vao(), common_vao(), reflect_buffer(),
|
||||
render_buffer(), screen_buffer(), shadow_buffer(), empty_texture_2d(), empty_texture_cube_map(),
|
||||
samplers(), render_samplers(), sprite_samplers(), screen_width(), screen_height() {
|
||||
gl_state.get();
|
||||
|
||||
static const float_t box_texcoords[] = {
|
||||
1.0f, 0.0f, 0.0f, 1.0f, -1.0f, 0.0f, 0.0f, -1.0f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||
@@ -471,10 +840,10 @@ samplers(), render_samplers(), sprite_samplers(), screen_width(), screen_height(
|
||||
};
|
||||
|
||||
glGenVertexArrays(1, &box_vao);
|
||||
gl_rend_state.bind_vertex_array(box_vao);
|
||||
gl_state.bind_vertex_array(box_vao);
|
||||
|
||||
box_vbo.Create(sizeof(box_texcoords), box_texcoords);
|
||||
box_vbo.Bind();
|
||||
box_vbo.Create(gl_state, sizeof(box_texcoords), box_texcoords);
|
||||
gl_state.bind_array_buffer(box_vbo);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(float_t) * 16, (void*)0);
|
||||
@@ -486,39 +855,41 @@ samplers(), render_samplers(), sprite_samplers(), screen_width(), screen_height(
|
||||
glVertexAttribPointer(3, 4, GL_FLOAT, GL_FALSE, sizeof(float_t) * 16, (void*)(sizeof(float_t) * 12));
|
||||
|
||||
glGenVertexArrays(1, &lens_ghost_vao);
|
||||
gl_rend_state.bind_vertex_array(lens_ghost_vao);
|
||||
gl_state.bind_vertex_array(lens_ghost_vao);
|
||||
|
||||
lens_ghost_vbo.Create(sizeof(float_t) * 5 * (6 * 16));
|
||||
lens_ghost_vbo.Bind();
|
||||
lens_ghost_vbo.Create(gl_state, sizeof(float_t) * 5 * (6 * 16));
|
||||
gl_state.bind_array_buffer(lens_ghost_vbo);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float_t) * 5, (void*)0);
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(float_t) * 5, (void*)(sizeof(float_t) * 2));
|
||||
gl_rend_state.bind_array_buffer(0);
|
||||
gl_rend_state.bind_vertex_array(0);
|
||||
gl_state.bind_array_buffer(0);
|
||||
gl_state.bind_vertex_array(0);
|
||||
|
||||
glGenVertexArrays(1, &common_vao);
|
||||
|
||||
camera_blur_ubo.Create(sizeof(camera_blur_shader_data));
|
||||
contour_coef_ubo.Create(sizeof(contour_coef_shader_data));
|
||||
contour_params_ubo.Create(sizeof(contour_params_shader_data));
|
||||
filter_scene_ubo.Create(sizeof(filter_scene_shader_data));
|
||||
esm_filter_batch_ubo.Create(sizeof(esm_filter_batch_shader_data));
|
||||
imgfilter_batch_ubo.Create(sizeof(imgfilter_batch_shader_data));
|
||||
exposure_measure_ubo.Create(sizeof(exposure_measure_shader_data));
|
||||
gaussian_coef_ubo.Create(sizeof(gaussian_coef_shader_data));
|
||||
glass_eye_batch_ubo.Create(sizeof(glass_eye_batch_shader_data));
|
||||
glitter_batch_ubo.Create(sizeof(glitter_batch_shader_data));
|
||||
quad_ubo.Create(sizeof(quad_shader_data));
|
||||
sprite_scene_ubo.Create(sizeof(sprite_scene_shader_data));
|
||||
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));
|
||||
camera_blur_ubo.Create(gl_state, sizeof(camera_blur_shader_data));
|
||||
contour_coef_ubo.Create(gl_state, sizeof(contour_coef_shader_data));
|
||||
contour_params_ubo.Create(gl_state, sizeof(contour_params_shader_data));
|
||||
filter_scene_ubo.Create(gl_state, sizeof(filter_scene_shader_data));
|
||||
esm_filter_batch_ubo.Create(gl_state, sizeof(esm_filter_batch_shader_data));
|
||||
imgfilter_batch_ubo.Create(gl_state, sizeof(imgfilter_batch_shader_data));
|
||||
exposure_measure_ubo.Create(gl_state, sizeof(exposure_measure_shader_data));
|
||||
gaussian_coef_ubo.Create(gl_state, sizeof(gaussian_coef_shader_data));
|
||||
glass_eye_batch_ubo.Create(gl_state, sizeof(glass_eye_batch_shader_data));
|
||||
glitter_batch_ubo.Create(gl_state, sizeof(glitter_batch_shader_data));
|
||||
quad_ubo.Create(gl_state, sizeof(quad_shader_data));
|
||||
sprite_scene_ubo.Create(gl_state, sizeof(sprite_scene_shader_data));
|
||||
sss_filter_gaussian_coef_ubo.Create(gl_state, sizeof(sss_filter_gaussian_coef_shader_data));
|
||||
sun_quad_ubo.Create(gl_state, sizeof(sun_quad_shader_data));
|
||||
tone_map_ubo.Create(gl_state, sizeof(tone_map_shader_data));
|
||||
transparency_batch_ubo.Create(gl_state, sizeof(transparency_batch_shader_data));
|
||||
|
||||
data = {};
|
||||
data.init();
|
||||
for (render_data& i : data) {
|
||||
i = {};
|
||||
i.init();
|
||||
}
|
||||
|
||||
static const vec4 border_color = 0.0f;
|
||||
|
||||
@@ -639,7 +1010,8 @@ render_context::~render_context() {
|
||||
glDeleteSamplers(4, render_samplers);
|
||||
glDeleteSamplers(18, samplers);
|
||||
|
||||
data.free();
|
||||
for (render_data& i : data)
|
||||
i.free();
|
||||
|
||||
transparency_batch_ubo.Destroy();
|
||||
tone_map_ubo.Destroy();
|
||||
@@ -711,7 +1083,7 @@ void render_context::ctrl(bool change_res) {
|
||||
|
||||
/*if (render_res_change)
|
||||
render.resize(render_width, render_height);*/
|
||||
|
||||
|
||||
if (!change_res || /*!render_res_change && */!screen_res_change)
|
||||
return;
|
||||
|
||||
@@ -837,35 +1209,6 @@ void render_context::add_shared_storage_uniform_buffer_data(size_t index,
|
||||
}
|
||||
}
|
||||
|
||||
void render_context::get_scene_fog_params(render_context::fog_params& value) {
|
||||
render_data* data = &this->data;
|
||||
value.depth_color = data->buffer_scene_data.g_fog_depth_color;
|
||||
value.height_params = data->buffer_scene_data.g_fog_height_params;
|
||||
value.height_color = data->buffer_scene_data.g_fog_height_color;
|
||||
value.bump_params = data->buffer_scene_data.g_fog_bump_params;
|
||||
value.density = data->buffer_scene_data.g_fog_state_params.x;
|
||||
value.start = data->buffer_scene_data.g_fog_state_params.y;
|
||||
value.end = data->buffer_scene_data.g_fog_state_params.z;
|
||||
}
|
||||
|
||||
void render_context::get_scene_light(vec4* light_env_stage_diffuse,
|
||||
vec4* light_env_stage_specular, vec4* light_chara_dir, vec4* light_chara_luce,
|
||||
vec4* light_env_chara_diffuse, vec4* light_env_chara_specular) {
|
||||
render_data* data = &this->data;
|
||||
if (light_env_stage_diffuse)
|
||||
*light_env_stage_diffuse = data->buffer_scene_data.g_light_env_stage_diffuse;
|
||||
if (light_env_stage_specular)
|
||||
*light_env_stage_specular = data->buffer_scene_data.g_light_env_stage_specular;
|
||||
if (light_chara_dir)
|
||||
*light_chara_dir = data->buffer_scene_data.g_light_chara_dir;
|
||||
if (light_chara_luce)
|
||||
*light_chara_luce = data->buffer_scene_data.g_light_chara_luce;
|
||||
if (light_env_chara_diffuse)
|
||||
*light_env_chara_diffuse = data->buffer_scene_data.g_light_env_chara_diffuse;
|
||||
if (light_env_chara_specular)
|
||||
*light_env_chara_specular = data->buffer_scene_data.g_light_env_chara_specular;
|
||||
}
|
||||
|
||||
bool render_context::get_shared_storage_uniform_buffer_data(size_t index,
|
||||
GLuint& buffer, size_t& offset, size_t& size, bool storage) {
|
||||
if (storage) {
|
||||
@@ -909,20 +1252,21 @@ void render_context::pre_proc() {
|
||||
|
||||
const int32_t mat_count = min_def(args->mat_count, 256);
|
||||
const mat4* mats = args->mats;
|
||||
vec4* g_joint_transforms = rctx->data.buffer_skinning_data.g_joint_transforms;
|
||||
vec4 g_joint_transforms[768];
|
||||
vec4* g_joint_transform = g_joint_transforms;
|
||||
|
||||
mat4 mat;
|
||||
for (int32_t i = 0; i < mat_count; i++, mats++, g_joint_transforms += 3) {
|
||||
for (int32_t i = 0; i < mat_count; i++, mats++, g_joint_transform += 3) {
|
||||
mat4_transpose(mats, &mat);
|
||||
g_joint_transforms[0] = mat.row0;
|
||||
g_joint_transforms[1] = mat.row1;
|
||||
g_joint_transforms[2] = mat.row2;
|
||||
g_joint_transform[0] = mat.row0;
|
||||
g_joint_transform[1] = mat.row1;
|
||||
g_joint_transform[2] = mat.row2;
|
||||
}
|
||||
|
||||
const size_t buffer_size = sizeof(vec4) * 3 * 256;
|
||||
const size_t size = sizeof(vec4) * 3 * mat_count;
|
||||
rctx->add_shared_storage_uniform_buffer_data((size_t)args->mats,
|
||||
rctx->data.buffer_skinning_data.g_joint_transforms, size, buffer_size, !!DIVA_GL_VERSION_4_3);
|
||||
g_joint_transforms, size, buffer_size, !!DIVA_GL_VERSION_4_3);
|
||||
};
|
||||
|
||||
for (int32_t type = 0; type < mdl::OBJ_TYPE_MAX; type++)
|
||||
@@ -970,7 +1314,7 @@ void render_context::pre_proc() {
|
||||
const size_t align = size - i.offset;
|
||||
if (align)
|
||||
memset((void*)((size_t)i.data + i.offset), 0, align);
|
||||
i.buffer.WriteMemory(0, size, i.data);
|
||||
i.buffer.WriteMemory(gl_state, 0, size, i.data);
|
||||
}
|
||||
|
||||
for (render_context::shared_uniform_buffer& i : shared_uniform_buffers) {
|
||||
@@ -981,7 +1325,7 @@ void render_context::pre_proc() {
|
||||
const size_t align = size - i.offset;
|
||||
if (align)
|
||||
memset((void*)((size_t)i.data + i.offset), 0, align);
|
||||
i.buffer.WriteMemory(0, size, i.data);
|
||||
i.buffer.WriteMemory(gl_state, 0, size, i.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1002,298 +1346,6 @@ void render_context::post_proc() {
|
||||
}
|
||||
}
|
||||
|
||||
void render_context::set_batch_alpha_threshold(const float_t value) {
|
||||
render_data* data = &this->data;
|
||||
data->buffer_batch_data.g_max_alpha.z = value;
|
||||
enum_or(data->flags, RENDER_DATA_BATCH_UPDATE);
|
||||
}
|
||||
|
||||
void render_context::set_batch_blend_color(const vec4& blend_color) {
|
||||
render_data* data = &this->data;
|
||||
data->buffer_batch_data.g_blend_color = blend_color;
|
||||
enum_or(data->flags, RENDER_DATA_BATCH_UPDATE);
|
||||
}
|
||||
|
||||
void render_context::set_batch_blend_color_offset_color(
|
||||
const vec4& blend_color, const vec4& offset_color) {
|
||||
render_data* data = &this->data;
|
||||
data->buffer_batch_data.g_blend_color = blend_color;
|
||||
data->buffer_batch_data.g_offset_color = offset_color;
|
||||
enum_or(data->flags, RENDER_DATA_BATCH_UPDATE);
|
||||
}
|
||||
|
||||
void render_context::set_batch_joint(const mat4& mat) {
|
||||
render_data* data = &this->data;
|
||||
mat4 temp;
|
||||
mat4_transpose(&mat, &temp);
|
||||
if (data->buffer_batch_data.g_joint[0] != temp.row0
|
||||
|| data->buffer_batch_data.g_joint[1] != temp.row1
|
||||
|| data->buffer_batch_data.g_joint[2] != temp.row2) {
|
||||
data->buffer_batch_data.g_joint[0] = temp.row0;
|
||||
data->buffer_batch_data.g_joint[1] = temp.row1;
|
||||
data->buffer_batch_data.g_joint[2] = temp.row2;
|
||||
enum_or(data->flags, RENDER_DATA_BATCH_UPDATE);
|
||||
}
|
||||
}
|
||||
|
||||
void render_context::set_batch_material_color(const vec4& diffuse, const vec4& ambient,
|
||||
const vec4& emission, const float_t material_shininess, const vec4& specular,
|
||||
const vec4& fresnel_coefficients, const vec4& texture_color_coefficients,
|
||||
const vec4& texture_color_offset, const vec4& texture_specular_coefficients,
|
||||
const vec4& texture_specular_offset, const float_t shininess) {
|
||||
render_data* data = &this->data;
|
||||
data->buffer_batch_data.g_material_state_diffuse = diffuse;
|
||||
data->buffer_batch_data.g_material_state_ambient = ambient;
|
||||
data->buffer_batch_data.g_material_state_emission = emission;
|
||||
data->buffer_batch_data.g_material_state_shininess = { material_shininess, 0.0f, 0.0f, 1.0f };
|
||||
data->buffer_batch_data.g_material_state_specular = specular;
|
||||
data->buffer_batch_data.g_fresnel_coefficients = fresnel_coefficients;
|
||||
data->buffer_batch_data.g_texture_color_coefficients = texture_color_coefficients;
|
||||
data->buffer_batch_data.g_texture_color_offset = texture_color_offset;
|
||||
data->buffer_batch_data.g_texture_specular_coefficients = texture_specular_coefficients;
|
||||
data->buffer_batch_data.g_shininess.x = shininess;
|
||||
data->buffer_batch_data.g_texture_specular_offset = texture_specular_offset;
|
||||
enum_or(data->flags, RENDER_DATA_BATCH_UPDATE);
|
||||
}
|
||||
|
||||
void render_context::set_batch_material_color_emission(const vec4& emission) {
|
||||
render_data* data = &this->data;
|
||||
data->buffer_batch_data.g_material_state_emission = emission;
|
||||
enum_or(data->flags, RENDER_DATA_BATCH_UPDATE);
|
||||
}
|
||||
|
||||
void render_context::set_batch_material_parameter(const vec4* specular, const vec4& bump_depth,
|
||||
const vec4& intensity, const float_t reflect_uv_scale, const float_t refract_uv_scale) {
|
||||
render_data* data = &this->data;
|
||||
if (specular)
|
||||
data->buffer_batch_data.g_material_state_specular = *specular;
|
||||
data->buffer_batch_data.g_bump_depth = bump_depth;
|
||||
data->buffer_batch_data.g_intensity = intensity;
|
||||
data->buffer_batch_data.g_reflect_uv_scale.x = reflect_uv_scale;
|
||||
data->buffer_batch_data.g_reflect_uv_scale.y = reflect_uv_scale;
|
||||
data->buffer_batch_data.g_reflect_uv_scale.z = refract_uv_scale;
|
||||
data->buffer_batch_data.g_reflect_uv_scale.w = refract_uv_scale;
|
||||
enum_or(data->flags, RENDER_DATA_BATCH_UPDATE);
|
||||
}
|
||||
|
||||
void render_context::set_batch_min_alpha(const float_t value) {
|
||||
render_data* data = &this->data;
|
||||
data->buffer_batch_data.g_max_alpha.w = value;
|
||||
enum_or(data->flags, RENDER_DATA_BATCH_UPDATE);
|
||||
}
|
||||
|
||||
void render_context::set_batch_morph_weight(const float_t value) {
|
||||
render_data* data = &this->data;
|
||||
data->buffer_batch_data.g_morph_weight.x = value;
|
||||
data->buffer_batch_data.g_morph_weight.y = 1.0f - value;
|
||||
data->buffer_batch_data.g_morph_weight.z = 0.0f;
|
||||
data->buffer_batch_data.g_morph_weight.w = 0.0f;
|
||||
enum_or(data->flags, RENDER_DATA_BATCH_UPDATE);
|
||||
}
|
||||
|
||||
void render_context::set_batch_offset_color(const vec4& offset_color) {
|
||||
render_data* data = &this->data;
|
||||
data->buffer_batch_data.g_offset_color = offset_color;
|
||||
enum_or(data->flags, RENDER_DATA_BATCH_UPDATE);
|
||||
}
|
||||
|
||||
void render_context::set_batch_sss_param(const vec4& sss_param) {
|
||||
render_data* data = &this->data;
|
||||
data->buffer_batch_data.g_sss_param = sss_param;
|
||||
enum_or(data->flags, RENDER_DATA_BATCH_UPDATE);
|
||||
}
|
||||
|
||||
void render_context::set_batch_texcoord_transforms(const mat4 mats[2]) {
|
||||
render_data* data = &this->data;
|
||||
mat4 temp;
|
||||
mat4_transpose(&mats[0], &temp);
|
||||
data->buffer_batch_data.g_texcoord_transforms[0] = temp.row0;
|
||||
data->buffer_batch_data.g_texcoord_transforms[1] = temp.row1;
|
||||
mat4_transpose(&mats[1], &temp);
|
||||
data->buffer_batch_data.g_texcoord_transforms[2] = temp.row0;
|
||||
data->buffer_batch_data.g_texcoord_transforms[3] = temp.row1;
|
||||
enum_or(data->flags, RENDER_DATA_BATCH_UPDATE);
|
||||
}
|
||||
|
||||
void render_context::set_batch_worlds(const mat4& mat) {
|
||||
render_data* data = &this->data;
|
||||
mat4 temp;
|
||||
mat4_transpose(&mat, &temp);
|
||||
if (data->buffer_batch_data.g_worlds[0] != temp.row0
|
||||
|| data->buffer_batch_data.g_worlds[1] != temp.row1
|
||||
|| data->buffer_batch_data.g_worlds[2] != temp.row2) {
|
||||
data->buffer_batch_data.g_worlds[0] = temp.row0;
|
||||
data->buffer_batch_data.g_worlds[1] = temp.row1;
|
||||
data->buffer_batch_data.g_worlds[2] = temp.row2;
|
||||
enum_or(data->flags, RENDER_DATA_BATCH_UPDATE);
|
||||
}
|
||||
}
|
||||
|
||||
void render_context::set_glitter_render_data() {
|
||||
render_data* data = &this->data;
|
||||
data->buffer_shader_data.set_shader_flags(uniform->arr);
|
||||
data->buffer_shader.WriteMemory(data->buffer_shader_data);
|
||||
data->buffer_shader.Bind(0);
|
||||
|
||||
if (data->flags & RENDER_DATA_SCENE_UPDATE) {
|
||||
data->buffer_scene.WriteMemory(data->buffer_scene_data);
|
||||
enum_and(data->flags, ~RENDER_DATA_SCENE_UPDATE);
|
||||
}
|
||||
data->buffer_scene.Bind(1);
|
||||
}
|
||||
|
||||
void render_context::set_render_data() {
|
||||
data.set(this);
|
||||
}
|
||||
|
||||
void render_context::set_scene_fog_params(const render_context::fog_params& value) {
|
||||
render_data* data = &this->data;
|
||||
data->buffer_scene_data.g_fog_depth_color = value.depth_color;
|
||||
data->buffer_scene_data.g_fog_height_params = value.height_params;
|
||||
data->buffer_scene_data.g_fog_height_color = value.height_color;
|
||||
data->buffer_scene_data.g_fog_bump_params = value.bump_params;
|
||||
const float_t start = value.start;
|
||||
const float_t end = value.end;
|
||||
data->buffer_scene_data.g_fog_state_params.x = value.density;
|
||||
data->buffer_scene_data.g_fog_state_params.y = value.start;
|
||||
data->buffer_scene_data.g_fog_state_params.z = value.end;
|
||||
data->buffer_scene_data.g_fog_state_params.w = end - start > 0.0f ? 1.0f / (end - start) : 0.0f;
|
||||
enum_or(data->flags, RENDER_DATA_SCENE_UPDATE);
|
||||
}
|
||||
|
||||
void render_context::set_scene_framebuffer_size(const int32_t width, const int32_t height,
|
||||
const int32_t render_width, const int32_t render_height) {
|
||||
render_data* data = &this->data;
|
||||
enum_or(data->flags, RENDER_DATA_SCENE_UPDATE);
|
||||
data->buffer_scene_data.g_framebuffer_size.x = 1.0f / (float_t)width;
|
||||
data->buffer_scene_data.g_framebuffer_size.y = 1.0f / (float_t)height;
|
||||
data->buffer_scene_data.g_framebuffer_size.w = 1.0f / (float_t)render_height;
|
||||
data->buffer_scene_data.g_framebuffer_size.z = 1.0f / (float_t)render_width;
|
||||
}
|
||||
|
||||
void render_context::set_scene_light(const mat4& irradiance_r_transforms, const mat4& irradiance_g_transforms,
|
||||
const mat4& irradiance_b_transforms, const vec4& light_env_stage_diffuse,
|
||||
const vec4& light_env_stage_specular, const vec4& light_env_chara_diffuse,
|
||||
const vec4& light_env_chara_ambient, const vec4& light_env_chara_specular,
|
||||
const vec4& light_env_reflect_diffuse, const vec4& light_env_reflect_ambient,
|
||||
const vec4& light_env_proj_diffuse, const vec4& light_env_proj_specular,
|
||||
const vec4& light_env_proj_position, const vec4& light_stage_dir, const vec4& light_stage_diff,
|
||||
const vec4& light_stage_spec, const vec4& light_chara_dir, const vec4& light_chara_spec,
|
||||
const vec4& light_chara_luce, const vec4& light_chara_back, const vec4& light_face_diff,
|
||||
const vec4& chara_color0, const vec4& chara_color1, const vec4& chara_f_dir, const vec4& chara_f_ambient,
|
||||
const vec4& chara_f_diffuse, const vec4& chara_tc_param, const mat4& normal_tangent_transforms,
|
||||
const vec4& light_reflect_dir, const vec4& clip_plane, const vec4& npr_cloth_spec_color) {
|
||||
render_data* data = &this->data;
|
||||
mat4 temp;
|
||||
mat4_transpose(&irradiance_r_transforms, &temp);
|
||||
data->buffer_scene_data.g_irradiance_r_transforms[0] = temp.row0;
|
||||
data->buffer_scene_data.g_irradiance_r_transforms[1] = temp.row1;
|
||||
data->buffer_scene_data.g_irradiance_r_transforms[2] = temp.row2;
|
||||
data->buffer_scene_data.g_irradiance_r_transforms[3] = temp.row3;
|
||||
mat4_transpose(&irradiance_g_transforms, &temp);
|
||||
data->buffer_scene_data.g_irradiance_g_transforms[0] = temp.row0;
|
||||
data->buffer_scene_data.g_irradiance_g_transforms[1] = temp.row1;
|
||||
data->buffer_scene_data.g_irradiance_g_transforms[2] = temp.row2;
|
||||
data->buffer_scene_data.g_irradiance_g_transforms[3] = temp.row3;
|
||||
mat4_transpose(&irradiance_b_transforms, &temp);
|
||||
data->buffer_scene_data.g_irradiance_b_transforms[0] = temp.row0;
|
||||
data->buffer_scene_data.g_irradiance_b_transforms[1] = temp.row1;
|
||||
data->buffer_scene_data.g_irradiance_b_transforms[2] = temp.row2;
|
||||
data->buffer_scene_data.g_irradiance_b_transforms[3] = temp.row3;
|
||||
data->buffer_scene_data.g_light_env_stage_diffuse = light_env_stage_diffuse;
|
||||
data->buffer_scene_data.g_light_env_stage_specular = light_env_stage_specular;
|
||||
data->buffer_scene_data.g_light_env_chara_diffuse = light_env_chara_diffuse;
|
||||
data->buffer_scene_data.g_light_env_chara_ambient = light_env_chara_ambient;
|
||||
data->buffer_scene_data.g_light_env_chara_specular = light_env_chara_specular;
|
||||
data->buffer_scene_data.g_light_env_reflect_diffuse = light_env_reflect_diffuse;
|
||||
data->buffer_scene_data.g_light_env_reflect_ambient = light_env_reflect_ambient;
|
||||
data->buffer_scene_data.g_light_env_proj_diffuse = light_env_proj_diffuse;
|
||||
data->buffer_scene_data.g_light_env_proj_specular = light_env_proj_specular;
|
||||
data->buffer_scene_data.g_light_env_proj_position = light_env_proj_position;
|
||||
data->buffer_scene_data.g_light_stage_dir = light_stage_dir;
|
||||
data->buffer_scene_data.g_light_stage_diff = light_stage_diff;
|
||||
data->buffer_scene_data.g_light_stage_spec = light_stage_spec;
|
||||
data->buffer_scene_data.g_light_chara_dir = light_chara_dir;
|
||||
data->buffer_scene_data.g_light_chara_spec = light_chara_spec;
|
||||
data->buffer_scene_data.g_light_chara_luce = light_chara_luce;
|
||||
data->buffer_scene_data.g_light_chara_back = light_chara_back;
|
||||
data->buffer_scene_data.g_light_face_diff = light_face_diff;
|
||||
data->buffer_scene_data.g_chara_color0 = chara_color0;
|
||||
data->buffer_scene_data.g_chara_color1 = chara_color1;
|
||||
data->buffer_scene_data.g_chara_f_dir = chara_f_dir;
|
||||
data->buffer_scene_data.g_chara_f_ambient = chara_f_ambient;
|
||||
data->buffer_scene_data.g_chara_f_diffuse = chara_f_diffuse;
|
||||
data->buffer_scene_data.g_chara_tc_param = chara_tc_param;
|
||||
mat4_transpose(&normal_tangent_transforms, &temp);
|
||||
data->buffer_scene_data.g_normal_tangent_transforms[0] = temp.row0;
|
||||
data->buffer_scene_data.g_normal_tangent_transforms[1] = temp.row1;
|
||||
data->buffer_scene_data.g_normal_tangent_transforms[2] = temp.row2;
|
||||
data->buffer_scene_data.g_light_reflect_dir = light_reflect_dir;
|
||||
data->buffer_scene_data.g_clip_plane = clip_plane;
|
||||
data->buffer_scene_data.g_npr_cloth_spec_color = npr_cloth_spec_color;
|
||||
enum_or(data->flags, RENDER_DATA_SCENE_UPDATE);
|
||||
}
|
||||
|
||||
void render_context::set_scene_light_projection(const mat4& light_projection) {
|
||||
render_data* data = &this->data;
|
||||
mat4 temp;
|
||||
mat4_transpose(&light_projection, &temp);
|
||||
data->buffer_scene_data.g_light_projection[0] = temp.row0;
|
||||
data->buffer_scene_data.g_light_projection[1] = temp.row1;
|
||||
data->buffer_scene_data.g_light_projection[2] = temp.row2;
|
||||
data->buffer_scene_data.g_light_projection[3] = temp.row3;
|
||||
enum_or(data->flags, RENDER_DATA_SCENE_UPDATE);
|
||||
}
|
||||
|
||||
void render_context::set_scene_projection_view(const mat4& view, const mat4& proj, const vec3& view_position) {
|
||||
render_data* data = &this->data;
|
||||
mat4 temp;
|
||||
mat4_transpose(&view, &temp);
|
||||
data->buffer_scene_data.g_view[0] = temp.row0;
|
||||
data->buffer_scene_data.g_view[1] = temp.row1;
|
||||
data->buffer_scene_data.g_view[2] = temp.row2;
|
||||
|
||||
mat4_invert(&view, &temp);
|
||||
mat4_transpose(&temp, &temp);
|
||||
data->buffer_scene_data.g_view_inverse[0] = temp.row0;
|
||||
data->buffer_scene_data.g_view_inverse[1] = temp.row1;
|
||||
data->buffer_scene_data.g_view_inverse[2] = temp.row2;
|
||||
|
||||
mat4_mul(&view, &proj, &temp);
|
||||
mat4_transpose(&temp, &temp);
|
||||
data->buffer_scene_data.g_projection_view[0] = temp.row0;
|
||||
data->buffer_scene_data.g_projection_view[1] = temp.row1;
|
||||
data->buffer_scene_data.g_projection_view[2] = temp.row2;
|
||||
data->buffer_scene_data.g_projection_view[3] = temp.row3;
|
||||
data->buffer_scene_data.g_view_position.x = view_position.x;
|
||||
data->buffer_scene_data.g_view_position.y = view_position.y;
|
||||
data->buffer_scene_data.g_view_position.z = view_position.z;
|
||||
data->buffer_scene_data.g_view_position.w = 0.0f;
|
||||
enum_or(data->flags, RENDER_DATA_SCENE_UPDATE);
|
||||
}
|
||||
|
||||
void render_context::set_scene_shadow_params(const float_t esm_param,
|
||||
const mat4 mats[2], const vec4& shadow_ambient, const vec4& shadow_ambient1) {
|
||||
render_data* data = &this->data;
|
||||
data->buffer_scene_data.g_esm_param = { esm_param, 0.0f, 0.0f, 0.0f };
|
||||
mat4 temp;
|
||||
mat4_transpose(&mats[0], &temp);
|
||||
data->buffer_scene_data.g_self_shadow_receivers[0] = temp.row0;
|
||||
data->buffer_scene_data.g_self_shadow_receivers[1] = temp.row1;
|
||||
data->buffer_scene_data.g_self_shadow_receivers[2] = temp.row2;
|
||||
mat4_transpose(&mats[1], &temp);
|
||||
data->buffer_scene_data.g_self_shadow_receivers[3] = temp.row0;
|
||||
data->buffer_scene_data.g_self_shadow_receivers[4] = temp.row1;
|
||||
data->buffer_scene_data.g_self_shadow_receivers[5] = temp.row2;
|
||||
data->buffer_scene_data.g_shadow_ambient = shadow_ambient;
|
||||
data->buffer_scene_data.g_shadow_ambient1 = shadow_ambient1;
|
||||
enum_or(data->flags, RENDER_DATA_SCENE_UPDATE);
|
||||
}
|
||||
|
||||
void render_context::set_shader(uint32_t index) {
|
||||
data.set_shader(index);
|
||||
}
|
||||
|
||||
sss_data* sss_data_get() {
|
||||
return &_sss_data;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "../KKdLib/vec.hpp"
|
||||
#include "../AFTModsShared/light_param/fog.hpp"
|
||||
#include "../AFTModsShared/light_param/light.hpp"
|
||||
#include "../AFTModsShared/uniform.hpp"
|
||||
#include "GL/array_buffer.hpp"
|
||||
#include "GL/shader_storage_buffer.hpp"
|
||||
#include "GL/uniform_buffer.hpp"
|
||||
@@ -26,9 +27,9 @@ enum render_data_flags {
|
||||
};
|
||||
|
||||
struct draw_state_stats {
|
||||
int32_t object_draw_count;
|
||||
int32_t object_translucent_draw_count;
|
||||
int32_t object_reflect_draw_count;
|
||||
int32_t sub_mesh_count;
|
||||
int32_t sub_mesh_no_mat_count;
|
||||
int32_t sub_mesh_cheap_count;
|
||||
int32_t field_C;
|
||||
int32_t field_10;
|
||||
int32_t draw_count;
|
||||
@@ -49,7 +50,7 @@ struct sss_data {
|
||||
|
||||
void free();
|
||||
void init();
|
||||
void set_texture(int32_t);
|
||||
void set_texture(struct p_gl_rend_state& p_gl_rend_st, int32_t texture_index);
|
||||
};
|
||||
|
||||
static_assert(sizeof(sss_data) == 0xD8, "\"sss_data\" struct should have a size of 0xD8");
|
||||
@@ -65,6 +66,18 @@ struct global_material_struct {
|
||||
static_assert(sizeof(global_material_struct) == 0x14, "\"global_material_struct\" struct should have a size of 0x14");
|
||||
|
||||
struct draw_state_struct {
|
||||
struct render_data {
|
||||
int32_t shader_index;
|
||||
bool self_shadow;
|
||||
bool shadow;
|
||||
bool blend;
|
||||
bool cull_front;
|
||||
int32_t field_8;
|
||||
draw_state_stats stats;
|
||||
|
||||
render_data();
|
||||
};
|
||||
|
||||
draw_state_stats stats;
|
||||
draw_state_stats stats_prev;
|
||||
bool vertex_buffer;
|
||||
@@ -376,7 +389,10 @@ struct render_data {
|
||||
};
|
||||
|
||||
render_data_flags flags;
|
||||
cam_data cam;
|
||||
mat4 inv_view_mat;
|
||||
int32_t shader_index;
|
||||
uniform_value shader_flags;
|
||||
obj_shader_data buffer_shader_data;
|
||||
obj_scene_data buffer_scene_data;
|
||||
obj_batch_data buffer_batch_data;
|
||||
@@ -389,11 +405,12 @@ struct render_data {
|
||||
|
||||
void init();
|
||||
void free();
|
||||
void set(render_context* rctx);
|
||||
void set_skinning_data(struct p_gl_rend_state& p_gl_rend_st, const mat4* mats, int32_t count);
|
||||
void set_state(struct p_gl_rend_state& p_gl_rend_st);
|
||||
void set_shader(uint32_t index);
|
||||
};
|
||||
|
||||
struct render_context {
|
||||
struct render_data_context {
|
||||
struct fog_params {
|
||||
vec4 depth_color;
|
||||
vec4 height_params;
|
||||
@@ -404,6 +421,61 @@ struct render_context {
|
||||
float_t end;
|
||||
};
|
||||
|
||||
p_gl_rend_state state;
|
||||
gl_rend_state_index index;
|
||||
render_data& data;
|
||||
uniform_value& shader_flags;
|
||||
|
||||
render_data_context(gl_rend_state_index index);
|
||||
|
||||
void get_scene_fog_params(render_data_context::fog_params& value);
|
||||
void get_scene_light(vec4* light_env_stage_diffuse,
|
||||
vec4* light_env_stage_specular, vec4* light_chara_dir, vec4* light_chara_luce,
|
||||
vec4* light_env_chara_diffuse, vec4* light_env_chara_specular);
|
||||
void reset_shader_flags();
|
||||
void set_batch_alpha_threshold(const float_t value);
|
||||
void set_batch_blend_color_offset_color(const vec4& blend_color, const vec4& offset_color);
|
||||
void set_batch_material_color(const vec4& diffuse, const vec4& ambient,
|
||||
const vec4& emission, const float_t material_shininess, const vec4& specular,
|
||||
const vec4& fresnel_coefficients, const vec4& texture_color_coefficients,
|
||||
const vec4& texture_color_offset, const vec4& texture_specular_coefficients,
|
||||
const vec4& texture_specular_offset, const float_t shininess);
|
||||
void set_batch_material_color_emission(const vec4& emission);
|
||||
void set_batch_material_parameter(const vec4* specular, const vec4& bump_depth,
|
||||
const vec4& intensity, const float_t reflect_uv_scale, const float_t refract_uv_scale);
|
||||
void set_batch_min_alpha(const float_t value);
|
||||
void set_batch_morph_weight(const float_t value);
|
||||
void set_batch_scene_camera(const cam_data& cam);
|
||||
void set_batch_sss_param(const vec4& sss_param);
|
||||
void set_batch_texcoord_transforms(const mat4 mats[2]);
|
||||
void set_batch_worlds(const mat4& mat);
|
||||
void set_glitter_render_data_state();
|
||||
void set_render_data_state();
|
||||
void set_scene_fog_params(const render_data_context::fog_params& value);
|
||||
void set_scene_framebuffer_size(const int32_t width, const int32_t height,
|
||||
const int32_t render_width, const int32_t render_height);
|
||||
void set_scene_light(const mat4& irradiance_r_transforms, const mat4& irradiance_g_transforms,
|
||||
const mat4& irradiance_b_transforms, const vec4& light_env_stage_diffuse,
|
||||
const vec4& light_env_stage_specular, const vec4& light_env_chara_diffuse,
|
||||
const vec4& light_env_chara_ambient, const vec4& light_env_chara_specular,
|
||||
const vec4& light_env_reflect_diffuse, const vec4& light_env_reflect_ambient,
|
||||
const vec4& light_env_proj_diffuse, const vec4& light_env_proj_specular,
|
||||
const vec4& light_env_proj_position, const vec4& light_stage_dir, const vec4& light_stage_diff,
|
||||
const vec4& light_stage_spec, const vec4& light_chara_dir, const vec4& light_chara_spec,
|
||||
const vec4& light_chara_luce, const vec4& light_chara_back, const vec4& light_face_diff,
|
||||
const vec4& chara_color0, const vec4& chara_color1, const vec4& chara_f_dir, const vec4& chara_f_ambient,
|
||||
const vec4& chara_f_diffuse, const vec4& chara_tc_param, const mat4& normal_tangent_transforms,
|
||||
const vec4& light_reflect_dir, const vec4& clip_plane, const vec4& npr_cloth_spec_color);
|
||||
void set_scene_light_projection(const mat4& light_projection);
|
||||
void set_scene_shadow_params(const float_t esm_param,
|
||||
const mat4 mats[2], const vec4& shadow_ambient, const vec4& shadow_ambient1);
|
||||
void set_self_shadow(bool value);
|
||||
void set_shader(uint32_t index);
|
||||
void set_shadow(bool value);
|
||||
void set_skinning_data(p_gl_rend_state& p_gl_rend_st, const mat4* mats, int32_t count);
|
||||
};
|
||||
|
||||
struct render_context {
|
||||
struct shared_storage_buffer {
|
||||
void* data;
|
||||
size_t offset;
|
||||
@@ -434,11 +506,6 @@ struct render_context {
|
||||
size_t size;
|
||||
};
|
||||
|
||||
mat4 view_mat;
|
||||
mat4 proj_mat;
|
||||
mat4 vp_mat;
|
||||
vec4 g_near_far;
|
||||
|
||||
GLuint box_vao;
|
||||
GL::ArrayBuffer box_vbo;
|
||||
|
||||
@@ -470,7 +537,9 @@ struct render_context {
|
||||
GL::UniformBuffer tone_map_ubo;
|
||||
GL::UniformBuffer transparency_batch_ubo;
|
||||
|
||||
render_data data;
|
||||
render_data data[GL_REND_STATE_COUNT];
|
||||
draw_state_struct::render_data draw_state_rend_data[GL_REND_STATE_COUNT];
|
||||
cam_data render_manager_cam;
|
||||
|
||||
texture* empty_texture_2d;
|
||||
texture* empty_texture_cube_map;
|
||||
@@ -502,54 +571,10 @@ struct render_context {
|
||||
|
||||
void add_shared_storage_uniform_buffer_data(size_t index,
|
||||
const void* data, size_t size, size_t max_size, bool storage = false);
|
||||
void get_scene_fog_params(render_context::fog_params& value);
|
||||
void get_scene_light(vec4* light_env_stage_diffuse,
|
||||
vec4* light_env_stage_specular, vec4* light_chara_dir, vec4* light_chara_luce,
|
||||
vec4* light_env_chara_diffuse, vec4* light_env_chara_specular);
|
||||
bool get_shared_storage_uniform_buffer_data(size_t index,
|
||||
GLuint& buffer, size_t& offset, size_t& size, bool storage = false);
|
||||
void post_proc();
|
||||
void pre_proc();
|
||||
void set_batch_alpha_threshold(const float_t value);
|
||||
void set_batch_blend_color(const vec4& blend_color);
|
||||
void set_batch_blend_color_offset_color(const vec4& blend_color, const vec4& offset_color);
|
||||
void set_batch_joint(const mat4& mat);
|
||||
void set_batch_material_color(const vec4& diffuse, const vec4& ambient,
|
||||
const vec4& emission, const float_t material_shininess, const vec4& specular,
|
||||
const vec4& fresnel_coefficients, const vec4& texture_color_coefficients,
|
||||
const vec4& texture_color_offset, const vec4& texture_specular_coefficients,
|
||||
const vec4& texture_specular_offset, const float_t shininess);
|
||||
void set_batch_material_color_emission(const vec4& emission);
|
||||
void set_batch_material_parameter(const vec4* specular, const vec4& bump_depth,
|
||||
const vec4& intensity, const float_t reflect_uv_scale, const float_t refract_uv_scale);
|
||||
void set_batch_min_alpha(const float_t value);
|
||||
void set_batch_morph_weight(const float_t value);
|
||||
void set_batch_offset_color(const vec4& offset_color);
|
||||
void set_batch_sss_param(const vec4& sss_param);
|
||||
void set_batch_texcoord_transforms(const mat4 mats[2]);
|
||||
void set_batch_worlds(const mat4& mat);
|
||||
void set_glitter_render_data();
|
||||
void set_render_data();
|
||||
void set_scene_fog_params(const render_context::fog_params& value);
|
||||
void set_scene_framebuffer_size(const int32_t width, const int32_t height,
|
||||
const int32_t render_width, const int32_t render_height);
|
||||
void set_scene_light(const mat4& irradiance_r_transforms, const mat4& irradiance_g_transforms,
|
||||
const mat4& irradiance_b_transforms, const vec4& light_env_stage_diffuse,
|
||||
const vec4& light_env_stage_specular, const vec4& light_env_chara_diffuse,
|
||||
const vec4& light_env_chara_ambient, const vec4& light_env_chara_specular,
|
||||
const vec4& light_env_reflect_diffuse, const vec4& light_env_reflect_ambient,
|
||||
const vec4& light_env_proj_diffuse, const vec4& light_env_proj_specular,
|
||||
const vec4& light_env_proj_position, const vec4& light_stage_dir, const vec4& light_stage_diff,
|
||||
const vec4& light_stage_spec, const vec4& light_chara_dir, const vec4& light_chara_spec,
|
||||
const vec4& light_chara_luce, const vec4& light_chara_back, const vec4& light_face_diff,
|
||||
const vec4& chara_color0, const vec4& chara_color1, const vec4& chara_f_dir, const vec4& chara_f_ambient,
|
||||
const vec4& chara_f_diffuse, const vec4& chara_tc_param, const mat4& normal_tangent_transforms,
|
||||
const vec4& light_reflect_dir, const vec4& clip_plane, const vec4& npr_cloth_spec_color);
|
||||
void set_scene_light_projection(const mat4& light_projection);
|
||||
void set_scene_projection_view(const mat4& view, const mat4& proj, const vec3& view_position);
|
||||
void set_scene_shadow_params(const float_t esm_param,
|
||||
const mat4 mats[2], const vec4& shadow_ambient, const vec4& shadow_ambient1);
|
||||
void set_shader(uint32_t index);
|
||||
};
|
||||
|
||||
extern draw_state_struct& draw_state;
|
||||
|
||||
+928
-936
File diff suppressed because it is too large
Load Diff
@@ -20,12 +20,17 @@ enum draw_pass_3d_type {
|
||||
DRAW_PASS_3D_MAX,
|
||||
};
|
||||
|
||||
typedef void(*draw_pre_process_func)(struct render_data_context& rend_data_ctx,
|
||||
void* data, const struct cam_data& cam);
|
||||
|
||||
struct draw_pre_process {
|
||||
int32_t type;
|
||||
void(FASTCALL* func)(void*);
|
||||
draw_pre_process_func func;
|
||||
void* data;
|
||||
};
|
||||
|
||||
struct render_data_context;
|
||||
|
||||
namespace rndr {
|
||||
enum RenderPassID {
|
||||
RND_PASSID_SHADOW = 0,
|
||||
@@ -88,7 +93,7 @@ namespace rndr {
|
||||
bool light_stage_ambient;
|
||||
bool npr;
|
||||
|
||||
void add_pre_process(int32_t type, void(*func)(void*), void* data);
|
||||
void add_pre_process(int32_t type, draw_pre_process_func func, void* data);
|
||||
void clear_pre_process(int32_t type);
|
||||
RenderTexture& get_render_texture(int32_t index);
|
||||
void reset();
|
||||
@@ -109,25 +114,25 @@ namespace rndr {
|
||||
|
||||
void render_all();
|
||||
|
||||
void render_single_pass(rndr::RenderPassID id);
|
||||
void render_single_pass(render_data_context& rend_data_ct, rndr::RenderPassID id);
|
||||
|
||||
void render_pass_begin();
|
||||
void render_pass_end(rndr::RenderPassID id);
|
||||
|
||||
void pass_shadow();
|
||||
void pass_ss_sss();
|
||||
void pass_reflect();
|
||||
void pass_refract();
|
||||
void pass_pre_process();
|
||||
void pass_clear();
|
||||
void pass_pre_sprite();
|
||||
void pass_3d();
|
||||
void pass_show_vector();
|
||||
void pass_post_process();
|
||||
void pass_sprite();
|
||||
void pass_shadow(render_data_context& rend_data_ct);
|
||||
void pass_ss_sss(render_data_context& rend_data_ct);
|
||||
void pass_reflect(render_data_context& rend_data_ct);
|
||||
void pass_refract(render_data_context& rend_data_ct);
|
||||
void pass_pre_process(render_data_context& rend_data_ct);
|
||||
void pass_clear(render_data_context& rend_data_ct);
|
||||
void pass_pre_sprite(render_data_context& rend_data_ct);
|
||||
void pass_3d(render_data_context& rend_data_ct);
|
||||
void pass_show_vector(render_data_context& rend_data_ct);
|
||||
void pass_post_process(render_data_context& rend_data_ct);
|
||||
void pass_sprite(render_data_context& rend_data_ct);
|
||||
|
||||
void pass_3d_contour();
|
||||
void pass_sprite_surf();
|
||||
void pass_3d_contour(render_data_context& rend_data_ct);
|
||||
void pass_sprite_surf(render_data_context& rend_data_ct);
|
||||
};
|
||||
|
||||
static_assert(sizeof(rndr::RenderManager) == 0x328, "\"rndr::RenderManager\" struct should have a size of 0x328");
|
||||
@@ -137,9 +142,8 @@ extern RenderTexture* litproj_shadow;
|
||||
extern RenderTexture* litproj_texture;
|
||||
extern rndr::RenderManager& render_manager;
|
||||
|
||||
extern void image_filter_scale(RenderTexture* dst, texture* src, const vec4& scale = 1.0f);
|
||||
|
||||
extern void draw_pass_set_camera();
|
||||
extern void image_filter_scale(render_data_context& rend_data_ctx,
|
||||
RenderTexture* dst, texture* src, const vec4& scale = 1.0f);
|
||||
|
||||
extern void reflect_full_init();
|
||||
extern void reflect_full_free();
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "render_texture.hpp"
|
||||
#include "gl_rend_state.hpp"
|
||||
#include "gl_state.hpp"
|
||||
#include <Helpers.h>
|
||||
|
||||
static uint32_t& render_texture_counter = *(uint32_t*)0x00000001411AD648;
|
||||
@@ -22,11 +23,11 @@ RenderTexture::~RenderTexture() {
|
||||
Free();
|
||||
}
|
||||
|
||||
int32_t RenderTexture::Bind(int32_t index) {
|
||||
int32_t RenderTexture::Bind(gl_state_struct& gl_st, int32_t index) {
|
||||
if (index < 0 || index > max_level)
|
||||
return -1;
|
||||
|
||||
gl_rend_state.bind_framebuffer(fbos[index]);
|
||||
gl_st.bind_framebuffer(fbos[index]);
|
||||
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
||||
return -1;
|
||||
|
||||
@@ -34,6 +35,19 @@ int32_t RenderTexture::Bind(int32_t index) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t RenderTexture::Bind(p_gl_rend_state& p_gl_rend_st, int32_t index) {
|
||||
if (index < 0 || index > max_level)
|
||||
return -1;
|
||||
|
||||
p_gl_rend_st.bind_framebuffer(fbos[index]);
|
||||
if (p_gl_rend_st.check_framebuffer_status(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
||||
return -1;
|
||||
|
||||
gl_get_error_print();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void RenderTexture::Free() {
|
||||
if (depth_texture) {
|
||||
texture_release(depth_texture);
|
||||
@@ -82,12 +96,12 @@ int32_t RenderTexture::Init(int32_t width, int32_t height,
|
||||
|
||||
render_texture_counter++;
|
||||
color_texture = GetColorTex();
|
||||
gl_rend_state.bind_texture_2d(GetColorTex());
|
||||
if (color_format == GL_RGBA32F) {
|
||||
gl_state.bind_texture_2d(GetColorTex());
|
||||
glTexParameteriDLL(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteriDLL(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
gl_state.bind_texture_2d(0);
|
||||
}
|
||||
gl_rend_state.bind_texture_2d(0);
|
||||
}
|
||||
else {
|
||||
this->color_texture = 0;
|
||||
@@ -150,6 +164,10 @@ int32_t RenderTexture::SetColorDepthTextures(GLuint color_texture,
|
||||
return error;
|
||||
}
|
||||
|
||||
void RenderTexture::SetViewport(p_gl_rend_state& p_gl_rend_st) {
|
||||
p_gl_rend_st.set_viewport(0, 0, GetWidth(), GetHeight());
|
||||
}
|
||||
|
||||
void render_texture_counter_reset() {
|
||||
render_texture_counter = 0;
|
||||
}
|
||||
@@ -169,7 +187,7 @@ static int32_t render_texture_set_framebuffer_texture(RenderTexture* rt,
|
||||
if (level < 0 || level > rt->max_level)
|
||||
return -1;
|
||||
|
||||
gl_rend_state.bind_framebuffer(rt->fbos[level]);
|
||||
gl_state.bind_framebuffer(rt->fbos[level]);
|
||||
gl_get_error_print();
|
||||
|
||||
if (color_texture) {
|
||||
@@ -202,7 +220,7 @@ static int32_t render_texture_set_framebuffer_texture(RenderTexture* rt,
|
||||
int32_t ret = 0;
|
||||
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
||||
ret = -1;
|
||||
gl_rend_state.bind_framebuffer(0);
|
||||
gl_state.bind_framebuffer(0);
|
||||
gl_get_error_print();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,8 @@ struct RenderTexture {
|
||||
RenderTexture();
|
||||
virtual ~RenderTexture();
|
||||
|
||||
int32_t Bind(int32_t index = 0);
|
||||
int32_t Bind(struct gl_state_struct& gl_st, int32_t index = 0);
|
||||
int32_t Bind(struct p_gl_rend_state& p_gl_rend_st, int32_t index = 0);
|
||||
void Free();
|
||||
int32_t Init(int32_t width, int32_t height,
|
||||
int32_t max_level, GLenum color_format, GLenum depth_format);
|
||||
@@ -29,6 +30,7 @@ struct RenderTexture {
|
||||
int32_t InitStencilRenderbuffer(GLenum internal_format, int32_t width, int32_t height);*/
|
||||
int32_t SetColorDepthTextures(GLuint color_texture,
|
||||
int32_t max_level = 0, GLuint depth_texture = 0, bool stencil = false);
|
||||
void SetViewport(struct p_gl_rend_state& p_gl_rend_st);
|
||||
|
||||
inline GLuint GetColorTex() {
|
||||
return color_texture->glid;
|
||||
@@ -45,10 +47,6 @@ struct RenderTexture {
|
||||
inline int32_t GetWidth() {
|
||||
return color_texture->width;
|
||||
};
|
||||
|
||||
inline void SetViewport() {
|
||||
gl_rend_state.set_viewport(0, 0, GetWidth(), GetHeight());
|
||||
};
|
||||
};
|
||||
|
||||
static_assert(sizeof(RenderTexture) == 0x30, "\"RenderTexture\" struct should have a size of 0x30");
|
||||
|
||||
+123
-118
@@ -7,6 +7,7 @@
|
||||
#include "../rob/rob.hpp"
|
||||
#include "../camera.hpp"
|
||||
#include "../gl_rend_state.hpp"
|
||||
#include "../gl_state.hpp"
|
||||
#include "../render_context.hpp"
|
||||
#include "../shader_ft.hpp"
|
||||
#include <streambuf>
|
||||
@@ -37,7 +38,7 @@ namespace renderer {
|
||||
|
||||
}
|
||||
|
||||
void DOF3::apply(RenderTexture* rt, RenderTexture* buf_rt) {
|
||||
void DOF3::apply(render_data_context& rend_data_ctx, RenderTexture* rt, RenderTexture* buf_rt) {
|
||||
if (dof_debug_data->flags & DOF_DEBUG_USE_UI_PARAMS) {
|
||||
if (dof_debug_data->flags & DOF_DEBUG_ENABLE_DOF) {
|
||||
if (dof_debug_data->flags & DOF_DEBUG_ENABLE_PHYS_DOF) {
|
||||
@@ -65,7 +66,7 @@ namespace renderer {
|
||||
}
|
||||
|
||||
focus = max_def(focus, camera_data.min_distance);
|
||||
apply_physical(rt, buf_rt, rt->GetColorTex(), rt->GetDepthTex(),
|
||||
apply_physical(rend_data_ctx, rt, buf_rt, rt->GetColorTex(), rt->GetDepthTex(),
|
||||
camera_data.min_distance, camera_data.max_distance,
|
||||
focus, dof_debug_data->focal_length,
|
||||
camera_data.fov * DEG_TO_RAD_FLOAT,
|
||||
@@ -73,7 +74,7 @@ namespace renderer {
|
||||
}
|
||||
else {
|
||||
float_t fuzzing_range = max_def(dof_debug_data->f2.fuzzing_range, 0.01f);
|
||||
apply_f2(rt, buf_rt, rt->GetColorTex(), rt->GetDepthTex(),
|
||||
apply_f2(rend_data_ctx, rt, buf_rt, rt->GetColorTex(), rt->GetDepthTex(),
|
||||
camera_data.min_distance, camera_data.max_distance,
|
||||
camera_data.fov * DEG_TO_RAD_FLOAT,
|
||||
dof_debug_data->f2.focus, dof_debug_data->f2.focus_range,
|
||||
@@ -83,7 +84,7 @@ namespace renderer {
|
||||
}
|
||||
else if (dof_pv_data->enable && dof_pv_data->f2.ratio > 0.0f) {
|
||||
float_t fuzzing_range = max_def(dof_pv_data->f2.fuzzing_range, 0.01f);
|
||||
apply_f2(rt, buf_rt, rt->GetColorTex(), rt->GetDepthTex(),
|
||||
apply_f2(rend_data_ctx, rt, buf_rt, rt->GetColorTex(), rt->GetDepthTex(),
|
||||
camera_data.min_distance, camera_data.max_distance,
|
||||
camera_data.fov * DEG_TO_RAD_FLOAT,
|
||||
dof_pv_data->f2.focus, dof_pv_data->f2.focus_range,
|
||||
@@ -142,155 +143,158 @@ namespace renderer {
|
||||
glSamplerParameteri(samplers[1], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameteri(samplers[1], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
common_ubo.Create(sizeof(dof_common_shader_data));
|
||||
common_ubo.Create(gl_state, sizeof(dof_common_shader_data));
|
||||
|
||||
vec2 data[50] = {};
|
||||
renderer::DOF3::calculate_texcoords(data, 3.0f);
|
||||
texcoords_ubo.Create(sizeof(data), data);
|
||||
texcoords_ubo.Create(gl_state, sizeof(data), data);
|
||||
|
||||
glGenVertexArrays(1, &vao);
|
||||
}
|
||||
|
||||
void DOF3::apply_f2(RenderTexture* rt, RenderTexture* buf_rt, GLuint color_texture,
|
||||
void DOF3::apply_f2(render_data_context& rend_data_ctx,
|
||||
RenderTexture* rt, RenderTexture* buf_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) {
|
||||
gl_rend_state.begin_event("renderer::DOF3::apply_f2");
|
||||
gl_rend_state.disable_blend();
|
||||
gl_rend_state.set_depth_mask(GL_FALSE);
|
||||
gl_rend_state.set_depth_func(GL_ALWAYS);
|
||||
update_data(min_distance, max_distance,
|
||||
rend_data_ctx.state.begin_event("renderer::DOF3::apply_f2");
|
||||
rend_data_ctx.state.disable_blend();
|
||||
rend_data_ctx.state.set_depth_mask(GL_FALSE);
|
||||
rend_data_ctx.state.set_depth_func(GL_ALWAYS);
|
||||
update_data(rend_data_ctx, min_distance, max_distance,
|
||||
fov, focus, 0.0f, 1.0f, focus_range, fuzzing_range, ratio);
|
||||
|
||||
uniform->arr[U_DOF] = 1;
|
||||
rend_data_ctx.shader_flags.arr[U_DOF] = 1;
|
||||
|
||||
gl_rend_state.bind_vertex_array(vao);
|
||||
render_tiles(depth_texture, true);
|
||||
downsample(color_texture, depth_texture, true);
|
||||
apply_main_filter(true);
|
||||
upsample(rt, buf_rt, color_texture, depth_texture, true);
|
||||
rend_data_ctx.state.bind_vertex_array(vao);
|
||||
render_tiles(rend_data_ctx, depth_texture, true);
|
||||
downsample(rend_data_ctx, color_texture, depth_texture, true);
|
||||
apply_main_filter(rend_data_ctx, true);
|
||||
upsample(rend_data_ctx, rt, buf_rt, color_texture, depth_texture, true);
|
||||
|
||||
gl_rend_state.use_program(0);
|
||||
rend_data_ctx.state.use_program(0);
|
||||
for (int32_t i = 0; i < 8; i++) {
|
||||
gl_rend_state.bind_sampler(i, 0);
|
||||
gl_rend_state.active_bind_texture_2d(i, 0);
|
||||
rend_data_ctx.state.bind_sampler(i, 0);
|
||||
rend_data_ctx.state.active_bind_texture_2d(i, 0);
|
||||
}
|
||||
gl_rend_state.bind_vertex_array(0);
|
||||
gl_rend_state.end_event();
|
||||
rend_data_ctx.state.bind_vertex_array(0);
|
||||
rend_data_ctx.state.end_event();
|
||||
}
|
||||
|
||||
void DOF3::apply_physical(RenderTexture* rt, RenderTexture* buf_rt, GLuint color_texture,
|
||||
void DOF3::apply_physical(render_data_context& rend_data_ctx,
|
||||
RenderTexture* rt, RenderTexture* buf_rt, GLuint color_texture,
|
||||
GLuint depth_texture, float_t min_distance, float_t max_distance,
|
||||
float_t focus, float_t focal_length, float_t fov, float_t f_number) {
|
||||
gl_rend_state.begin_event("renderer::DOF3::apply_physical");
|
||||
gl_rend_state.disable_blend();
|
||||
gl_rend_state.set_depth_mask(GL_FALSE);
|
||||
gl_rend_state.set_depth_func(GL_ALWAYS);
|
||||
update_data(min_distance, max_distance,
|
||||
rend_data_ctx.state.begin_event("renderer::DOF3::apply_physical");
|
||||
rend_data_ctx.state.disable_blend();
|
||||
rend_data_ctx.state.set_depth_mask(GL_FALSE);
|
||||
rend_data_ctx.state.set_depth_func(GL_ALWAYS);
|
||||
update_data(rend_data_ctx, min_distance, max_distance,
|
||||
fov, focus, focal_length, f_number, 0.0f, 0.1f, 0.0f);
|
||||
|
||||
uniform->arr[U_DOF] = 0;
|
||||
rend_data_ctx.shader_flags.arr[U_DOF] = 0;
|
||||
|
||||
gl_rend_state.bind_vertex_array(vao);
|
||||
render_tiles(depth_texture, false);
|
||||
downsample(color_texture, depth_texture, false);
|
||||
apply_main_filter(false);
|
||||
upsample(rt, buf_rt, color_texture, depth_texture, false);
|
||||
rend_data_ctx.state.bind_vertex_array(vao);
|
||||
render_tiles(rend_data_ctx, depth_texture, false);
|
||||
downsample(rend_data_ctx, color_texture, depth_texture, false);
|
||||
apply_main_filter(rend_data_ctx, false);
|
||||
upsample(rend_data_ctx, rt, buf_rt, color_texture, depth_texture, false);
|
||||
|
||||
shader::unbind();
|
||||
shader::unbind(rend_data_ctx.state);
|
||||
for (int32_t i = 0; i < 8; i++) {
|
||||
gl_rend_state.bind_sampler(i, 0);
|
||||
gl_rend_state.active_bind_texture_2d(i, 0);
|
||||
rend_data_ctx.state.bind_sampler(i, 0);
|
||||
rend_data_ctx.state.active_bind_texture_2d(i, 0);
|
||||
}
|
||||
gl_rend_state.bind_vertex_array(0);
|
||||
gl_rend_state.end_event();
|
||||
rend_data_ctx.state.bind_vertex_array(0);
|
||||
rend_data_ctx.state.end_event();
|
||||
}
|
||||
|
||||
void DOF3::render_tiles(GLuint depth_texture, bool f2) {
|
||||
gl_rend_state.begin_event("renderer::DOF3::render_tiles");
|
||||
fbo[0].bind_buffer();
|
||||
gl_rend_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_rend_state.active_bind_texture_2d(0, depth_texture);
|
||||
gl_rend_state.bind_sampler(0, samplers[1]);
|
||||
glDrawArraysDLL(GL_TRIANGLE_STRIP, 0, 4);
|
||||
void DOF3::render_tiles(render_data_context& rend_data_ctx, GLuint depth_texture, bool f2) {
|
||||
rend_data_ctx.state.begin_event("renderer::DOF3::render_tiles");
|
||||
rend_data_ctx.state.bind_framebuffer(fbo[0].buffer);
|
||||
rend_data_ctx.state.set_viewport(0, 0, fbo[0].width, fbo[0].height);
|
||||
rend_data_ctx.shader_flags.arr[U_DOF_STAGE] = 0;
|
||||
shaders_ft.set(rend_data_ctx.state, rend_data_ctx.shader_flags, SHADER_FT_DOF);
|
||||
rend_data_ctx.state.bind_uniform_buffer_base(0, common_ubo);
|
||||
rend_data_ctx.state.active_bind_texture_2d(0, depth_texture);
|
||||
rend_data_ctx.state.bind_sampler(0, samplers[1]);
|
||||
rend_data_ctx.state.draw_arrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
fbo[1].bind_buffer();
|
||||
gl_rend_state.set_viewport(0, 0, fbo[1].width, fbo[1].height);
|
||||
uniform->arr[U_DOF_STAGE] = 1;
|
||||
shaders_ft.set(SHADER_FT_DOF);
|
||||
gl_rend_state.active_bind_texture_2d(0, textures[0]);
|
||||
gl_rend_state.bind_sampler(0, samplers[1]);
|
||||
glDrawArraysDLL(GL_TRIANGLE_STRIP, 0, 4);
|
||||
gl_rend_state.end_event();
|
||||
rend_data_ctx.state.bind_framebuffer(fbo[1].buffer);
|
||||
rend_data_ctx.state.set_viewport(0, 0, fbo[1].width, fbo[1].height);
|
||||
rend_data_ctx.shader_flags.arr[U_DOF_STAGE] = 1;
|
||||
shaders_ft.set(rend_data_ctx.state, rend_data_ctx.shader_flags, SHADER_FT_DOF);
|
||||
rend_data_ctx.state.active_bind_texture_2d(0, textures[0]);
|
||||
rend_data_ctx.state.bind_sampler(0, samplers[1]);
|
||||
rend_data_ctx.state.draw_arrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
rend_data_ctx.state.end_event();
|
||||
|
||||
}
|
||||
|
||||
void DOF3::downsample(GLuint color_texture, GLuint depth_texture, bool f2) {
|
||||
gl_rend_state.begin_event("renderer::DOF3::downsample");
|
||||
fbo[2].bind_buffer();
|
||||
gl_rend_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_rend_state.active_bind_texture_2d(0, depth_texture);
|
||||
gl_rend_state.bind_sampler(0, samplers[1]);
|
||||
gl_rend_state.active_bind_texture_2d(1, color_texture);
|
||||
gl_rend_state.bind_sampler(1, samplers[0]);
|
||||
gl_rend_state.active_bind_texture_2d(2, textures[1]);
|
||||
gl_rend_state.bind_sampler(2, samplers[1]);
|
||||
glDrawArraysDLL(GL_TRIANGLE_STRIP, 0, 4);
|
||||
gl_rend_state.end_event();
|
||||
void DOF3::downsample(render_data_context& rend_data_ctx, GLuint color_texture, GLuint depth_texture, bool f2) {
|
||||
rend_data_ctx.state.begin_event("renderer::DOF3::downsample");
|
||||
rend_data_ctx.state.bind_framebuffer(fbo[2].buffer);
|
||||
rend_data_ctx.state.set_viewport(0, 0, fbo[2].width, fbo[2].height);
|
||||
rend_data_ctx.shader_flags.arr[U_DOF_STAGE] = 2;
|
||||
shaders_ft.set(rend_data_ctx.state, rend_data_ctx.shader_flags, SHADER_FT_DOF);
|
||||
rend_data_ctx.state.bind_uniform_buffer_base(0, common_ubo);
|
||||
rend_data_ctx.state.active_bind_texture_2d(0, depth_texture);
|
||||
rend_data_ctx.state.bind_sampler(0, samplers[1]);
|
||||
rend_data_ctx.state.active_bind_texture_2d(1, color_texture);
|
||||
rend_data_ctx.state.bind_sampler(1, samplers[0]);
|
||||
rend_data_ctx.state.active_bind_texture_2d(2, textures[1]);
|
||||
rend_data_ctx.state.bind_sampler(2, samplers[1]);
|
||||
rend_data_ctx.state.draw_arrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
rend_data_ctx.state.end_event();
|
||||
}
|
||||
|
||||
void DOF3::apply_main_filter(bool f2) {
|
||||
gl_rend_state.begin_event("renderer::DOF3::apply_main_filter");
|
||||
fbo[3].bind_buffer();
|
||||
gl_rend_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_rend_state.active_bind_texture_2d(0, textures[3]);
|
||||
gl_rend_state.bind_sampler(0, samplers[1]);
|
||||
gl_rend_state.active_bind_texture_2d(1, textures[2]);
|
||||
gl_rend_state.bind_sampler(1, samplers[1]);
|
||||
gl_rend_state.active_bind_texture_2d(2, textures[1]);
|
||||
gl_rend_state.bind_sampler(2, samplers[1]);
|
||||
glDrawArraysDLL(GL_TRIANGLE_STRIP, 0, 4);
|
||||
gl_rend_state.end_event();
|
||||
void DOF3::apply_main_filter(render_data_context& rend_data_ctx, bool f2) {
|
||||
rend_data_ctx.state.begin_event("renderer::DOF3::apply_main_filter");
|
||||
rend_data_ctx.state.bind_framebuffer(fbo[3].buffer);
|
||||
rend_data_ctx.state.set_viewport(0, 0, fbo[3].width, fbo[3].height);
|
||||
rend_data_ctx.shader_flags.arr[U_DOF_STAGE] = 3;
|
||||
shaders_ft.set(rend_data_ctx.state, rend_data_ctx.shader_flags, SHADER_FT_DOF);
|
||||
rend_data_ctx.state.bind_uniform_buffer_base(0, common_ubo);
|
||||
rend_data_ctx.state.bind_uniform_buffer_base(1, texcoords_ubo);
|
||||
rend_data_ctx.state.active_bind_texture_2d(0, textures[3]);
|
||||
rend_data_ctx.state.bind_sampler(0, samplers[1]);
|
||||
rend_data_ctx.state.active_bind_texture_2d(1, textures[2]);
|
||||
rend_data_ctx.state.bind_sampler(1, samplers[1]);
|
||||
rend_data_ctx.state.active_bind_texture_2d(2, textures[1]);
|
||||
rend_data_ctx.state.bind_sampler(2, samplers[1]);
|
||||
rend_data_ctx.state.draw_arrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
rend_data_ctx.state.end_event();
|
||||
}
|
||||
|
||||
void DOF3::upsample(RenderTexture* rt, RenderTexture* buf_rt,
|
||||
void DOF3::upsample(render_data_context& rend_data_ctx,
|
||||
RenderTexture* rt, RenderTexture* buf_rt,
|
||||
GLuint color_texture, GLuint depth_texture, bool f2) {
|
||||
gl_rend_state.begin_event("renderer::DOF3::upsample");
|
||||
buf_rt->Bind();
|
||||
gl_rend_state.set_viewport(0, 0, width, height);
|
||||
uniform->arr[U_DOF_STAGE] = 4;
|
||||
shaders_ft.set(SHADER_FT_DOF);
|
||||
common_ubo.Bind(0);
|
||||
gl_rend_state.active_bind_texture_2d(0, textures[4]);
|
||||
gl_rend_state.bind_sampler(0, samplers[1]);
|
||||
gl_rend_state.active_bind_texture_2d(1, textures[5]);
|
||||
gl_rend_state.bind_sampler(1, samplers[1]);
|
||||
gl_rend_state.active_bind_texture_2d(2, textures[1]);
|
||||
gl_rend_state.bind_sampler(2, samplers[1]);
|
||||
gl_rend_state.active_bind_texture_2d(3, color_texture);
|
||||
gl_rend_state.bind_sampler(3, samplers[1]);
|
||||
gl_rend_state.active_bind_texture_2d(4, depth_texture);
|
||||
gl_rend_state.bind_sampler(4, samplers[1]);
|
||||
glDrawArraysDLL(GL_TRIANGLE_STRIP, 0, 4);
|
||||
rend_data_ctx.state.begin_event("renderer::DOF3::upsample");
|
||||
buf_rt->Bind(rend_data_ctx.state);
|
||||
rend_data_ctx.state.set_viewport(0, 0, width, height);
|
||||
rend_data_ctx.shader_flags.arr[U_DOF_STAGE] = 4;
|
||||
shaders_ft.set(rend_data_ctx.state, rend_data_ctx.shader_flags, SHADER_FT_DOF);
|
||||
rend_data_ctx.state.bind_uniform_buffer_base(0, common_ubo);
|
||||
rend_data_ctx.state.active_bind_texture_2d(0, textures[4]);
|
||||
rend_data_ctx.state.bind_sampler(0, samplers[1]);
|
||||
rend_data_ctx.state.active_bind_texture_2d(1, textures[5]);
|
||||
rend_data_ctx.state.bind_sampler(1, samplers[1]);
|
||||
rend_data_ctx.state.active_bind_texture_2d(2, textures[1]);
|
||||
rend_data_ctx.state.bind_sampler(2, samplers[1]);
|
||||
rend_data_ctx.state.active_bind_texture_2d(3, color_texture);
|
||||
rend_data_ctx.state.bind_sampler(3, samplers[1]);
|
||||
rend_data_ctx.state.active_bind_texture_2d(4, depth_texture);
|
||||
rend_data_ctx.state.bind_sampler(4, samplers[1]);
|
||||
rend_data_ctx.state.draw_arrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
if (DIVA_GL_VERSION_4_3)
|
||||
glCopyImageSubData(
|
||||
rend_data_ctx.state.copy_image_sub_data(
|
||||
buf_rt->GetColorTex(), GL_TEXTURE_2D, 0, 0, 0, 0,
|
||||
rt->GetColorTex(), GL_TEXTURE_2D, 0, 0, 0, 0, width, height, 1);
|
||||
else
|
||||
fbo_blit(buf_rt->fbos[0], rt->fbos[0],
|
||||
fbo_blit(rend_data_ctx.state, buf_rt->fbos[0], rt->fbos[0],
|
||||
0, 0, width, height,
|
||||
0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
gl_rend_state.end_event();
|
||||
rend_data_ctx.state.end_event();
|
||||
}
|
||||
|
||||
void DOF3::init_textures(int32_t width, int32_t height) {
|
||||
@@ -300,28 +304,29 @@ namespace renderer {
|
||||
int32_t h2 = max_def(height / 2, 1);
|
||||
|
||||
glGenTextures(6, textures);
|
||||
gl_rend_state.bind_texture_2d(textures[0]);
|
||||
gl_state.bind_texture_2d(textures[0]);
|
||||
glTexImage2DDLL(GL_TEXTURE_2D, 0, GL_RG16F, w20, h20, 0, GL_RG, GL_HALF_FLOAT, 0);
|
||||
fbo[0].init(w20, h20, &textures[0], 1, 0);
|
||||
|
||||
gl_rend_state.bind_texture_2d(textures[1]);
|
||||
gl_state.bind_texture_2d(textures[1]);
|
||||
glTexImage2DDLL(GL_TEXTURE_2D, 0, GL_RG16F, w20, h20, 0, GL_RG, GL_HALF_FLOAT, 0);
|
||||
fbo[1].init(w20, h20, &textures[1], 1, 0);
|
||||
|
||||
gl_rend_state.bind_texture_2d(textures[2]);
|
||||
gl_state.bind_texture_2d(textures[2]);
|
||||
glTexImage2DDLL(GL_TEXTURE_2D, 0, GL_R11F_G11F_B10F, w2, h2, 0, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, 0);
|
||||
gl_rend_state.bind_texture_2d(textures[3]);
|
||||
gl_state.bind_texture_2d(textures[3]);
|
||||
glTexImage2DDLL(GL_TEXTURE_2D, 0, GL_R11F_G11F_B10F, w2, h2, 0, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, 0);
|
||||
fbo[2].init(w2, h2, &textures[2], 2, 0);
|
||||
|
||||
gl_rend_state.bind_texture_2d(textures[4]);
|
||||
gl_state.bind_texture_2d(textures[4]);
|
||||
glTexImage2DDLL(GL_TEXTURE_2D, 0, GL_R11F_G11F_B10F, w2, h2, 0, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, 0);
|
||||
gl_rend_state.bind_texture_2d(textures[5]);
|
||||
gl_state.bind_texture_2d(textures[5]);
|
||||
glTexImage2DDLL(GL_TEXTURE_2D, 0, GL_R8, w2, h2, 0, GL_RED, GL_UNSIGNED_BYTE, 0);
|
||||
fbo[3].init(w2, h2, &textures[4], 2, 0);
|
||||
}
|
||||
|
||||
void DOF3::update_data(float_t min_dist, float_t max_dist, float_t fov, float_t dist, float_t focal_length,
|
||||
void DOF3::update_data(render_data_context& rend_data_ctx,
|
||||
float_t min_dist, float_t max_dist, float_t fov, float_t dist, float_t focal_length,
|
||||
float_t f_number, float_t focus_range, float_t fuzzing_range, float_t ratio) {
|
||||
float_t fl = focal_length;
|
||||
if (dist <= focal_length)
|
||||
@@ -341,7 +346,7 @@ namespace renderer {
|
||||
shader_data.g_depth_params2.y = focus_range;
|
||||
shader_data.g_depth_params2.z = -4.5f / (fuzzing_range * fuzzing_range);
|
||||
shader_data.g_depth_params2.w = ratio * 8.0f;
|
||||
common_ubo.WriteMemory(shader_data);
|
||||
common_ubo.WriteMemory(rend_data_ctx.state, shader_data);
|
||||
}
|
||||
|
||||
void DOF3::calculate_texcoords(vec2* data, float_t size) {
|
||||
|
||||
@@ -43,6 +43,8 @@ struct dof_pv {
|
||||
|
||||
static_assert(sizeof(dof_pv) == 0x14, "\"dof_pv\" struct should have a size of 0x14");
|
||||
|
||||
struct render_data_context;
|
||||
|
||||
namespace renderer {
|
||||
struct DOF3 {
|
||||
int32_t width;
|
||||
@@ -58,28 +60,32 @@ namespace renderer {
|
||||
DOF3(int32_t width, int32_t height);
|
||||
~DOF3();
|
||||
|
||||
void apply(RenderTexture* rt, RenderTexture* buf_rt);
|
||||
void apply(render_data_context& rend_data_ctx, RenderTexture* rt, RenderTexture* buf_rt);
|
||||
void resize(int32_t width, int32_t height);
|
||||
|
||||
private:
|
||||
void free();
|
||||
void init(int32_t width, int32_t height);
|
||||
|
||||
void apply_f2(RenderTexture* rt, RenderTexture* buf_rt, GLuint color_texture,
|
||||
void apply_f2(render_data_context& rend_data_ctx,
|
||||
RenderTexture* rt, RenderTexture* buf_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);
|
||||
void apply_physical(RenderTexture* rt, RenderTexture* buf_rt, GLuint color_texture,
|
||||
void apply_physical(render_data_context& rend_data_ctx,
|
||||
RenderTexture* rt, RenderTexture* buf_rt, GLuint color_texture,
|
||||
GLuint depth_texture, float_t min_distance, float_t max_distance,
|
||||
float_t focus, float_t focal_length, float_t fov, float_t f_number);
|
||||
|
||||
void render_tiles(GLuint depth_texture, bool f2);
|
||||
void downsample(GLuint color_texture, GLuint depth_texture, bool f2);
|
||||
void apply_main_filter(bool f2);
|
||||
void upsample(RenderTexture* rt, RenderTexture* buf_rt,
|
||||
void render_tiles(render_data_context& rend_data_ctx, GLuint depth_texture, bool f2);
|
||||
void downsample(render_data_context& rend_data_ctx, GLuint color_texture, GLuint depth_texture, bool f2);
|
||||
void apply_main_filter(render_data_context& rend_data_ctx, bool f2);
|
||||
void upsample(render_data_context& rend_data_ctx,
|
||||
RenderTexture* rt, RenderTexture* buf_rt,
|
||||
GLuint color_texture, GLuint depth_texture, bool f2);
|
||||
|
||||
void init_textures(int32_t width, int32_t height);
|
||||
void update_data(float_t min_dist, float_t max_dist, float_t fov, float_t dist, float_t focal_length,
|
||||
void update_data(render_data_context& rend_data_ctx,
|
||||
float_t min_dist, float_t max_dist, float_t fov, float_t dist, float_t focal_length,
|
||||
float_t f_number, float_t focus_range, float_t fuzzing_range, float_t ratio);
|
||||
|
||||
static void calculate_texcoords(vec2* data, float_t size);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "fbo.hpp"
|
||||
#include "../../AFTModsShared/types.hpp"
|
||||
#include "../gl_state.hpp"
|
||||
|
||||
namespace renderer {
|
||||
FBO::FBO() : flags(), width(), height(), buffer(), count(), textures() {
|
||||
@@ -41,7 +42,7 @@ namespace renderer {
|
||||
textures[count] = depth_texture;
|
||||
|
||||
glGenFramebuffers(1, &buffer);
|
||||
gl_rend_state.bind_framebuffer(buffer, true);
|
||||
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,7 +54,7 @@ namespace renderer {
|
||||
color_attachments[i] = GL_COLOR_ATTACHMENT0 + i;
|
||||
glDrawBuffers(count, color_attachments);
|
||||
glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
gl_rend_state.bind_framebuffer(0);
|
||||
gl_state.bind_framebuffer(0);
|
||||
}
|
||||
#pragma warning(pop)
|
||||
|
||||
|
||||
@@ -27,10 +27,6 @@ namespace renderer {
|
||||
void init(int32_t width, int32_t height,
|
||||
GLuint* color_textures, int32_t count, GLuint depth_texture);
|
||||
void free();
|
||||
|
||||
inline void bind_buffer() {
|
||||
gl_rend_state.bind_framebuffer(buffer);
|
||||
}
|
||||
};
|
||||
|
||||
static_assert(sizeof(renderer::FBO) == 0x20, "\"renderer::FBO\" struct should have a size of 0x20");
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
#include "transparency.hpp"
|
||||
#include "../../KKdLib/str_utils.hpp"
|
||||
#include "../render_context.hpp"
|
||||
#include "../gl_rend_state.hpp"
|
||||
#include "../render_context.hpp"
|
||||
#include "../shader_ft.hpp"
|
||||
|
||||
extern render_context* rctx;
|
||||
@@ -39,48 +39,49 @@ namespace renderer {
|
||||
}
|
||||
}
|
||||
|
||||
void Transparency::combine(RenderTexture* rt, float_t alpha) {
|
||||
void Transparency::combine(render_data_context& rend_data_ctx, RenderTexture* rt, float_t alpha) {
|
||||
transparency_batch_shader_data shader_data = {};
|
||||
shader_data.g_opacity = { alpha, 0.0f, 0.0f, 0.0f };
|
||||
rctx->transparency_batch_ubo.WriteMemory(shader_data);
|
||||
rctx->transparency_batch_ubo.WriteMemory(rend_data_ctx.state, shader_data);
|
||||
|
||||
gl_rend_state.disable_blend();
|
||||
gl_rend_state.disable_depth_test();
|
||||
rctx->render_buffer.Bind();
|
||||
shaders_ft.set(SHADER_FT_TRANSPARENCY);
|
||||
rctx->transparency_batch_ubo.Bind(0);
|
||||
gl_rend_state.active_bind_texture_2d(0, fbo.textures[0]);
|
||||
gl_rend_state.active_bind_texture_2d(1, rt->GetColorTex());
|
||||
gl_rend_state.bind_vertex_array(vao);
|
||||
shaders_ft.draw_arrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
gl_rend_state.enable_depth_test();
|
||||
rend_data_ctx.state.disable_blend();
|
||||
rend_data_ctx.state.disable_depth_test();
|
||||
rctx->render_buffer.Bind(rend_data_ctx.state);
|
||||
shaders_ft.set(rend_data_ctx.state, rend_data_ctx.shader_flags, SHADER_FT_TRANSPARENCY);
|
||||
rend_data_ctx.state.bind_uniform_buffer_base(0, rctx->transparency_batch_ubo);
|
||||
rend_data_ctx.state.active_bind_texture_2d(0, fbo.textures[0]);
|
||||
rend_data_ctx.state.active_bind_texture_2d(1, rt->GetColorTex());
|
||||
rend_data_ctx.state.bind_vertex_array(vao);
|
||||
rend_data_ctx.state.draw_arrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
rend_data_ctx.state.enable_depth_test();
|
||||
|
||||
if (DIVA_GL_VERSION_4_3)
|
||||
glCopyImageSubData(rctx->render_buffer.GetColorTex(), GL_TEXTURE_2D, 0, 0, 0, 0,
|
||||
rend_data_ctx.state.copy_image_sub_data(
|
||||
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);
|
||||
else
|
||||
fbo_blit(rctx->render_buffer.fbos[0], rt->fbos[0],
|
||||
fbo_blit(rend_data_ctx.state, rctx->render_buffer.fbos[0], rt->fbos[0],
|
||||
0, 0, fbo.width, fbo.height,
|
||||
0, 0, fbo.width, fbo.height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
}
|
||||
|
||||
void Transparency::copy(GLuint texture) {
|
||||
void Transparency::copy(render_data_context& rend_data_ctx, GLuint texture) {
|
||||
if (DIVA_GL_VERSION_4_3)
|
||||
glCopyImageSubData(texture, GL_TEXTURE_2D, 0, 0, 0, 0,
|
||||
rend_data_ctx.state.copy_image_sub_data(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();
|
||||
gl_rend_state.set_viewport(0, 0, fbo.width, fbo.height);
|
||||
rend_data_ctx.state.bind_framebuffer(fbo.buffer);
|
||||
rend_data_ctx.state.set_viewport(0, 0, fbo.width, fbo.height);
|
||||
|
||||
if (!DIVA_GL_VERSION_4_3) {
|
||||
gl_rend_state.disable_depth_test();
|
||||
uniform->arr[U_REDUCE] = 0;
|
||||
shaders_ft.set(SHADER_FT_REDUCE);
|
||||
gl_rend_state.active_bind_texture_2d(0, texture);
|
||||
gl_rend_state.bind_sampler(0, rctx->render_samplers[1]);
|
||||
render_get()->draw_quad(fbo.width, fbo.height, 1.0f, 1.0f,
|
||||
0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
gl_rend_state.enable_depth_test();
|
||||
rend_data_ctx.state.disable_depth_test();
|
||||
rend_data_ctx.shader_flags.arr[U_REDUCE] = 0;
|
||||
shaders_ft.set(rend_data_ctx.state, rend_data_ctx.shader_flags, SHADER_FT_REDUCE);
|
||||
rend_data_ctx.state.active_bind_texture_2d(0, texture);
|
||||
rend_data_ctx.state.bind_sampler(0, rctx->render_samplers[1]);
|
||||
render_get()->draw_quad(rend_data_ctx, fbo.width, fbo.height,
|
||||
1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
rend_data_ctx.state.enable_depth_test();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include "../render_texture.hpp"
|
||||
#include "fbo.hpp"
|
||||
|
||||
struct render_data_context;
|
||||
|
||||
namespace renderer {
|
||||
struct Transparency {
|
||||
private:
|
||||
@@ -22,8 +24,8 @@ namespace renderer {
|
||||
Transparency(GLuint color_texture, GLuint depth_texture, int32_t width, int32_t height);
|
||||
~Transparency();
|
||||
|
||||
void combine(RenderTexture* rt, float_t alpha);
|
||||
void copy(GLuint texture);
|
||||
void combine(render_data_context& rend_data_ctx, RenderTexture* rt, float_t alpha);
|
||||
void copy(render_data_context& rend_data_ctx, GLuint texture);
|
||||
|
||||
void resize(GLuint color_texture, GLuint depth_texture, int32_t width, int32_t height);
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "rob.hpp"
|
||||
#include "../../KKdLib/str_utils.hpp"
|
||||
#include "../mdl/disp_manager.hpp"
|
||||
#include "../gl_rend_state.hpp"
|
||||
#include "../gl_state.hpp"
|
||||
#include "../object.hpp"
|
||||
#include "../render_manager.hpp"
|
||||
#include <Helpers.h>
|
||||
@@ -146,7 +146,7 @@ HOOK(void, FASTCALL, RobCloth__UpdateVertexBuffer, 0x000000014021CF00, obj_mesh*
|
||||
|
||||
vertex_buffer->cycle_index();
|
||||
GL::ArrayBuffer buffer = vertex_buffer->get_buffer();
|
||||
size_t data = (size_t)buffer.MapMemory();
|
||||
size_t data = (size_t)buffer.MapMemory(gl_state);
|
||||
if (!data)
|
||||
return;
|
||||
|
||||
@@ -284,7 +284,7 @@ HOOK(void, FASTCALL, RobCloth__UpdateVertexBuffer, 0x000000014021CF00, obj_mesh*
|
||||
break;
|
||||
}
|
||||
|
||||
buffer.UnmapMemory();
|
||||
buffer.UnmapMemory(gl_state);
|
||||
}
|
||||
|
||||
HOOK(void, FASTCALL, sub_1405044B0, 0x00000001405044B0, rob_chara* rob_chr) {
|
||||
@@ -754,7 +754,7 @@ void rob_chara_age_age_object::disp(size_t chara_index,
|
||||
obj_vert_buf.cycle_index();
|
||||
|
||||
GL::ArrayBuffer buffer = obj_vert_buf.get_buffer();
|
||||
size_t vtx_data = (size_t)buffer.MapMemory();
|
||||
size_t vtx_data = (size_t)buffer.MapMemory(gl_state);
|
||||
if (!vtx_data)
|
||||
return;
|
||||
|
||||
@@ -763,7 +763,7 @@ void rob_chara_age_age_object::disp(size_t chara_index,
|
||||
memmove((void*)(vtx_data + vertex_array_size * i),
|
||||
(void*)((size_t)vertex_data + vertex_array_size * v44[i].second), vertex_array_size);
|
||||
|
||||
buffer.UnmapMemory();
|
||||
buffer.UnmapMemory(gl_state);
|
||||
|
||||
mesh.num_vertex = disp_count * num_vertex;
|
||||
sub_mesh.num_index = disp_count * num_index;
|
||||
|
||||
+25
-23
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "screen_shot.hpp"
|
||||
#include "gl_rend_state.hpp"
|
||||
#include "gl_state.hpp"
|
||||
#include "render_context.hpp"
|
||||
#include "shader_ft.hpp"
|
||||
#include "texture.hpp"
|
||||
@@ -62,9 +63,9 @@ HOOK(bool, FASTCALL, sub_1401898E0, 0x00000001401898E0, __int64 a1, texture* tex
|
||||
struc_21 v9 = {};
|
||||
sub_140188010(&v9, tex->width, tex->height, 1);
|
||||
|
||||
gl_rend_state.bind_texture_2d(tex->glid);
|
||||
gl_state.bind_texture_2d(tex->glid);
|
||||
glGetTexImageDLL(GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, sub_140188410(&v9));
|
||||
gl_rend_state.bind_texture_2d(0);
|
||||
gl_state.bind_texture_2d(0);
|
||||
|
||||
struc_21 v10 = {};
|
||||
sub_140188100(&v9, sub_140189B10(&v9, &v10, false, true));
|
||||
@@ -74,20 +75,21 @@ HOOK(bool, FASTCALL, sub_1401898E0, 0x00000001401898E0, __int64 a1, texture* tex
|
||||
return true;
|
||||
}
|
||||
|
||||
HOOK(void, FASTCALL, ScreenShotImpl__get_data, 0x0000000140557F50, ScreenShotImpl* impl) {
|
||||
gl_rend_state.active_bind_texture_2d(0, impl->tex->glid);
|
||||
glCopyTexSubImage2DDLL(GL_TEXTURE_2D, 0, 0, 0, 0, 0, impl->width, impl->height);
|
||||
HOOK(void, FASTCALL, ScreenShotImpl__copy, 0x0000000140557F50, ScreenShotImpl* impl) {
|
||||
render_data_context rend_data_ctx(GL_REND_STATE_POST_2D);
|
||||
rend_data_ctx.state.active_bind_texture_2d(0, impl->tex->glid);
|
||||
rend_data_ctx.state.copy_tex_sub_image_2d(GL_TEXTURE_2D, 0, 0, 0, 0, 0, impl->width, impl->height);
|
||||
|
||||
float_t ratio = (float_t)(impl->curr_height * impl->curr_width) / (float_t)(impl->width * impl->height);
|
||||
float_t scale = 1.0f;
|
||||
if (ratio < 0.1f)
|
||||
uniform->arr[U_REDUCE] = 1;
|
||||
rend_data_ctx.shader_flags.arr[U_REDUCE] = 1;
|
||||
else if (ratio < 0.6f) {
|
||||
scale = 0.75f;
|
||||
uniform->arr[U_REDUCE] = 1;
|
||||
rend_data_ctx.shader_flags.arr[U_REDUCE] = 1;
|
||||
}
|
||||
else
|
||||
uniform->arr[U_REDUCE] = 0;
|
||||
rend_data_ctx.shader_flags.arr[U_REDUCE] = 0;
|
||||
|
||||
quad_shader_data quad = {};
|
||||
quad.g_texcoord_modifier = { 0.5f, 0.5f, 0.5f, 0.5f };
|
||||
@@ -95,23 +97,23 @@ HOOK(void, FASTCALL, ScreenShotImpl__get_data, 0x0000000140557F50, ScreenShotImp
|
||||
quad.g_color = 0.0f;
|
||||
quad.g_texture_lod = 0.0f;
|
||||
|
||||
rctx->quad_ubo.WriteMemory(quad);
|
||||
rctx->quad_ubo.Bind(0);
|
||||
rctx->quad_ubo.WriteMemory(rend_data_ctx.state, quad);
|
||||
rend_data_ctx.state.bind_uniform_buffer_base(0, rctx->quad_ubo);
|
||||
|
||||
gl_rend_state.disable_depth_test();
|
||||
gl_rend_state.disable_blend();
|
||||
gl_rend_state.disable_cull_face();
|
||||
gl_rend_state.set_viewport(0, 0, impl->curr_width, impl->curr_height);
|
||||
rend_data_ctx.state.disable_depth_test();
|
||||
rend_data_ctx.state.disable_blend();
|
||||
rend_data_ctx.state.disable_cull_face();
|
||||
rend_data_ctx.state.set_viewport(0, 0, impl->curr_width, impl->curr_height);
|
||||
|
||||
shaders_ft.set(SHADER_FT_REDUCE);
|
||||
gl_rend_state.bind_vertex_array(rctx->common_vao);
|
||||
shaders_ft.draw_arrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
gl_rend_state.bind_vertex_array(0);
|
||||
shader::unbind();
|
||||
shaders_ft.set(rend_data_ctx.state, rend_data_ctx.shader_flags, SHADER_FT_REDUCE);
|
||||
rend_data_ctx.state.bind_vertex_array(rctx->common_vao);
|
||||
rend_data_ctx.state.draw_arrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
rend_data_ctx.state.bind_vertex_array(0);
|
||||
shader::unbind(rend_data_ctx.state);
|
||||
|
||||
gl_rend_state.enable_cull_face();
|
||||
gl_rend_state.enable_blend();
|
||||
gl_rend_state.enable_depth_test();
|
||||
rend_data_ctx.state.enable_cull_face();
|
||||
rend_data_ctx.state.enable_blend();
|
||||
rend_data_ctx.state.enable_depth_test();
|
||||
}
|
||||
|
||||
HOOK(void, FASTCALL, ScreenShotData__get_data, 0x0000000140557BE0, ScreenShotData* data) {
|
||||
@@ -126,6 +128,6 @@ HOOK(void, FASTCALL, ScreenShotData__get_data, 0x0000000140557BE0, ScreenShotDat
|
||||
void screen_shot_patch() {
|
||||
INSTALL_HOOK(sub_1401898E0);
|
||||
|
||||
INSTALL_HOOK(ScreenShotImpl__get_data);
|
||||
INSTALL_HOOK(ScreenShotImpl__copy);
|
||||
INSTALL_HOOK(ScreenShotData__get_data);
|
||||
}
|
||||
|
||||
+15
-123
@@ -27,11 +27,9 @@ static GLuint shader_compile(const char* vert, const char* frag, const char* vp,
|
||||
static GLuint shader_compile_binary(const char* vert, const char* frag, const char* vp, const char* fp,
|
||||
program_binary* bin, GLsizei* buffer_size, void** binary);
|
||||
static bool shader_load_binary_shader(program_binary* bin, GLuint* program, const char* vp, const char* fp);
|
||||
static bool shader_update_data(shader_set_data* set);
|
||||
|
||||
int32_t shader::bind(shader_set_data* set, uint32_t sub_index) {
|
||||
set->curr_program = 0;
|
||||
|
||||
int32_t shader::bind(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, uint32_t sub_index) {
|
||||
if (num_sub < 1)
|
||||
return -1;
|
||||
|
||||
@@ -50,7 +48,7 @@ int32_t shader::bind(shader_set_data* set, uint32_t sub_index) {
|
||||
|
||||
int32_t i = 0;
|
||||
for (i = 0; i < num_uniform; i++) {
|
||||
const int32_t unival = uniform->arr[use_uniform[i]];
|
||||
const int32_t unival = shader_flags.arr[use_uniform[i]];
|
||||
const int32_t unival_max = max_def(vp_unival_max[i], fp_unival_max[i]);
|
||||
unival_shad += unival_shad_curr * min_def(unival, unival_max);
|
||||
unival_shad_curr *= unival_max + 1;
|
||||
@@ -58,9 +56,7 @@ int32_t shader::bind(shader_set_data* set, uint32_t sub_index) {
|
||||
}
|
||||
|
||||
GLuint program = sub_shader->programs[unival_shad];
|
||||
set->curr_program = program;
|
||||
|
||||
gl_rend_state.use_program(program);
|
||||
p_gl_rend_st.use_program(program);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -452,104 +448,14 @@ char* shader::parse_include(char* data, farc* f) {
|
||||
return temp_data;
|
||||
}
|
||||
|
||||
void shader::unbind() {
|
||||
gl_rend_state.use_program(0);
|
||||
void shader::unbind(p_gl_rend_state& p_gl_rend_st) {
|
||||
p_gl_rend_st.use_program(0);
|
||||
}
|
||||
|
||||
shader_set_data::shader_set_data() : size(), shaders(), curr_program(),
|
||||
primitive_restart(), primitive_restart_index(), get_index_by_name_func() {
|
||||
shader_set_data::shader_set_data() : size(), shaders(), get_index_by_name_func() {
|
||||
|
||||
}
|
||||
|
||||
void shader_set_data::disable_primitive_restart() {
|
||||
primitive_restart = false;
|
||||
}
|
||||
|
||||
void shader_set_data::draw_arrays(GLenum mode, GLint first, GLsizei count) {
|
||||
if (!shader_update_data(this))
|
||||
return;
|
||||
|
||||
glDrawArraysDLL(mode, first, count);
|
||||
}
|
||||
|
||||
void shader_set_data::draw_elements(GLenum mode,
|
||||
GLsizei count, GLenum type, const void* indices) {
|
||||
switch (mode) {
|
||||
case GL_TRIANGLE_STRIP:
|
||||
uint32_t index;
|
||||
switch (type) {
|
||||
case GL_UNSIGNED_BYTE:
|
||||
index = 0xFF;
|
||||
break;
|
||||
case GL_UNSIGNED_SHORT:
|
||||
index = 0xFFFF;
|
||||
break;
|
||||
case GL_UNSIGNED_INT:
|
||||
default:
|
||||
index = 0xFFFFFFFF;
|
||||
break;
|
||||
}
|
||||
|
||||
enable_primitive_restart();
|
||||
|
||||
if (primitive_restart_index != index)
|
||||
primitive_restart_index = index;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!shader_update_data(this))
|
||||
return;
|
||||
|
||||
glDrawElementsDLL(mode, count, type, indices);
|
||||
|
||||
switch (mode) {
|
||||
case GL_TRIANGLE_STRIP:
|
||||
disable_primitive_restart();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void shader_set_data::draw_range_elements(GLenum mode,
|
||||
GLuint start, GLuint end, GLsizei count, GLenum type, const void* indices) {
|
||||
switch (mode) {
|
||||
case GL_TRIANGLE_STRIP:
|
||||
uint32_t index;
|
||||
switch (type) {
|
||||
case GL_UNSIGNED_BYTE:
|
||||
index = 0xFF;
|
||||
break;
|
||||
case GL_UNSIGNED_SHORT:
|
||||
index = 0xFFFF;
|
||||
break;
|
||||
case GL_UNSIGNED_INT:
|
||||
default:
|
||||
index = 0xFFFFFFFF;
|
||||
break;
|
||||
}
|
||||
|
||||
enable_primitive_restart();
|
||||
|
||||
if (primitive_restart_index != index)
|
||||
primitive_restart_index = index;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!shader_update_data(this))
|
||||
return;
|
||||
|
||||
glDrawRangeElements(mode, start, end, count, type, indices);
|
||||
|
||||
switch (mode) {
|
||||
case GL_TRIANGLE_STRIP:
|
||||
disable_primitive_restart();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void shader_set_data::enable_primitive_restart() {
|
||||
primitive_restart = true;
|
||||
}
|
||||
|
||||
int32_t shader_set_data::get_index_by_name(const char* name) {
|
||||
if (get_index_by_name_func) {
|
||||
int32_t index = get_index_by_name_func(name);
|
||||
@@ -814,13 +720,13 @@ void shader_set_data::load(farc* f, bool ignore_cache,
|
||||
if (programs[k] && samplers.size()) {
|
||||
GLuint program = programs[k];
|
||||
|
||||
gl_rend_state.use_program(program);
|
||||
glUseProgram(program);
|
||||
for (auto& i : samplers) {
|
||||
GLint loc = glGetUniformLocation(program, i.second.c_str());
|
||||
if (loc != -1)
|
||||
glUniform1i(loc, i.first);
|
||||
}
|
||||
gl_rend_state.use_program(0);
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
if (programs[k] && uniforms.size()) {
|
||||
@@ -879,13 +785,13 @@ void shader_set_data::load(farc* f, bool ignore_cache,
|
||||
if (programs[0] && samplers.size()) {
|
||||
GLuint program = programs[0];
|
||||
|
||||
gl_rend_state.use_program(program);
|
||||
glUseProgram(program);
|
||||
for (auto& i : samplers) {
|
||||
GLint loc = glGetUniformLocation(program, i.second.c_str());
|
||||
if (loc != -1)
|
||||
glUniform1i(loc, i.first);
|
||||
}
|
||||
gl_rend_state.use_program(0);
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
if (programs[0] && uniforms.size()) {
|
||||
@@ -962,16 +868,16 @@ void shader_set_data::load(farc* f, bool ignore_cache,
|
||||
this->get_index_by_name_func = get_index_by_name;
|
||||
}
|
||||
|
||||
void shader_set_data::set(uint32_t index) {
|
||||
void shader_set_data::set(p_gl_rend_state& p_gl_rend_st, uniform_value& shader_flags, uint32_t index) {
|
||||
if (this && index && index != -1) {
|
||||
shader* shader = &shaders[index];
|
||||
if (shader->bind_func)
|
||||
shader->bind_func(this, shader);
|
||||
shader->bind_func(p_gl_rend_st, shader_flags, this, shader);
|
||||
else
|
||||
shader->bind(this, shader->sub[0].sub_index);
|
||||
shader->bind(p_gl_rend_st, shader_flags, this, shader->sub[0].sub_index);
|
||||
}
|
||||
else
|
||||
shader::unbind();
|
||||
shader::unbind(p_gl_rend_st);
|
||||
}
|
||||
|
||||
void shader_set_data::unload() {
|
||||
@@ -1252,17 +1158,3 @@ static bool shader_load_binary_shader(program_binary* bin, GLuint* program, cons
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool shader_update_data(shader_set_data* set) {
|
||||
if (!set || !set->curr_program)
|
||||
return false;
|
||||
|
||||
if (set->primitive_restart) {
|
||||
gl_rend_state.enable_primitive_restart();
|
||||
gl_rend_state.set_primitive_restart_index(set->primitive_restart_index);
|
||||
}
|
||||
else
|
||||
gl_rend_state.disable_primitive_restart();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+6
-14
@@ -36,7 +36,8 @@ struct shader_set_data;
|
||||
|
||||
typedef int32_t (*PFNSHADERGETINDEXFUNCPROC)(const char* name);
|
||||
|
||||
typedef void (*PFNSHADERBINDFUNCPROC)(shader_set_data* set, shader* shad);
|
||||
typedef void (*PFNSHADERBINDFUNCPROC)(struct p_gl_rend_state& p_gl_rend_st,
|
||||
struct uniform_value& shader_flags, shader_set_data* set, shader* shad);
|
||||
|
||||
struct shader_bind_func {
|
||||
uint32_t name_index;
|
||||
@@ -59,38 +60,29 @@ struct shader {
|
||||
const uniform_name* use_uniform;
|
||||
PFNSHADERBINDFUNCPROC bind_func;
|
||||
|
||||
int32_t bind(shader_set_data* set, uint32_t sub_index);
|
||||
int32_t bind(struct p_gl_rend_state& p_gl_rend_st,
|
||||
struct uniform_value& shader_flags, shader_set_data* set, uint32_t sub_index);
|
||||
|
||||
static bool parse_define(const char* data, std::string& temp);
|
||||
static bool parse_define(const char* data, int32_t num_uniform,
|
||||
int32_t* uniform_value, std::string& temp);
|
||||
static char* parse_include(char* data, farc* f);
|
||||
static void unbind();
|
||||
static void unbind(struct p_gl_rend_state& p_gl_rend_st);
|
||||
};
|
||||
|
||||
struct shader_set_data {
|
||||
size_t size;
|
||||
shader* shaders;
|
||||
GLuint curr_program;
|
||||
GLboolean primitive_restart;
|
||||
GLuint primitive_restart_index;
|
||||
|
||||
PFNSHADERGETINDEXFUNCPROC get_index_by_name_func;
|
||||
|
||||
shader_set_data();
|
||||
|
||||
void disable_primitive_restart();
|
||||
void draw_arrays(GLenum mode, GLint first, GLsizei count);
|
||||
void draw_elements(GLenum mode,
|
||||
GLsizei count, GLenum type, const void* indices);
|
||||
void draw_range_elements(GLenum mode,
|
||||
GLuint start, GLuint end, GLsizei count, GLenum type, const void* indices);
|
||||
void enable_primitive_restart();
|
||||
int32_t get_index_by_name(const char* name);
|
||||
void load(farc* f, bool ignore_cache, const char* name,
|
||||
const shader_table* shaders_table, const size_t size,
|
||||
const shader_bind_func* bind_func_table, const size_t bind_func_table_size,
|
||||
PFNSHADERGETINDEXFUNCPROC get_index_by_name);
|
||||
void set(uint32_t index);
|
||||
void set(struct p_gl_rend_state& p_gl_rend_st, struct uniform_value& shader_flags, uint32_t index);
|
||||
void unload();
|
||||
};
|
||||
|
||||
+131
-99
@@ -1261,23 +1261,39 @@ const size_t shader_ft_table_size =
|
||||
sizeof(shader_ft_table) / sizeof(shader_table);
|
||||
|
||||
static void glass_eye_calc(glass_eye_struct* glass_eye);
|
||||
static void glass_eye_set(glass_eye_struct* glass_eye);
|
||||
static void shader_bind_blinn(shader_set_data* set, shader* shad);
|
||||
static void shader_bind_cloth(shader_set_data* set, shader* shad);
|
||||
static void shader_bind_hair(shader_set_data* set, shader* shad);
|
||||
static void shader_bind_glass_eye(shader_set_data* set, shader* shad);
|
||||
static void shader_bind_tone_map(shader_set_data* set, shader* shad);
|
||||
static void shader_bind_sss_filter(shader_set_data* set, shader* shad);
|
||||
static void shader_bind_esm_filter(shader_set_data* set, shader* shad);
|
||||
static void shader_bind_reduce_tex(shader_set_data* set, shader* shad);
|
||||
static void shader_bind_magnify(shader_set_data* set, shader* shad);
|
||||
static void shader_bind_mlaa(shader_set_data* set, shader* shad);
|
||||
static void shader_bind_exposure(shader_set_data* set, shader* shad);
|
||||
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);
|
||||
static void glass_eye_set(p_gl_rend_state& p_gl_rend_st, glass_eye_struct* glass_eye);
|
||||
static void shader_bind_blinn(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad);
|
||||
static void shader_bind_cloth(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad);
|
||||
static void shader_bind_hair(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad);
|
||||
static void shader_bind_glass_eye(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad);
|
||||
static void shader_bind_tone_map(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad);
|
||||
static void shader_bind_sss_filter(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad);
|
||||
static void shader_bind_esm_filter(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad);
|
||||
static void shader_bind_reduce_tex(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad);
|
||||
static void shader_bind_magnify(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad);
|
||||
static void shader_bind_mlaa(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad);
|
||||
static void shader_bind_exposure(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad);
|
||||
static void shader_bind_gauss(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad);
|
||||
static void shader_bind_snow_particle(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad);
|
||||
static void shader_bind_star(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad);
|
||||
static void shader_bind_imgfilter(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad);
|
||||
static void shader_bind_dof(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad);
|
||||
|
||||
const shader_bind_func shader_ft_bind_func_table[] = {
|
||||
{
|
||||
@@ -1483,7 +1499,7 @@ static void glass_eye_calc(glass_eye_struct* glass_eye) {
|
||||
glass_eye->tex_offset.w = 0.0f;
|
||||
}
|
||||
|
||||
static void glass_eye_set(glass_eye_struct* glass_eye) {
|
||||
static void glass_eye_set(p_gl_rend_state& p_gl_rend_st, glass_eye_struct* glass_eye) {
|
||||
glass_eye_batch_shader_data glass_eye_batch = {};
|
||||
|
||||
vec3 ellipsoid_radius = glass_eye->cornea_radius * glass_eye->cornea_radius;
|
||||
@@ -1530,228 +1546,244 @@ static void glass_eye_set(glass_eye_struct* glass_eye) {
|
||||
glass_eye_batch.g_tex_scale.w = glass_eye->lens_depth;
|
||||
|
||||
extern render_context* rctx;
|
||||
rctx->glass_eye_batch_ubo.WriteMemory(glass_eye_batch);
|
||||
rctx->glass_eye_batch_ubo.Bind(3);
|
||||
rctx->glass_eye_batch_ubo.WriteMemory(p_gl_rend_st, glass_eye_batch);
|
||||
p_gl_rend_st.bind_uniform_buffer_base(3, rctx->glass_eye_batch_ubo);
|
||||
}
|
||||
|
||||
static void shader_bind_blinn(shader_set_data* set, shader* shad) {
|
||||
shad->bind(set, uniform->arr[U_NORMAL]
|
||||
static void shader_bind_blinn(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad) {
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, shader_flags.arr[U_NORMAL]
|
||||
? SHADER_FT_SUB_BLINN_FRAG : SHADER_FT_SUB_BLINN_VERT);
|
||||
}
|
||||
|
||||
static void shader_bind_cloth(shader_set_data* set, shader* shad) {
|
||||
shad->bind(set, uniform->arr[U_NPR] ? SHADER_FT_SUB_CLOTH_NPR1
|
||||
: (uniform->arr[U_ANISO] ? SHADER_FT_SUB_CLOTH_ANISO : SHADER_FT_SUB_CLOTH_DEFAULT));
|
||||
static void shader_bind_cloth(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad) {
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, shader_flags.arr[U_NPR] ? SHADER_FT_SUB_CLOTH_NPR1
|
||||
: (shader_flags.arr[U_ANISO] ? SHADER_FT_SUB_CLOTH_ANISO : SHADER_FT_SUB_CLOTH_DEFAULT));
|
||||
}
|
||||
|
||||
static void shader_bind_hair(shader_set_data* set, shader* shad) {
|
||||
shad->bind(set, uniform->arr[U_NPR] ? SHADER_FT_SUB_HAIR_NPR1 : SHADER_FT_SUB_HAIR_DEFAULT);
|
||||
static void shader_bind_hair(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad) {
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, shader_flags.arr[U_NPR] ? SHADER_FT_SUB_HAIR_NPR1 : SHADER_FT_SUB_HAIR_DEFAULT);
|
||||
}
|
||||
|
||||
static void shader_bind_glass_eye(shader_set_data* set, shader* shad) {
|
||||
uniform->arr[U_EYE_LENS] = 0;
|
||||
if (set->shaders[SHADER_FT_GLASEYE].bind(set, SHADER_FT_SUB_GLASS_EYE) >= 0) {
|
||||
static void shader_bind_glass_eye(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad) {
|
||||
shader_flags.arr[U_EYE_LENS] = 0;
|
||||
if (set->shaders[SHADER_FT_GLASEYE].bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_GLASS_EYE) >= 0) {
|
||||
glass_eye_calc(&glass_eye);
|
||||
glass_eye_set(&glass_eye);
|
||||
glass_eye_set(p_gl_rend_st, &glass_eye);
|
||||
}
|
||||
}
|
||||
|
||||
static void shader_bind_tone_map(shader_set_data* set, shader* shad) {
|
||||
shad->bind(set, uniform->arr[U_NPR] == 1
|
||||
static void shader_bind_tone_map(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad) {
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, shader_flags.arr[U_NPR] == 1
|
||||
? SHADER_FT_SUB_TONEMAP_NPR1 : SHADER_FT_SUB_TONEMAP);
|
||||
}
|
||||
|
||||
static void shader_bind_sss_filter(shader_set_data* set, shader* shad) {
|
||||
switch (uniform->arr[U_SSS_FILTER]) {
|
||||
static void shader_bind_sss_filter(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad) {
|
||||
switch (shader_flags.arr[U_SSS_FILTER]) {
|
||||
case 0:
|
||||
shad->bind(set, uniform->arr[U_NPR]
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, shader_flags.arr[U_NPR]
|
||||
? SHADER_FT_SUB_SSS_FILTER_MIN_NPR : SHADER_FT_SUB_SSS_FILTER_MIN);
|
||||
break;
|
||||
case 3:
|
||||
shad->bind(set, SHADER_FT_SUB_SSS_FILTER_GAUSS_2D);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_SSS_FILTER_GAUSS_2D);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void shader_bind_esm_filter(shader_set_data* set, shader* shad) {
|
||||
switch (uniform->arr[U_ESM_FILTER]) {
|
||||
static void shader_bind_esm_filter(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad) {
|
||||
switch (shader_flags.arr[U_ESM_FILTER]) {
|
||||
case 0:
|
||||
shad->bind(set, SHADER_FT_SUB_ESM_FILTER_MIN);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_ESM_FILTER_MIN);
|
||||
break;
|
||||
case 1:
|
||||
shad->bind(set, SHADER_FT_SUB_ESM_FILTER_EROSION);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_ESM_FILTER_EROSION);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void shader_bind_reduce_tex(shader_set_data* set, shader* shad) {
|
||||
switch (uniform->arr[U_REDUCE]) {
|
||||
static void shader_bind_reduce_tex(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad) {
|
||||
switch (shader_flags.arr[U_REDUCE]) {
|
||||
case 0:
|
||||
switch (uniform->arr[U_ALPHA_MASK]) {
|
||||
switch (shader_flags.arr[U_ALPHA_MASK]) {
|
||||
case 0:
|
||||
shad->bind(set, SHADER_FT_SUB_REDUCE_TEX_REDUCE_2);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_REDUCE_TEX_REDUCE_2);
|
||||
break;
|
||||
default:
|
||||
shad->bind(set, SHADER_FT_SUB_REDUCE_TEX_REDUCE_2_ALPHAMASK);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_REDUCE_TEX_REDUCE_2_ALPHAMASK);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
switch (uniform->arr[U_ALPHA_MASK]) {
|
||||
switch (shader_flags.arr[U_ALPHA_MASK]) {
|
||||
case 0:
|
||||
shad->bind(set, SHADER_FT_SUB_REDUCE_TEX_REDUCE_4);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_REDUCE_TEX_REDUCE_4);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
switch (uniform->arr[U_ALPHA_MASK]) {
|
||||
switch (shader_flags.arr[U_ALPHA_MASK]) {
|
||||
case 0:
|
||||
shad->bind(set, SHADER_FT_SUB_REDUCE_TEX_REDUCE_4_EXTRACT);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_REDUCE_TEX_REDUCE_4_EXTRACT);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
switch (uniform->arr[U_ALPHA_MASK]) {
|
||||
switch (shader_flags.arr[U_ALPHA_MASK]) {
|
||||
case 0:
|
||||
shad->bind(set, SHADER_FT_SUB_GHOST);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_GHOST);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
switch (uniform->arr[U_ALPHA_MASK]) {
|
||||
switch (shader_flags.arr[U_ALPHA_MASK]) {
|
||||
case 0:
|
||||
shad->bind(set, SHADER_FT_SUB_REDUCE_TEX_REDUCE_COMPOSITE_2);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_REDUCE_TEX_REDUCE_COMPOSITE_2);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
switch (uniform->arr[U_ALPHA_MASK]) {
|
||||
switch (shader_flags.arr[U_ALPHA_MASK]) {
|
||||
case 0:
|
||||
shad->bind(set, SHADER_FT_SUB_REDUCE_TEX_REDUCE_COMPOSITE_BLUR);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_REDUCE_TEX_REDUCE_COMPOSITE_BLUR);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
switch (uniform->arr[U_ALPHA_MASK]) {
|
||||
switch (shader_flags.arr[U_ALPHA_MASK]) {
|
||||
case 0:
|
||||
shad->bind(set, SHADER_FT_SUB_REDUCE_TEX_REDUCE_COMPOSITE_4);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_REDUCE_TEX_REDUCE_COMPOSITE_4);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void shader_bind_magnify(shader_set_data* set, shader* shad) {
|
||||
switch (uniform->arr[U_MAGNIFY]) {
|
||||
static void shader_bind_magnify(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad) {
|
||||
switch (shader_flags.arr[U_MAGNIFY]) {
|
||||
case 0:
|
||||
shad->bind(set, SHADER_FT_SUB_MAGNIFY_LINEAR);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_MAGNIFY_LINEAR);
|
||||
break;
|
||||
case 2:
|
||||
shad->bind(set, SHADER_FT_SUB_MAGNIFY_DIFF);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_MAGNIFY_DIFF);
|
||||
break;
|
||||
case 3:
|
||||
shad->bind(set, SHADER_FT_SUB_MAGNIFY_DIFF2);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_MAGNIFY_DIFF2);
|
||||
break;
|
||||
case 4:
|
||||
shad->bind(set, SHADER_FT_SUB_MAGNIFY_CONE);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_MAGNIFY_CONE);
|
||||
break;
|
||||
case 5:
|
||||
shad->bind(set, SHADER_FT_SUB_MAGNIFY_CONE2);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_MAGNIFY_CONE2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void shader_bind_mlaa(shader_set_data* set, shader* shad) {
|
||||
switch (uniform->arr[U_MLAA]) {
|
||||
static void shader_bind_mlaa(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad) {
|
||||
switch (shader_flags.arr[U_MLAA]) {
|
||||
case 0:
|
||||
shad->bind(set, SHADER_FT_SUB_MLAA_EDGE);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_MLAA_EDGE);
|
||||
break;
|
||||
case 1:
|
||||
shad->bind(set, SHADER_FT_SUB_MLAA_AREA);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_MLAA_AREA);
|
||||
break;
|
||||
case 2:
|
||||
shad->bind(set, SHADER_FT_SUB_MLAA_BLEND);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_MLAA_BLEND);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void shader_bind_exposure(shader_set_data* set, shader* shad) {
|
||||
switch (uniform->arr[U_EXPOSURE]) {
|
||||
static void shader_bind_exposure(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad) {
|
||||
switch (shader_flags.arr[U_EXPOSURE]) {
|
||||
case 0:
|
||||
shad->bind(set, SHADER_FT_SUB_EXPOSURE_MINIFY);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_EXPOSURE_MINIFY);
|
||||
break;
|
||||
case 1:
|
||||
shad->bind(set, SHADER_FT_SUB_EXPOSURE_MEASURE);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_EXPOSURE_MEASURE);
|
||||
break;
|
||||
case 2:
|
||||
shad->bind(set, SHADER_FT_SUB_EXPOSURE_AVERAGE);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_EXPOSURE_AVERAGE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void shader_bind_gauss(shader_set_data* set, shader* shad) {
|
||||
switch (uniform->arr[U_GAUSS]) {
|
||||
static void shader_bind_gauss(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad) {
|
||||
switch (shader_flags.arr[U_GAUSS]) {
|
||||
case 0:
|
||||
shad->bind(set, SHADER_FT_SUB_PP_GAUSS_USUAL);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_PP_GAUSS_USUAL);
|
||||
break;
|
||||
case 1:
|
||||
shad->bind(set, SHADER_FT_SUB_PP_GAUSS_CONE);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_PP_GAUSS_CONE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void shader_bind_snow_particle(shader_set_data* set, shader* shad) {
|
||||
switch (uniform->arr[U_SNOW_PARTICLE]) {
|
||||
static void shader_bind_snow_particle(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad) {
|
||||
switch (shader_flags.arr[U_SNOW_PARTICLE]) {
|
||||
case 0:
|
||||
shad->bind(set, SHADER_FT_SUB_SNOW_PARTICLE_CPU);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_SNOW_PARTICLE_CPU);
|
||||
break;
|
||||
case 1:
|
||||
shad->bind(set, SHADER_FT_SUB_SNOW_PARTICLE);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_SNOW_PARTICLE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void shader_bind_star(shader_set_data* set, shader* shad) {
|
||||
switch (uniform->arr[U_STAR]) {
|
||||
static void shader_bind_star(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad) {
|
||||
switch (shader_flags.arr[U_STAR]) {
|
||||
case 0:
|
||||
shad->bind(set, SHADER_FT_SUB_STAR);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_STAR);
|
||||
break;
|
||||
case 1:
|
||||
shad->bind(set, SHADER_FT_SUB_STAR_MILKY_WAY);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_STAR_MILKY_WAY);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void shader_bind_imgfilter(shader_set_data* set, shader* shad) {
|
||||
switch (uniform->arr[U_IMAGE_FILTER]) {
|
||||
static void shader_bind_imgfilter(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad) {
|
||||
switch (shader_flags.arr[U_IMAGE_FILTER]) {
|
||||
case 0:
|
||||
shad->bind(set, SHADER_FT_SUB_BOX4);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_BOX4);
|
||||
break;
|
||||
case 1:
|
||||
shad->bind(set, SHADER_FT_SUB_BOX8);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_BOX8);
|
||||
break;
|
||||
case 5:
|
||||
shad->bind(set, SHADER_FT_SUB_COPY);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_COPY);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void shader_bind_dof(shader_set_data* set, shader* shad) {
|
||||
switch (uniform->arr[U_DOF_STAGE]) {
|
||||
static void shader_bind_dof(p_gl_rend_state& p_gl_rend_st,
|
||||
uniform_value& shader_flags, shader_set_data* set, shader* shad) {
|
||||
switch (shader_flags.arr[U_DOF_STAGE]) {
|
||||
case 0:
|
||||
shad->bind(set, SHADER_FT_SUB_DOF_RENDER_TILE);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_DOF_RENDER_TILE);
|
||||
break;
|
||||
case 1:
|
||||
shad->bind(set, SHADER_FT_SUB_DOF_GATHER_TILE);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_DOF_GATHER_TILE);
|
||||
break;
|
||||
case 2:
|
||||
shad->bind(set, SHADER_FT_SUB_DOF_DOWNSAMPLE);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_DOF_DOWNSAMPLE);
|
||||
break;
|
||||
case 3:
|
||||
shad->bind(set, SHADER_FT_SUB_DOF_MAIN_FILTER);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_DOF_MAIN_FILTER);
|
||||
break;
|
||||
case 4:
|
||||
shad->bind(set, SHADER_FT_SUB_DOF_UPSAMPLE);
|
||||
shad->bind(p_gl_rend_st, shader_flags, set, SHADER_FT_SUB_DOF_UPSAMPLE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+41
-3
@@ -5,8 +5,8 @@
|
||||
|
||||
#include "shadow.hpp"
|
||||
#include "../AFTModsShared/light_param/light.hpp"
|
||||
#include "gl_state.hpp"
|
||||
#include "render_context.hpp"
|
||||
#include "render_manager.hpp"
|
||||
#include <Helpers.h>
|
||||
|
||||
#define MIN_SHADOW_RANGE (1.2f)
|
||||
@@ -25,6 +25,40 @@ static void sub_1405E6840(Shadow* shad);
|
||||
static void sub_1405E6910(Shadow* shad);
|
||||
static void sub_1405E6B70(Shadow* shad);
|
||||
|
||||
void Shadow::calc_proj_view_mat(cam_data& cam, const vec3& view_point,
|
||||
const vec3& interest, float_t range, float_t offset, float_t scale) {
|
||||
cam.set_view_point(view_point);
|
||||
cam.set_interest(interest);
|
||||
|
||||
vec3 up = { 0.0f, 1.0f, 0.0f };
|
||||
const vec3 dir = interest - view_point;
|
||||
if (vec3::length_squared(dir) <= 0.000001f) {
|
||||
up.x = 0.0f;
|
||||
up.y = 0.0f;
|
||||
if (dir.z < 0.0f)
|
||||
up.z = 1.0f;
|
||||
else
|
||||
up.z = -1.0f;
|
||||
}
|
||||
cam.set_up(up);
|
||||
|
||||
cam.calc_view_mat();
|
||||
cam.set_min_distance(z_near);
|
||||
cam.set_max_distance(z_far);
|
||||
cam.calc_ortho_proj_mat(-range, range, -range, range, scale, { offset, 0.0f });
|
||||
cam.calc_view_proj_mat();
|
||||
}
|
||||
|
||||
void Shadow::clear_textures(p_gl_rend_state& p_gl_rend_st) {
|
||||
for (int32_t i = 1; i < 3; i++)
|
||||
for (int32_t j = 0; j < 4; j++) {
|
||||
curr_render_textures[i]->Bind(p_gl_rend_st, j);
|
||||
p_gl_rend_st.clear_color(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
p_gl_rend_st.clear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
p_gl_rend_st.bind_framebuffer(0);
|
||||
}
|
||||
|
||||
void Shadow::ctrl() {
|
||||
for (int32_t i = 0; i < 2; i++)
|
||||
shadow_enable[i] = false;
|
||||
@@ -79,13 +113,17 @@ int32_t Shadow::init() {
|
||||
return -1;
|
||||
|
||||
for (int32_t i = 0; i < 3; i++) {
|
||||
gl_rend_state.bind_texture_2d(render_textures[i].GetColorTex());
|
||||
gl_state.bind_texture_2d(render_textures[i].GetColorTex());
|
||||
glTexParameteriDLL(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
|
||||
glTexParameteriDLL(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
|
||||
static const vec4 border_color = 1.0f;
|
||||
glTexParameterfvDLL(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, (GLfloat*)&border_color);
|
||||
}
|
||||
gl_rend_state.bind_texture_2d(0);
|
||||
|
||||
gl_state.bind_texture_2d(render_textures[0].GetDepthTex());
|
||||
GLint swizzle[] = { GL_RED, GL_RED, GL_RED, GL_ONE };
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
|
||||
gl_state.bind_texture_2d(0);
|
||||
gl_get_error_print();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -53,6 +53,9 @@ struct Shadow {
|
||||
bool blur_filter_enable[2];
|
||||
bool separate;
|
||||
|
||||
void calc_proj_view_mat(struct cam_data& cam, const vec3& view_point,
|
||||
const vec3& interest, float_t range, float_t offset, float_t scale);
|
||||
void clear_textures(struct p_gl_rend_state& p_gl_rend_st);
|
||||
void ctrl();
|
||||
void free();
|
||||
float_t get_shadow_range();
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
#include "shared.hpp"
|
||||
#include "gl_rend_state.hpp"
|
||||
|
||||
void fbo_blit(GLuint src_fbo, GLuint dst_fbo,
|
||||
void fbo_blit(p_gl_rend_state& p_gl_rend_st, GLuint src_fbo, GLuint dst_fbo,
|
||||
GLint src_x, GLint src_y, GLint src_width, GLint src_height,
|
||||
GLint dst_x, GLint dst_y, GLint dst_width, GLint dst_height, GLbitfield mask, GLenum filter) {
|
||||
gl_rend_state.bind_read_framebuffer(src_fbo);
|
||||
gl_rend_state.bind_draw_framebuffer(dst_fbo);
|
||||
glBlitFramebuffer(src_x, src_y, src_x + src_width, src_y + src_height,
|
||||
p_gl_rend_st.bind_read_framebuffer(src_fbo);
|
||||
p_gl_rend_st.bind_draw_framebuffer(dst_fbo);
|
||||
p_gl_rend_st.blit_framebuffer(src_x, src_y, src_x + src_width, src_y + src_height,
|
||||
dst_x, dst_y, dst_x + dst_width, dst_y + dst_height, mask, filter);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "../AFTModsShared/shared.hpp"
|
||||
#include "wrap.hpp"
|
||||
|
||||
extern void fbo_blit(GLuint src_fbo, GLuint dst_fbo,
|
||||
extern void fbo_blit(struct p_gl_rend_state& p_gl_rend_st, GLuint src_fbo, GLuint dst_fbo,
|
||||
GLint src_x, GLint src_y, GLint src_width, GLint src_height,
|
||||
GLint dst_x, GLint dst_y, GLint dst_width, GLint dst_height, GLbitfield mask, GLenum filter);
|
||||
|
||||
|
||||
+92
-86
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
#include "sprite.hpp"
|
||||
#include "gl_state.hpp"
|
||||
#include "render_context.hpp"
|
||||
#include "shader_ft.hpp"
|
||||
#include <Helpers.h>
|
||||
@@ -93,7 +94,8 @@ namespace spr {
|
||||
mat4 mat;
|
||||
resolution_mode resolution_mode;
|
||||
|
||||
void Draw(int32_t index, bool font, texture* overlay_tex);
|
||||
void Draw(render_data_context& rend_data_ctx,
|
||||
int32_t index, bool font, texture* overlay_tex);
|
||||
void PostDraw();
|
||||
void PreDraw();
|
||||
};
|
||||
@@ -111,12 +113,13 @@ namespace spr {
|
||||
static void add_draw_sprite(spr::SprArgs** args_array, int32_t count, bool font,
|
||||
spr::SprArgsInner& args_inner, std::vector<sprite_draw_param>& draw_param_buffer,
|
||||
std::vector<sprite_draw_vertex>& vertex_buffer, std::vector<uint32_t>& index_buffer);
|
||||
static void draw_sprite(const SprArgs& args, const mat4& mat,
|
||||
static void draw_sprite(render_data_context& rend_data_ctx, const SprArgs& args, const mat4& mat,
|
||||
int32_t x_min, int32_t y_min, int32_t x_max, int32_t y_max, texture* overlay_tex);
|
||||
static void draw_sprite_begin();
|
||||
static void draw_sprite_copy_overlay_texture(const SprArgs& args, const mat4& mat,
|
||||
const vec3* vtx, int32_t overlay_x_min, int32_t overlay_y_min, int32_t overlay_x_max, int32_t overlay_y_max);
|
||||
static void draw_sprite_end();
|
||||
static void draw_sprite_begin(render_data_context& rend_data_ctx);
|
||||
static void draw_sprite_copy_overlay_texture(
|
||||
render_data_context& rend_data_ctx, const SprArgs& args, const mat4& mat, const vec3* vtx,
|
||||
int32_t overlay_x_min, int32_t overlay_y_min, int32_t overlay_x_max, int32_t overlay_y_max);
|
||||
static void draw_sprite_end(render_data_context& rend_data_ctx);
|
||||
static void draw_sprite_scale(spr::SprArgs* args);
|
||||
}
|
||||
|
||||
@@ -138,16 +141,16 @@ static const GLenum spr_blend_param[6][4] = {
|
||||
};
|
||||
|
||||
namespace spr {
|
||||
SpriteManager::RenderData::RenderData() {
|
||||
SpriteManager::RenderData::RenderData() : vao() {
|
||||
glGenVertexArrays(1, &vao);
|
||||
glBindVertexArray(vao);
|
||||
gl_state.bind_vertex_array(vao);
|
||||
|
||||
vbo_vertex_count = 4096;
|
||||
|
||||
static const GLsizei buffer_size = sizeof(sprite_draw_vertex);
|
||||
|
||||
vbo.Create(buffer_size * vbo_vertex_count);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
vbo.Create(gl_state, buffer_size * vbo_vertex_count);
|
||||
gl_state.bind_array_buffer(vbo, true);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, buffer_size,
|
||||
@@ -161,12 +164,12 @@ namespace spr {
|
||||
|
||||
ebo_index_count = 4096;
|
||||
|
||||
ebo.Create(sizeof(uint32_t) * ebo_index_count);
|
||||
ebo.Bind();
|
||||
ebo.Create(gl_state, sizeof(uint32_t) * ebo_index_count);
|
||||
gl_state.bind_element_array_buffer(ebo, true);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
gl_state.bind_array_buffer(0);
|
||||
gl_state.bind_vertex_array(0);
|
||||
gl_state.bind_element_array_buffer(0);
|
||||
}
|
||||
|
||||
SpriteManager::RenderData::~RenderData() {
|
||||
@@ -194,10 +197,10 @@ namespace spr {
|
||||
|
||||
vbo.Destroy();
|
||||
|
||||
glBindVertexArray(vao);
|
||||
gl_state.bind_vertex_array(vao);
|
||||
|
||||
vbo.Create(buffer_size * vbo_vertex_count);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
vbo.Create(gl_state, buffer_size * vbo_vertex_count);
|
||||
gl_state.bind_array_buffer(vbo, true);
|
||||
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, (GLsizeiptr)(buffer_size
|
||||
* vertex_buffer.size()), vertex_buffer.data());
|
||||
@@ -212,11 +215,11 @@ namespace spr {
|
||||
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, buffer_size,
|
||||
(void*)offsetof(sprite_draw_vertex, uv));
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindVertexArray(0);
|
||||
gl_state.bind_array_buffer(0);
|
||||
gl_state.bind_vertex_array(0);
|
||||
}
|
||||
else
|
||||
vbo.WriteMemory(0, buffer_size * vertex_buffer.size(), vertex_buffer.data());
|
||||
vbo.WriteMemory(gl_state, 0, buffer_size * vertex_buffer.size(), vertex_buffer.data());
|
||||
|
||||
if (ebo_index_count < index_buffer.size()) {
|
||||
while (ebo_index_count < index_buffer.size())
|
||||
@@ -224,23 +227,24 @@ namespace spr {
|
||||
|
||||
ebo.Destroy();
|
||||
|
||||
glBindVertexArray(vao);
|
||||
gl_state.bind_vertex_array(vao);
|
||||
|
||||
ebo.Create(sizeof(uint32_t) * ebo_index_count);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo);
|
||||
ebo.Create(gl_state, sizeof(uint32_t) * ebo_index_count);
|
||||
gl_state.bind_element_array_buffer(ebo, true);
|
||||
|
||||
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, (GLsizeiptr)(sizeof(uint32_t)
|
||||
* index_buffer.size()), index_buffer.data());
|
||||
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
gl_state.bind_vertex_array(0);
|
||||
gl_state.bind_element_array_buffer(0);
|
||||
}
|
||||
else
|
||||
ebo.WriteMemory(0, sizeof(uint32_t) * index_buffer.size(), index_buffer.data());
|
||||
ebo.WriteMemory(gl_state, 0, sizeof(uint32_t) * index_buffer.size(), index_buffer.data());
|
||||
}
|
||||
|
||||
void SpriteManager::Draw(int32_t index, bool font, texture* overlay_tex) {
|
||||
draw_sprite_begin();
|
||||
void SpriteManager::Draw(render_data_context& rend_data_ctx,
|
||||
int32_t index, bool font, texture* overlay_tex) {
|
||||
draw_sprite_begin(rend_data_ctx);
|
||||
|
||||
size_t count = 0;
|
||||
for (auto& i : reqlist[index])
|
||||
@@ -251,7 +255,7 @@ namespace spr {
|
||||
if (index == 2 && resolution_mode != RESOLUTION_MODE_MAX)
|
||||
res_window_get()->resolution_mode = resolution_mode;
|
||||
|
||||
gl_rend_state_rect viewport_rect = gl_rend_state.get_viewport();
|
||||
gl_rend_state_rect viewport_rect = rend_data_ctx.state.get_viewport();
|
||||
|
||||
for (int32_t i = 0; i < 2; i++) {
|
||||
auto reqlist = this->reqlist[index][i];
|
||||
@@ -298,7 +302,7 @@ namespace spr {
|
||||
y_min = (int32_t)min.y;
|
||||
x_max = (int32_t)(max.x - min.x);
|
||||
y_max = (int32_t)(max.y - min.y);
|
||||
gl_rend_state.set_viewport(x_min, y_min, x_max, y_max);
|
||||
rend_data_ctx.state.set_viewport(x_min, y_min, x_max, y_max);
|
||||
}
|
||||
else {
|
||||
view_projection = view_projection_aet;
|
||||
@@ -333,23 +337,23 @@ namespace spr {
|
||||
1.0f / (float_t)overlay_tex->height, 0.0f, 0.0f
|
||||
};
|
||||
shader_data.g_transform = view_projection;
|
||||
rctx->sprite_scene_ubo.WriteMemory(shader_data);
|
||||
rctx->sprite_scene_ubo.Bind(0);
|
||||
rctx->sprite_scene_ubo.WriteMemory(rend_data_ctx.state, shader_data);
|
||||
rend_data_ctx.state.bind_uniform_buffer_base(0, rctx->sprite_scene_ubo);
|
||||
|
||||
RenderData& render_data = *sprite_manager_render_data;
|
||||
|
||||
gl_rend_state.bind_vertex_array(render_data.vao);
|
||||
rend_data_ctx.state.bind_vertex_array(render_data.vao);
|
||||
for (uint32_t j = SPR_PRIO_MAX; j; j--, reqlist++)
|
||||
for (auto& k : *reqlist)
|
||||
if (k.sprite_draw_param_index >= 0)
|
||||
draw_sprite(k, mat, x_min, y_min, x_max, y_max, overlay_tex);
|
||||
gl_rend_state.bind_vertex_array(0);
|
||||
draw_sprite(rend_data_ctx, k, mat, x_min, y_min, x_max, y_max, overlay_tex);
|
||||
rend_data_ctx.state.bind_vertex_array(0);
|
||||
}
|
||||
|
||||
if (index == 2 && resolution_mode != RESOLUTION_MODE_MAX)
|
||||
res_window_get()->resolution_mode = mode;
|
||||
|
||||
draw_sprite_end();
|
||||
draw_sprite_end(rend_data_ctx);
|
||||
}
|
||||
|
||||
void SpriteManager::PostDraw() {
|
||||
@@ -1067,7 +1071,7 @@ namespace spr {
|
||||
args_array[i]->sprite_draw_param_index = -1;
|
||||
}
|
||||
|
||||
static void draw_sprite(const SprArgs& args, const mat4& mat,
|
||||
static void draw_sprite(render_data_context& rend_data_ctx, const SprArgs& args, const mat4& mat,
|
||||
int32_t x_min, int32_t y_min, int32_t x_max, int32_t y_max, texture* overlay_tex) {
|
||||
sprite_draw_param& draw_param
|
||||
= sprite_manager_render_data->draw_param_buffer.data()[args.sprite_draw_param_index];
|
||||
@@ -1075,8 +1079,9 @@ namespace spr {
|
||||
int32_t combiner = 0;
|
||||
if (draw_param.attrib.m.enable_blend) {
|
||||
if (draw_param.attrib.m.blend == 5) {
|
||||
gl_rend_state.active_bind_texture_2d(7, overlay_tex->glid);
|
||||
draw_sprite_copy_overlay_texture(args, mat, draw_param.vtx, x_min, y_min, x_max, y_max);
|
||||
rend_data_ctx.state.active_bind_texture_2d(7, overlay_tex->glid);
|
||||
draw_sprite_copy_overlay_texture(rend_data_ctx,
|
||||
args, mat, draw_param.vtx, x_min, y_min, x_max, y_max);
|
||||
combiner = 2;
|
||||
}
|
||||
else
|
||||
@@ -1084,11 +1089,11 @@ namespace spr {
|
||||
|
||||
const GLenum* blend = spr_blend_param[draw_param.attrib.m.blend];
|
||||
|
||||
gl_rend_state.enable_blend();
|
||||
gl_rend_state.set_blend_func_separate(blend[0], blend[1], blend[2], blend[3]);
|
||||
rend_data_ctx.state.enable_blend();
|
||||
rend_data_ctx.state.set_blend_func_separate(blend[0], blend[1], blend[2], blend[3]);
|
||||
}
|
||||
else
|
||||
gl_rend_state.disable_blend();
|
||||
rend_data_ctx.state.disable_blend();
|
||||
|
||||
if (draw_param.shader == SHADER_FT_SPRITE) {
|
||||
int32_t tex_0_type = 0;
|
||||
@@ -1111,51 +1116,50 @@ namespace spr {
|
||||
}
|
||||
}
|
||||
|
||||
uniform->arr[U_TEX_0_TYPE] = tex_0_type;
|
||||
uniform->arr[U_TEX_1_TYPE] = tex_1_type;
|
||||
uniform->arr[U_COMBINER] = combiner;
|
||||
rend_data_ctx.shader_flags.arr[U_TEX_0_TYPE] = tex_0_type;
|
||||
rend_data_ctx.shader_flags.arr[U_TEX_1_TYPE] = tex_1_type;
|
||||
rend_data_ctx.shader_flags.arr[U_COMBINER] = combiner;
|
||||
}
|
||||
|
||||
if (draw_param.textures[0]) {
|
||||
gl_rend_state.active_bind_texture_2d(0, draw_param.textures[0]->glid);
|
||||
gl_rend_state.bind_sampler(0, rctx->sprite_samplers[draw_param.attrib.m.sampler]);
|
||||
rend_data_ctx.state.active_bind_texture_2d(0, draw_param.textures[0]->glid);
|
||||
rend_data_ctx.state.bind_sampler(0, rctx->sprite_samplers[draw_param.attrib.m.sampler]);
|
||||
|
||||
if (draw_param.textures[1]) {
|
||||
gl_rend_state.active_bind_texture_2d(1, draw_param.textures[1]->glid);
|
||||
gl_rend_state.bind_sampler(1, rctx->sprite_samplers[draw_param.attrib.m.sampler]);
|
||||
rend_data_ctx.state.active_bind_texture_2d(1, draw_param.textures[1]->glid);
|
||||
rend_data_ctx.state.bind_sampler(1, rctx->sprite_samplers[draw_param.attrib.m.sampler]);
|
||||
}
|
||||
else if (!gl_rend_state.texture_binding_2d[1])
|
||||
gl_rend_state.active_bind_texture_2d(1, rctx->empty_texture_2d->glid);
|
||||
else
|
||||
rend_data_ctx.state.active_bind_texture_2d(1, rctx->empty_texture_2d->glid);
|
||||
}
|
||||
else {
|
||||
if (!gl_rend_state.texture_binding_2d[0])
|
||||
gl_rend_state.active_bind_texture_2d(0, rctx->empty_texture_2d->glid);
|
||||
if (!gl_rend_state.texture_binding_2d[1])
|
||||
gl_rend_state.active_bind_texture_2d(1, rctx->empty_texture_2d->glid);
|
||||
rend_data_ctx.state.active_bind_texture_2d(0, rctx->empty_texture_2d->glid);
|
||||
rend_data_ctx.state.active_bind_texture_2d(1, rctx->empty_texture_2d->glid);
|
||||
}
|
||||
|
||||
shaders_ft.set(draw_param.shader);
|
||||
shaders_ft.set(rend_data_ctx.state, rend_data_ctx.shader_flags, draw_param.shader);
|
||||
if (draw_param.attrib.m.primitive != GL_TRIANGLES)
|
||||
shaders_ft.draw_arrays(draw_param.attrib.m.primitive, draw_param.first, draw_param.count);
|
||||
rend_data_ctx.state.draw_arrays(draw_param.attrib.m.primitive, draw_param.first, draw_param.count);
|
||||
else
|
||||
shaders_ft.draw_range_elements(draw_param.attrib.m.primitive, draw_param.start, draw_param.end,
|
||||
rend_data_ctx.state.draw_range_elements(draw_param.attrib.m.primitive, draw_param.start, draw_param.end,
|
||||
draw_param.count, GL_UNSIGNED_INT, (void*)draw_param.offset);
|
||||
}
|
||||
|
||||
static void draw_sprite_begin() {
|
||||
gl_rend_state.disable_blend(true);
|
||||
gl_rend_state.active_bind_texture_2d(0, rctx->empty_texture_2d->glid, true);
|
||||
gl_rend_state.bind_sampler(0, 0, true);
|
||||
gl_rend_state.active_bind_texture_2d(1, rctx->empty_texture_2d->glid, true);
|
||||
gl_rend_state.bind_sampler(1, 0, true);
|
||||
gl_rend_state.bind_sampler(7, 0, true);
|
||||
gl_rend_state.set_blend_func_separate(GL_ONE, GL_ZERO, GL_ONE, GL_ZERO, true);
|
||||
gl_rend_state.bind_vertex_array(0, true);
|
||||
gl_rend_state.bind_uniform_buffer_base(0, 0, true);
|
||||
static void draw_sprite_begin(render_data_context& rend_data_ctx) {
|
||||
rend_data_ctx.state.disable_blend();
|
||||
rend_data_ctx.state.active_bind_texture_2d(0, rctx->empty_texture_2d->glid);
|
||||
rend_data_ctx.state.bind_sampler(0, 0);
|
||||
rend_data_ctx.state.active_bind_texture_2d(1, rctx->empty_texture_2d->glid);
|
||||
rend_data_ctx.state.bind_sampler(1, 0);
|
||||
rend_data_ctx.state.bind_sampler(7, 0);
|
||||
rend_data_ctx.state.set_blend_func_separate(GL_ONE, GL_ZERO, GL_ONE, GL_ZERO);
|
||||
rend_data_ctx.state.bind_vertex_array(0);
|
||||
rend_data_ctx.state.bind_uniform_buffer_base(0, 0);
|
||||
}
|
||||
|
||||
static void draw_sprite_copy_overlay_texture(const SprArgs& args, const mat4& mat,
|
||||
const vec3* vtx, int32_t overlay_x_min, int32_t overlay_y_min, int32_t overlay_x_max, int32_t overlay_y_max) {
|
||||
static void draw_sprite_copy_overlay_texture(
|
||||
render_data_context& rend_data_ctx, const SprArgs& args, const mat4& mat, const vec3* vtx,
|
||||
int32_t overlay_x_min, int32_t overlay_y_min, int32_t overlay_x_max, int32_t overlay_y_max) {
|
||||
if (args.num_vertex || args.kind != SPR_KIND_NORMAL)
|
||||
return;
|
||||
|
||||
@@ -1210,21 +1214,21 @@ namespace spr {
|
||||
const int32_t width = x_max - x_min + 1;
|
||||
const int32_t height = y_max - y_min + 1;
|
||||
if (width * height > 0) {
|
||||
gl_rend_state.active_texture(7);
|
||||
glCopyTexSubImage2DDLL(GL_TEXTURE_2D, 0, x_min, y_min, x_min, y_min, width, height);
|
||||
rend_data_ctx.state.active_texture(7);
|
||||
rend_data_ctx.state.copy_tex_sub_image_2d(GL_TEXTURE_2D, 0, x_min, y_min, x_min, y_min, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_sprite_end() {
|
||||
gl_rend_state.disable_blend();
|
||||
gl_rend_state.active_bind_texture_2d(0, 0);
|
||||
gl_rend_state.bind_sampler(0, 0);
|
||||
gl_rend_state.active_bind_texture_2d(1, 0);
|
||||
gl_rend_state.bind_sampler(1, 0);
|
||||
gl_rend_state.active_bind_texture_2d(7, 0);
|
||||
gl_rend_state.bind_sampler(7, 0);
|
||||
gl_rend_state.set_blend_func_separate(GL_ONE, GL_ZERO, GL_ONE, GL_ZERO);
|
||||
shaders_ft.set(-1);
|
||||
static void draw_sprite_end(render_data_context& rend_data_ctx) {
|
||||
rend_data_ctx.state.disable_blend();
|
||||
rend_data_ctx.state.active_bind_texture_2d(0, 0);
|
||||
rend_data_ctx.state.bind_sampler(0, 0);
|
||||
rend_data_ctx.state.active_bind_texture_2d(1, 0);
|
||||
rend_data_ctx.state.bind_sampler(1, 0);
|
||||
rend_data_ctx.state.active_bind_texture_2d(7, 0);
|
||||
rend_data_ctx.state.bind_sampler(7, 0);
|
||||
rend_data_ctx.state.set_blend_func_separate(GL_ONE, GL_ZERO, GL_ONE, GL_ZERO);
|
||||
shader::unbind(rend_data_ctx.state);
|
||||
}
|
||||
|
||||
static void draw_sprite_scale(spr::SprArgs* args) {
|
||||
@@ -1266,8 +1270,9 @@ void sprite_manager_init() {
|
||||
sprite_manager_render_data = new spr::SpriteManager::RenderData;
|
||||
}
|
||||
|
||||
void sprite_manager_draw(int32_t index, bool font, texture* overlay_tex) {
|
||||
sprite_manager->Draw(index, font, overlay_tex);
|
||||
void sprite_manager_draw(render_data_context& rend_data_ctx,
|
||||
int32_t index, bool font, texture* overlay_tex) {
|
||||
sprite_manager->Draw(rend_data_ctx, index, font, overlay_tex);
|
||||
}
|
||||
|
||||
void sprite_manager_post_draw() {
|
||||
@@ -1308,7 +1313,8 @@ HOOK(void, FASTCALL, spr__SprArgs__Reset, 0x000000014063CA10, spr::SprArgs* This
|
||||
}
|
||||
|
||||
HOOK(void, FASTCALL, sprite_manager_draw, 0x000000014063F870, int32_t index, bool font, texture* tex) {
|
||||
sprite_manager_draw(index, font, tex);
|
||||
render_data_context rend_data_ctx(GL_REND_STATE_POST_2D);
|
||||
sprite_manager_draw(rend_data_ctx, index, font, tex);
|
||||
}
|
||||
|
||||
void sprite_patch() {
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
#include "texture.hpp"
|
||||
|
||||
extern void sprite_manager_init();
|
||||
extern void sprite_manager_draw(int32_t index, bool font, texture* overlay_tex);
|
||||
extern void sprite_manager_draw(struct render_data_context& rend_data_ctx,
|
||||
int32_t index, bool font, texture* overlay_tex);
|
||||
extern void sprite_manager_post_draw();
|
||||
extern void sprite_manager_pre_draw();
|
||||
extern void sprite_manager_set_res(double_t aspect, int32_t width, int32_t height);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "texture.hpp"
|
||||
#include "../AFTModsShared/types.hpp"
|
||||
#include "gl_rend_state.hpp"
|
||||
#include "gl_state.hpp"
|
||||
#include "shared.hpp"
|
||||
#include <Helpers.h>
|
||||
|
||||
@@ -281,7 +281,7 @@ HOOK(texture*, FASTCALL, texture_load_tex_cube_map, 0x000000014069B860,
|
||||
width, height, max_mipmap_level, data_ptr, false);
|
||||
}
|
||||
|
||||
HOOK(texture*, FASTCALL, texture_load_tex_2d, 0x000000014069B8E0,
|
||||
HOOK(texture*, FASTCALL, texture_load_tex_2d, 0x000000014069B8E0,
|
||||
texture_id id, GLenum internal_format, int32_t width, int32_t height,
|
||||
int32_t max_mipmap_level, const void** data_ptr, bool use_high_anisotropy) {
|
||||
return texture_load_tex(id, GL_TEXTURE_2D, internal_format,
|
||||
@@ -334,10 +334,10 @@ texture_handler::texture_handler() : field_2C(), field_30(), field_34() {
|
||||
inline static void texture_bind(GLenum target, GLuint texture) {
|
||||
switch (target) {
|
||||
case GL_TEXTURE_2D:
|
||||
gl_rend_state.bind_texture_2d(texture);
|
||||
gl_state.bind_texture_2d(texture);
|
||||
break;
|
||||
case GL_TEXTURE_CUBE_MAP:
|
||||
gl_rend_state.bind_texture_cube_map(texture);
|
||||
gl_state.bind_texture_cube_map(texture);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+11
-5
@@ -2613,6 +2613,9 @@ PFNWGLGETPROCADDRESSGLUTPROC* divagl_wglGetProcAddressGLUT = 0;
|
||||
PFNWGLMAKECURRENTGLUTPROC* divagl_wglMakeCurrentGLUT = 0;
|
||||
|
||||
PFNGLTEXPARAMETERIVPROC divagl_glTexParameteriv = 0;
|
||||
PFNGLSTENCILMASKPROC diva_glStencilMask = 0;
|
||||
PFNGLSTENCILFUNCPROC diva_glStencilFunc = 0;
|
||||
PFNGLSTENCILOPPROC diva_glStencilOp = 0;
|
||||
PFNGLDRAWARRAYSINSTANCEDPROC divagl_glDrawArraysInstanced = 0;
|
||||
PFNGLPRIMITIVERESTARTINDEXPROC divagl_glPrimitiveRestartIndex = 0;
|
||||
PFNGLGETUNIFORMBLOCKINDEXPROC divagl_glGetUniformBlockIndex = 0;
|
||||
@@ -2632,6 +2635,8 @@ PFNGLMAPNAMEDBUFFERPROC divagl_glMapNamedBuffer = 0;
|
||||
PFNGLMAPNAMEDBUFFERRANGEPROC divagl_glMapNamedBufferRange = 0;
|
||||
PFNGLUNMAPNAMEDBUFFERPROC divagl_glUnmapNamedBuffer = 0;
|
||||
PFNGLTEXTURESUBIMAGE2DPROC divagl_glTextureSubImage2D = 0;
|
||||
PFNGLGENERATETEXTUREMIPMAPPROC divagl_glGenerateTextureMipmap = 0;
|
||||
PFNGLBINDTEXTUREUNITPROC divagl_glBindTextureUnit = 0;
|
||||
|
||||
PFNGLGETBOOLEANVDLLPROC divagl_glGetBooleanvDLL_orig = 0;
|
||||
PFNGLTEXIMAGE1DDLLPROC divagl_glTexImage1DDLL_orig = 0;
|
||||
@@ -2767,6 +2772,9 @@ HOOK(void, FASTCALL, wglGetProcAddresses, 0x0000000140461B50) {
|
||||
REPLACE_FUNC(glTexImage2DDLL);
|
||||
|
||||
glTexParameteriv = (PFNGLTEXPARAMETERIVPROC)GetProcAddress((HMODULE)opengl32_handle, "glTexParameteriv");
|
||||
glStencilMask = (PFNGLSTENCILMASKPROC)GetProcAddress((HMODULE)opengl32_handle, "glStencilMask");
|
||||
glStencilFunc = (PFNGLSTENCILFUNCPROC)GetProcAddress((HMODULE)opengl32_handle, "glStencilFunc");
|
||||
glStencilOp = (PFNGLSTENCILOPPROC)GetProcAddress((HMODULE)opengl32_handle, "glStencilOp");
|
||||
|
||||
// 3.1
|
||||
glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC)wglGetProcAddressDLL("glDrawArraysInstanced");
|
||||
@@ -2809,6 +2817,8 @@ HOOK(void, FASTCALL, wglGetProcAddresses, 0x0000000140461B50) {
|
||||
glMapNamedBufferRange = (PFNGLMAPNAMEDBUFFERRANGEPROC)wglGetProcAddressDLL("glMapNamedBufferRange");
|
||||
glUnmapNamedBuffer = (PFNGLUNMAPNAMEDBUFFERPROC)wglGetProcAddressDLL("glUnmapNamedBuffer");
|
||||
glTextureSubImage2D = (PFNGLTEXTURESUBIMAGE2DPROC)wglGetProcAddressDLL("glTextureSubImage2D");
|
||||
glGenerateTextureMipmap = (PFNGLGENERATETEXTUREMIPMAPPROC)wglGetProcAddressDLL("glGenerateTextureMipmap");
|
||||
glBindTextureUnit = (PFNGLBINDTEXTUREUNITPROC)wglGetProcAddressDLL("glBindTextureUnit");
|
||||
}
|
||||
|
||||
#undef REPLACE_FUNC
|
||||
@@ -2827,11 +2837,7 @@ void wrap_patch() {
|
||||
}
|
||||
|
||||
void GLAPIENTRY glAlphaFuncDLL(GLenum func, GLfloat ref) {
|
||||
if (func == GL_GREATER && ref >= 0.5f)
|
||||
uniform->arr[U_ALPHA_TEST] = 1;
|
||||
else
|
||||
uniform->arr[U_ALPHA_TEST] = 0;
|
||||
//((PFNGLALPHAFUNCDLLPROC)wrap_addr_dll[GLALPHAFUNCDLL].orig_func)(func, ref);
|
||||
((PFNGLALPHAFUNCDLLPROC)wrap_addr_dll[GLALPHAFUNCDLL].orig_func)(func, ref);
|
||||
}
|
||||
|
||||
void GLAPIENTRY glBeginDLL(GLenum mode) {
|
||||
|
||||
@@ -1130,6 +1130,9 @@ typedef PROC (GLAPIENTRY * PFNWGLGETPROCADDRESSGLUTPROC) (LPCSTR lpszProc);
|
||||
typedef BOOL (GLAPIENTRY * PFNWGLMAKECURRENTGLUTPROC) (HDC hDc, HGLRC newContext);
|
||||
|
||||
typedef void (GLAPIENTRY* PFNGLTEXPARAMETERIVPROC)(GLenum target, GLenum pname, const GLint* params);
|
||||
typedef void (GLAPIENTRY* PFNGLSTENCILMASKPROC)(GLuint mask);
|
||||
typedef void (GLAPIENTRY* PFNGLSTENCILFUNCPROC)(GLenum func, GLint ref, GLuint mask);
|
||||
typedef void (GLAPIENTRY* PFNGLSTENCILOPPROC)(GLenum fail, GLenum zfail, GLenum zpass);
|
||||
typedef void (GLAPIENTRY* PFNGLDRAWARRAYSINSTANCEDPROC)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount);
|
||||
typedef void (GLAPIENTRY* PFNGLPRIMITIVERESTARTINDEXPROC)(GLuint index);
|
||||
typedef GLuint (GLAPIENTRY* PFNGLGETUNIFORMBLOCKINDEXPROC)(GLuint program, const GLchar* uniformBlockName);
|
||||
@@ -1149,6 +1152,8 @@ typedef void* (GLAPIENTRY* PFNGLMAPNAMEDBUFFERPROC)(GLuint buffer, GLenum access
|
||||
typedef void* (GLAPIENTRY* PFNGLMAPNAMEDBUFFERRANGEPROC)(GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access);
|
||||
typedef GLboolean (GLAPIENTRY* PFNGLUNMAPNAMEDBUFFERPROC)(GLuint buffer);
|
||||
typedef void (GLAPIENTRY* PFNGLTEXTURESUBIMAGE2DPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels);
|
||||
typedef void (GLAPIENTRY* PFNGLGENERATETEXTUREMIPMAPPROC)(GLuint texture);
|
||||
typedef void (GLAPIENTRY* PFNGLBINDTEXTUREUNITPROC)(GLuint unit, GLuint texture);
|
||||
|
||||
extern PFNGLBINDTEXTUREDLLPROC* divagl_glBindTextureDLL;
|
||||
extern PFNGLBLENDFUNCDLLPROC* divagl_glBlendFuncDLL;
|
||||
@@ -2272,6 +2277,9 @@ extern PFNWGLGETPROCADDRESSGLUTPROC* divagl_wglGetProcAddressGLUT;
|
||||
extern PFNWGLMAKECURRENTGLUTPROC* divagl_wglMakeCurrentGLUT;
|
||||
|
||||
extern PFNGLTEXPARAMETERIVPROC divagl_glTexParameteriv;
|
||||
extern PFNGLSTENCILMASKPROC diva_glStencilMask;
|
||||
extern PFNGLSTENCILFUNCPROC diva_glStencilFunc;
|
||||
extern PFNGLSTENCILOPPROC diva_glStencilOp;
|
||||
extern PFNGLDRAWARRAYSINSTANCEDPROC divagl_glDrawArraysInstanced;
|
||||
extern PFNGLPRIMITIVERESTARTINDEXPROC divagl_glPrimitiveRestartIndex;
|
||||
extern PFNGLGETUNIFORMBLOCKINDEXPROC divagl_glGetUniformBlockIndex;
|
||||
@@ -2291,6 +2299,8 @@ extern PFNGLMAPNAMEDBUFFERPROC divagl_glMapNamedBuffer;
|
||||
extern PFNGLMAPNAMEDBUFFERRANGEPROC divagl_glMapNamedBufferRange;
|
||||
extern PFNGLUNMAPNAMEDBUFFERPROC divagl_glUnmapNamedBuffer;
|
||||
extern PFNGLTEXTURESUBIMAGE2DPROC divagl_glTextureSubImage2D;
|
||||
extern PFNGLGENERATETEXTUREMIPMAPPROC divagl_glGenerateTextureMipmap;
|
||||
extern PFNGLBINDTEXTUREUNITPROC divagl_glBindTextureUnit;
|
||||
|
||||
#define glBindTextureDLL (*divagl_glBindTextureDLL)
|
||||
#define glBlendFuncDLL (*divagl_glBlendFuncDLL)
|
||||
@@ -3414,6 +3424,9 @@ extern PFNGLTEXTURESUBIMAGE2DPROC divagl_glTextureSubImage2D;
|
||||
#define wglMakeCurrentGLUT (*divagl_wglMakeCurrentGLUT)
|
||||
|
||||
#define glTexParameteriv divagl_glTexParameteriv
|
||||
#define glStencilMask diva_glStencilMask
|
||||
#define glStencilFunc diva_glStencilFunc
|
||||
#define glStencilOp diva_glStencilOp
|
||||
#define glDrawArraysInstanced divagl_glDrawArraysInstanced
|
||||
#define glPrimitiveRestartIndex divagl_glPrimitiveRestartIndex
|
||||
#define glGetUniformBlockIndex divagl_glGetUniformBlockIndex
|
||||
@@ -3433,6 +3446,8 @@ extern PFNGLTEXTURESUBIMAGE2DPROC divagl_glTextureSubImage2D;
|
||||
#define glMapNamedBufferRange divagl_glMapNamedBufferRange
|
||||
#define glUnmapNamedBuffer divagl_glUnmapNamedBuffer
|
||||
#define glTextureSubImage2D divagl_glTextureSubImage2D
|
||||
#define glGenerateTextureMipmap divagl_glGenerateTextureMipmap
|
||||
#define glBindTextureUnit divagl_glBindTextureUnit
|
||||
|
||||
extern bool DIVA_GL_VERSION_4_1;
|
||||
extern bool DIVA_GL_VERSION_4_2;
|
||||
|
||||
+1
-1
Submodule src/KKdLib updated: 6b42f33ae9...5be3d43806
Reference in New Issue
Block a user