First commit
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
.vs
|
||||
bin
|
||||
lib
|
||||
obj
|
||||
src/KKdLib
|
||||
*.aps
|
||||
*.cs
|
||||
!extern/lib
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30320.27
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DivaGL", "src\DivaGL\DivaGL.vcxproj", "{4D949362-9095-4113-9423-7E0492618F16}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KKdLib", "src\KKdLib\KKdLib.vcxproj", "{4C9636B9-E5B6-41E5-9AFC-5B33CC9633DE}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
DebugDLL|x64 = DebugDLL|x64
|
||||
Release|x64 = Release|x64
|
||||
ReleaseDLL|x64 = ReleaseDLL|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{4D949362-9095-4113-9423-7E0492618F16}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{4D949362-9095-4113-9423-7E0492618F16}.Debug|x64.Build.0 = Debug|x64
|
||||
{4D949362-9095-4113-9423-7E0492618F16}.DebugDLL|x64.ActiveCfg = DebugDLL|x64
|
||||
{4D949362-9095-4113-9423-7E0492618F16}.DebugDLL|x64.Build.0 = DebugDLL|x64
|
||||
{4D949362-9095-4113-9423-7E0492618F16}.Release|x64.ActiveCfg = Release|x64
|
||||
{4D949362-9095-4113-9423-7E0492618F16}.Release|x64.Build.0 = Release|x64
|
||||
{4D949362-9095-4113-9423-7E0492618F16}.ReleaseDLL|x64.ActiveCfg = ReleaseDLL|x64
|
||||
{4D949362-9095-4113-9423-7E0492618F16}.ReleaseDLL|x64.Build.0 = ReleaseDLL|x64
|
||||
{4C9636B9-E5B6-41E5-9AFC-5B33CC9633DE}.Debug|x64.ActiveCfg = DebugOpt|x64
|
||||
{4C9636B9-E5B6-41E5-9AFC-5B33CC9633DE}.Debug|x64.Build.0 = DebugOpt|x64
|
||||
{4C9636B9-E5B6-41E5-9AFC-5B33CC9633DE}.DebugDLL|x64.ActiveCfg = DebugOpt|x64
|
||||
{4C9636B9-E5B6-41E5-9AFC-5B33CC9633DE}.DebugDLL|x64.Build.0 = DebugOpt|x64
|
||||
{4C9636B9-E5B6-41E5-9AFC-5B33CC9633DE}.Release|x64.ActiveCfg = Release|x64
|
||||
{4C9636B9-E5B6-41E5-9AFC-5B33CC9633DE}.Release|x64.Build.0 = Release|x64
|
||||
{4C9636B9-E5B6-41E5-9AFC-5B33CC9633DE}.ReleaseDLL|x64.ActiveCfg = Release|x64
|
||||
{4C9636B9-E5B6-41E5-9AFC-5B33CC9633DE}.ReleaseDLL|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {90795F07-C3EF-4F00-A79A-0647DBB7117E}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
+169
@@ -0,0 +1,169 @@
|
||||
#pragma once
|
||||
|
||||
#include "detours.h"
|
||||
|
||||
#define _CONCAT2(x, y) x##y
|
||||
#define CONCAT2(x, y) _CONCAT(x, y)
|
||||
#define INSERT_PADDING(length) \
|
||||
uint8_t CONCAT2(pad, __LINE__)[length]
|
||||
|
||||
#define ASSERT_OFFSETOF(type, field, offset) \
|
||||
static_assert(offsetof(type, field) == offset, "offsetof assertion failed")
|
||||
|
||||
#define ASSERT_SIZEOF(type, size) \
|
||||
static_assert(sizeof(type) == size, "sizeof assertion failed")
|
||||
|
||||
#ifdef BASE_ADDRESS
|
||||
const HMODULE MODULE_HANDLE = GetModuleHandle(nullptr);
|
||||
|
||||
#define ASLR(address) \
|
||||
((size_t)MODULE_HANDLE + (size_t)address - (size_t)BASE_ADDRESS)
|
||||
#endif
|
||||
|
||||
#define FUNCTION_PTR(returnType, callingConvention, function, location, ...) \
|
||||
returnType (callingConvention *function)(__VA_ARGS__) = (returnType(callingConvention*)(__VA_ARGS__))(location)
|
||||
|
||||
#define FUNCTION_PTR_H(returnType, callingConvention, function, ...) \
|
||||
extern returnType (callingConvention *function) (__VA_ARGS__)
|
||||
|
||||
#define PROC_ADDRESS(libraryName, procName) \
|
||||
GetProcAddress(LoadLibrary(TEXT(libraryName)), procName)
|
||||
|
||||
#define HOOK(returnType, callingConvention, functionName, location, ...) \
|
||||
typedef returnType callingConvention _##functionName(__VA_ARGS__); \
|
||||
_##functionName* original##functionName = (_##functionName*)(location); \
|
||||
returnType callingConvention implOf##functionName(__VA_ARGS__)
|
||||
|
||||
#define INSTALL_HOOK(functionName) \
|
||||
{ \
|
||||
DetourTransactionBegin(); \
|
||||
DetourUpdateThread(GetCurrentThread()); \
|
||||
DetourAttach((void**)&original##functionName, implOf##functionName); \
|
||||
DetourTransactionCommit(); \
|
||||
}
|
||||
|
||||
#define VTABLE_HOOK(returnType, callingConvention, className, functionName, ...) \
|
||||
typedef returnType callingConvention className##functionName(className* This, __VA_ARGS__); \
|
||||
className##functionName* original##className##functionName; \
|
||||
returnType callingConvention implOf##className##functionName(className* This, __VA_ARGS__)
|
||||
|
||||
#define INSTALL_VTABLE_HOOK(className, object, functionName, functionIndex) \
|
||||
{ \
|
||||
void** addr = &(*(void***)object)[functionIndex]; \
|
||||
if (*addr != implOf##className##functionName) \
|
||||
{ \
|
||||
original##className##functionName = (className##functionName*)*addr; \
|
||||
DWORD oldProtect; \
|
||||
VirtualProtect(addr, sizeof(void*), PAGE_EXECUTE_READWRITE, &oldProtect); \
|
||||
*addr = implOf##className##functionName; \
|
||||
VirtualProtect(addr, sizeof(void*), oldProtect, &oldProtect); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define READ_MEMORY(location, type) \
|
||||
*(type *)location
|
||||
|
||||
#define WRITE_MEMORY(location, type, ...) \
|
||||
{ \
|
||||
const type data[] = { __VA_ARGS__ }; \
|
||||
DWORD oldProtect; \
|
||||
VirtualProtect((void*)(location), sizeof(data), PAGE_EXECUTE_READWRITE, &oldProtect); \
|
||||
memcpy((void*)(location), data, sizeof(data)); \
|
||||
VirtualProtect((void*)(location), sizeof(data), oldProtect, &oldProtect); \
|
||||
}
|
||||
|
||||
#define WRITE_MEMORY_STRING(location, data, length) \
|
||||
{ \
|
||||
DWORD oldProtect; \
|
||||
VirtualProtect ((void *)(location), length, PAGE_EXECUTE_READWRITE, &oldProtect); \
|
||||
memcpy ((void *)(location), data, length); \
|
||||
VirtualProtect ((void *)(location), length, oldProtect, &oldProtect); \
|
||||
}
|
||||
|
||||
#define WRITE_JUMP(location, function) \
|
||||
{ \
|
||||
WRITE_MEMORY(location, uint8_t, 0xE9); \
|
||||
WRITE_MEMORY(location + 1, uint32_t, (uint32_t)(function - location - 5)); \
|
||||
}
|
||||
|
||||
#define WRITE_CALL(location, function) \
|
||||
{ \
|
||||
WRITE_MEMORY(location, uint8_t, 0xE8); \
|
||||
WRITE_MEMORY(location + 1, uint32_t, (uint32_t)(function - location - 5)); \
|
||||
}
|
||||
|
||||
#define WRITE_NOP(location, count) \
|
||||
{ \
|
||||
DWORD oldProtect; \
|
||||
VirtualProtect((void*)(location), (size_t)(count), PAGE_EXECUTE_READWRITE, &oldProtect); \
|
||||
for (size_t i = 0; i < (size_t)(count); i++) \
|
||||
*((uint8_t*)(location) + i) = 0x90; \
|
||||
VirtualProtect((void*)(location), (size_t)(count), oldProtect, &oldProtect); \
|
||||
}
|
||||
|
||||
#define WRITE_NOP_1(location) \
|
||||
{ \
|
||||
WRITE_MEMORY(location, uint8_t, 0x90); \
|
||||
}
|
||||
|
||||
#define WRITE_NOP_2(location) \
|
||||
{ \
|
||||
WRITE_MEMORY(location, uint8_t, 0x66, 0x90); \
|
||||
}
|
||||
|
||||
#define WRITE_NOP_3(location) \
|
||||
{ \
|
||||
WRITE_MEMORY(location, uint8_t, 0x0F, 0x1F, 0x00); \
|
||||
}
|
||||
|
||||
#define WRITE_NOP_4(location) \
|
||||
{ \
|
||||
WRITE_MEMORY(location, uint8_t, 0x0F, 0x1F, 0x40, 0x00); \
|
||||
}
|
||||
|
||||
#define WRITE_NOP_5(location) \
|
||||
{ \
|
||||
WRITE_MEMORY(location, uint8_t, 0x0F, 0x1F, 0x44, 0x00, 0x00); \
|
||||
}
|
||||
|
||||
#define WRITE_NOP_6(location) \
|
||||
{ \
|
||||
WRITE_MEMORY(location, uint8_t, 0x66, 0x0F, 0x1F, 0x44, 0x00, 0x00); \
|
||||
}
|
||||
|
||||
#define WRITE_NOP_7(location) \
|
||||
{ \
|
||||
WRITE_MEMORY(location, uint8_t, 0x0F, 0x1F, 0x80, 0x00, 0x00, 0x00, 0x00); \
|
||||
}
|
||||
|
||||
#define WRITE_NOP_8(location) \
|
||||
{ \
|
||||
WRITE_MEMORY(location, uint8_t, 0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00); \
|
||||
}
|
||||
|
||||
#define WRITE_NOP_9(location) \
|
||||
{ \
|
||||
WRITE_MEMORY(location, uint8_t, 0x66, 0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00); \
|
||||
}
|
||||
|
||||
#define WRITE_NOP_10(location) \
|
||||
{ \
|
||||
WRITE_MEMORY(location, uint8_t, 0x66, 0x66, 0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00); \
|
||||
}
|
||||
|
||||
#define WRITE_NOP_11(location) \
|
||||
{ \
|
||||
WRITE_MEMORY(location, uint8_t, 0x66, 0x66, 0x66, 0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00); \
|
||||
}
|
||||
|
||||
#define WRITE_NULL(location, count) \
|
||||
{ \
|
||||
DWORD oldProtect; \
|
||||
VirtualProtect((void*)(location), (size_t)(count), PAGE_EXECUTE_READWRITE, &oldProtect); \
|
||||
for (size_t i = 0; i < (size_t)(count); i++) \
|
||||
*((uint8_t*)(location) + i) = 0x00; \
|
||||
VirtualProtect((void*)(location), (size_t)(count), oldProtect, &oldProtect); \
|
||||
}
|
||||
|
||||
#define COUNTOFARR(arr) \
|
||||
sizeof(arr) / sizeof(arr[0])
|
||||
Vendored
+111
@@ -0,0 +1,111 @@
|
||||
#pragma once
|
||||
|
||||
#include <Psapi.h>
|
||||
|
||||
FORCEINLINE const MODULEINFO& getModuleInfo() {
|
||||
static MODULEINFO moduleInfo;
|
||||
|
||||
if (moduleInfo.SizeOfImage)
|
||||
return moduleInfo;
|
||||
|
||||
ZeroMemory(&moduleInfo, sizeof(MODULEINFO));
|
||||
GetModuleInformation(GetCurrentProcess(), GetModuleHandle(nullptr), &moduleInfo, sizeof(MODULEINFO));
|
||||
|
||||
return moduleInfo;
|
||||
}
|
||||
|
||||
// Signature scan in specified memory region
|
||||
FORCEINLINE void* sigScan(const char* signature, const char* mask, size_t sigSize, void* memory, const size_t memorySize) {
|
||||
if (sigSize == 0)
|
||||
sigSize = strlen(mask);
|
||||
|
||||
for (size_t i = 0; i < memorySize; i++) {
|
||||
char* currMemory = (char*)memory + i;
|
||||
|
||||
size_t j;
|
||||
for (j = 0; j < sigSize; j++) {
|
||||
if (mask[j] != '?' && signature[j] != currMemory[j])
|
||||
break;
|
||||
}
|
||||
|
||||
if (j == sigSize)
|
||||
return currMemory;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Signature scan in current process
|
||||
FORCEINLINE void* sigScan(const char* signature, const char* mask, void* hint) {
|
||||
const MODULEINFO& info = getModuleInfo();
|
||||
const size_t sigSize = strlen(mask);
|
||||
|
||||
// Ensure hint address is within the process memory region so there are no crashes.
|
||||
if ((hint >= info.lpBaseOfDll) && ((char*)hint + sigSize <= (char*)info.lpBaseOfDll + info.SizeOfImage)) {
|
||||
void* result = sigScan(signature, mask, sigSize, hint, sigSize);
|
||||
|
||||
if (result)
|
||||
return result;
|
||||
}
|
||||
|
||||
return sigScan(signature, mask, sigSize, info.lpBaseOfDll, info.SizeOfImage);
|
||||
}
|
||||
|
||||
// Signature scan string in specified memory region
|
||||
FORCEINLINE void* sigScanString(const char* signature, void* memory, const size_t memorySize) {
|
||||
const size_t sigSize = strlen(signature);
|
||||
|
||||
for (size_t i = 0; i < memorySize; i++) {
|
||||
char* currMemory = (char*)memory + i;
|
||||
|
||||
if (!memcmp(signature, currMemory, sigSize))
|
||||
return currMemory;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Signature scan string in current process
|
||||
FORCEINLINE void* sigScanString(const char* signature) {
|
||||
const MODULEINFO& info = getModuleInfo();
|
||||
return sigScanString(signature, info.lpBaseOfDll, info.SizeOfImage);
|
||||
}
|
||||
|
||||
// Automatically scanned signature
|
||||
#define SIG_SCAN(x, y, ...) \
|
||||
FORCEINLINE void* x(); \
|
||||
inline bool x##Valid = true; \
|
||||
inline void* x##Addr = x(); \
|
||||
FORCEINLINE void* x() { \
|
||||
constexpr const char* x##Data[] = { __VA_ARGS__ }; \
|
||||
constexpr size_t x##Size = _countof(x##Data); \
|
||||
if (!x##Addr) { \
|
||||
if constexpr (x##Size == 2) { \
|
||||
x##Addr = sigScan(x##Data[0], x##Data[1], (void*)(y)); \
|
||||
if (x##Addr) \
|
||||
return x##Addr; \
|
||||
} \
|
||||
else \
|
||||
for (int i = 0; i < x##Size; i += 2) { \
|
||||
x##Addr = sigScan(x##Data[i], x##Data[i + 1], (void*)(y)); \
|
||||
if (x##Addr) \
|
||||
return x##Addr; \
|
||||
} \
|
||||
x##Valid = false; \
|
||||
} \
|
||||
return x##Addr; \
|
||||
}
|
||||
|
||||
#define SIG_SCAN_STRING(x, y) \
|
||||
FORCEINLINE void* x(); \
|
||||
inline bool x##Valid = true; \
|
||||
inline void* x##Addr = x(); \
|
||||
FORCEINLINE void* x() { \
|
||||
if (!x##Addr) { \
|
||||
x##Addr = sigScanString(y); \
|
||||
if (x##Addr) \
|
||||
return x##Addr; \
|
||||
x##Valid = false; \
|
||||
} \
|
||||
return x##Addr; \
|
||||
}
|
||||
Vendored
+1233
File diff suppressed because it is too large
Load Diff
Vendored
+411
@@ -0,0 +1,411 @@
|
||||
/*
|
||||
* libdeflate.h - public header for libdeflate
|
||||
*/
|
||||
|
||||
#ifndef LIBDEFLATE_H
|
||||
#define LIBDEFLATE_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LIBDEFLATE_VERSION_MAJOR 1
|
||||
#define LIBDEFLATE_VERSION_MINOR 19
|
||||
#define LIBDEFLATE_VERSION_STRING "1.19"
|
||||
|
||||
/*
|
||||
* Users of libdeflate.dll on Windows can define LIBDEFLATE_DLL to cause
|
||||
* __declspec(dllimport) to be used. This should be done when it's easy to do.
|
||||
* Otherwise it's fine to skip it, since it is a very minor performance
|
||||
* optimization that is irrelevant for most use cases of libdeflate.
|
||||
*/
|
||||
#ifndef LIBDEFLATEAPI
|
||||
# if defined(LIBDEFLATE_DLL) && (defined(_WIN32) || defined(__CYGWIN__))
|
||||
# define LIBDEFLATEAPI __declspec(dllimport)
|
||||
# else
|
||||
# define LIBDEFLATEAPI
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* ========================================================================== */
|
||||
/* Compression */
|
||||
/* ========================================================================== */
|
||||
|
||||
struct libdeflate_compressor;
|
||||
struct libdeflate_options;
|
||||
|
||||
/*
|
||||
* libdeflate_alloc_compressor() allocates a new compressor that supports
|
||||
* DEFLATE, zlib, and gzip compression. 'compression_level' is the compression
|
||||
* level on a zlib-like scale but with a higher maximum value (1 = fastest, 6 =
|
||||
* medium/default, 9 = slow, 12 = slowest). Level 0 is also supported and means
|
||||
* "no compression", specifically "create a valid stream, but only emit
|
||||
* uncompressed blocks" (this will expand the data slightly).
|
||||
*
|
||||
* The return value is a pointer to the new compressor, or NULL if out of memory
|
||||
* or if the compression level is invalid (i.e. outside the range [0, 12]).
|
||||
*
|
||||
* Note: for compression, the sliding window size is defined at compilation time
|
||||
* to 32768, the largest size permissible in the DEFLATE format. It cannot be
|
||||
* changed at runtime.
|
||||
*
|
||||
* A single compressor is not safe to use by multiple threads concurrently.
|
||||
* However, different threads may use different compressors concurrently.
|
||||
*/
|
||||
LIBDEFLATEAPI struct libdeflate_compressor *
|
||||
libdeflate_alloc_compressor(int compression_level);
|
||||
|
||||
/*
|
||||
* Like libdeflate_alloc_compressor(), but adds the 'options' argument.
|
||||
*/
|
||||
LIBDEFLATEAPI struct libdeflate_compressor *
|
||||
libdeflate_alloc_compressor_ex(int compression_level,
|
||||
const struct libdeflate_options *options);
|
||||
|
||||
/*
|
||||
* libdeflate_deflate_compress() performs raw DEFLATE compression on a buffer of
|
||||
* data. It attempts to compress 'in_nbytes' bytes of data located at 'in' and
|
||||
* write the result to 'out', which has space for 'out_nbytes_avail' bytes. The
|
||||
* return value is the compressed size in bytes, or 0 if the data could not be
|
||||
* compressed to 'out_nbytes_avail' bytes or fewer.
|
||||
*
|
||||
* If compression is successful, then the output data is guaranteed to be a
|
||||
* valid DEFLATE stream that decompresses to the input data. No other
|
||||
* guarantees are made about the output data. Notably, different versions of
|
||||
* libdeflate can produce different compressed data for the same uncompressed
|
||||
* data, even at the same compression level. Do ***NOT*** do things like
|
||||
* writing tests that compare compressed data to a golden output, as this can
|
||||
* break when libdeflate is updated. (This property isn't specific to
|
||||
* libdeflate; the same is true for zlib and other compression libraries too.)
|
||||
*/
|
||||
LIBDEFLATEAPI size_t
|
||||
libdeflate_deflate_compress(struct libdeflate_compressor *compressor,
|
||||
const void *in, size_t in_nbytes,
|
||||
void *out, size_t out_nbytes_avail);
|
||||
|
||||
/*
|
||||
* libdeflate_deflate_compress_bound() returns a worst-case upper bound on the
|
||||
* number of bytes of compressed data that may be produced by compressing any
|
||||
* buffer of length less than or equal to 'in_nbytes' using
|
||||
* libdeflate_deflate_compress() with the specified compressor. This bound will
|
||||
* necessarily be a number greater than or equal to 'in_nbytes'. It may be an
|
||||
* overestimate of the true upper bound. The return value is guaranteed to be
|
||||
* the same for all invocations with the same compressor and same 'in_nbytes'.
|
||||
*
|
||||
* As a special case, 'compressor' may be NULL. This causes the bound to be
|
||||
* taken across *any* libdeflate_compressor that could ever be allocated with
|
||||
* this build of the library, with any options.
|
||||
*
|
||||
* Note that this function is not necessary in many applications. With
|
||||
* block-based compression, it is usually preferable to separately store the
|
||||
* uncompressed size of each block and to store any blocks that did not compress
|
||||
* to less than their original size uncompressed. In that scenario, there is no
|
||||
* need to know the worst-case compressed size, since the maximum number of
|
||||
* bytes of compressed data that may be used would always be one less than the
|
||||
* input length. You can just pass a buffer of that size to
|
||||
* libdeflate_deflate_compress() and store the data uncompressed if
|
||||
* libdeflate_deflate_compress() returns 0, indicating that the compressed data
|
||||
* did not fit into the provided output buffer.
|
||||
*/
|
||||
LIBDEFLATEAPI size_t
|
||||
libdeflate_deflate_compress_bound(struct libdeflate_compressor *compressor,
|
||||
size_t in_nbytes);
|
||||
|
||||
/*
|
||||
* Like libdeflate_deflate_compress(), but uses the zlib wrapper format instead
|
||||
* of raw DEFLATE.
|
||||
*/
|
||||
LIBDEFLATEAPI size_t
|
||||
libdeflate_zlib_compress(struct libdeflate_compressor *compressor,
|
||||
const void *in, size_t in_nbytes,
|
||||
void *out, size_t out_nbytes_avail);
|
||||
|
||||
/*
|
||||
* Like libdeflate_deflate_compress_bound(), but assumes the data will be
|
||||
* compressed with libdeflate_zlib_compress() rather than with
|
||||
* libdeflate_deflate_compress().
|
||||
*/
|
||||
LIBDEFLATEAPI size_t
|
||||
libdeflate_zlib_compress_bound(struct libdeflate_compressor *compressor,
|
||||
size_t in_nbytes);
|
||||
|
||||
/*
|
||||
* Like libdeflate_deflate_compress(), but uses the gzip wrapper format instead
|
||||
* of raw DEFLATE.
|
||||
*/
|
||||
LIBDEFLATEAPI size_t
|
||||
libdeflate_gzip_compress(struct libdeflate_compressor *compressor,
|
||||
const void *in, size_t in_nbytes,
|
||||
void *out, size_t out_nbytes_avail);
|
||||
|
||||
/*
|
||||
* Like libdeflate_deflate_compress_bound(), but assumes the data will be
|
||||
* compressed with libdeflate_gzip_compress() rather than with
|
||||
* libdeflate_deflate_compress().
|
||||
*/
|
||||
LIBDEFLATEAPI size_t
|
||||
libdeflate_gzip_compress_bound(struct libdeflate_compressor *compressor,
|
||||
size_t in_nbytes);
|
||||
|
||||
/*
|
||||
* libdeflate_free_compressor() frees a compressor that was allocated with
|
||||
* libdeflate_alloc_compressor(). If a NULL pointer is passed in, no action is
|
||||
* taken.
|
||||
*/
|
||||
LIBDEFLATEAPI void
|
||||
libdeflate_free_compressor(struct libdeflate_compressor *compressor);
|
||||
|
||||
/* ========================================================================== */
|
||||
/* Decompression */
|
||||
/* ========================================================================== */
|
||||
|
||||
struct libdeflate_decompressor;
|
||||
struct libdeflate_options;
|
||||
|
||||
/*
|
||||
* libdeflate_alloc_decompressor() allocates a new decompressor that can be used
|
||||
* for DEFLATE, zlib, and gzip decompression. The return value is a pointer to
|
||||
* the new decompressor, or NULL if out of memory.
|
||||
*
|
||||
* This function takes no parameters, and the returned decompressor is valid for
|
||||
* decompressing data that was compressed at any compression level and with any
|
||||
* sliding window size.
|
||||
*
|
||||
* A single decompressor is not safe to use by multiple threads concurrently.
|
||||
* However, different threads may use different decompressors concurrently.
|
||||
*/
|
||||
LIBDEFLATEAPI struct libdeflate_decompressor *
|
||||
libdeflate_alloc_decompressor(void);
|
||||
|
||||
/*
|
||||
* Like libdeflate_alloc_decompressor(), but adds the 'options' argument.
|
||||
*/
|
||||
LIBDEFLATEAPI struct libdeflate_decompressor *
|
||||
libdeflate_alloc_decompressor_ex(const struct libdeflate_options *options);
|
||||
|
||||
/*
|
||||
* Result of a call to libdeflate_deflate_decompress(),
|
||||
* libdeflate_zlib_decompress(), or libdeflate_gzip_decompress().
|
||||
*/
|
||||
enum libdeflate_result {
|
||||
/* Decompression was successful. */
|
||||
LIBDEFLATE_SUCCESS = 0,
|
||||
|
||||
/* Decompression failed because the compressed data was invalid,
|
||||
* corrupt, or otherwise unsupported. */
|
||||
LIBDEFLATE_BAD_DATA = 1,
|
||||
|
||||
/* A NULL 'actual_out_nbytes_ret' was provided, but the data would have
|
||||
* decompressed to fewer than 'out_nbytes_avail' bytes. */
|
||||
LIBDEFLATE_SHORT_OUTPUT = 2,
|
||||
|
||||
/* The data would have decompressed to more than 'out_nbytes_avail'
|
||||
* bytes. */
|
||||
LIBDEFLATE_INSUFFICIENT_SPACE = 3,
|
||||
};
|
||||
|
||||
/*
|
||||
* libdeflate_deflate_decompress() decompresses a DEFLATE stream from the buffer
|
||||
* 'in' with compressed size up to 'in_nbytes' bytes. The uncompressed data is
|
||||
* written to 'out', a buffer with size 'out_nbytes_avail' bytes. If
|
||||
* decompression succeeds, then 0 (LIBDEFLATE_SUCCESS) is returned. Otherwise,
|
||||
* a nonzero result code such as LIBDEFLATE_BAD_DATA is returned, and the
|
||||
* contents of the output buffer are undefined.
|
||||
*
|
||||
* Decompression stops at the end of the DEFLATE stream (as indicated by the
|
||||
* BFINAL flag), even if it is actually shorter than 'in_nbytes' bytes.
|
||||
*
|
||||
* libdeflate_deflate_decompress() can be used in cases where the actual
|
||||
* uncompressed size is known (recommended) or unknown (not recommended):
|
||||
*
|
||||
* - If the actual uncompressed size is known, then pass the actual
|
||||
* uncompressed size as 'out_nbytes_avail' and pass NULL for
|
||||
* 'actual_out_nbytes_ret'. This makes libdeflate_deflate_decompress() fail
|
||||
* with LIBDEFLATE_SHORT_OUTPUT if the data decompressed to fewer than the
|
||||
* specified number of bytes.
|
||||
*
|
||||
* - If the actual uncompressed size is unknown, then provide a non-NULL
|
||||
* 'actual_out_nbytes_ret' and provide a buffer with some size
|
||||
* 'out_nbytes_avail' that you think is large enough to hold all the
|
||||
* uncompressed data. In this case, if the data decompresses to less than
|
||||
* or equal to 'out_nbytes_avail' bytes, then
|
||||
* libdeflate_deflate_decompress() will write the actual uncompressed size
|
||||
* to *actual_out_nbytes_ret and return 0 (LIBDEFLATE_SUCCESS). Otherwise,
|
||||
* it will return LIBDEFLATE_INSUFFICIENT_SPACE if the provided buffer was
|
||||
* not large enough but no other problems were encountered, or another
|
||||
* nonzero result code if decompression failed for another reason.
|
||||
*/
|
||||
LIBDEFLATEAPI enum libdeflate_result
|
||||
libdeflate_deflate_decompress(struct libdeflate_decompressor *decompressor,
|
||||
const void *in, size_t in_nbytes,
|
||||
void *out, size_t out_nbytes_avail,
|
||||
size_t *actual_out_nbytes_ret);
|
||||
|
||||
/*
|
||||
* Like libdeflate_deflate_decompress(), but adds the 'actual_in_nbytes_ret'
|
||||
* argument. If decompression succeeds and 'actual_in_nbytes_ret' is not NULL,
|
||||
* then the actual compressed size of the DEFLATE stream (aligned to the next
|
||||
* byte boundary) is written to *actual_in_nbytes_ret.
|
||||
*/
|
||||
LIBDEFLATEAPI enum libdeflate_result
|
||||
libdeflate_deflate_decompress_ex(struct libdeflate_decompressor *decompressor,
|
||||
const void *in, size_t in_nbytes,
|
||||
void *out, size_t out_nbytes_avail,
|
||||
size_t *actual_in_nbytes_ret,
|
||||
size_t *actual_out_nbytes_ret);
|
||||
|
||||
/*
|
||||
* Like libdeflate_deflate_decompress(), but assumes the zlib wrapper format
|
||||
* instead of raw DEFLATE.
|
||||
*
|
||||
* Decompression will stop at the end of the zlib stream, even if it is shorter
|
||||
* than 'in_nbytes'. If you need to know exactly where the zlib stream ended,
|
||||
* use libdeflate_zlib_decompress_ex().
|
||||
*/
|
||||
LIBDEFLATEAPI enum libdeflate_result
|
||||
libdeflate_zlib_decompress(struct libdeflate_decompressor *decompressor,
|
||||
const void *in, size_t in_nbytes,
|
||||
void *out, size_t out_nbytes_avail,
|
||||
size_t *actual_out_nbytes_ret);
|
||||
|
||||
/*
|
||||
* Like libdeflate_zlib_decompress(), but adds the 'actual_in_nbytes_ret'
|
||||
* argument. If 'actual_in_nbytes_ret' is not NULL and the decompression
|
||||
* succeeds (indicating that the first zlib-compressed stream in the input
|
||||
* buffer was decompressed), then the actual number of input bytes consumed is
|
||||
* written to *actual_in_nbytes_ret.
|
||||
*/
|
||||
LIBDEFLATEAPI enum libdeflate_result
|
||||
libdeflate_zlib_decompress_ex(struct libdeflate_decompressor *decompressor,
|
||||
const void *in, size_t in_nbytes,
|
||||
void *out, size_t out_nbytes_avail,
|
||||
size_t *actual_in_nbytes_ret,
|
||||
size_t *actual_out_nbytes_ret);
|
||||
|
||||
/*
|
||||
* Like libdeflate_deflate_decompress(), but assumes the gzip wrapper format
|
||||
* instead of raw DEFLATE.
|
||||
*
|
||||
* If multiple gzip-compressed members are concatenated, then only the first
|
||||
* will be decompressed. Use libdeflate_gzip_decompress_ex() if you need
|
||||
* multi-member support.
|
||||
*/
|
||||
LIBDEFLATEAPI enum libdeflate_result
|
||||
libdeflate_gzip_decompress(struct libdeflate_decompressor *decompressor,
|
||||
const void *in, size_t in_nbytes,
|
||||
void *out, size_t out_nbytes_avail,
|
||||
size_t *actual_out_nbytes_ret);
|
||||
|
||||
/*
|
||||
* Like libdeflate_gzip_decompress(), but adds the 'actual_in_nbytes_ret'
|
||||
* argument. If 'actual_in_nbytes_ret' is not NULL and the decompression
|
||||
* succeeds (indicating that the first gzip-compressed member in the input
|
||||
* buffer was decompressed), then the actual number of input bytes consumed is
|
||||
* written to *actual_in_nbytes_ret.
|
||||
*/
|
||||
LIBDEFLATEAPI enum libdeflate_result
|
||||
libdeflate_gzip_decompress_ex(struct libdeflate_decompressor *decompressor,
|
||||
const void *in, size_t in_nbytes,
|
||||
void *out, size_t out_nbytes_avail,
|
||||
size_t *actual_in_nbytes_ret,
|
||||
size_t *actual_out_nbytes_ret);
|
||||
|
||||
/*
|
||||
* libdeflate_free_decompressor() frees a decompressor that was allocated with
|
||||
* libdeflate_alloc_decompressor(). If a NULL pointer is passed in, no action
|
||||
* is taken.
|
||||
*/
|
||||
LIBDEFLATEAPI void
|
||||
libdeflate_free_decompressor(struct libdeflate_decompressor *decompressor);
|
||||
|
||||
/* ========================================================================== */
|
||||
/* Checksums */
|
||||
/* ========================================================================== */
|
||||
|
||||
/*
|
||||
* libdeflate_adler32() updates a running Adler-32 checksum with 'len' bytes of
|
||||
* data and returns the updated checksum. When starting a new checksum, the
|
||||
* required initial value for 'adler' is 1. This value is also returned when
|
||||
* 'buffer' is specified as NULL.
|
||||
*/
|
||||
LIBDEFLATEAPI uint32_t
|
||||
libdeflate_adler32(uint32_t adler, const void *buffer, size_t len);
|
||||
|
||||
|
||||
/*
|
||||
* libdeflate_crc32() updates a running CRC-32 checksum with 'len' bytes of data
|
||||
* and returns the updated checksum. When starting a new checksum, the required
|
||||
* initial value for 'crc' is 0. This value is also returned when 'buffer' is
|
||||
* specified as NULL.
|
||||
*/
|
||||
LIBDEFLATEAPI uint32_t
|
||||
libdeflate_crc32(uint32_t crc, const void *buffer, size_t len);
|
||||
|
||||
/* ========================================================================== */
|
||||
/* Custom memory allocator */
|
||||
/* ========================================================================== */
|
||||
|
||||
/*
|
||||
* Install a custom memory allocator which libdeflate will use for all memory
|
||||
* allocations by default. 'malloc_func' is a function that must behave like
|
||||
* malloc(), and 'free_func' is a function that must behave like free().
|
||||
*
|
||||
* The per-(de)compressor custom memory allocator that can be specified in
|
||||
* 'struct libdeflate_options' takes priority over this.
|
||||
*
|
||||
* This doesn't affect the free() function that will be used to free
|
||||
* (de)compressors that were already in existence when this is called.
|
||||
*/
|
||||
LIBDEFLATEAPI void
|
||||
libdeflate_set_memory_allocator(void *(*malloc_func)(size_t),
|
||||
void (*free_func)(void *));
|
||||
|
||||
/*
|
||||
* Advanced options. This is the options structure that
|
||||
* libdeflate_alloc_compressor_ex() and libdeflate_alloc_decompressor_ex()
|
||||
* require. Most users won't need this and should just use the non-"_ex"
|
||||
* functions instead. If you do need this, it should be initialized like this:
|
||||
*
|
||||
* struct libdeflate_options options;
|
||||
*
|
||||
* memset(&options, 0, sizeof(options));
|
||||
* options.sizeof_options = sizeof(options);
|
||||
* // Then set the fields that you need to override the defaults for.
|
||||
*/
|
||||
struct libdeflate_options {
|
||||
|
||||
/*
|
||||
* This field must be set to the struct size. This field exists for
|
||||
* extensibility, so that fields can be appended to this struct in
|
||||
* future versions of libdeflate while still supporting old binaries.
|
||||
*/
|
||||
size_t sizeof_options;
|
||||
|
||||
/*
|
||||
* An optional custom memory allocator to use for this (de)compressor.
|
||||
* 'malloc_func' must be a function that behaves like malloc(), and
|
||||
* 'free_func' must be a function that behaves like free().
|
||||
*
|
||||
* This is useful in cases where a process might have multiple users of
|
||||
* libdeflate who want to use different memory allocators. For example,
|
||||
* a library might want to use libdeflate with a custom memory allocator
|
||||
* without interfering with user code that might use libdeflate too.
|
||||
*
|
||||
* This takes priority over the "global" memory allocator (which by
|
||||
* default is malloc() and free(), but can be changed by
|
||||
* libdeflate_set_memory_allocator()). Moreover, libdeflate will never
|
||||
* call the "global" memory allocator if a per-(de)compressor custom
|
||||
* allocator is always given.
|
||||
*/
|
||||
void *(*malloc_func)(size_t);
|
||||
void (*free_func)(void *);
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LIBDEFLATE_H */
|
||||
@@ -0,0 +1,46 @@
|
||||
#define IDR_VERSION2 101
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 102
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
#include "winres.h"
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 0,2,0
|
||||
PRODUCTVERSION 0,2,0,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x0L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "000904b0"
|
||||
BEGIN
|
||||
VALUE "FileDescription", "DivaGL plugin for PDAFT 7.10"
|
||||
VALUE "FileVersion", "0.2.0.0"
|
||||
VALUE "InternalName", "DivaGL"
|
||||
VALUE "LegalCopyright", "korenkonder (C) 2020-2023"
|
||||
VALUE "OriginalFilename", "DivaGL.dll"
|
||||
VALUE "ProductName", "DivaGL"
|
||||
VALUE "ProductVersion", "0.2.0.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x9, 1200
|
||||
END
|
||||
END
|
||||
@@ -0,0 +1,339 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="DebugDLL|x64">
|
||||
<Configuration>DebugDLL</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="ReleaseDLL|x64">
|
||||
<Configuration>ReleaseDLL</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<ProjectGuid>{4D949362-9095-4113-9423-7E0492618F16}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugDLL|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseDLL|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugDLL|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseDLL|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>DivaGL</TargetName>
|
||||
<OutDir>$(SolutionDir)bin\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\debug\DivaGL\</IntDir>
|
||||
<TargetExt>.dva</TargetExt>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugDLL|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>dinput8</TargetName>
|
||||
<OutDir>$(SolutionDir)bin\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\debug\DivaGL\</IntDir>
|
||||
<TargetExt>.dll</TargetExt>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>DivaGL</TargetName>
|
||||
<OutDir>$(SolutionDir)bin\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\release\DivaGL\</IntDir>
|
||||
<TargetExt>.dva</TargetExt>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseDLL|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>dinput8</TargetName>
|
||||
<OutDir>$(SolutionDir)bin\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\release\DivaGL\</IntDir>
|
||||
<TargetExt>.dll</TargetExt>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)extern\src</AdditionalIncludeDirectories>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<OmitFramePointers>false</OmitFramePointers>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<CallingConvention>FastCall</CallingConvention>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<CompileAs>CompileAsCpp</CompileAs>
|
||||
<ObjectFileName>$(IntDir)/%(RelativeDir)</ObjectFileName>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
|
||||
<UseFullPaths>false</UseFullPaths>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)extern\lib;$(SolutionDir)lib\debugopt\</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>opengl32.lib;detours.lib;syelog.lib;libdeflatestatic.lib;KKdLib.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalOptions>/ignore:4098 /ignore:4099 /ignore:4286 %(AdditionalOptions)</AdditionalOptions>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy /Y "$(SolutionDir)bin\$(TargetName).dva" "N:\DUMP\plugins\$(TargetName).dva"
|
||||
copy /Y "$(SolutionDir)bin\$(TargetName).pdb" "N:\DUMP\plugins\$(TargetName).pdb"
|
||||
del "$(SolutionDir)bin\$(TargetName).exp"
|
||||
del "$(SolutionDir)bin\$(TargetName).lib"</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugDLL|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;DINPUT8_DLL;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)extern\src</AdditionalIncludeDirectories>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<OmitFramePointers>false</OmitFramePointers>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<CallingConvention>FastCall</CallingConvention>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<CompileAs>CompileAsCpp</CompileAs>
|
||||
<ObjectFileName>$(IntDir)/%(RelativeDir)</ObjectFileName>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
|
||||
<UseFullPaths>false</UseFullPaths>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)extern\lib;$(SolutionDir)lib\debugopt\</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>opengl32.lib;detours.lib;syelog.lib;libdeflatestatic.lib;KKdLib.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalOptions>/ignore:4098 /ignore:4099 /ignore:4286 %(AdditionalOptions)</AdditionalOptions>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy /Y "$(SolutionDir)bin\$(TargetName).dll" "N:\DUMP\$(TargetName).dll"
|
||||
copy /Y "$(SolutionDir)bin\$(TargetName).pdb" "N:\DUMP\$(TargetName).pdb"
|
||||
del "$(SolutionDir)bin\$(TargetName).exp"
|
||||
del "$(SolutionDir)bin\$(TargetName).lib"</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)extern\src</AdditionalIncludeDirectories>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<OmitFramePointers>false</OmitFramePointers>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<CallingConvention>FastCall</CallingConvention>
|
||||
<CompileAs>CompileAsCpp</CompileAs>
|
||||
<FunctionLevelLinking>
|
||||
</FunctionLevelLinking>
|
||||
<ObjectFileName>$(IntDir)/%(RelativeDir)</ObjectFileName>
|
||||
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
|
||||
<RuntimeTypeInfo>
|
||||
</RuntimeTypeInfo>
|
||||
<UseFullPaths>false</UseFullPaths>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)extern\lib;$(SolutionDir)lib\release\</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>opengl32.lib;detours.lib;syelog.lib;libdeflatestatic.lib;KKdLib.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalOptions>/ignore:4098 /ignore:4099 /ignore:4286 %(AdditionalOptions)</AdditionalOptions>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy /Y "$(SolutionDir)bin\$(TargetName).dva" "N:\DUMP\plugins\$(TargetName).dva"
|
||||
copy /Y "$(SolutionDir)bin\$(TargetName).pdb" "N:\DUMP\plugins\$(TargetName).pdb"
|
||||
del "$(SolutionDir)bin\$(TargetName).exp"
|
||||
del "$(SolutionDir)bin\$(TargetName).lib"</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseDLL|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;DINPUT8_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)extern\src</AdditionalIncludeDirectories>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<OmitFramePointers>false</OmitFramePointers>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<CallingConvention>FastCall</CallingConvention>
|
||||
<CompileAs>CompileAsCpp</CompileAs>
|
||||
<FunctionLevelLinking>
|
||||
</FunctionLevelLinking>
|
||||
<ObjectFileName>$(IntDir)/%(RelativeDir)</ObjectFileName>
|
||||
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
|
||||
<RuntimeTypeInfo>
|
||||
</RuntimeTypeInfo>
|
||||
<UseFullPaths>false</UseFullPaths>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<DisableSpecificWarnings>26812</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)extern\lib;$(SolutionDir)lib\release\</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>opengl32.lib;detours.lib;syelog.lib;libdeflatestatic.lib;KKdLib.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalOptions>/ignore:4098 /ignore:4099 /ignore:4286 %(AdditionalOptions)</AdditionalOptions>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy /Y "$(SolutionDir)bin\$(TargetName).dll" "N:\DUMP\$(TargetName).dll"
|
||||
copy /Y "$(SolutionDir)bin\$(TargetName).pdb" "N:\DUMP\$(TargetName).pdb"
|
||||
del "$(SolutionDir)bin\$(TargetName).exp"
|
||||
del "$(SolutionDir)bin\$(TargetName).lib"</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="auth_3d.cpp" />
|
||||
<ClCompile Include="camera.cpp" />
|
||||
<ClCompile Include="color.cpp" />
|
||||
<ClCompile Include="dllmain.cpp" />
|
||||
<ClCompile Include="mdl\disp_manager.cpp" />
|
||||
<ClCompile Include="mdl\draw_object.cpp" />
|
||||
<ClCompile Include="Glitter\glitter.cpp" />
|
||||
<ClCompile Include="Glitter\particle.cpp" />
|
||||
<ClCompile Include="Glitter\particle_manager.cpp" />
|
||||
<ClCompile Include="Glitter\render_group.cpp" />
|
||||
<ClCompile Include="Glitter\render_scene.cpp" />
|
||||
<ClCompile Include="Glitter\scene.cpp" />
|
||||
<ClCompile Include="gl_state.cpp" />
|
||||
<ClCompile Include="inject.cpp" />
|
||||
<ClCompile Include="light_param\fog.cpp" />
|
||||
<ClCompile Include="light_param\light.cpp" />
|
||||
<ClCompile Include="object.cpp" />
|
||||
<ClCompile Include="print.cpp" />
|
||||
<ClCompile Include="render.cpp" />
|
||||
<ClCompile Include="renderer\dof.cpp" />
|
||||
<ClCompile Include="renderer\fbo.cpp" />
|
||||
<ClCompile Include="renderer\transparency.cpp" />
|
||||
<ClCompile Include="render_context.cpp" />
|
||||
<ClCompile Include="render_manager.cpp" />
|
||||
<ClCompile Include="render_texture.cpp" />
|
||||
<ClCompile Include="resolution_mode.cpp" />
|
||||
<ClCompile Include="rob\rob.cpp" />
|
||||
<ClCompile Include="shader_glsl.cpp" />
|
||||
<ClCompile Include="shader_glsl_ft.cpp" />
|
||||
<ClCompile Include="shader_table.cpp" />
|
||||
<ClCompile Include="shadow.cpp" />
|
||||
<ClCompile Include="shared.cpp" />
|
||||
<ClCompile Include="sprite.cpp" />
|
||||
<ClCompile Include="stage.cpp" />
|
||||
<ClCompile Include="stage_param.cpp" />
|
||||
<ClCompile Include="texture.cpp" />
|
||||
<ClCompile Include="uniform.cpp" />
|
||||
<ClCompile Include="hook.cpp" />
|
||||
<ClCompile Include="wrap.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="DivaGL.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="auth_3d.hpp" />
|
||||
<ClInclude Include="camera.hpp" />
|
||||
<ClInclude Include="color.hpp" />
|
||||
<ClInclude Include="mdl\disp_manager.hpp" />
|
||||
<ClInclude Include="mdl\draw_object.hpp" />
|
||||
<ClInclude Include="gl.hpp" />
|
||||
<ClInclude Include="Glitter\glitter.hpp" />
|
||||
<ClInclude Include="gl_array_buffer.hpp" />
|
||||
<ClInclude Include="gl_element_array_buffer.hpp" />
|
||||
<ClInclude Include="gl_shader_storage_buffer.hpp" />
|
||||
<ClInclude Include="gl_uniform_buffer.hpp" />
|
||||
<ClInclude Include="gl_state.hpp" />
|
||||
<ClInclude Include="inject.hpp" />
|
||||
<ClInclude Include="light_param\fog.hpp" />
|
||||
<ClInclude Include="light_param\light.hpp" />
|
||||
<ClInclude Include="object.hpp" />
|
||||
<ClInclude Include="print.hpp" />
|
||||
<ClInclude Include="render.hpp" />
|
||||
<ClInclude Include="renderer\dof.hpp" />
|
||||
<ClInclude Include="renderer\fbo.hpp" />
|
||||
<ClInclude Include="renderer\transparency.hpp" />
|
||||
<ClInclude Include="render_context.hpp" />
|
||||
<ClInclude Include="render_manager.hpp" />
|
||||
<ClInclude Include="render_texture.hpp" />
|
||||
<ClInclude Include="resolution_mode.hpp" />
|
||||
<ClInclude Include="rob\rob.hpp" />
|
||||
<ClInclude Include="shader_glsl.hpp" />
|
||||
<ClInclude Include="shader_glsl_ft.hpp" />
|
||||
<ClInclude Include="shader_table.hpp" />
|
||||
<ClInclude Include="shadow.hpp" />
|
||||
<ClInclude Include="shared.hpp" />
|
||||
<ClInclude Include="sprite.hpp" />
|
||||
<ClInclude Include="stage.hpp" />
|
||||
<ClInclude Include="stage_param.hpp" />
|
||||
<ClInclude Include="texture.hpp" />
|
||||
<ClInclude Include="types.hpp" />
|
||||
<ClInclude Include="uniform.hpp" />
|
||||
<ClInclude Include="hook.hpp" />
|
||||
<ClInclude Include="wrap.hpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\KKdLib\KKdLib.vcxproj">
|
||||
<Project>{4c9636b9-e5b6-41e5-9afc-5b33cc9633de}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LocalDebuggerCommand>N:\DUMP\diva.exe</LocalDebuggerCommand>
|
||||
<LocalDebuggerWorkingDirectory>N:\DUMP</LocalDebuggerWorkingDirectory>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
<LocalDebuggerCommandArguments>--launch -w</LocalDebuggerCommandArguments>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseDLL|x64'">
|
||||
<LocalDebuggerCommand>N:\DUMP\diva.exe</LocalDebuggerCommand>
|
||||
<LocalDebuggerWorkingDirectory>N:\DUMP</LocalDebuggerWorkingDirectory>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
<LocalDebuggerCommandArguments>--launch -w</LocalDebuggerCommandArguments>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LocalDebuggerCommand>N:\DUMP\diva.exe</LocalDebuggerCommand>
|
||||
<LocalDebuggerCommandArguments>--launch -w</LocalDebuggerCommandArguments>
|
||||
<LocalDebuggerWorkingDirectory>N:\DUMP</LocalDebuggerWorkingDirectory>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugDLL|x64'">
|
||||
<LocalDebuggerCommand>N:\DUMP\diva.exe</LocalDebuggerCommand>
|
||||
<LocalDebuggerCommandArguments>--launch -w</LocalDebuggerCommandArguments>
|
||||
<LocalDebuggerWorkingDirectory>N:\DUMP</LocalDebuggerWorkingDirectory>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ShowAllFiles>true</ShowAllFiles>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "glitter.hpp"
|
||||
#include "../inject.hpp"
|
||||
#include "../gl_state.hpp"
|
||||
#include "../wrap.hpp"
|
||||
|
||||
namespace Glitter {
|
||||
void axis_angle_from_vectors(vec3* axis, float_t* angle, const vec3* vec1, const vec3* vec2) {
|
||||
*axis = vec3::cross(*vec1, *vec2);
|
||||
*angle = vec3::length(*axis);
|
||||
if (*angle >= 0.000001f)
|
||||
*angle = asinf(min_def(*angle, 1.0f));
|
||||
else {
|
||||
*angle = 0.0f;
|
||||
axis->x = vec1->z;
|
||||
axis->y = 0.0f;
|
||||
axis->z = vec1->x;
|
||||
if (vec3::length(*axis) < 0.000001f) {
|
||||
axis->x = -vec1->y;
|
||||
axis->y = vec1->x;
|
||||
axis->z = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
if (vec3::dot(*vec1, *vec2) < 0.0f)
|
||||
*angle = (float_t)M_PI - *angle;
|
||||
}
|
||||
|
||||
void CreateBuffer(int32_t max_count, bool is_quad, GLuint& vao, GLuint& vbo, GLuint& ebo) {
|
||||
glGenVertexArrays(1, &vao);
|
||||
gl_state_bind_vertex_array(vao, true);
|
||||
|
||||
glGenBuffers(1, &vbo);
|
||||
gl_state_bind_array_buffer(vbo, true);
|
||||
|
||||
glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)(sizeof(Buffer) * max_count), 0, GL_DYNAMIC_DRAW);
|
||||
|
||||
if (is_quad) {
|
||||
size_t count = (size_t)max_count / 4 * 5;
|
||||
int32_t* ebo_data = (int32_t*)_operator_new(sizeof(int32_t) * (count - 1));
|
||||
for (size_t i = 0, j = 0, k = count / 5 - 1; i < count; i += 5, j += 4, k--) {
|
||||
ebo_data[i + 0] = (uint32_t)(j + 0);
|
||||
ebo_data[i + 1] = (uint32_t)(j + 1);
|
||||
ebo_data[i + 2] = (uint32_t)(j + 3);
|
||||
ebo_data[i + 3] = (uint32_t)(j + 2);
|
||||
if (k)
|
||||
ebo_data[i + 4] = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
glGenBuffers(1, &ebo);
|
||||
gl_state_bind_element_array_buffer(ebo);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(int32_t) * (count - 1), ebo_data, GL_STATIC_DRAW);
|
||||
_operator_delete(ebo_data);
|
||||
}
|
||||
else
|
||||
ebo = 0;
|
||||
|
||||
static const GLsizei buffer_size = sizeof(Buffer);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, buffer_size,
|
||||
(void*)offsetof(Buffer, position));
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, buffer_size,
|
||||
(void*)offsetof(Buffer, uv));
|
||||
glEnableVertexAttribArray(2);
|
||||
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, buffer_size,
|
||||
(void*)offsetof(Buffer, color));
|
||||
|
||||
gl_state_bind_array_buffer(0);
|
||||
gl_state_bind_vertex_array(0);
|
||||
if (is_quad)
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
void DeleteBuffer(GLuint& vao, GLuint& vbo, GLuint& ebo) {
|
||||
if (ebo) {
|
||||
glDeleteBuffers(1, &ebo);
|
||||
ebo = 0;
|
||||
}
|
||||
|
||||
if (vbo) {
|
||||
glDeleteBuffers(1, &vbo);
|
||||
vbo = 0;
|
||||
}
|
||||
|
||||
if (vao) {
|
||||
glDeleteVertexArrays(1, &vao);
|
||||
vao = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Particle
|
||||
const char* _000000014039BC78_patch_data
|
||||
= "\x48\x89\xE9\x48\xB8\x00\x00\x00\x00\x00\x00\x00\x80\xFF\xD0\xEB\x3D";
|
||||
const char* _00000001403AEA7E_patch_data
|
||||
= "\x48\x89\xD9\x48\xB8\x00\x00\x00\x00\x00\x00\x00\x80\xFF\xD0\xEB\x0B";
|
||||
|
||||
// RenderGroup
|
||||
const char* _00000001403A5CA7_patch_data
|
||||
= "\x48\x8B\xCE\x48\xB8\x00\x00\x00\x00\x00\x00\x00\x80\xFF\xD0\xE9\x95\x00\x00\x00";
|
||||
const char* _00000001403A8552_patch_data
|
||||
= "\x48\x89\xD9\x48\xB8\x00\x00\x00\x00\x00\x00\x00\x80\xFF\xD0\xEB\x07";
|
||||
|
||||
void Patch() {
|
||||
uint8_t buf[0x100];
|
||||
|
||||
// Particle
|
||||
inject_uint32_t((void*)0x000000014039A396,
|
||||
0x1B0 + sizeof(GLuint) * 2 + sizeof(DrawListData*));
|
||||
|
||||
memcpy(buf, _000000014039BC78_patch_data, 0x11);
|
||||
*(uint64_t*)&buf[0x05] = (uint64_t)Particle::CreateBuffer;
|
||||
inject_data((void*)0x000000014039BC78, buf, 0x11);
|
||||
|
||||
memcpy(buf, _00000001403AEA7E_patch_data, 0x11);
|
||||
*(uint64_t*)&buf[0x05] = (uint64_t)Particle::DeleteBuffer;
|
||||
inject_data((void*)0x00000001403AEA7E, buf, 0x11);
|
||||
|
||||
// RenderGroup
|
||||
inject_uint32_t((void*)0x00000001403A9740, sizeof(RenderGroup));
|
||||
|
||||
memcpy(buf, _00000001403A5CA7_patch_data, 0x14);
|
||||
*(uint64_t*)&buf[0x05] = (uint64_t)RenderGroup::CreateBuffer;
|
||||
inject_data((void*)0x00000001403A5CA7, buf, 0x14);
|
||||
|
||||
memcpy(buf, _00000001403A8552_patch_data, 0x11);
|
||||
*(uint64_t*)&buf[0x05] = (uint64_t)RenderGroup::DeleteBuffer;
|
||||
inject_data((void*)0x00000001403A8552, buf, 0x11);
|
||||
|
||||
// RenderScene
|
||||
buf[0x00] = 0x48;
|
||||
buf[0x01] = 0xB8;
|
||||
*(uint64_t*)&buf[0x02] = (uint64_t)RenderScene::Disp;
|
||||
buf[0x0A] = 0xFF;
|
||||
buf[0x0B] = 0xE0;
|
||||
inject_data((void*)0x00000001403AA140, buf, 0x0C);
|
||||
|
||||
// GltParticleManager
|
||||
inject_uint64_t((void*)(0x00000001409EB880 + 0x20), (uint64_t)GltParticleManager::Disp);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,322 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../KKdLib/mat.hpp"
|
||||
#include "../../KKdLib/vec.hpp"
|
||||
#include "../gl.hpp"
|
||||
#include "../types.hpp"
|
||||
#include "../texture.hpp"
|
||||
|
||||
namespace Glitter {
|
||||
enum Direction {
|
||||
DIRECTION_BILLBOARD = 0,
|
||||
DIRECTION_EMITTER_DIRECTION = 1,
|
||||
DIRECTION_PREV_POSITION = 2,
|
||||
DIRECTION_EMIT_POSITION = 3,
|
||||
DIRECTION_Y_AXIS = 4,
|
||||
DIRECTION_X_AXIS = 5,
|
||||
DIRECTION_Z_AXIS = 6,
|
||||
DIRECTION_BILLBOARD_Y_AXIS = 7,
|
||||
DIRECTION_PREV_POSITION_DUP = 8,
|
||||
DIRECTION_EMITTER_ROTATION = 9,
|
||||
DIRECTION_EFFECT_ROTATION = 10,
|
||||
DIRECTION_PARTICLE_ROTATION = 11,
|
||||
};
|
||||
|
||||
enum DispType {
|
||||
DISP_OPAQUE = 0,
|
||||
DISP_NORMAL = 1,
|
||||
DISP_ALPHA = 2,
|
||||
};
|
||||
|
||||
enum FogType {
|
||||
FOG_NONE = 0,
|
||||
FOG_DEPTH = 1,
|
||||
FOG_HEIGHT = 2,
|
||||
};
|
||||
|
||||
enum ParticleBlend {
|
||||
PARTICLE_BLEND_ZERO = 0,
|
||||
PARTICLE_BLEND_TYPICAL = 1,
|
||||
PARTICLE_BLEND_ADD = 2,
|
||||
PARTICLE_BLEND_SUBTRACT = 3,
|
||||
PARTICLE_BLEND_MULTIPLY = 4,
|
||||
PARTICLE_BLEND_PUNCH_THROUGH = 5,
|
||||
};
|
||||
|
||||
enum ParticleFlag {
|
||||
PARTICLE_NONE = 0x00000,
|
||||
PARTICLE_LOOP = 0x00001,
|
||||
PARTICLE_EMITTER_LOCAL = 0x00004,
|
||||
PARTICLE_SCALE_Y_BY_X = 0x00010,
|
||||
PARTICLE_REBOUND_PLANE = 0x00020,
|
||||
PARTICLE_ROTATE_BY_EMITTER = 0x00040,
|
||||
PARTICLE_SCALE = 0x00080,
|
||||
PARTICLE_TEXTURE_MASK = 0x00100,
|
||||
PARTICLE_DEPTH_TEST = 0x00200,
|
||||
PARTICLE_ROTATE_LOCUS = 0x00800,
|
||||
PARTICLE_LOCAL = 0x10000,
|
||||
PARTICLE_EMISSION = 0x20000,
|
||||
};
|
||||
|
||||
enum ParticleManagerFlag {
|
||||
PARTICLE_MANAGER_PAUSE = 0x01,
|
||||
PARTICLE_MANAGER_NOT_DISP = 0x02,
|
||||
PARTICLE_MANAGER_RESET_SCENE_COUNTER = 0x04,
|
||||
PARTICLE_MANAGER_READ_FILES = 0x08,
|
||||
};
|
||||
|
||||
enum ParticleType {
|
||||
PARTICLE_QUAD = 0,
|
||||
PARTICLE_LINE = 1,
|
||||
PARTICLE_LOCUS = 2,
|
||||
};
|
||||
|
||||
enum Pivot {
|
||||
PIVOT_TOP_LEFT = 0,
|
||||
PIVOT_TOP_CENTER = 1,
|
||||
PIVOT_TOP_RIGHT = 2,
|
||||
PIVOT_MIDDLE_LEFT = 3,
|
||||
PIVOT_MIDDLE_CENTER = 4,
|
||||
PIVOT_MIDDLE_RIGHT = 5,
|
||||
PIVOT_BOTTOM_LEFT = 6,
|
||||
PIVOT_BOTTOM_CENTER = 7,
|
||||
PIVOT_BOTTOM_RIGHT = 8,
|
||||
};
|
||||
|
||||
enum SceneFlag {
|
||||
SCENE_NONE = 0x00,
|
||||
SCENE_FLAG_1 = 0x01,
|
||||
SCENE_NOT_DISP = 0x02,
|
||||
SCENE_FLAG_3 = 0x04,
|
||||
};
|
||||
|
||||
struct Animation;
|
||||
struct Buffer;
|
||||
struct Camera;
|
||||
struct Curve;
|
||||
struct Effect;
|
||||
struct Emitter;
|
||||
struct EmitterInst;
|
||||
struct ItemBase;
|
||||
struct Node;
|
||||
struct Particle;
|
||||
struct ParticleInst;
|
||||
struct Random;
|
||||
struct RenderElement;
|
||||
struct RenderGroup;
|
||||
struct RenderScene;
|
||||
|
||||
struct BatchShaderData;
|
||||
struct Scene;
|
||||
struct GltParticleManager;
|
||||
|
||||
#define GPM Glitter::GltParticleManager* glt_particle_manager
|
||||
#define GPM_VAL (glt_particle_manager)
|
||||
|
||||
struct Buffer {
|
||||
vec3 position;
|
||||
vec2 uv[2];
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
struct LocusHistory {
|
||||
struct Data {
|
||||
vec3 translation;
|
||||
vec4 color;
|
||||
float_t scale;
|
||||
};
|
||||
|
||||
struct Sub {
|
||||
prj::vector<Data> vec;
|
||||
int32_t count;
|
||||
};
|
||||
|
||||
void* __vftable;
|
||||
Sub sub;
|
||||
};
|
||||
|
||||
struct Particle {
|
||||
static void CreateBuffer(size_t data);
|
||||
static void DeleteBuffer(size_t data);
|
||||
};
|
||||
|
||||
struct RenderElement {
|
||||
bool alive;
|
||||
uint8_t uv_counter;
|
||||
int32_t random;
|
||||
float_t frame;
|
||||
float_t life_time;
|
||||
float_t rebound_time;
|
||||
float_t frame_step_uv;
|
||||
float_t speed;
|
||||
float_t deceleration;
|
||||
vec2 uv;
|
||||
vec4 color;
|
||||
vec3 base_translation;
|
||||
vec3 translation;
|
||||
vec3 translation_prev;
|
||||
vec3 direction;
|
||||
vec3 acceleration;
|
||||
vec2 scale_particle;
|
||||
vec3 scale;
|
||||
vec3 rotation;
|
||||
vec3 rotation_add;
|
||||
float_t rot_z_cos;
|
||||
float_t rot_z_sin;
|
||||
float_t scale_all;
|
||||
vec2 uv_scroll;
|
||||
mat4 mat;
|
||||
LocusHistory* locus_history;
|
||||
};
|
||||
|
||||
struct EffectGroup {
|
||||
void* __vftable;
|
||||
std::vector<void*> effects; // Glitter::Effect
|
||||
int32_t load_count;
|
||||
texture** textures;
|
||||
void* scene; // Glitter::Scene
|
||||
float_t emission;
|
||||
bool not_loaded;
|
||||
bool scene_init;
|
||||
bool buffer_init;
|
||||
};
|
||||
|
||||
typedef prj::vector<prj::pair<GLint, GLsizei>> DrawListData;
|
||||
|
||||
struct RenderGroup {
|
||||
void* __vftable;
|
||||
ParticleFlag flags;
|
||||
ParticleType type;
|
||||
Direction draw_type;
|
||||
ParticleBlend blend_mode;
|
||||
ParticleBlend mask_blend_mode;
|
||||
int32_t dword1C;
|
||||
Pivot pivot;
|
||||
int32_t split_u;
|
||||
int32_t split_v;
|
||||
vec2 split_uv;
|
||||
float_t z_offset;
|
||||
int32_t count;
|
||||
int32_t ctrl;
|
||||
int32_t texture;
|
||||
int32_t mask_texture;
|
||||
prj::string name;
|
||||
float_t frame;
|
||||
mat4 mat;
|
||||
mat4 mat_rot;
|
||||
bool has_mask;
|
||||
int32_t dwordF0;
|
||||
int32_t dwordF4;
|
||||
RenderElement* elements;
|
||||
Buffer* buffer;
|
||||
int32_t max_count;
|
||||
int32_t dword10C;
|
||||
void* particle_inst; // Glitter::ParticleInst
|
||||
DispType disp_type;
|
||||
FogType fog_type;
|
||||
GLuint vbo;
|
||||
float_t emission;
|
||||
bool use_own_buffer;
|
||||
GLuint vao;
|
||||
GLuint ebo;
|
||||
size_t disp;
|
||||
mat4 mat_draw;
|
||||
DrawListData* draw_list;
|
||||
|
||||
static mat4 RotateToEmitPosition(RenderGroup* rend_group,
|
||||
RenderElement* rend_elem, vec3* vec);
|
||||
static mat4 RotateToPrevPosition(RenderGroup* rend_group,
|
||||
RenderElement* rend_elem, vec3* vec);
|
||||
|
||||
static void CreateBuffer(RenderGroup* rend_group);
|
||||
static void DeleteBuffer(RenderGroup* rend_group);
|
||||
};
|
||||
|
||||
struct RenderScene {
|
||||
prj::vector<RenderGroup*> render_groups;
|
||||
int32_t disp_quad;
|
||||
int32_t disp_locus;
|
||||
int32_t disp_line;
|
||||
int32_t ctrl_quad;
|
||||
int32_t ctrl_locus;
|
||||
int32_t ctrl_line;
|
||||
|
||||
static void CalcDisp(RenderScene* rend_sc);
|
||||
static void CalcDisp(RenderScene* rend_sc, RenderGroup* rend_group);
|
||||
static void CalcDispLine(RenderGroup* rend_group);
|
||||
static void CalcDispLocus(RenderGroup* rend_group);
|
||||
static void CalcDispQuad(RenderGroup* rend_group);
|
||||
static void CalcDispQuadDirectionRotation(
|
||||
RenderGroup* rend_group, mat4* model_mat, mat4* dir_mat);
|
||||
static void CalcDispQuadNormal(
|
||||
RenderGroup* rend_group, mat4* model_mat, mat4* dir_mat);
|
||||
static void Disp(RenderScene* rend_sc, RenderGroup* rend_group);
|
||||
|
||||
static void CalcDispLocusSetPivot(Pivot pivot,
|
||||
float_t w, float_t& v00, float_t& v01);
|
||||
static void CalcDispQuadSetPivot(Pivot pivot,
|
||||
float_t w, float_t h, float_t& v00, float_t& v01, float_t& v10, float_t& v11);
|
||||
};
|
||||
|
||||
struct SceneEffect {
|
||||
void* ptr; // Glitter::EffectInst
|
||||
bool draw;
|
||||
};
|
||||
|
||||
struct Scene {
|
||||
void* __vftable;
|
||||
prj::vector<SceneEffect*> effects;
|
||||
uint32_t load_counter;
|
||||
uint64_t hash;
|
||||
SceneFlag flags;
|
||||
float_t emission;
|
||||
EffectGroup* effect_group;
|
||||
RenderScene render_scene;
|
||||
|
||||
static void CalcDisp(Scene* sc);
|
||||
};
|
||||
|
||||
struct GltParticleManager {
|
||||
void* __vftable;
|
||||
uint8_t app_task_data[0x60];
|
||||
prj::map<uint64_t, EffectGroup> effect_groups;
|
||||
void* field_78;
|
||||
uint64_t field_80;
|
||||
prj::vector<Scene*> scenes;
|
||||
prj::vector<void*> file_readers;
|
||||
void* sys_frame_rate;
|
||||
ParticleManagerFlag flags;
|
||||
int32_t scene_load_counter;
|
||||
int32_t available_buffers_init;
|
||||
int32_t available_buffers;
|
||||
float_t field_D0;
|
||||
float_t field_D4;
|
||||
float_t emission;
|
||||
float_t delta_frame;
|
||||
prj::map<uint64_t, uint32_t> resources;
|
||||
uint32_t texture_counter;
|
||||
int32_t field_F4;
|
||||
int32_t field_F8;
|
||||
int32_t random;
|
||||
int32_t counter;
|
||||
int32_t field_104;
|
||||
|
||||
static void Disp(GPM);
|
||||
};
|
||||
|
||||
extern GPM;
|
||||
|
||||
extern void axis_angle_from_vectors(vec3* axis, float_t* angle, const vec3* vec0, const vec3* vec1);
|
||||
|
||||
extern void CreateBuffer(int32_t max_count, bool is_quad, GLuint& vao, GLuint& vbo, GLuint& ebo);
|
||||
extern void DeleteBuffer(GLuint& vao, GLuint& vbo, GLuint& ebo);
|
||||
|
||||
extern void Patch();
|
||||
|
||||
extern void (FASTCALL* GltParticleManager__DispScenes)(GPM, DispType disp_type);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "glitter.hpp"
|
||||
|
||||
namespace Glitter {
|
||||
void Particle::CreateBuffer(size_t data) {
|
||||
ParticleType type = (ParticleType) * (int32_t*)(data + 0x40 + 0x00 + 0x08);
|
||||
GLuint& vbo = ((GLuint*)(data + 0x40 + 0x160))[0];
|
||||
int32_t max_count = *(int32_t*)(data + 0x40 + 0x164);
|
||||
GLuint& vao = ((GLuint*)(data + 0x40 + 0x170))[0];
|
||||
GLuint& ebo = ((GLuint*)(data + 0x40 + 0x170))[1];
|
||||
Glitter::CreateBuffer(max_count, type == PARTICLE_QUAD, vao, vbo, ebo);
|
||||
|
||||
DrawListData*& draw_list = *(DrawListData**)(data + 0x40 + 0x170 + sizeof(GLuint) * 2);
|
||||
draw_list = new DrawListData;
|
||||
}
|
||||
|
||||
void Particle::DeleteBuffer(size_t data) {
|
||||
DrawListData*& draw_list = *(DrawListData**)(data + 0x40 + 0x170 + sizeof(GLuint) * 2);
|
||||
if (draw_list) {
|
||||
delete draw_list;
|
||||
draw_list = 0;
|
||||
}
|
||||
|
||||
GLuint& vbo = ((GLuint*)(data + 0x40 + 0x160))[0];
|
||||
GLuint& vao = ((GLuint*)(data + 0x40 + 0x170))[0];
|
||||
GLuint& ebo = ((GLuint*)(data + 0x40 + 0x170))[1];
|
||||
Glitter::DeleteBuffer(vao, vbo, ebo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "glitter.hpp"
|
||||
#include "../gl_state.hpp"
|
||||
|
||||
namespace Glitter {
|
||||
GPM = (GltParticleManager*)0x000000141199BB0;
|
||||
|
||||
void GltParticleManager::Disp(GPM) {
|
||||
if (glt_particle_manager->flags & PARTICLE_MANAGER_NOT_DISP)
|
||||
return;
|
||||
|
||||
for (Scene*& i : glt_particle_manager->scenes)
|
||||
if (i)
|
||||
Scene::CalcDisp(i);
|
||||
}
|
||||
|
||||
void (FASTCALL* GltParticleManager__DispScenes)(GPM, DispType disp_type)
|
||||
= (void (FASTCALL*)(GPM, DispType disp_type))0x00000001403A1020;
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "glitter.hpp"
|
||||
#include "../gl_state.hpp"
|
||||
|
||||
namespace Glitter {
|
||||
mat4 RenderGroup::RotateToEmitPosition(RenderGroup* rend_group,
|
||||
RenderElement* rend_elem, vec3* vec) {
|
||||
vec3 vec2;
|
||||
if (rend_group->flags & PARTICLE_EMITTER_LOCAL)
|
||||
vec2 = rend_elem->translation;
|
||||
else {
|
||||
mat4_get_translation(&rend_group->mat, &vec2);
|
||||
vec2 -= rend_elem->translation;
|
||||
}
|
||||
vec2 = vec3::normalize(vec2);
|
||||
|
||||
mat4 mat;
|
||||
if (fabsf(vec2.y) >= 0.000001f) {
|
||||
mat = mat4_identity;
|
||||
vec3 vec1 = *vec;
|
||||
|
||||
vec3 axis;
|
||||
float_t angle;
|
||||
axis_angle_from_vectors(&axis, &angle, &vec1, &vec2);
|
||||
mat4_mul_rotation(&mat, &axis, angle, &mat);
|
||||
}
|
||||
else
|
||||
mat4_rotate_z((float_t)M_PI, &mat);
|
||||
return mat;
|
||||
}
|
||||
|
||||
mat4 RenderGroup::RotateToPrevPosition(RenderGroup* rend_group,
|
||||
RenderElement* rend_elem, vec3* vec) {
|
||||
vec3 vec2 = rend_elem->translation - rend_elem->translation_prev;
|
||||
|
||||
if (vec3::length_squared(vec2) < 0.000001f)
|
||||
vec2 = rend_elem->translation;
|
||||
vec2 = vec3::normalize(vec2);
|
||||
|
||||
mat4 mat;
|
||||
mat4_rotate_z((float_t)M_PI, &mat);
|
||||
if (fabsf(vec2.y) >= 0.000001f) {
|
||||
vec3 vec1 = *vec;
|
||||
|
||||
vec3 axis;
|
||||
float_t angle;
|
||||
axis_angle_from_vectors(&axis, &angle, &vec1, &vec2);
|
||||
mat4_mul_rotation(&mat, &axis, angle, &mat);
|
||||
}
|
||||
return mat;
|
||||
}
|
||||
|
||||
void RenderGroup::CreateBuffer(RenderGroup* rend_group) {
|
||||
if (rend_group->use_own_buffer) {
|
||||
if (rend_group->max_count > 0) {
|
||||
rend_group->buffer = (Buffer*)_operator_new(sizeof(Buffer) * rend_group->max_count);
|
||||
if (!rend_group->buffer)
|
||||
rend_group->max_count = 0;
|
||||
|
||||
ParticleType type = rend_group->type;
|
||||
GLuint& vbo = rend_group->vbo;
|
||||
int32_t max_count = rend_group->max_count;
|
||||
GLuint& vao = rend_group->vao;
|
||||
GLuint& ebo = rend_group->ebo;
|
||||
Glitter::CreateBuffer(max_count, type == PARTICLE_QUAD, vao, vbo, ebo);
|
||||
rend_group->draw_list = new DrawListData;
|
||||
}
|
||||
}
|
||||
else {
|
||||
size_t particle = *(size_t*)((size_t)rend_group->particle_inst + 0x98 + 0x178);
|
||||
rend_group->vao = ((GLuint*)(particle + 0x40 + 0x170))[0];
|
||||
rend_group->ebo = ((GLuint*)(particle + 0x40 + 0x170))[1];
|
||||
rend_group->draw_list = *(DrawListData**)(particle
|
||||
+ 0x40 + 0x170 + sizeof(GLuint) * 2);
|
||||
}
|
||||
}
|
||||
|
||||
void RenderGroup::DeleteBuffer(RenderGroup* rend_group) {
|
||||
if (rend_group->use_own_buffer) {
|
||||
DrawListData* draw_list = rend_group->draw_list;
|
||||
if (draw_list) {
|
||||
draw_list->clear();
|
||||
draw_list->shrink_to_fit();
|
||||
_operator_delete(draw_list);
|
||||
rend_group->draw_list = 0;
|
||||
}
|
||||
|
||||
GLuint& vbo = rend_group->vbo;
|
||||
GLuint& vao = rend_group->vao;
|
||||
GLuint& ebo = rend_group->ebo;
|
||||
Glitter::DeleteBuffer(vao, vbo, ebo);
|
||||
}
|
||||
else {
|
||||
rend_group->vbo = 0;
|
||||
rend_group->ebo = 0;
|
||||
rend_group->draw_list = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "glitter.hpp"
|
||||
#include "../gl_state.hpp"
|
||||
|
||||
namespace Glitter {
|
||||
void Scene::CalcDisp(Scene* sc) {
|
||||
if (!(sc->flags & SCENE_NOT_DISP))
|
||||
RenderScene::CalcDisp(&sc->render_scene);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,750 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "auth_3d.hpp"
|
||||
#include "../KKdLib/database/item_table.hpp"
|
||||
#include "light_param/fog.hpp"
|
||||
#include "mdl/disp_manager.hpp"
|
||||
#include "rob/rob.hpp"
|
||||
#include "object.hpp"
|
||||
#include "render_context.hpp"
|
||||
#include "sprite.hpp"
|
||||
#include "texture.hpp"
|
||||
#include "types.hpp"
|
||||
#include <Helpers.h>
|
||||
|
||||
enum auth_3d_camera_auxiliary_flags {
|
||||
AUTH_3D_CAMERA_AUXILIARY_EXPOSURE = 0x01,
|
||||
AUTH_3D_CAMERA_AUXILIARY_GAMMA = 0x02,
|
||||
AUTH_3D_CAMERA_AUXILIARY_SATURATE = 0x04,
|
||||
AUTH_3D_CAMERA_AUXILIARY_AUTO_EXPOSURE = 0x08,
|
||||
};
|
||||
|
||||
enum auth_3d_ep_type {
|
||||
AUTH_3D_EP_NONE = 0x00,
|
||||
AUTH_3D_EP_LINEAR = 0x01,
|
||||
AUTH_3D_EP_CYCLE = 0x02,
|
||||
AUTH_3D_EP_CYCLE_OFFSET = 0x03,
|
||||
};
|
||||
|
||||
enum auth_3d_fog_flags {
|
||||
AUTH_3D_FOG_DENSITY = 0x01,
|
||||
AUTH_3D_FOG_START = 0x02,
|
||||
AUTH_3D_FOG_END = 0x04,
|
||||
AUTH_3D_FOG_COLOR = 0x08,
|
||||
};
|
||||
|
||||
enum auth_3d_key_type {
|
||||
AUTH_3D_KEY_NONE = 0x00,
|
||||
AUTH_3D_KEY_STATIC = 0x01,
|
||||
AUTH_3D_KEY_LINEAR = 0x02,
|
||||
AUTH_3D_KEY_HERMITE = 0x03,
|
||||
AUTH_3D_KEY_HOLD = 0x04,
|
||||
};
|
||||
|
||||
enum auth_3d_light_flags {
|
||||
AUTH_3D_LIGHT_AMBIENT = 0x01,
|
||||
AUTH_3D_LIGHT_DIFFUSE = 0x02,
|
||||
AUTH_3D_LIGHT_SPECULAR = 0x04,
|
||||
AUTH_3D_LIGHT_TONE_CURVE = 0x08,
|
||||
};
|
||||
|
||||
enum auth_3d_object_texture_transform_flags {
|
||||
AUTH_3D_OBJECT_TEX_TRANSFORM_COVERAGE_U = 0x001,
|
||||
AUTH_3D_OBJECT_TEX_TRANSFORM_COVERAGE_V = 0x002,
|
||||
AUTH_3D_OBJECT_TEX_TRANSFORM_REPEAT_U = 0x004,
|
||||
AUTH_3D_OBJECT_TEX_TRANSFORM_REPEAT_V = 0x008,
|
||||
AUTH_3D_OBJECT_TEX_TRANSFORM_TRANSLATE_FRAME_U = 0x010,
|
||||
AUTH_3D_OBJECT_TEX_TRANSFORM_TRANSLATE_FRAME_V = 0x020,
|
||||
AUTH_3D_OBJECT_TEX_TRANSFORM_OFFSET_U = 0x040,
|
||||
AUTH_3D_OBJECT_TEX_TRANSFORM_OFFSET_V = 0x080,
|
||||
AUTH_3D_OBJECT_TEX_TRANSFORM_ROTATE_FRAME = 0x100,
|
||||
AUTH_3D_OBJECT_TEX_TRANSFORM_ROTATE = 0x200,
|
||||
};
|
||||
|
||||
enum auth_3d_post_process_flags {
|
||||
AUTH_3D_POST_PROCESS_LENS_FLARE = 0x01,
|
||||
AUTH_3D_POST_PROCESS_LENS_SHAFT = 0x02,
|
||||
AUTH_3D_POST_PROCESS_LENS_GHOST = 0x04,
|
||||
AUTH_3D_POST_PROCESS_RADIUS = 0x08,
|
||||
AUTH_3D_POST_PROCESS_INTENSITY = 0x10,
|
||||
AUTH_3D_POST_PROCESS_SCENE_FADE = 0x20,
|
||||
};
|
||||
|
||||
struct kft3 {
|
||||
float_t frame;
|
||||
float_t value;
|
||||
float_t tangent1;
|
||||
float_t tangent2;
|
||||
};
|
||||
|
||||
static_assert(sizeof(kft3) == 0x10, "\"kft3\" struct should have a size of 0x10");
|
||||
|
||||
struct auth_3d_key {
|
||||
auth_3d_key_type type;
|
||||
float_t value;
|
||||
float_t max_frame;
|
||||
auth_3d_ep_type ep_type_pre;
|
||||
auth_3d_ep_type ep_type_post;
|
||||
float_t frame_delta;
|
||||
float_t value_delta;
|
||||
prj::vector<kft3> keys_vec;
|
||||
size_t length;
|
||||
kft3* keys;
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d_key) == 0x48, "\"auth_3d_key\" struct should have a size of 0x48");
|
||||
|
||||
struct auth_3d_vec3 {
|
||||
auth_3d_key x;
|
||||
auth_3d_key y;
|
||||
auth_3d_key z;
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d_vec3) == 0xD8, "\"auth_3d_vec3\" struct should have a size of 0xD8");
|
||||
|
||||
struct auth_3d_rgba {
|
||||
auth_3d_key r;
|
||||
auth_3d_key g;
|
||||
auth_3d_key b;
|
||||
auth_3d_key a;
|
||||
bool has_r;
|
||||
bool has_g;
|
||||
bool has_b;
|
||||
bool has_a;
|
||||
int32_t field_124;
|
||||
vec4 value;
|
||||
bool has_got[4];
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d_rgba) == 0x140, "\"auth_3d_rgba\" struct should have a size of 0x140");
|
||||
|
||||
struct auth_3d_model_transform {
|
||||
mat4 mat;
|
||||
auth_3d_vec3 scale;
|
||||
auth_3d_vec3 rotation;
|
||||
auth_3d_vec3 translation;
|
||||
auth_3d_key visibility;
|
||||
vec3 scale_value;
|
||||
vec3 rotation_value;
|
||||
vec3 translation_value;
|
||||
bool visible;
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d_model_transform) == 0x338, "\"auth_3d_model_transform\" struct should have a size of 0x338");
|
||||
|
||||
struct auth_3d_curve {
|
||||
auth_3d_key curve;
|
||||
prj::string name;
|
||||
float_t value;
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d_curve) == 0x70, "\"auth_3d_curve\" struct should have a size of 0x70");
|
||||
|
||||
struct auth_3d_object_curve {
|
||||
auth_3d_curve* curve;
|
||||
prj::string name;
|
||||
float_t frame_offset;
|
||||
float_t value;
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d_object_curve) == 0x30, "\"auth_3d_object_curve\" struct should have a size of 0x30");
|
||||
|
||||
struct auth_3d_object_texture_pattern {
|
||||
prj::string name;
|
||||
int32_t texture_id;
|
||||
auth_3d_object_curve pattern;
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d_object_texture_pattern) == 0x58, "\"auth_3d_object_texture_pattern\" struct should have a size of 0x58");
|
||||
|
||||
struct auth_3d_object_texture_transform {
|
||||
auth_3d_object_texture_transform_flags flags;
|
||||
prj::string name;
|
||||
int32_t texture_id;
|
||||
auth_3d_key coverageU;
|
||||
auth_3d_key coverageV;
|
||||
auth_3d_key repeatU;
|
||||
auth_3d_key repeatV;
|
||||
auth_3d_key translateFrameU;
|
||||
auth_3d_key translateFrameV;
|
||||
auth_3d_key offsetU;
|
||||
auth_3d_key offsetV;
|
||||
auth_3d_key rotateFrame;
|
||||
auth_3d_key rotate;
|
||||
mat4 mat;
|
||||
vec3 scale_value;
|
||||
vec3 repeat_value;
|
||||
vec3 rotate_value;
|
||||
vec3 translateFrame_value;
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d_object_texture_transform) == 0x370, "\"auth_3d_object_texture_transform\" struct should have a size of 0x370");
|
||||
|
||||
struct auth_3d_object_hrc;
|
||||
|
||||
struct auth_3d_object {
|
||||
auth_3d_model_transform model_transform;
|
||||
int64_t field_338;
|
||||
prj::string name;
|
||||
prj::string uid_name;
|
||||
prj::string parent_name;
|
||||
prj::string parent_node;
|
||||
auth_3d_object_curve pattern;
|
||||
auth_3d_object_curve morph;
|
||||
prj::vector<auth_3d_object_texture_pattern> texture_pattern;
|
||||
prj::vector<auth_3d_object_texture_transform >texture_transform;
|
||||
prj::vector<auth_3d_object*> children_object;
|
||||
prj::vector<auth_3d_object_hrc*> children_object_hrc;
|
||||
object_info object_info;
|
||||
bool reflect;
|
||||
bool refract;
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d_object) == 0x488, "\"auth_3d_object\" struct should have a size of 0x488");
|
||||
|
||||
struct auth_3d_object_model_transform {
|
||||
mat4 mat;
|
||||
mat4 mat_inner;
|
||||
auth_3d_vec3 translation;
|
||||
auth_3d_vec3 rotation;
|
||||
auth_3d_vec3 scale;
|
||||
auth_3d_key visibility;
|
||||
vec3 translation_value;
|
||||
vec3 rotation_value;
|
||||
vec3 scale_value;
|
||||
bool visible;
|
||||
mat4 mat_rot;
|
||||
int64_t field_3B8;
|
||||
int32_t field_3C0;
|
||||
mat4 field_3C4;
|
||||
vec3 field_404;
|
||||
float_t frame;
|
||||
bool has_rotation;
|
||||
bool has_translation;
|
||||
bool has_scale;
|
||||
bool has_visibility;
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d_object_model_transform) == 0x418, "\"auth_3d_object_model_transform\" struct should have a size of 0x418");
|
||||
|
||||
struct auth_3d_object_node {
|
||||
prj::string name;
|
||||
int32_t bone_id;
|
||||
int32_t parent;
|
||||
auth_3d_object_model_transform model_transform;
|
||||
mat4* mat;
|
||||
mat4 joint_orient;
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d_object_node) == 0x488, "\"auth_3d_object_node\" struct should have a size of 0x488");
|
||||
|
||||
struct auth_3d_object_hrc {
|
||||
prj::vector<auth_3d_object_node> node;
|
||||
prj::vector<mat4> node_bone_mats;
|
||||
mat4* bone_mats;
|
||||
prj::string name;
|
||||
prj::string uid_name;
|
||||
object_info object_info;
|
||||
bool reflect;
|
||||
bool refract;
|
||||
bool shadow;
|
||||
prj::string parent_name;
|
||||
prj::string parent_node;
|
||||
prj::vector<auth_3d_object*> children_object;
|
||||
prj::vector<int32_t> children_object_parent_node;
|
||||
prj::vector<auth_3d_object_hrc*> children_object_hrc;
|
||||
prj::vector<int32_t> children_object_hrc_parent_node;
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d_object_hrc) == 0x120, "\"auth_3d_object_hrc\" struct should have a size of 0x120");
|
||||
|
||||
struct auth_3d_object_instance {
|
||||
prj::string name;
|
||||
prj::string uid_name;
|
||||
object_info object_info;
|
||||
bool shadow;
|
||||
auth_3d_object_model_transform model_transform;
|
||||
prj::vector<int32_t> object_bone_indices;
|
||||
prj::vector<mat4> mats;
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d_object_instance) == 0x490, "\"auth_3d_object_instance\" struct should have a size of 0x490");
|
||||
|
||||
struct auth_3d_m_object_hrc {
|
||||
prj::string name;
|
||||
auth_3d_object_model_transform model_transform;
|
||||
prj::vector<auth_3d_object_node> node;
|
||||
prj::vector<auth_3d_object_instance> instance;
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d_m_object_hrc) == 0x468, "\"auth_3d_m_object_hrc\" struct should have a size of 0x468");
|
||||
|
||||
struct auth_3d_time_event {
|
||||
float_t frame;
|
||||
int32_t type;
|
||||
size_t event_index;
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d_time_event) == 0x10, "\"auth_3d_time_event\" struct should have a size of 0x10");
|
||||
|
||||
struct auth_3d_play_control {
|
||||
float_t begin;
|
||||
float_t size;
|
||||
float_t fps;
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d_play_control) == 0x0C, "\"auth_3d_play_control\" struct should have a size of 0x0C");
|
||||
|
||||
struct auth_3d_point {
|
||||
prj::string name;
|
||||
auth_3d_model_transform model_transform;
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d_point) == 0x358, "\"auth_3d_point\" struct should have a size of 0x358");
|
||||
|
||||
struct auth_3d_camera_root_view_point {
|
||||
auth_3d_model_transform model_transform;
|
||||
auth_3d_key roll;
|
||||
bool has_fov;
|
||||
bool fov_is_horizontal;
|
||||
auth_3d_key fov;
|
||||
float_t aspect;
|
||||
auth_3d_key focal_length;
|
||||
float_t camera_aperture_w;
|
||||
float_t camera_aperture_h;
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d_camera_root_view_point) == 0x428, "\"auth_3d_camera_root_view_point\" struct should have a size of 0x428");
|
||||
|
||||
struct auth_3d_camera_root {
|
||||
auth_3d_model_transform model_transform;
|
||||
auth_3d_camera_root_view_point view_point;
|
||||
auth_3d_model_transform interest;
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d_camera_root) == 0xA98, "\"auth_3d_camera_root\" struct should have a size of 0xA98");
|
||||
|
||||
struct auth_3d_camera_auxiliary {
|
||||
auth_3d_camera_auxiliary_flags flags;
|
||||
auth_3d_key exposure;
|
||||
auth_3d_key gamma;
|
||||
auth_3d_key saturate;
|
||||
auth_3d_key auto_exposure;
|
||||
float_t exposure_value;
|
||||
float_t gamma_value;
|
||||
float_t saturate_value;
|
||||
float_t auto_exposure_value;
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d_camera_auxiliary) == 0x138, "\"auth_3d_camera_auxiliary\" struct should have a size of 0x138");
|
||||
|
||||
struct auth_3d_light {
|
||||
auth_3d_light_flags flags;
|
||||
auth_3d_light_flags flags_init;
|
||||
light_id id;
|
||||
prj::string name;
|
||||
prj::string type;
|
||||
auth_3d_model_transform position;
|
||||
auth_3d_model_transform spot_direction;
|
||||
auth_3d_rgba Ambient;
|
||||
auth_3d_rgba Diffuse;
|
||||
auth_3d_rgba Specular;
|
||||
auth_3d_rgba Tone_Curve;
|
||||
vec4 Ambient_init;
|
||||
vec4 Diffuse_init;
|
||||
vec4 Specular_init;
|
||||
vec4 Tone_Curve_init;
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d_light) == 0xC00, "\"auth_3d_light\" struct should have a size of 0xC00");
|
||||
|
||||
struct auth_3d_fog {
|
||||
auth_3d_fog_flags flags;
|
||||
auth_3d_fog_flags flags_init;
|
||||
fog_id id;
|
||||
prj::string name;
|
||||
auth_3d_key density;
|
||||
auth_3d_key start;
|
||||
auth_3d_key end;
|
||||
float_t density_value;
|
||||
float_t start_value;
|
||||
float_t end_value;
|
||||
auth_3d_rgba color;
|
||||
float_t density_init;
|
||||
float_t start_init;
|
||||
float_t end_init;
|
||||
vec4 color_init;
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d_fog) == 0x278, "\"auth_3d_fog\" struct should have a size of 0x278");
|
||||
|
||||
struct auth_3d_post_process {
|
||||
auth_3d_post_process_flags flags;
|
||||
auth_3d_post_process_flags flags_init;
|
||||
auth_3d_key lens_flare;
|
||||
auth_3d_key lens_shaft;
|
||||
auth_3d_key lens_ghost;
|
||||
auth_3d_rgba radius;
|
||||
auth_3d_rgba intensity;
|
||||
auth_3d_rgba scene_fade;
|
||||
vec3 lens_init;
|
||||
vec4 radius_init_value;
|
||||
vec4 intensity_init_value;
|
||||
vec4 scene_fade_value;
|
||||
vec3 lens_value;
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d_post_process) == 0x4E8, "\"auth_3d_post_process\" struct should have a size of 0x4E8");
|
||||
|
||||
struct auth_3d_dof {
|
||||
bool has_dof;
|
||||
auth_3d_model_transform model_transform;
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d_dof) == 0x340, "\"auth_3d_dof\" struct should have a size of 0x340");
|
||||
|
||||
struct auth_3d_chara {
|
||||
prj::string name;
|
||||
auth_3d_model_transform model_transform;
|
||||
int32_t index;
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d_chara) == 0x360, "\"auth_3d_chara\" struct should have a size of 0x360");
|
||||
|
||||
struct auth_3d_motion {
|
||||
prj::string name;
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d_motion) == 0x20, "\"auth_3d_motion\" struct should have a size of 0x20");
|
||||
|
||||
struct auth_3d_auth_2d {
|
||||
prj::string name;
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d_auth_2d) == 0x20, "\"auth_3d_auth_2d\" struct should have a size of 0x20");
|
||||
|
||||
struct auth_3d {
|
||||
int32_t uid;
|
||||
int32_t id;
|
||||
bool enable;
|
||||
bool camera_root_update;
|
||||
bool visible;
|
||||
bool repeat;
|
||||
bool field_C;
|
||||
bool ended;
|
||||
bool left_right_reverse;
|
||||
bool once;
|
||||
mat4 mat;
|
||||
float_t alpha;
|
||||
mdl::ObjFlags obj_flags;
|
||||
bool field_58;
|
||||
prj::map<uint32_t, uint32_t> field_60;
|
||||
prj::vector<texture_pattern_struct> texture_pattern;
|
||||
int32_t chara_id;
|
||||
object_info object_info;
|
||||
mat4* bone_mats;
|
||||
bool shadow;
|
||||
chara_index src_chara;
|
||||
chara_index dst_chara;
|
||||
int32_t pos;
|
||||
int64_t field_A8;
|
||||
void* frame_rate; // FrameRateControl
|
||||
float_t frame;
|
||||
float_t req_frame;
|
||||
float_t max_frame;
|
||||
bool frame_changed;
|
||||
float_t frame_offset;
|
||||
float_t last_frame;
|
||||
float_t fov_scale;
|
||||
prj::vector<auth_3d_object_hrc*>* field_D8;
|
||||
float_t blend;
|
||||
int64_t field_E8;
|
||||
int64_t field_F0;
|
||||
bool paused;
|
||||
prj::vector<struct auth_3d_event*> event;
|
||||
prj::vector<auth_3d_time_event> event_time;
|
||||
auth_3d_time_event* event_time_next;
|
||||
auth_3d_play_control play_control;
|
||||
prj::vector<auth_3d_point> point;
|
||||
prj::vector<auth_3d_curve> curve;
|
||||
prj::vector<auth_3d_camera_root> camera_root;
|
||||
auth_3d_camera_auxiliary camera_auxiliary;
|
||||
prj::vector<auth_3d_light> light;
|
||||
prj::vector<auth_3d_fog> fog;
|
||||
auth_3d_post_process post_process;
|
||||
auth_3d_dof dof;
|
||||
prj::vector<auth_3d_chara> chara;
|
||||
prj::vector<auth_3d_motion> motion;
|
||||
prj::vector<auth_3d_object> object;
|
||||
prj::vector<auth_3d_object*> object_list;
|
||||
prj::vector<auth_3d_object_hrc> object_hrc;
|
||||
prj::vector<auth_3d_object_hrc*> object_hrc_list;
|
||||
prj::vector<auth_3d_m_object_hrc> m_object_hrc;
|
||||
prj::vector<auth_3d_m_object_hrc*> m_object_hrc_list;
|
||||
prj::vector<std::string> field_BE0;
|
||||
prj::vector<std::string> object_list_string;
|
||||
prj::vector<std::string> object_hrc_list_string;
|
||||
prj::vector<std::string> m_object_hrc_list_string;
|
||||
prj::vector<auth_3d_auth_2d> auth_2d;
|
||||
int32_t state;
|
||||
prj::vector<struct auth_3d_event_adapter*> field_C60;
|
||||
};
|
||||
|
||||
static_assert(sizeof(auth_3d) == 0xC78, "\"auth_3d\" struct should have a size of 0xC78");
|
||||
|
||||
HOOK(void, FASTCALL, auth_3d_m_object_hrc_disp, 0x00000001401D0760, auth_3d_m_object_hrc* moh, auth_3d* auth) {
|
||||
if (!auth->visible || !moh->model_transform.visible)
|
||||
return;
|
||||
|
||||
mdl::DispManager& disp_manager = *::disp_manager;
|
||||
|
||||
for (auth_3d_object_instance& i : moh->instance) {
|
||||
if (!i.model_transform.visible)
|
||||
return;
|
||||
|
||||
mdl::ObjFlags flags = mdl::OBJ_SSS;
|
||||
shadow_type_enum shadow_type = SHADOW_CHARA;
|
||||
if (auth->shadow || i.shadow) {
|
||||
enum_or(flags, mdl::OBJ_4 | mdl::OBJ_SHADOW);
|
||||
shadow_type = SHADOW_STAGE;
|
||||
}
|
||||
if (auth->alpha < 1.0f)
|
||||
enum_or(flags, auth->obj_flags);
|
||||
|
||||
disp_manager.set_obj_flags(flags);
|
||||
disp_manager.set_shadow_type(shadow_type);
|
||||
|
||||
Shadow* shad = shadow_ptr_get();
|
||||
if (shad && flags & mdl::OBJ_SHADOW) {
|
||||
disp_manager.set_shadow_type(SHADOW_STAGE);
|
||||
|
||||
mat4* m = &moh->model_transform.mat;
|
||||
for (auth_3d_object_node& j : moh->node)
|
||||
if (j.mat) {
|
||||
m = j.mat;
|
||||
break;
|
||||
}
|
||||
|
||||
mat4 mat = i.model_transform.mat;
|
||||
mat4 t = *m;
|
||||
mat4_mul(&mat, &t, &mat);
|
||||
|
||||
vec3 pos = *(vec3*)&mat.row3;
|
||||
pos.y -= 0.2f;
|
||||
shad->field_1D0[shadow_type].push_back(pos);
|
||||
}
|
||||
|
||||
if (i.mats.size())
|
||||
disp_manager.entry_obj_by_object_info_object_skin(
|
||||
i.object_info, 0, 0, auth->alpha, i.mats.data(), 0, 0, &i.model_transform.mat);
|
||||
}
|
||||
|
||||
disp_manager.set_obj_flags();
|
||||
disp_manager.set_shadow_type(SHADOW_CHARA);
|
||||
}
|
||||
|
||||
HOOK(void, FASTCALL, auth_3d_object_hrc_disp, 0x00000001401D04A0, auth_3d_object_hrc* oh, auth_3d* auth) {
|
||||
if (!auth->visible || !oh->node.front().model_transform.visible)
|
||||
return;
|
||||
|
||||
mdl::DispManager& disp_manager = *::disp_manager;
|
||||
|
||||
mdl::ObjFlags flags = mdl::OBJ_SSS;
|
||||
if (auth->shadow | oh->shadow)
|
||||
enum_or(flags, mdl::OBJ_4 | mdl::OBJ_SHADOW);
|
||||
if (oh->reflect)
|
||||
enum_or(flags, mdl::OBJ_NO_TRANSLUCENCY | mdl::OBJ_REFLECT);
|
||||
if (oh->refract)
|
||||
enum_or(flags, mdl::OBJ_NO_TRANSLUCENCY | mdl::OBJ_REFRACT);
|
||||
if (auth->alpha < 1.0f)
|
||||
enum_or(flags, auth->obj_flags);
|
||||
|
||||
disp_manager.set_obj_flags(flags);
|
||||
disp_manager.set_shadow_type(SHADOW_CHARA);
|
||||
|
||||
mat4 mat = mat4_identity;
|
||||
if (auth->chara_id >= 0 && auth->chara_id < ROB_CHARA_COUNT) {
|
||||
size_t rob_chara_smth = get_rob_chara_smth();
|
||||
if (rob_chara_pv_data_array_check_chara_id(rob_chara_smth, auth->chara_id)) {
|
||||
size_t rob_chr = rob_chara_array_get(rob_chara_smth, auth->chara_id);
|
||||
mat4_mul(rob_chara_get_adjust_data_mat(rob_chr), sub_140516740(rob_chr), &mat);
|
||||
if (auth->chara_id)
|
||||
disp_manager.set_shadow_type(SHADOW_STAGE);
|
||||
}
|
||||
}
|
||||
else if (flags & mdl::OBJ_SHADOW) {
|
||||
disp_manager.set_shadow_type(SHADOW_STAGE);
|
||||
|
||||
mat4* m = &oh->node.front().model_transform.mat;
|
||||
for (auth_3d_object_node& i : oh->node)
|
||||
if (i.mat) {
|
||||
m = i.mat;
|
||||
break;
|
||||
}
|
||||
|
||||
Shadow* shad = shadow_ptr_get();
|
||||
if (shad) {
|
||||
vec3 pos = *(vec3*)&m->row3;
|
||||
pos.y -= 0.2f;
|
||||
shad->field_1D0[SHADOW_STAGE].push_back(pos);
|
||||
}
|
||||
}
|
||||
|
||||
if (oh->node_bone_mats.size())
|
||||
disp_manager.entry_obj_by_object_info_object_skin(
|
||||
oh->object_info, 0, 0, auth->alpha, oh->node_bone_mats.data(), 0, 0, &mat);
|
||||
|
||||
disp_manager.set_obj_flags();
|
||||
disp_manager.set_shadow_type(SHADOW_CHARA);
|
||||
|
||||
extern void FASTCALL implOfauth_3d_object_disp(auth_3d_object * o, auth_3d * auth);
|
||||
|
||||
for (auth_3d_object*& i : oh->children_object)
|
||||
implOfauth_3d_object_disp(i, auth);
|
||||
|
||||
for (auth_3d_object_hrc*& i : oh->children_object_hrc)
|
||||
implOfauth_3d_object_hrc_disp(i, auth);
|
||||
}
|
||||
|
||||
HOOK(void, FASTCALL, auth_3d_object_disp, 0x00000001401D0970, auth_3d_object* o, auth_3d* auth) {
|
||||
if (!o->model_transform.visible)
|
||||
return;
|
||||
|
||||
if (!auth->visible) {
|
||||
if (auth->pos)
|
||||
spr::put_rgb_cross(&o->model_transform.mat);
|
||||
|
||||
for (auth_3d_object*& i : o->children_object)
|
||||
implOfauth_3d_object_disp(i, auth);
|
||||
for (auth_3d_object_hrc*& i : o->children_object_hrc)
|
||||
implOfauth_3d_object_hrc_disp(i, auth);
|
||||
return;
|
||||
}
|
||||
|
||||
mat4 mat = o->model_transform.mat;
|
||||
|
||||
mdl::DispManager& disp_manager = *::disp_manager;
|
||||
|
||||
if (auth->chara_id >= 0 && auth->chara_id < ROB_CHARA_COUNT) {
|
||||
size_t rob_chara_smth = get_rob_chara_smth();
|
||||
if (rob_chara_pv_data_array_check_chara_id(rob_chara_smth, auth->chara_id)) {
|
||||
size_t rob_chr = rob_chara_array_get(rob_chara_smth, auth->chara_id);
|
||||
mat4 m;
|
||||
mat4_mul(rob_chara_get_adjust_data_mat(rob_chr), sub_140516740(rob_chr), &m);
|
||||
mat4_mul(&mat, &m, &mat);
|
||||
disp_manager.set_shadow_type(auth->chara_id ? SHADOW_STAGE : SHADOW_CHARA);
|
||||
}
|
||||
}
|
||||
|
||||
mdl::ObjFlags flags = (mdl::ObjFlags)0;
|
||||
if (auth->shadow)
|
||||
enum_or(flags, mdl::OBJ_4 | mdl::OBJ_SHADOW);
|
||||
if (o->reflect)
|
||||
enum_or(flags, mdl::OBJ_NO_TRANSLUCENCY | mdl::OBJ_REFLECT);
|
||||
if (o->refract)
|
||||
enum_or(flags, mdl::OBJ_NO_TRANSLUCENCY | mdl::OBJ_REFRACT);
|
||||
|
||||
disp_manager.set_obj_flags(flags);
|
||||
|
||||
char buf[0x80];
|
||||
int32_t tex_pat_count = 0;
|
||||
texture_pattern_struct tex_pat[TEXTURE_PATTERN_COUNT];
|
||||
|
||||
for (auth_3d_object_texture_pattern& i : o->texture_pattern) {
|
||||
if (!i.pattern.curve || i.name.size() <= 3)
|
||||
continue;
|
||||
else if (tex_pat_count >= TEXTURE_PATTERN_COUNT)
|
||||
break;
|
||||
|
||||
sprintf_s(buf, sizeof(buf), "%.*s%03d",
|
||||
(int32_t)(i.name.size() - 3), i.name.c_str(), (int32_t)prj::roundf(i.pattern.value));
|
||||
|
||||
tex_pat[tex_pat_count].src = i.texture_id;
|
||||
tex_pat[tex_pat_count].dst = texture_info_get_id(buf);
|
||||
tex_pat_count++;
|
||||
}
|
||||
|
||||
if (tex_pat_count)
|
||||
disp_manager.set_texture_pattern(tex_pat_count, tex_pat);
|
||||
|
||||
int32_t tex_trans_count = 0;
|
||||
texture_transform_struct tex_trans[TEXTURE_TRANSFORM_COUNT];
|
||||
|
||||
for (auth_3d_object_texture_transform& i : o->texture_transform) {
|
||||
if (tex_trans_count >= TEXTURE_TRANSFORM_COUNT || i.texture_id == -1
|
||||
|| !texture_handler_get_texture(i.texture_id))
|
||||
break;
|
||||
|
||||
tex_trans[tex_trans_count].id = i.texture_id;
|
||||
tex_trans[tex_trans_count].mat = i.mat;
|
||||
tex_trans_count++;
|
||||
}
|
||||
|
||||
if (tex_trans_count)
|
||||
disp_manager.set_texture_transform(tex_trans_count, tex_trans);
|
||||
|
||||
const char* uid_name = o->uid_name.c_str();
|
||||
int32_t uid_name_length = (int32_t)o->uid_name.size();
|
||||
|
||||
if (uid_name_length <= 3)
|
||||
disp_manager.entry_obj_by_object_info(&mat, o->object_info);
|
||||
else if (o->morph.curve) {
|
||||
float_t morph = o->morph.value;
|
||||
int32_t morph_int = (int32_t)morph;
|
||||
morph = fmodf(morph, 1.0f);
|
||||
if (morph > 0.0f && morph < 1.0f) {
|
||||
sprintf_s(buf, sizeof(buf), "%.*s%03d", uid_name_length - 3, uid_name, morph_int + 1);
|
||||
object_info morph_obj_info = obj_database_get_object_info(buf);
|
||||
if (morph_obj_info.is_null())
|
||||
morph_obj_info = o->object_info;
|
||||
disp_manager.set_morph(morph_obj_info, morph);
|
||||
|
||||
sprintf_s(buf, sizeof(buf), "%.*s%03d", uid_name_length - 3, uid_name, morph_int);
|
||||
object_info obj_info = obj_database_get_object_info(buf);
|
||||
if (auth->alpha < 0.999f)
|
||||
disp_manager.entry_obj_by_object_info(&mat, obj_info, auth->alpha);
|
||||
else
|
||||
disp_manager.entry_obj_by_object_info(&mat, obj_info);
|
||||
disp_manager.set_morph({}, 0.0f);
|
||||
}
|
||||
else {
|
||||
if (morph >= 1.0f)
|
||||
morph_int++;
|
||||
|
||||
sprintf_s(buf, sizeof(buf), "%.*s%03d", uid_name_length - 3, uid_name, morph_int);
|
||||
object_info obj_info = obj_database_get_object_info(buf);
|
||||
if (obj_info.is_null())
|
||||
obj_info = o->object_info;
|
||||
disp_manager.entry_obj_by_object_info(&mat, obj_info);
|
||||
}
|
||||
}
|
||||
else if (o->pattern.curve) {
|
||||
sprintf_s(buf, sizeof(buf), "%.*s%03d",
|
||||
uid_name_length - 3, uid_name, (int32_t)prj::roundf(o->pattern.value));
|
||||
object_info obj_info = obj_database_get_object_info(buf);
|
||||
disp_manager.entry_obj_by_object_info(&mat, obj_info);
|
||||
}
|
||||
else
|
||||
disp_manager.entry_obj_by_object_info(&mat, o->object_info);
|
||||
|
||||
disp_manager.set_texture_transform();
|
||||
disp_manager.set_texture_pattern();
|
||||
disp_manager.set_obj_flags();
|
||||
|
||||
if (auth->pos)
|
||||
spr::put_rgb_cross(&o->model_transform.mat);
|
||||
|
||||
for (auth_3d_object*& i : o->children_object)
|
||||
implOfauth_3d_object_disp(i, auth);
|
||||
for (auth_3d_object_hrc*& i : o->children_object_hrc)
|
||||
implOfauth_3d_object_hrc_disp(i, auth);
|
||||
}
|
||||
|
||||
void auth_3d_patch() {
|
||||
INSTALL_HOOK(auth_3d_m_object_hrc_disp);
|
||||
INSTALL_HOOK(auth_3d_object_hrc_disp);
|
||||
INSTALL_HOOK(auth_3d_object_disp);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "../KKdLib/mat.hpp"
|
||||
#include "../KKdLib/vec.hpp"
|
||||
|
||||
extern void auth_3d_patch();
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "camera.hpp"
|
||||
#include "render.hpp"
|
||||
#include "resolution_mode.hpp"
|
||||
#include <Helpers.h>
|
||||
|
||||
camera_struct* camera_data = (camera_struct*)0x0000000140FBC2C0;
|
||||
|
||||
static void (FASTCALL* camera_struct__update_view)(camera_struct* cam)
|
||||
= (void (FASTCALL*)(camera_struct * cam))0x00000001401F7690;
|
||||
|
||||
HOOK(void, FASTCALL, camera_data_update_projection, 0x00000001401F8E90) {
|
||||
resolution_struct* res_wind_int = res_window_internal_get();
|
||||
resolution_struct* res_wind = res_window_get();
|
||||
|
||||
float_t sprite_half_width = (float_t)res_wind->width * 0.5f;
|
||||
float_t sprite_half_height = (float_t)res_wind->height * 0.5f;
|
||||
float_t render_half_width = (float_t)res_wind_int->width * 0.5f;
|
||||
float_t render_half_height = (float_t)res_wind_int->height * 0.5f;
|
||||
|
||||
static float_t field_20 = tanf(atanf(tanf(0.34557518363f) * 0.75f));
|
||||
|
||||
float_t aet_depth = sprite_half_height / field_20;
|
||||
camera_data->aet_depth = aet_depth;
|
||||
|
||||
float_t fov_correct_height = sprite_half_height / tanf(camera_data->fov * 0.5f * DEG_TO_RAD_FLOAT);
|
||||
camera_data->fov_correct_height = fov_correct_height;
|
||||
|
||||
float_t v8 = (float_t)camera_data->min_distance / aet_depth;
|
||||
float_t v8a = v8 * sprite_half_width;
|
||||
float_t v8b = v8 * sprite_half_height;
|
||||
|
||||
mat4 spr_2d_proj;
|
||||
mat4_frustrum(-v8a, v8a, v8b, -v8b, camera_data->min_distance, 3000.0, &spr_2d_proj);
|
||||
|
||||
vec3 spr_2d_viewpoint = { sprite_half_width, sprite_half_height, aet_depth };
|
||||
vec3 spr_2d_interest = { sprite_half_width, sprite_half_height, 0.0f };
|
||||
vec3 spr_2d_up = { 0.0f, 1.0f, 0.0f };
|
||||
mat4 spr_2d_view;
|
||||
mat4_look_at(&spr_2d_viewpoint, &spr_2d_interest, &spr_2d_up, &spr_2d_view);
|
||||
|
||||
mat4_mul(&spr_2d_view, &spr_2d_proj, &camera_data->view_projection_aet_2d_matrix);
|
||||
mat4_transpose(&camera_data->view_projection_aet_2d_matrix,
|
||||
&camera_data->view_projection_aet_2d_matrix);
|
||||
|
||||
float_t v13c = render_half_height / tanf(camera_data->fov * 0.5f * DEG_TO_RAD_FLOAT);
|
||||
|
||||
float_t v13 = (float_t)camera_data->min_distance / v13c;
|
||||
float_t v13a = v13 * render_half_width;
|
||||
float_t v13b = v13 * render_half_height;
|
||||
|
||||
mat4 spr_3d_proj;
|
||||
mat4_frustrum(-v13a, v13a, v13b, -v13b, camera_data->min_distance, 3000.0, &spr_3d_proj);
|
||||
|
||||
vec3 spr_3d_viewpoint = { render_half_width, render_half_height, v13c };
|
||||
vec3 spr_3d_interest = { render_half_width, render_half_height, 0.0f };
|
||||
vec3 spr_3d_up = { 0.0f, 1.0f, 0.0f };
|
||||
mat4 spr_3d_view;
|
||||
mat4_look_at(&spr_3d_viewpoint, &spr_3d_interest, &spr_3d_up, &spr_3d_view);
|
||||
|
||||
mat4_mul(&spr_3d_view, &spr_3d_proj, &camera_data->view_projection_aet_3d_matrix);
|
||||
mat4_transpose(&camera_data->view_projection_aet_3d_matrix,
|
||||
&camera_data->view_projection_aet_3d_matrix);
|
||||
|
||||
render->calc_projection_matrix(&camera_data->projection_matrix,
|
||||
camera_data->fov, camera_data->aspect, camera_data->min_distance, camera_data->max_distance,
|
||||
camera_data->projection_scale.x, camera_data->projection_scale.y,
|
||||
camera_data->projection_scale.z, camera_data->projection_scale.w);
|
||||
camera_data->fov_horizontal_rad = tanf(camera_data->fov * 0.5f * DEG_TO_RAD_FLOAT);
|
||||
}
|
||||
|
||||
HOOK(void, FASTCALL, camera_update, 0x00000001401F8970) {
|
||||
implOfcamera_data_update_projection();
|
||||
camera_struct__update_view(camera_data);
|
||||
camera_data->fast_change_hist1 = camera_data->fast_change_hist0;
|
||||
camera_data->fast_change_hist0 = camera_data->fast_change;
|
||||
camera_data->fast_change = false;
|
||||
}
|
||||
|
||||
void camera_struct::update_data() {
|
||||
implOfcamera_data_update_projection();
|
||||
camera_struct__update_view(camera_data);
|
||||
}
|
||||
|
||||
void camera_patch() {
|
||||
INSTALL_HOOK(camera_data_update_projection);
|
||||
INSTALL_HOOK(camera_update);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "../KKdLib/mat.hpp"
|
||||
#include "../KKdLib/vec.hpp"
|
||||
|
||||
struct camera_struct {
|
||||
vec3 view_point;
|
||||
vec3 interest;
|
||||
float_t roll;
|
||||
float_t fov;
|
||||
float_t field_20;
|
||||
int32_t field_24;
|
||||
double_t aspect;
|
||||
float_t min_distance;
|
||||
float_t max_distance;
|
||||
vec4 projection_scale;
|
||||
bool use_up;
|
||||
char field_49;
|
||||
char field_4A;
|
||||
char field_4B;
|
||||
vec3 up;
|
||||
bool ignore_fov;
|
||||
bool ignore_min_dist;
|
||||
char field_5A;
|
||||
char field_5B;
|
||||
mat4 view_matrix;
|
||||
mat4 inv_view_matrix;
|
||||
mat4 projection_matrix;
|
||||
mat4 view_projection_matrix;
|
||||
mat4 view_projection_aet_2d_matrix;
|
||||
mat4 view_projection_aet_3d_matrix;
|
||||
float_t fov_correct_height;
|
||||
float_t aet_depth;
|
||||
vec3 field_1E4;
|
||||
vec3 field_1F0;
|
||||
vec3 field_1FC;
|
||||
vec3 field_208;
|
||||
float_t distance;
|
||||
vec3 rotation;
|
||||
float_t fov_horizontal_rad;
|
||||
char field_228;
|
||||
bool fast_change;
|
||||
bool fast_change_hist0;
|
||||
bool fast_change_hist1;
|
||||
int32_t field_22C;
|
||||
|
||||
static void update_data();
|
||||
};
|
||||
|
||||
extern camera_struct* camera_data;
|
||||
|
||||
extern void camera_patch();
|
||||
@@ -0,0 +1,6 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "color.hpp"
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "../KKdLib/vec.hpp"
|
||||
|
||||
struct color4u8 {
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
uint8_t a;
|
||||
|
||||
inline color4u8() : r(), g(), b(), a() {
|
||||
|
||||
}
|
||||
|
||||
inline color4u8(uint8_t r, uint8_t g, uint8_t b, uint8_t a) : r(r), g(g), b(b), a(a) {
|
||||
|
||||
}
|
||||
|
||||
inline color4u8(uint32_t value) {
|
||||
r = (uint8_t)(value & 0xFF);
|
||||
g = (uint8_t)((value >> 8) & 0xFF);
|
||||
b = (uint8_t)((value >> 16) & 0xFF);
|
||||
a = (uint8_t)((value >> 24) & 0xFF);
|
||||
}
|
||||
|
||||
inline color4u8(vec4 value) {
|
||||
vec4i _value = vec4i::store_xmm(_mm_cvtps_epi32(vec4::load_xmm(vec4::clamp(value, 0.0f, 1.0f) * 255.0f)));
|
||||
r = (uint8_t)_value.x;
|
||||
g = (uint8_t)_value.y;
|
||||
b = (uint8_t)_value.z;
|
||||
a = (uint8_t)_value.w;
|
||||
}
|
||||
|
||||
inline operator vec4() const {
|
||||
return vec4::store_xmm(_mm_cvtepi32_ps(vec4i::load_xmm(vec4i(r, g, b, a)))) * (1.0f / 255.0f);
|
||||
}
|
||||
};
|
||||
|
||||
struct color4u8_bgra {
|
||||
uint8_t b;
|
||||
uint8_t g;
|
||||
uint8_t r;
|
||||
uint8_t a;
|
||||
|
||||
inline color4u8_bgra() : r(), g(), b(), a() {
|
||||
|
||||
}
|
||||
|
||||
inline color4u8_bgra(uint8_t r, uint8_t g, uint8_t b, uint8_t a) : r(r), g(g), b(b), a(a) {
|
||||
|
||||
}
|
||||
|
||||
inline color4u8_bgra(uint32_t value) {
|
||||
b = (uint8_t)(value & 0xFF);
|
||||
g = (uint8_t)((value >> 8) & 0xFF);
|
||||
r = (uint8_t)((value >> 16) & 0xFF);
|
||||
a = (uint8_t)((value >> 24) & 0xFF);
|
||||
}
|
||||
|
||||
inline color4u8_bgra(vec4 value) {
|
||||
vec4i _value = vec4i::store_xmm(_mm_cvtps_epi32(vec4::load_xmm(vec4::clamp(value, 0.0f, 1.0f) * 255.0f)));
|
||||
r = (uint8_t)_value.x;
|
||||
g = (uint8_t)_value.y;
|
||||
b = (uint8_t)_value.z;
|
||||
a = (uint8_t)_value.w;
|
||||
}
|
||||
|
||||
inline operator vec4() const {
|
||||
return vec4::store_xmm(_mm_cvtepi32_ps(vec4i::load_xmm(vec4i(r, g, b, a)))) * (1.0f / 255.0f);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include <Windows.h>
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "hook.hpp"
|
||||
#include "inject.hpp"
|
||||
#include "print.hpp"
|
||||
#include "shader_table.hpp"
|
||||
#include "wrap.hpp"
|
||||
#include <intrin.h>
|
||||
#include <knownfolders.h>
|
||||
#include <shlobj_core.h>
|
||||
|
||||
size_t diva_handle;
|
||||
size_t glut_handle;
|
||||
size_t opengl32_handle;
|
||||
size_t dll_handle;
|
||||
bool aes_ni;
|
||||
bool f16c;
|
||||
|
||||
#if defined(DINPUT8_DLL)
|
||||
struct dinput8 {
|
||||
HMODULE dll;
|
||||
HRESULT(*DirectInput8Create)(HINSTANCE hinst,
|
||||
DWORD dwVersion, REFIID riidltf, LPVOID* ppvOut, LPUNKNOWN punkOuter);
|
||||
|
||||
void LoadOriginalLibrary(HMODULE module) {
|
||||
dll = module;
|
||||
DirectInput8Create = (HRESULT(*)(HINSTANCE hinst, DWORD dwVersion,
|
||||
REFIID riidltf, LPVOID * ppvOut, LPUNKNOWN punkOuter))GetProcAddress(dll, "DirectInput8Create");
|
||||
}
|
||||
} dinput8;
|
||||
|
||||
extern "C" __declspec(dllexport) HRESULT DirectInput8Create(HINSTANCE hinst,
|
||||
DWORD dwVersion, REFIID riidltf, LPVOID * ppvOut, LPUNKNOWN punkOuter) {
|
||||
if (!dinput8.DirectInput8Create)
|
||||
return (HRESULT)0x80000002;
|
||||
return dinput8.DirectInput8Create(hinst, dwVersion, riidltf, ppvOut, punkOuter);
|
||||
}
|
||||
|
||||
void load_original_dll() {
|
||||
wchar_t dll_file_path[MAX_PATH];
|
||||
GetModuleFileNameW((HMODULE)dll_handle, dll_file_path, MAX_PATH);
|
||||
|
||||
wchar_t* dll_file_name = wcsrchr(dll_file_path, '\\');
|
||||
if (!dll_file_name)
|
||||
dll_file_name = wcsrchr(dll_file_path, '/');
|
||||
|
||||
if (!dll_file_name)
|
||||
return;
|
||||
|
||||
dll_file_name++;
|
||||
|
||||
_wcslwr_s(dll_file_name, MAX_PATH - (dll_file_name - dll_file_path));
|
||||
|
||||
wchar_t* sys_folder;
|
||||
if (dll_file_name && SUCCEEDED(SHGetKnownFolderPath(FOLDERID_System, 0, 0, &sys_folder))) {
|
||||
size_t dll_path_len = wcslen(sys_folder) + wcslen(dll_file_name) + 2;
|
||||
wchar_t* dll_path = (wchar_t*)malloc(sizeof(wchar_t) * dll_path_len);
|
||||
if (dll_path) {
|
||||
wcscpy_s(dll_path, dll_path_len, sys_folder);
|
||||
wcscat_s(dll_path, dll_path_len, L"\\");
|
||||
wcscat_s(dll_path, dll_path_len, dll_file_name);
|
||||
if (!wcscmp(dll_file_name, L"dinput8.dll")) {
|
||||
HMODULE dinput8_handle = LoadLibraryW(dll_path);
|
||||
if (dinput8_handle)
|
||||
dinput8.LoadOriginalLibrary(dinput8_handle);
|
||||
}
|
||||
free(dll_path);
|
||||
}
|
||||
CoTaskMemFree((LPVOID)sys_folder);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void FASTCALL divagl_main() {
|
||||
int32_t cpuid_data[4] = {};
|
||||
__cpuid(cpuid_data, 1);
|
||||
aes_ni = (cpuid_data[2] & (1 << 25)) ? true : false;
|
||||
f16c = (cpuid_data[2] & (1 << 29)) ? true : false;
|
||||
|
||||
glut_handle = (size_t)GetModuleHandleW(L"glut32.dll");
|
||||
opengl32_handle = (size_t)GetModuleHandleW(L"opengl32.dll");
|
||||
|
||||
#if defined(DINPUT8_DLL)
|
||||
load_original_dll();
|
||||
LoadLibraryW(L"N:\\DUMP\\plugins\\DivaSound.dva");
|
||||
LoadLibraryW(L"N:\\DUMP\\plugins\\TLAC.dva");
|
||||
#endif
|
||||
extern void FASTCALL wrap_addresses();
|
||||
wrap_addresses();
|
||||
//return;
|
||||
|
||||
printf_divagl("Patching memory");
|
||||
hook_funcs();
|
||||
wrap_patch();
|
||||
inject_patches();
|
||||
}
|
||||
|
||||
bool APIENTRY DllMain(HMODULE handle, DWORD ul_reason_for_call, LPVOID lpReserved) {
|
||||
switch (ul_reason_for_call) {
|
||||
case DLL_PROCESS_ATTACH:
|
||||
/*if (!GetConsoleWindow())
|
||||
AllocConsole();
|
||||
|
||||
FILE* f_stdin = 0;
|
||||
FILE* f_stdout = 0;
|
||||
freopen_s(&f_stdin, "CONIN$", "r", stdin);
|
||||
freopen_s(&f_stdout, "CONOUT$", "w", stdout);*/
|
||||
|
||||
dll_handle = (size_t)handle;
|
||||
printf_divagl("Current version - v0.1.3.0");
|
||||
printf_divagl("Attach");
|
||||
divagl_main();
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) LPCWSTR GetPluginName(void) {
|
||||
return L"DivaGL";
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) LPCWSTR GetPluginDescription(void) {
|
||||
return L"DivaGL Plugin by korenkonder";
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) LPCWSTR GetBuildDate(void) {
|
||||
return L"v0.2.0.0";
|
||||
}
|
||||
+6371
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "wrap.hpp"
|
||||
#include "gl_state.hpp"
|
||||
|
||||
struct GLArrayBuffer {
|
||||
private:
|
||||
GLuint buffer;
|
||||
|
||||
public:
|
||||
inline GLArrayBuffer() : buffer() {
|
||||
|
||||
}
|
||||
|
||||
inline ~GLArrayBuffer() {
|
||||
|
||||
}
|
||||
|
||||
inline void Bind(bool force = false) {
|
||||
gl_state_bind_array_buffer(buffer, force);
|
||||
}
|
||||
|
||||
inline void Create(size_t size) {
|
||||
if (buffer)
|
||||
return;
|
||||
|
||||
if (GL_VERSION_4_5) {
|
||||
glCreateBuffers(1, &buffer);
|
||||
glNamedBufferStorage(buffer, (GLsizeiptr)size, 0, GL_DYNAMIC_STORAGE_BIT | GL_MAP_WRITE_BIT);
|
||||
}
|
||||
else {
|
||||
glGenBuffers(1, &buffer);
|
||||
gl_state_bind_array_buffer(buffer);
|
||||
if (GL_VERSION_4_4)
|
||||
glBufferStorage(GL_ARRAY_BUFFER, (GLsizeiptr)size,
|
||||
0, GL_DYNAMIC_STORAGE_BIT | GL_MAP_WRITE_BIT);
|
||||
else
|
||||
glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)size, 0, GL_DYNAMIC_DRAW);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inline void Create(size_t size, const void* data, bool dynamic = false) {
|
||||
if (buffer)
|
||||
return;
|
||||
|
||||
if (GL_VERSION_4_5) {
|
||||
glCreateBuffers(1, &buffer);
|
||||
glNamedBufferStorage(buffer, (GLsizeiptr)size, data,
|
||||
dynamic ? GL_DYNAMIC_STORAGE_BIT | GL_MAP_WRITE_BIT : 0);
|
||||
}
|
||||
else {
|
||||
glGenBuffers(1, &buffer);
|
||||
gl_state_bind_array_buffer(buffer);
|
||||
if (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);
|
||||
}
|
||||
}
|
||||
|
||||
inline void Destroy() {
|
||||
if (buffer) {
|
||||
glDeleteBuffers(1, &buffer);
|
||||
buffer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool IsNull() {
|
||||
return !buffer;
|
||||
}
|
||||
|
||||
inline void* MapMemory() {
|
||||
if (!buffer)
|
||||
return 0;
|
||||
|
||||
void* data;
|
||||
if (GL_VERSION_4_5)
|
||||
data = glMapNamedBuffer(buffer, GL_WRITE_ONLY);
|
||||
else {
|
||||
gl_state_bind_array_buffer(buffer);
|
||||
data = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
|
||||
}
|
||||
|
||||
if (data)
|
||||
return data;
|
||||
|
||||
if (GL_VERSION_4_5)
|
||||
glUnmapNamedBuffer(buffer);
|
||||
else {
|
||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||
gl_state_bind_array_buffer(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline bool NotNull() {
|
||||
return !!buffer;
|
||||
}
|
||||
|
||||
inline void UnmapMemory() {
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
if (GL_VERSION_4_5)
|
||||
glUnmapNamedBuffer(buffer);
|
||||
else {
|
||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||
gl_state_bind_array_buffer(0);
|
||||
}
|
||||
}
|
||||
|
||||
inline void WriteMemory(size_t offset, size_t size, const void* data) {
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
if (GL_VERSION_4_5)
|
||||
glNamedBufferSubData(buffer, (GLsizeiptr)offset, (GLsizeiptr)size, data);
|
||||
else {
|
||||
gl_state_bind_array_buffer(buffer);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, (GLsizeiptr)offset, (GLsizeiptr)size, data);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void WriteMemory(T& data) {
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
if (GL_VERSION_4_5)
|
||||
glNamedBufferSubData(buffer, 0, sizeof(T), &data);
|
||||
else {
|
||||
gl_state_bind_array_buffer(buffer);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(T), &data);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "wrap.hpp"
|
||||
#include "gl_state.hpp"
|
||||
|
||||
struct GLElementArrayBuffer {
|
||||
private:
|
||||
GLuint buffer;
|
||||
|
||||
public:
|
||||
inline GLElementArrayBuffer() : buffer() {
|
||||
|
||||
}
|
||||
|
||||
inline ~GLElementArrayBuffer() {
|
||||
|
||||
}
|
||||
|
||||
inline void Bind(bool force = false) {
|
||||
gl_state_bind_element_array_buffer(buffer, force);
|
||||
}
|
||||
|
||||
inline void Create(size_t size) {
|
||||
if (buffer)
|
||||
return;
|
||||
|
||||
if (GL_VERSION_4_5) {
|
||||
glCreateBuffers(1, &buffer);
|
||||
glNamedBufferStorage(buffer, (GLsizeiptr)size, 0, GL_DYNAMIC_STORAGE_BIT | GL_MAP_WRITE_BIT);
|
||||
}
|
||||
else {
|
||||
glGenBuffers(1, &buffer);
|
||||
gl_state_bind_element_array_buffer(buffer);
|
||||
if (GL_VERSION_4_4)
|
||||
glBufferStorage(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)size,
|
||||
0, GL_DYNAMIC_STORAGE_BIT | GL_MAP_WRITE_BIT);
|
||||
else
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)size, 0, GL_DYNAMIC_DRAW);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inline void Create(size_t size, const void* data, bool dynamic = false) {
|
||||
if (buffer)
|
||||
return;
|
||||
|
||||
if (GL_VERSION_4_5) {
|
||||
glCreateBuffers(1, &buffer);
|
||||
glNamedBufferStorage(buffer, (GLsizeiptr)size, data,
|
||||
dynamic ? GL_DYNAMIC_STORAGE_BIT | GL_MAP_WRITE_BIT : 0);
|
||||
}
|
||||
else {
|
||||
glGenBuffers(1, &buffer);
|
||||
gl_state_bind_element_array_buffer(buffer);
|
||||
if (GL_VERSION_4_4)
|
||||
glBufferStorage(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)size, data,
|
||||
dynamic ? GL_DYNAMIC_STORAGE_BIT | GL_MAP_WRITE_BIT : 0);
|
||||
else
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)size, data,
|
||||
dynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW);
|
||||
}
|
||||
}
|
||||
|
||||
inline void Destroy() {
|
||||
if (buffer) {
|
||||
glDeleteBuffers(1, &buffer);
|
||||
buffer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool IsNull() {
|
||||
return !buffer;
|
||||
}
|
||||
|
||||
inline void* MapMemory() {
|
||||
if (!buffer)
|
||||
return 0;
|
||||
|
||||
void* data;
|
||||
if (GL_VERSION_4_5)
|
||||
data = glMapNamedBuffer(buffer, GL_WRITE_ONLY);
|
||||
else {
|
||||
gl_state_bind_element_array_buffer(buffer);
|
||||
data = glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY);
|
||||
}
|
||||
|
||||
if (data)
|
||||
return data;
|
||||
|
||||
if (GL_VERSION_4_5)
|
||||
glUnmapNamedBuffer(buffer);
|
||||
else {
|
||||
glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER);
|
||||
gl_state_bind_element_array_buffer(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline bool NotNull() {
|
||||
return !!buffer;
|
||||
}
|
||||
|
||||
inline void UnmapMemory() {
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
if (GL_VERSION_4_5)
|
||||
glUnmapNamedBuffer(buffer);
|
||||
else {
|
||||
glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER);
|
||||
gl_state_bind_element_array_buffer(0);
|
||||
}
|
||||
}
|
||||
|
||||
inline void WriteMemory(size_t offset, size_t size, const void* data) {
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
if (GL_VERSION_4_5)
|
||||
glNamedBufferSubData(buffer, (GLsizeiptr)offset, (GLsizeiptr)size, data);
|
||||
else {
|
||||
gl_state_bind_element_array_buffer(buffer);
|
||||
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)offset, (GLsizeiptr)size, data);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void WriteMemory(T& data) {
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
if (GL_VERSION_4_5)
|
||||
glNamedBufferSubData(buffer, 0, sizeof(T), &data);
|
||||
else {
|
||||
gl_state_bind_element_array_buffer(buffer);
|
||||
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(T), &data);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "wrap.hpp"
|
||||
#include "gl_state.hpp"
|
||||
|
||||
struct GLShaderStorageBuffer {
|
||||
private:
|
||||
GLuint buffer;
|
||||
|
||||
public:
|
||||
inline GLShaderStorageBuffer() : buffer() {
|
||||
|
||||
}
|
||||
|
||||
inline ~GLShaderStorageBuffer() {
|
||||
|
||||
}
|
||||
|
||||
inline void Bind(int32_t index, bool force = false) {
|
||||
gl_state_bind_shader_storage_buffer_base(index, buffer, force);
|
||||
}
|
||||
|
||||
inline void Create(size_t size) {
|
||||
if (buffer)
|
||||
return;
|
||||
|
||||
if (GL_VERSION_4_5) {
|
||||
glCreateBuffers(1, &buffer);
|
||||
glNamedBufferStorage(buffer, (GLsizeiptr)size, 0, GL_DYNAMIC_STORAGE_BIT | GL_MAP_WRITE_BIT);
|
||||
}
|
||||
else {
|
||||
glGenBuffers(1, &buffer);
|
||||
gl_state_bind_shader_storage_buffer(buffer);
|
||||
if (GL_VERSION_4_4)
|
||||
glBufferStorage(GL_SHADER_STORAGE_BUFFER, (GLsizeiptr)size,
|
||||
0, GL_DYNAMIC_STORAGE_BIT | GL_MAP_WRITE_BIT);
|
||||
else
|
||||
glBufferData(GL_SHADER_STORAGE_BUFFER, (GLsizeiptr)size, 0, GL_DYNAMIC_DRAW);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inline void Create(size_t size, const void* data, bool dynamic = false) {
|
||||
if (buffer)
|
||||
return;
|
||||
|
||||
if (GL_VERSION_4_5) {
|
||||
glCreateBuffers(1, &buffer);
|
||||
glNamedBufferStorage(buffer, (GLsizeiptr)size, data,
|
||||
dynamic ? GL_DYNAMIC_STORAGE_BIT | GL_MAP_WRITE_BIT : 0);
|
||||
}
|
||||
else {
|
||||
glGenBuffers(1, &buffer);
|
||||
gl_state_bind_shader_storage_buffer(buffer);
|
||||
if (GL_VERSION_4_4)
|
||||
glBufferStorage(GL_SHADER_STORAGE_BUFFER, (GLsizeiptr)size, data,
|
||||
dynamic ? GL_DYNAMIC_STORAGE_BIT | GL_MAP_WRITE_BIT : 0);
|
||||
else
|
||||
glBufferData(GL_SHADER_STORAGE_BUFFER, (GLsizeiptr)size, data,
|
||||
dynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW);
|
||||
}
|
||||
}
|
||||
|
||||
inline void Destroy() {
|
||||
if (buffer) {
|
||||
glDeleteBuffers(1, &buffer);
|
||||
buffer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool IsNull() {
|
||||
return !buffer;
|
||||
}
|
||||
|
||||
inline void* MapMemory() {
|
||||
if (!buffer)
|
||||
return 0;
|
||||
|
||||
void* data;
|
||||
if (GL_VERSION_4_5)
|
||||
data = glMapNamedBuffer(buffer, GL_WRITE_ONLY);
|
||||
else {
|
||||
gl_state_bind_shader_storage_buffer(buffer);
|
||||
data = glMapBuffer(GL_SHADER_STORAGE_BUFFER, GL_WRITE_ONLY);
|
||||
}
|
||||
|
||||
if (data)
|
||||
return data;
|
||||
|
||||
if (GL_VERSION_4_5)
|
||||
glUnmapNamedBuffer(buffer);
|
||||
else {
|
||||
glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);
|
||||
gl_state_bind_shader_storage_buffer(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline bool NotNull() {
|
||||
return !!buffer;
|
||||
}
|
||||
|
||||
inline void UnmapMemory() {
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
if (GL_VERSION_4_5)
|
||||
glUnmapNamedBuffer(buffer);
|
||||
else {
|
||||
glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);
|
||||
gl_state_bind_shader_storage_buffer(0);
|
||||
}
|
||||
}
|
||||
|
||||
inline void WriteMemory(size_t offset, size_t size, const void* data) {
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
if (GL_VERSION_4_5)
|
||||
glNamedBufferSubData(buffer, (GLsizeiptr)offset, (GLsizeiptr)size, data);
|
||||
else {
|
||||
gl_state_bind_shader_storage_buffer(buffer);
|
||||
glBufferSubData(GL_SHADER_STORAGE_BUFFER, (GLsizeiptr)offset, (GLsizeiptr)size, data);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void WriteMemory(T& data) {
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
if (GL_VERSION_4_5)
|
||||
glNamedBufferSubData(buffer, 0, sizeof(T), &data);
|
||||
else {
|
||||
gl_state_bind_shader_storage_buffer(buffer);
|
||||
glBufferSubData(GL_SHADER_STORAGE_BUFFER, 0, sizeof(T), &data);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,489 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "gl_state.hpp"
|
||||
#include "wrap.hpp"
|
||||
|
||||
gl_state_struct gl_state;
|
||||
|
||||
void gl_state_active_bind_texture_2d(int32_t index, GLuint texture, bool force) {
|
||||
if (force || gl_state.texture_binding_2d[index] != texture) {
|
||||
if (force || gl_state.active_texture_index != index) {
|
||||
glActiveTexture((GLenum)(GL_TEXTURE0 + index));
|
||||
gl_state.active_texture = (GLenum)(GL_TEXTURE0 + index);
|
||||
gl_state.active_texture_index = (GLuint)index;
|
||||
}
|
||||
glBindTextureDLL(GL_TEXTURE_2D, texture);
|
||||
gl_state.texture_binding_2d[index] = texture;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_active_bind_texture_cube_map(int32_t index, GLuint texture, bool force) {
|
||||
if (force || gl_state.texture_binding_cube_map[index] != texture) {
|
||||
if (force || gl_state.active_texture_index != index) {
|
||||
glActiveTexture((GLenum)(GL_TEXTURE0 + index));
|
||||
gl_state.active_texture = (GLenum)(GL_TEXTURE0 + index);
|
||||
gl_state.active_texture_index = (GLuint)index;
|
||||
}
|
||||
glBindTextureDLL(GL_TEXTURE_CUBE_MAP, texture);
|
||||
gl_state.texture_binding_cube_map[index] = texture;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_active_texture(size_t index, bool force) {
|
||||
if (force || gl_state.active_texture_index != index) {
|
||||
glActiveTexture((GLenum)(GL_TEXTURE0 + index));
|
||||
gl_state.active_texture = (GLenum)(GL_TEXTURE0 + index);
|
||||
gl_state.active_texture_index = (GLuint)index;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_bind_framebuffer(GLuint framebuffer, bool force) {
|
||||
if (force || gl_state.read_framebuffer_binding != framebuffer
|
||||
|| gl_state.draw_framebuffer_binding != framebuffer) {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
|
||||
gl_state.read_framebuffer_binding = framebuffer;
|
||||
gl_state.draw_framebuffer_binding = framebuffer;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_bind_read_framebuffer(GLuint framebuffer, bool force) {
|
||||
if (force || gl_state.read_framebuffer_binding != framebuffer) {
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer);
|
||||
gl_state.read_framebuffer_binding = framebuffer;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_bind_draw_framebuffer(GLuint framebuffer, bool force) {
|
||||
if (force || gl_state.draw_framebuffer_binding != framebuffer) {
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer);
|
||||
gl_state.draw_framebuffer_binding = framebuffer;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_bind_vertex_array(GLuint array, bool force) {
|
||||
if (force || gl_state.vertex_array_binding != array) {
|
||||
glBindVertexArray(array);
|
||||
gl_state.vertex_array_binding = array;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_bind_array_buffer(GLuint buffer, bool force) {
|
||||
if (force || gl_state.array_buffer_binding != buffer) {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
||||
gl_state.array_buffer_binding = buffer;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_bind_element_array_buffer(GLuint buffer, bool force) {
|
||||
if (force || gl_state.element_array_buffer_binding != buffer) {
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer);
|
||||
gl_state.element_array_buffer_binding = buffer;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_bind_uniform_buffer(GLuint buffer, bool force) {
|
||||
if (force || gl_state.uniform_buffer_binding != buffer) {
|
||||
glBindBuffer(GL_UNIFORM_BUFFER, buffer);
|
||||
gl_state.uniform_buffer_binding = buffer;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_bind_uniform_buffer_base(GLuint index, GLuint buffer, bool force) {
|
||||
if (force || gl_state.uniform_buffer_bindings[index] != buffer) {
|
||||
glBindBufferBase(GL_UNIFORM_BUFFER, index, buffer);
|
||||
gl_state.uniform_buffer_bindings[index] = buffer;
|
||||
gl_state.uniform_buffer_offsets[index] = 0;
|
||||
gl_state.uniform_buffer_sizes[index] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_bind_uniform_buffer_range(GLuint index,
|
||||
GLuint buffer, GLintptr offset, GLsizeiptr size, bool force) {
|
||||
if (force || gl_state.uniform_buffer_bindings[index] != buffer
|
||||
|| gl_state.uniform_buffer_offsets[index] != offset
|
||||
|| gl_state.uniform_buffer_sizes[index] != size) {
|
||||
glBindBufferRange(GL_UNIFORM_BUFFER, index, buffer, offset, size);
|
||||
gl_state.uniform_buffer_bindings[index] = buffer;
|
||||
gl_state.uniform_buffer_offsets[index] = offset;
|
||||
gl_state.uniform_buffer_sizes[index] = size;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_bind_shader_storage_buffer(GLuint buffer, bool force) {
|
||||
if (force || gl_state.shader_storage_buffer_binding != buffer) {
|
||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, buffer);
|
||||
gl_state.shader_storage_buffer_binding = buffer;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_bind_shader_storage_buffer_base(GLuint index, GLuint buffer, bool force) {
|
||||
if (force || gl_state.shader_storage_buffer_bindings[index] != buffer) {
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, index, buffer);
|
||||
gl_state.shader_storage_buffer_bindings[index] = buffer;
|
||||
gl_state.shader_storage_buffer_offsets[index] = 0;
|
||||
gl_state.shader_storage_buffer_sizes[index] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_bind_shader_storage_buffer_range(GLuint index,
|
||||
GLuint buffer, GLintptr offset, GLsizeiptr size, bool force) {
|
||||
if (force || gl_state.shader_storage_buffer_bindings[index] != buffer
|
||||
|| gl_state.shader_storage_buffer_offsets[index] != offset
|
||||
|| gl_state.shader_storage_buffer_sizes[index] != size) {
|
||||
glBindBufferRange(GL_SHADER_STORAGE_BUFFER, index, buffer, offset, size);
|
||||
gl_state.shader_storage_buffer_bindings[index] = buffer;
|
||||
gl_state.shader_storage_buffer_offsets[index] = offset;
|
||||
gl_state.shader_storage_buffer_sizes[index] = size;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_bind_texture_2d(GLuint texture, bool force) {
|
||||
if (gl_state.texture_binding_2d[gl_state.active_texture_index] != texture) {
|
||||
glBindTextureDLL(GL_TEXTURE_2D, texture);
|
||||
gl_state.texture_binding_2d[gl_state.active_texture_index] = texture;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_bind_texture_cube_map(GLuint texture, bool force) {
|
||||
if (force || gl_state.texture_binding_cube_map[gl_state.active_texture_index] != texture) {
|
||||
glBindTextureDLL(GL_TEXTURE_CUBE_MAP, texture);
|
||||
gl_state.texture_binding_cube_map[gl_state.active_texture_index] = texture;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_bind_sampler(int32_t index, GLuint sampler, bool force) {
|
||||
if (force || gl_state.sampler_binding[index] != sampler) {
|
||||
glBindSampler(index, sampler);
|
||||
gl_state.sampler_binding[index] = sampler;
|
||||
}
|
||||
}
|
||||
|
||||
bool gl_state_check_uniform_buffer_binding() {
|
||||
return gl_state.uniform_buffer_binding != 0;
|
||||
}
|
||||
|
||||
bool gl_state_check_uniform_buffer_binding_base(size_t index) {
|
||||
return gl_state.uniform_buffer_bindings[index] != 0;
|
||||
}
|
||||
|
||||
bool gl_state_check_texture_binding_2d(size_t index) {
|
||||
return gl_state.texture_binding_2d[index] != 0;
|
||||
}
|
||||
|
||||
bool gl_state_check_shader_storage_buffer_binding() {
|
||||
return gl_state.shader_storage_buffer_binding != 0;
|
||||
}
|
||||
|
||||
bool gl_state_check_shader_storage_buffer_binding_base(size_t index) {
|
||||
return gl_state.shader_storage_buffer_bindings[index] != 0;
|
||||
}
|
||||
|
||||
bool gl_state_check_texture_binding_cube_map(size_t index) {
|
||||
return gl_state.texture_binding_cube_map[index] != 0;
|
||||
}
|
||||
|
||||
bool gl_state_check_sampler_binding(int32_t index, GLuint sampler) {
|
||||
return gl_state.sampler_binding[index] != 0;
|
||||
}
|
||||
|
||||
void gl_state_disable_blend(bool force) {
|
||||
if (force || gl_state.blend) {
|
||||
glDisableDLL(GL_BLEND);
|
||||
gl_state.blend = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_disable_cull_face(bool force) {
|
||||
if (force || gl_state.cull_face) {
|
||||
glDisableDLL(GL_CULL_FACE);
|
||||
gl_state.cull_face = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_disable_depth_test(bool force) {
|
||||
if (force || gl_state.depth_test) {
|
||||
glDisableDLL(GL_DEPTH_TEST);
|
||||
gl_state.depth_test = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_disable_multisample(bool force) {
|
||||
if (force || gl_state.multisample) {
|
||||
glDisableDLL(GL_MULTISAMPLE);
|
||||
gl_state.multisample = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_disable_primitive_restart(bool force) {
|
||||
if (force || gl_state.primitive_restart) {
|
||||
glDisableDLL(GL_PRIMITIVE_RESTART);
|
||||
gl_state.primitive_restart = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_disable_scissor_test(bool force) {
|
||||
if (force || gl_state.scissor_test) {
|
||||
glDisableDLL(GL_SCISSOR_TEST);
|
||||
gl_state.scissor_test = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_disable_stencil_test(bool force) {
|
||||
if (force || gl_state.stencil_test) {
|
||||
glDisableDLL(GL_STENCIL_TEST);
|
||||
gl_state.stencil_test = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_enable_blend(bool force) {
|
||||
if (force || !gl_state.blend) {
|
||||
glEnableDLL(GL_BLEND);
|
||||
gl_state.blend = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_enable_cull_face(bool force) {
|
||||
if (force || !gl_state.cull_face) {
|
||||
glEnableDLL(GL_CULL_FACE);
|
||||
gl_state.cull_face = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_enable_depth_test(bool force) {
|
||||
if (force || !gl_state.depth_test) {
|
||||
glEnableDLL(GL_DEPTH_TEST);
|
||||
gl_state.depth_test = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_enable_multisample(bool force) {
|
||||
if (force || !gl_state.multisample) {
|
||||
glEnableDLL(GL_MULTISAMPLE);
|
||||
gl_state.multisample = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_enable_primitive_restart(bool force) {
|
||||
if (force || !gl_state.primitive_restart) {
|
||||
glEnableDLL(GL_PRIMITIVE_RESTART);
|
||||
gl_state.primitive_restart = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_enable_scissor_test(bool force) {
|
||||
if (force || !gl_state.scissor_test) {
|
||||
glEnableDLL(GL_SCISSOR_TEST);
|
||||
gl_state.scissor_test = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_enable_stencil_test(bool force) {
|
||||
if (force || !gl_state.stencil_test) {
|
||||
glEnableDLL(GL_STENCIL_TEST);
|
||||
gl_state.stencil_test = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_get() {
|
||||
glGetIntegervDLL(GL_CURRENT_PROGRAM, &gl_state.program);
|
||||
glGetIntegervDLL(GL_ACTIVE_TEXTURE, (GLint*)&gl_state.active_texture);
|
||||
gl_state.active_texture_index = gl_state.active_texture - GL_TEXTURE0;
|
||||
for (GLuint i = 0; i < 32; i++) {
|
||||
glActiveTexture((GLenum)(GL_TEXTURE0 + i));
|
||||
glGetIntegervDLL(GL_TEXTURE_BINDING_2D, &gl_state.texture_binding_2d[i]);
|
||||
glGetIntegervDLL(GL_TEXTURE_BINDING_CUBE_MAP, &gl_state.texture_binding_cube_map[i]);
|
||||
glGetIntegeri_v(GL_SAMPLER_BINDING, i, &gl_state.sampler_binding[i]);
|
||||
}
|
||||
glActiveTexture(gl_state.active_texture);
|
||||
|
||||
glGetBooleanvDLL(GL_BLEND, &gl_state.blend);
|
||||
glGetIntegervDLL(GL_BLEND_SRC_RGB, (GLint*)&gl_state.blend_src_rgb);
|
||||
glGetIntegervDLL(GL_BLEND_SRC_ALPHA, (GLint*)&gl_state.blend_src_alpha);
|
||||
glGetIntegervDLL(GL_BLEND_DST_RGB, (GLint*)&gl_state.blend_dst_rgb);
|
||||
glGetIntegervDLL(GL_BLEND_DST_ALPHA, (GLint*)&gl_state.blend_dst_alpha);
|
||||
glGetIntegervDLL(GL_BLEND_EQUATION_RGB, (GLint*)&gl_state.blend_mode_rgb);
|
||||
glGetIntegervDLL(GL_BLEND_EQUATION_ALPHA, (GLint*)&gl_state.blend_mode_alpha);
|
||||
|
||||
glGetIntegervDLL(GL_READ_FRAMEBUFFER_BINDING, (GLint*)&gl_state.read_framebuffer_binding);
|
||||
glGetIntegervDLL(GL_DRAW_FRAMEBUFFER_BINDING, (GLint*)&gl_state.draw_framebuffer_binding);
|
||||
glGetIntegervDLL(GL_VERTEX_ARRAY_BINDING, (GLint*)&gl_state.vertex_array_binding);
|
||||
glGetIntegervDLL(GL_ARRAY_BUFFER_BINDING, (GLint*)&gl_state.array_buffer_binding);
|
||||
glGetIntegervDLL(GL_ELEMENT_ARRAY_BUFFER_BINDING, (GLint*)&gl_state.element_array_buffer_binding);
|
||||
|
||||
glGetIntegervDLL(GL_UNIFORM_BUFFER_BINDING, (GLint*)&gl_state.uniform_buffer_binding);
|
||||
for (GLuint i = 0; i < 14; i++) {
|
||||
glGetIntegeri_v(GL_UNIFORM_BUFFER_BINDING, i, (GLint*)&gl_state.uniform_buffer_bindings[i]);
|
||||
glGetIntegeri_v(GL_UNIFORM_BUFFER_START, i, (GLint*)&gl_state.uniform_buffer_offsets[i]);
|
||||
glGetIntegeri_v(GL_UNIFORM_BUFFER_SIZE, i, (GLint*)&gl_state.uniform_buffer_sizes[i]);
|
||||
}
|
||||
|
||||
glGetIntegervDLL(GL_SHADER_STORAGE_BUFFER_BINDING, (GLint*)&gl_state.shader_storage_buffer_binding);
|
||||
for (GLuint i = 0; i < 14; i++) {
|
||||
glGetIntegeri_v(GL_SHADER_STORAGE_BUFFER_BINDING, i, (GLint*)&gl_state.shader_storage_buffer_bindings[i]);
|
||||
glGetIntegeri_v(GL_SHADER_STORAGE_BUFFER_START, i, (GLint*)&gl_state.shader_storage_buffer_offsets[i]);
|
||||
glGetIntegeri_v(GL_SHADER_STORAGE_BUFFER_SIZE, i, (GLint*)&gl_state.shader_storage_buffer_sizes[i]);
|
||||
}
|
||||
|
||||
glGetBooleanvDLL(GL_COLOR_WRITEMASK, gl_state.color_mask);
|
||||
glGetBooleanvDLL(GL_CULL_FACE, &gl_state.cull_face);
|
||||
glGetIntegervDLL(GL_CULL_FACE_MODE, (GLint*)&gl_state.cull_face_mode);
|
||||
glGetBooleanvDLL(GL_DEPTH_TEST, &gl_state.depth_test);
|
||||
glGetIntegervDLL(GL_DEPTH_FUNC, (GLint*)&gl_state.depth_func);
|
||||
glGetBooleanvDLL(GL_DEPTH_WRITEMASK, &gl_state.depth_mask);
|
||||
glGetBooleanvDLL(GL_MULTISAMPLE, &gl_state.multisample);
|
||||
glGetBooleanvDLL(GL_PRIMITIVE_RESTART, &gl_state.primitive_restart);
|
||||
glGetIntegervDLL(GL_PRIMITIVE_RESTART_INDEX, (GLint*)&gl_state.primitive_restart_index);
|
||||
glGetBooleanvDLL(GL_SCISSOR_TEST, &gl_state.scissor_test);
|
||||
glGetBooleanvDLL(GL_STENCIL_TEST, &gl_state.stencil_test);
|
||||
glGetIntegervDLL(GL_STENCIL_WRITEMASK, (GLint*)&gl_state.stencil_mask);
|
||||
|
||||
glPolygonModeDLL(GL_FRONT_AND_BACK, GL_FILL);
|
||||
gl_state.polygon_front_face_mode = GL_FILL;
|
||||
gl_state.polygon_back_face_mode = GL_FILL;
|
||||
}
|
||||
|
||||
void gl_state_get_all_gl_errors() {
|
||||
GLenum error;
|
||||
while (error = glGetErrorDLL())
|
||||
printf_debug("GL Error: 0x%04X\n", error);
|
||||
}
|
||||
|
||||
GLenum gl_state_get_error() {
|
||||
GLenum error = glGetErrorDLL();
|
||||
if (error)
|
||||
printf_debug("GL Error: 0x%04X\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
GLuint gl_state_get_program() {
|
||||
return gl_state.program;
|
||||
}
|
||||
|
||||
void gl_state_set_blend_func(GLenum src, GLenum dst, bool force) {
|
||||
if (force || gl_state.blend_src_rgb != src || gl_state.blend_dst_rgb != dst
|
||||
|| gl_state.blend_src_alpha != GL_ONE || gl_state.blend_dst_alpha != GL_ONE_MINUS_SRC_ALPHA) {
|
||||
glBlendFuncSeparate(src, dst, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
gl_state.blend_src_rgb = src;
|
||||
gl_state.blend_dst_rgb = dst;
|
||||
gl_state.blend_src_alpha = GL_ONE;
|
||||
gl_state.blend_dst_alpha = GL_ONE_MINUS_SRC_ALPHA;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_set_blend_func_separate(GLenum src_rgb, GLenum dst_rgb,
|
||||
GLenum src_alpha, GLenum dst_alpha, bool force) {
|
||||
if (force || gl_state.blend_src_rgb != src_rgb || gl_state.blend_dst_rgb != dst_rgb
|
||||
|| gl_state.blend_src_alpha != src_alpha || gl_state.blend_dst_alpha != dst_alpha) {
|
||||
glBlendFuncSeparate(src_rgb, dst_rgb, src_alpha, dst_alpha);
|
||||
gl_state.blend_src_rgb = src_rgb;
|
||||
gl_state.blend_dst_rgb = dst_rgb;
|
||||
gl_state.blend_src_alpha = src_alpha;
|
||||
gl_state.blend_dst_alpha = dst_alpha;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_set_blend_equation(GLenum mode, bool force) {
|
||||
if (force || gl_state.blend_mode_rgb != mode || gl_state.blend_mode_alpha != mode) {
|
||||
glBlendEquationSeparate(mode, mode);
|
||||
gl_state.blend_mode_rgb = mode;
|
||||
gl_state.blend_mode_alpha = mode;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_set_blend_equation_separate(GLenum mode_rgb, GLenum mode_alpha, bool force) {
|
||||
if (force || gl_state.blend_mode_rgb != mode_rgb || gl_state.blend_mode_alpha != mode_alpha) {
|
||||
glBlendEquationSeparate(mode_rgb, mode_alpha);
|
||||
gl_state.blend_mode_rgb = mode_rgb;
|
||||
gl_state.blend_mode_alpha = mode_alpha;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_set_color_mask(GLboolean red, GLboolean green,
|
||||
GLboolean blue, GLboolean alpha, bool force) {
|
||||
if (force || gl_state.color_mask[0] != red || gl_state.color_mask[1] != green
|
||||
|| gl_state.color_mask[2] != blue || gl_state.color_mask[3] != alpha) {
|
||||
glColorMaskDLL(red, green, blue, alpha);
|
||||
gl_state.color_mask[0] = red;
|
||||
gl_state.color_mask[1] = green;
|
||||
gl_state.color_mask[2] = blue;
|
||||
gl_state.color_mask[3] = alpha;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_set_cull_face_mode(GLenum mode, bool force) {
|
||||
if (force || gl_state.cull_face_mode != mode) {
|
||||
glCullFaceDLL(mode);
|
||||
gl_state.cull_face_mode = mode;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_set_depth_func(GLenum func, bool force) {
|
||||
if (force || gl_state.depth_func != func) {
|
||||
glDepthFuncDLL(func);
|
||||
gl_state.depth_func = func;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_set_depth_mask(GLboolean flag, bool force) {
|
||||
if (force || gl_state.depth_mask != flag) {
|
||||
glDepthMaskDLL(flag);
|
||||
gl_state.depth_mask = flag;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_set_polygon_mode(GLenum face, GLenum mode, bool force) {
|
||||
switch (face) {
|
||||
case GL_FRONT:
|
||||
if (force || gl_state.polygon_front_face_mode != mode) {
|
||||
glPolygonModeDLL(GL_FRONT, mode);
|
||||
gl_state.polygon_front_face_mode = mode;
|
||||
}
|
||||
break;
|
||||
case GL_BACK:
|
||||
if (force || gl_state.polygon_back_face_mode != mode) {
|
||||
glPolygonModeDLL(GL_BACK, mode);
|
||||
gl_state.polygon_back_face_mode = mode;
|
||||
}
|
||||
break;
|
||||
case GL_FRONT_AND_BACK:
|
||||
if (force || gl_state.polygon_front_face_mode != mode
|
||||
&& gl_state.polygon_back_face_mode != mode) {
|
||||
glPolygonModeDLL(GL_FRONT_AND_BACK, mode);
|
||||
gl_state.polygon_front_face_mode = mode;
|
||||
gl_state.polygon_back_face_mode = mode;
|
||||
}
|
||||
else if (gl_state.polygon_front_face_mode != mode) {
|
||||
glPolygonModeDLL(GL_FRONT, mode);
|
||||
gl_state.polygon_front_face_mode = mode;
|
||||
}
|
||||
else if (gl_state.polygon_back_face_mode != mode) {
|
||||
glPolygonModeDLL(GL_BACK, mode);
|
||||
gl_state.polygon_back_face_mode = mode;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_set_primitive_restart_index(GLuint index, bool force) {
|
||||
if (force || gl_state.primitive_restart_index != index) {
|
||||
glPrimitiveRestartIndex(index);
|
||||
gl_state.primitive_restart_index = index;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_set_stencil_mask(GLuint mask, bool force) {
|
||||
if (force || gl_state.stencil_mask != mask) {
|
||||
glStencilMask(mask);
|
||||
gl_state.stencil_mask = mask;
|
||||
}
|
||||
}
|
||||
|
||||
void gl_state_use_program(GLuint program, bool force) {
|
||||
if (force || gl_state.program != program) {
|
||||
glUseProgram(program);
|
||||
gl_state.program = program;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "wrap.hpp"
|
||||
|
||||
struct gl_state_struct {
|
||||
GLint program;
|
||||
GLenum active_texture;
|
||||
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 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;
|
||||
GLenum polygon_front_face_mode;
|
||||
GLenum polygon_back_face_mode;
|
||||
GLboolean multisample;
|
||||
GLboolean primitive_restart;
|
||||
GLuint primitive_restart_index;
|
||||
GLboolean scissor_test;
|
||||
GLboolean stencil_test;
|
||||
GLuint stencil_mask;
|
||||
};
|
||||
|
||||
extern gl_state_struct gl_state;
|
||||
|
||||
extern void gl_state_active_bind_texture_2d(int32_t index, GLuint texture, bool force = false);
|
||||
extern void gl_state_active_bind_texture_cube_map(int32_t index, GLuint texture, bool force = false);
|
||||
extern void gl_state_active_texture(size_t index, bool force = false);
|
||||
extern void gl_state_bind_framebuffer(GLuint framebuffer, bool force = false);
|
||||
extern void gl_state_bind_read_framebuffer(GLuint framebuffer, bool force = false);
|
||||
extern void gl_state_bind_draw_framebuffer(GLuint framebuffer, bool force = false);
|
||||
extern void gl_state_bind_vertex_array(GLuint array, bool force = false);
|
||||
extern void gl_state_bind_array_buffer(GLuint buffer, bool force = false);
|
||||
extern void gl_state_bind_element_array_buffer(GLuint buffer, bool force = false);
|
||||
extern void gl_state_bind_uniform_buffer(GLuint buffer, bool force = false);
|
||||
extern void gl_state_bind_uniform_buffer_base(GLuint index, GLuint buffer, bool force = false);
|
||||
extern void gl_state_bind_uniform_buffer_range(GLuint index,
|
||||
GLuint buffer, GLintptr offset, GLsizeiptr size, bool force = false);
|
||||
extern void gl_state_bind_shader_storage_buffer(GLuint buffer, bool force = false);
|
||||
extern void gl_state_bind_shader_storage_buffer_base(GLuint index, GLuint buffer, bool force = false);
|
||||
extern void gl_state_bind_shader_storage_buffer_range(GLuint index,
|
||||
GLuint buffer, GLintptr offset, GLsizeiptr size, bool force = false);
|
||||
extern void gl_state_bind_texture_2d(GLuint texture, bool force = false);
|
||||
extern void gl_state_bind_texture_cube_map(GLuint texture, bool force = false);
|
||||
extern void gl_state_bind_sampler(int32_t index, GLuint sampler, bool force = false);
|
||||
extern bool gl_state_check_uniform_buffer_binding();
|
||||
extern bool gl_state_check_uniform_buffer_binding_base(size_t index);
|
||||
extern bool gl_state_check_shader_storage_buffer_binding();
|
||||
extern bool gl_state_check_shader_storage_buffer_binding_base(size_t index);
|
||||
extern bool gl_state_check_texture_binding_2d(size_t index);
|
||||
extern bool gl_state_check_texture_binding_cube_map(size_t index);
|
||||
extern bool gl_state_check_sampler_binding(int32_t index, GLuint sampler);
|
||||
extern void gl_state_disable_blend(bool force = false);
|
||||
extern void gl_state_disable_cull_face(bool force = false);
|
||||
extern void gl_state_disable_depth_test(bool force = false);
|
||||
extern void gl_state_disable_multisample(bool force = false);
|
||||
extern void gl_state_disable_primitive_restart(bool force = false);
|
||||
extern void gl_state_disable_scissor_test(bool force = false);
|
||||
extern void gl_state_disable_stencil_test(bool force = false);
|
||||
extern void gl_state_enable_blend(bool force = false);
|
||||
extern void gl_state_enable_cull_face(bool force = false);
|
||||
extern void gl_state_enable_depth_test(bool force = false);
|
||||
extern void gl_state_enable_multisample(bool force = false);
|
||||
extern void gl_state_enable_primitive_restart(bool force = false);
|
||||
extern void gl_state_enable_scissor_test(bool force = false);
|
||||
extern void gl_state_enable_stencil_test(bool force = false);
|
||||
extern void gl_state_get();
|
||||
extern void gl_state_get_all_gl_errors();
|
||||
extern GLenum gl_state_get_error();
|
||||
extern GLuint gl_state_get_program();
|
||||
extern void gl_state_set_blend_func(GLenum src, GLenum dst, bool force = false);
|
||||
extern void gl_state_set_blend_func_separate(GLenum src_rgb, GLenum dst_rgb,
|
||||
GLenum src_alpha, GLenum dst_alpha, bool force = false);
|
||||
extern void gl_state_set_blend_equation(GLenum mode, bool force = false);
|
||||
extern void gl_state_set_blend_equation_separate(
|
||||
GLenum mode_rgb, GLenum mode_alpha, bool force = false);
|
||||
extern void gl_state_set_color_mask(GLboolean red, GLboolean green,
|
||||
GLboolean blue, GLboolean alpha, bool force = false);
|
||||
extern void gl_state_set_cull_face_mode(GLenum mode, bool force = false);
|
||||
extern void gl_state_set_depth_func(GLenum func, bool force = false);
|
||||
extern void gl_state_set_depth_mask(GLboolean flag, bool force = false);
|
||||
extern void gl_state_set_polygon_mode(GLenum face, GLenum mode, bool force = false);
|
||||
extern void gl_state_set_primitive_restart_index(GLuint index, bool force = false);
|
||||
extern void gl_state_set_stencil_mask(GLuint mask, bool force = false);
|
||||
extern void gl_state_use_program(GLuint program, bool force = false);
|
||||
|
||||
inline constexpr void gl_state_begin_event(const char* str) {
|
||||
#ifdef DEBUG
|
||||
glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, (GLsizei)utf8_length(str), str);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline constexpr void gl_state_end_event() {
|
||||
#ifdef DEBUG
|
||||
glPopDebugGroup();
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "wrap.hpp"
|
||||
#include "gl_state.hpp"
|
||||
|
||||
struct GLUniformBuffer {
|
||||
private:
|
||||
GLuint buffer;
|
||||
|
||||
public:
|
||||
inline GLUniformBuffer() : buffer() {
|
||||
|
||||
}
|
||||
|
||||
inline ~GLUniformBuffer() {
|
||||
|
||||
}
|
||||
|
||||
inline void Bind(int32_t index, bool force = false) {
|
||||
gl_state_bind_uniform_buffer_base(index, buffer, force);
|
||||
}
|
||||
|
||||
inline void Create(size_t size) {
|
||||
if (buffer)
|
||||
return;
|
||||
|
||||
if (GL_VERSION_4_5) {
|
||||
glCreateBuffers(1, &buffer);
|
||||
glNamedBufferStorage(buffer, (GLsizeiptr)size, 0, GL_DYNAMIC_STORAGE_BIT | GL_MAP_WRITE_BIT);
|
||||
}
|
||||
else {
|
||||
glGenBuffers(1, &buffer);
|
||||
gl_state_bind_uniform_buffer(buffer);
|
||||
if (GL_VERSION_4_4)
|
||||
glBufferStorage(GL_UNIFORM_BUFFER, (GLsizeiptr)size,
|
||||
0, GL_DYNAMIC_STORAGE_BIT | GL_MAP_WRITE_BIT);
|
||||
else
|
||||
glBufferData(GL_UNIFORM_BUFFER, (GLsizeiptr)size, 0, GL_DYNAMIC_DRAW);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inline void Create(size_t size, const void* data, bool dynamic = false) {
|
||||
if (buffer)
|
||||
return;
|
||||
|
||||
if (GL_VERSION_4_5) {
|
||||
glCreateBuffers(1, &buffer);
|
||||
glNamedBufferStorage(buffer, (GLsizeiptr)size, data,
|
||||
dynamic ? GL_DYNAMIC_STORAGE_BIT | GL_MAP_WRITE_BIT : 0);
|
||||
}
|
||||
else {
|
||||
glGenBuffers(1, &buffer);
|
||||
gl_state_bind_uniform_buffer(buffer);
|
||||
if (GL_VERSION_4_4)
|
||||
glBufferStorage(GL_UNIFORM_BUFFER, (GLsizeiptr)size, data,
|
||||
dynamic ? GL_DYNAMIC_STORAGE_BIT | GL_MAP_WRITE_BIT : 0);
|
||||
else
|
||||
glBufferData(GL_UNIFORM_BUFFER, (GLsizeiptr)size, data,
|
||||
dynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW);
|
||||
}
|
||||
}
|
||||
|
||||
inline void Destroy() {
|
||||
if (buffer) {
|
||||
glDeleteBuffers(1, &buffer);
|
||||
buffer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool IsNull() {
|
||||
return !buffer;
|
||||
}
|
||||
|
||||
inline void* MapMemory() {
|
||||
if (!buffer)
|
||||
return 0;
|
||||
|
||||
void* data;
|
||||
if (GL_VERSION_4_5)
|
||||
data = glMapNamedBuffer(buffer, GL_WRITE_ONLY);
|
||||
else {
|
||||
gl_state_bind_uniform_buffer(buffer);
|
||||
data = glMapBuffer(GL_UNIFORM_BUFFER, GL_WRITE_ONLY);
|
||||
}
|
||||
|
||||
if (data)
|
||||
return data;
|
||||
|
||||
if (GL_VERSION_4_5)
|
||||
glUnmapNamedBuffer(buffer);
|
||||
else {
|
||||
glUnmapBuffer(GL_UNIFORM_BUFFER);
|
||||
gl_state_bind_uniform_buffer(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline bool NotNull() {
|
||||
return !!buffer;
|
||||
}
|
||||
|
||||
inline void UnmapMemory() {
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
if (GL_VERSION_4_5)
|
||||
glUnmapNamedBuffer(buffer);
|
||||
else {
|
||||
glUnmapBuffer(GL_UNIFORM_BUFFER);
|
||||
gl_state_bind_uniform_buffer(0);
|
||||
}
|
||||
}
|
||||
|
||||
inline void WriteMemory(size_t offset, size_t size, const void* data) {
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
if (GL_VERSION_4_5)
|
||||
glNamedBufferSubData(buffer, (GLsizeiptr)offset, (GLsizeiptr)size, data);
|
||||
else {
|
||||
gl_state_bind_uniform_buffer(buffer);
|
||||
glBufferSubData(GL_UNIFORM_BUFFER, (GLsizeiptr)offset, (GLsizeiptr)size, data);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void WriteMemory(T& data) {
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
if (GL_VERSION_4_5)
|
||||
glNamedBufferSubData(buffer, 0, sizeof(T), &data);
|
||||
else {
|
||||
gl_state_bind_uniform_buffer(buffer);
|
||||
glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(T), &data);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "hook.hpp"
|
||||
#include "Glitter/glitter.hpp"
|
||||
#include "mdl/disp_manager.hpp"
|
||||
#include "rob/rob.hpp"
|
||||
#include "auth_3d.hpp"
|
||||
#include "camera.hpp"
|
||||
#include "shader_glsl_ft.hpp"
|
||||
#include "sprite.hpp"
|
||||
#include "stage.hpp"
|
||||
#include "texture.hpp"
|
||||
#include <Helpers.h>
|
||||
|
||||
HOOK(int32_t, FASTCALL, data_init, 0x0000000140192FF0) {
|
||||
extern void FASTCALL wrap_addresses();
|
||||
wrap_addresses();
|
||||
|
||||
auth_3d_patch();
|
||||
camera_patch();
|
||||
mdl::disp_manager_patch();
|
||||
render_manager_patch();
|
||||
rob_patch();
|
||||
sprite_patch();
|
||||
stage_patch();
|
||||
Glitter::Patch();
|
||||
|
||||
rctx = new render_context;
|
||||
int32_t ret = originaldata_init();
|
||||
|
||||
extern size_t diva_handle;
|
||||
diva_handle = (size_t)WindowFromDC(wglGetCurrentDC());
|
||||
|
||||
rctx->init();
|
||||
sprite_manager_init();
|
||||
return ret;
|
||||
}
|
||||
|
||||
HOOK(int32_t, FASTCALL, data_free, 0x000000140192490) {
|
||||
sprite_manager_free();
|
||||
rctx->free();
|
||||
|
||||
int32_t ret = originaldata_free();
|
||||
delete rctx;
|
||||
return ret;
|
||||
}
|
||||
|
||||
HOOK(void, FASTCALL, sub_140194CD0, 0x000000140194CD0) {
|
||||
rctx->ctrl();
|
||||
originalsub_140194CD0();
|
||||
}
|
||||
|
||||
HOOK(void, FASTCALL, _gl_state_get, 0x0000000140442DF0) {
|
||||
gl_state_get();
|
||||
}
|
||||
|
||||
HOOK(void, FASTCALL, rndr__Render__update_res, 0x00000001404A9480, rndr::Render* rend, bool set, int32_t base_downsample) {
|
||||
rend->update_res(set, base_downsample);
|
||||
}
|
||||
|
||||
HOOK(void, FASTCALL, rndr__Render__init_tone_map_buffers, 0x00000001404A9FF0, rndr::Render* rend) {
|
||||
rend->init_tone_map_buffers();
|
||||
}
|
||||
|
||||
HOOK(void, FASTCALL, rndr__Render__init_render_buffers, 0x00000001404AB0C0, rndr::Render* rend,
|
||||
int32_t width, int32_t height, int32_t ssaa, int32_t hd_res, int32_t ss_alpha_mask) {
|
||||
rend->init_render_buffers(width, height, ssaa, hd_res, ss_alpha_mask);
|
||||
}
|
||||
|
||||
HOOK(void, FASTCALL, rndr__Render__free, 0x00000001404AB900, rndr::Render* rend) {
|
||||
rend->free();
|
||||
}
|
||||
|
||||
HOOK(void, FASTCALL, rndr__RenderManager__render_ctrl, 0x0000000140502C90) {
|
||||
render_manager->render->ctrl();
|
||||
}
|
||||
|
||||
HOOK(void, FASTCALL, rndr__RenderManager__render_all, 0x0000000140502CA0) {
|
||||
render_manager->render_all();
|
||||
}
|
||||
|
||||
HOOK(int32_t, FASTCALL, shader_get_index_by_name, 0x00000001405E4ED0, const char* name) {
|
||||
return shaders_ft.get_index_by_name(name);
|
||||
}
|
||||
|
||||
HOOK(void, FASTCALL, env_set_blend_color, 0x00000001405E5600, float_t r, float_t g, float_t b, float_t a) {
|
||||
rctx->obj_batch.g_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->obj_batch.g_offset_color = { r, g, b, a };
|
||||
}
|
||||
|
||||
void hook_funcs() {
|
||||
INSTALL_HOOK(data_init);
|
||||
INSTALL_HOOK(data_free);
|
||||
|
||||
INSTALL_HOOK(sub_140194CD0);
|
||||
|
||||
INSTALL_HOOK(_gl_state_get);
|
||||
|
||||
INSTALL_HOOK(rndr__Render__update_res);
|
||||
INSTALL_HOOK(rndr__Render__init_tone_map_buffers);
|
||||
INSTALL_HOOK(rndr__Render__init_render_buffers);
|
||||
INSTALL_HOOK(rndr__Render__free);
|
||||
|
||||
INSTALL_HOOK(rndr__RenderManager__render_ctrl);
|
||||
INSTALL_HOOK(rndr__RenderManager__render_all);
|
||||
|
||||
INSTALL_HOOK(shader_get_index_by_name);
|
||||
|
||||
INSTALL_HOOK(env_set_blend_color);
|
||||
INSTALL_HOOK(env_set_offset_color);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gl_state.hpp"
|
||||
|
||||
extern void hook_funcs();
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "inject.hpp"
|
||||
#include "gl.hpp"
|
||||
#include "print.hpp"
|
||||
#include "shader_table.hpp"
|
||||
#include "shader_glsl_ft.hpp"
|
||||
#include "sprite.hpp"
|
||||
#include <Windows.h>
|
||||
|
||||
struct patch_struct {
|
||||
void* address;
|
||||
size_t func_ptr;
|
||||
};
|
||||
|
||||
void inject_data(void* address, const void* data, size_t count) {
|
||||
DWORD old_protect;
|
||||
VirtualProtect(address, count, PAGE_EXECUTE_READWRITE, &old_protect);
|
||||
memmove(address, (const void*)data, count);
|
||||
VirtualProtect(address, count, old_protect, &old_protect);
|
||||
}
|
||||
|
||||
void inject_uint8_t(void* address, uint8_t data) {
|
||||
DWORD old_protect;
|
||||
VirtualProtect(address, sizeof(uint8_t), PAGE_EXECUTE_READWRITE, &old_protect);
|
||||
*(uint8_t*)address = data;
|
||||
VirtualProtect(address, sizeof(uint8_t), old_protect, &old_protect);
|
||||
}
|
||||
|
||||
void inject_uint16_t(void* address, uint16_t data) {
|
||||
DWORD old_protect;
|
||||
VirtualProtect(address, sizeof(uint16_t), PAGE_EXECUTE_READWRITE, &old_protect);
|
||||
*(uint16_t*)address = data;
|
||||
VirtualProtect(address, sizeof(uint16_t), old_protect, &old_protect);
|
||||
}
|
||||
|
||||
void inject_uint32_t(void* address, uint32_t data) {
|
||||
DWORD old_protect;
|
||||
VirtualProtect(address, sizeof(uint32_t), PAGE_EXECUTE_READWRITE, &old_protect);
|
||||
*(uint32_t*)address = data;
|
||||
VirtualProtect(address, sizeof(uint32_t), old_protect, &old_protect);
|
||||
}
|
||||
|
||||
void inject_uint64_t(void* address, uint64_t data) {
|
||||
DWORD old_protect;
|
||||
VirtualProtect(address, sizeof(uint64_t), PAGE_EXECUTE_READWRITE, &old_protect);
|
||||
*(uint64_t*)address = data;
|
||||
VirtualProtect(address, sizeof(uint64_t), old_protect, &old_protect);
|
||||
}
|
||||
|
||||
extern size_t glut_handle;
|
||||
|
||||
static patch_struct patch_data[] = {
|
||||
{ (void*)0x00000001405E4CE0, (uint64_t)&shader_set, },
|
||||
{ (void*)0x00000001405E4FC0, (uint64_t)&shader_load_all_shaders, },
|
||||
{ (void*)0x00000001405E4DB0, (uint64_t)&shader_free, },
|
||||
{ (void*)0x00000001405E4B50, (uint64_t)&shader_bind, },
|
||||
{ (void*)0x00000001401D3860, (uint64_t)&printf_proxy, },
|
||||
{ (void*)0x00000001400DE640, (uint64_t)&printf_proxy, },
|
||||
{ (void*)0x0000000140442FB4, (uint64_t)&gl_state_get, },
|
||||
};
|
||||
|
||||
static HGLRC FASTCALL glut_create_context(int64_t a1, int64_t a2, int64_t a3, int64_t a4, int32_t a5);
|
||||
|
||||
void inject_patches() {
|
||||
// Reorder gl_state_get end
|
||||
inject_data((void*)0x0000000140442F99,
|
||||
"\xFF\x15\x51\x2B\x52\x00\x48\x8B\x5C\x24\x30\x48\x8B\x74\x24\x38"
|
||||
"\x48\x8B\x7C\x24\x40\x48\x83\xC4\x20\x41\x5E\xC3", 28);
|
||||
|
||||
uint8_t buf[0x0C];
|
||||
buf[0x00] = 0x48;
|
||||
buf[0x01] = 0xB8;
|
||||
buf[0x0A] = 0xFF;
|
||||
buf[0x0B] = 0xE0;
|
||||
|
||||
for (int32_t i = 0; i < sizeof(patch_data) / sizeof(patch_struct); i++)
|
||||
if (patch_data[i].func_ptr) {
|
||||
*(uint64_t*)&buf[0x02] = patch_data[i].func_ptr;
|
||||
inject_data(patch_data[i].address, buf, 0x0C);
|
||||
}
|
||||
;
|
||||
|
||||
*(uint64_t*)&buf[0x02] = (uint64_t)&glut_create_context;
|
||||
inject_data((void*)(glut_handle + 0x0000A970), buf, 0x0C);
|
||||
|
||||
inject_uint64_t((void*)&shader_name_bind_func_table[0].bind_func, (uint64_t)&shader_bind_blinn);
|
||||
inject_uint64_t((void*)&shader_name_bind_func_table[1].bind_func, (uint64_t)&shader_bind_cloth);
|
||||
inject_uint64_t((void*)&shader_name_bind_func_table[2].bind_func, (uint64_t)&shader_bind_hair);
|
||||
inject_uint64_t((void*)&shader_name_bind_func_table[3].bind_func, (uint64_t)&shader_bind_membrane);
|
||||
inject_uint64_t((void*)&shader_name_bind_func_table[4].bind_func, (uint64_t)&shader_bind_eye_ball);
|
||||
inject_uint64_t((void*)&shader_name_bind_func_table[5].bind_func, (uint64_t)&shader_bind_tone_map);
|
||||
|
||||
// Patch font shader index
|
||||
inject_uint32_t((void*)0x00000001401982D8, SHADER_FT_FONT);
|
||||
}
|
||||
|
||||
static HGLRC FASTCALL glut_create_context(int64_t a1, int64_t a2, int64_t a3, int64_t a4, int32_t a5) {
|
||||
HDC& hDc = *(HDC*)(glut_handle + 0x55F20);
|
||||
|
||||
if (true/*a5*/) {
|
||||
const int32_t attrib_list[] = {
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 4,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 3,
|
||||
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB,
|
||||
0,
|
||||
};
|
||||
|
||||
typedef HGLRC(GLAPIENTRY* PFNWGLCREATECONTEXTGLUTPROC)(HDC hDc);
|
||||
|
||||
HGLRC tmp_ctx = wglCreateContextGLUT(hDc);;
|
||||
wglMakeCurrentGLUT(hDc, tmp_ctx);
|
||||
PFNWGLCREATECONTEXTATTRIBSARBPROC _wglCreateContextAttribsARB
|
||||
= (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddressGLUT("wglCreateContextAttribsARB");
|
||||
HGLRC ctx = _wglCreateContextAttribsARB(hDc, 0, attrib_list);
|
||||
wglMakeCurrentGLUT(hDc, ctx);
|
||||
wglDeleteContextGLUT(tmp_ctx);
|
||||
return ctx;
|
||||
}
|
||||
else
|
||||
return wglCreateContextGLUT(hDc);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
|
||||
extern void inject_data(void* address, const void* data, size_t count);
|
||||
extern void inject_uint8_t(void* address, uint8_t data);
|
||||
extern void inject_uint16_t(void* address, uint16_t data);
|
||||
extern void inject_uint32_t(void* address, uint32_t data);
|
||||
extern void inject_uint64_t(void* address, uint64_t data);
|
||||
extern void inject_patches();
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "fog.hpp"
|
||||
#include "../render_context.hpp"
|
||||
|
||||
fog* fog_data = (fog*)0x00000001411974D0;
|
||||
|
||||
fog_type fog::get_type() const {
|
||||
return type;
|
||||
}
|
||||
|
||||
void fog::set_type(fog_type value) {
|
||||
type = value;
|
||||
}
|
||||
|
||||
float_t fog::get_density() const {
|
||||
return density;
|
||||
}
|
||||
|
||||
void fog::set_density(float_t value) {
|
||||
density = value;
|
||||
}
|
||||
|
||||
float_t fog::get_start() const {
|
||||
return start;
|
||||
}
|
||||
|
||||
void fog::set_start(float_t value) {
|
||||
start = value;
|
||||
}
|
||||
|
||||
float_t fog::get_end() const {
|
||||
return end;
|
||||
}
|
||||
|
||||
void fog::set_end(float_t value) {
|
||||
end = value;
|
||||
}
|
||||
|
||||
int32_t fog::get_index() const {
|
||||
return index;
|
||||
}
|
||||
|
||||
void fog::set_index(int32_t value) {
|
||||
index = value;
|
||||
}
|
||||
|
||||
void fog::get_color(vec4& value) const {
|
||||
value = color;
|
||||
}
|
||||
|
||||
void fog::set_color(const vec4& value) {
|
||||
color = value;
|
||||
}
|
||||
|
||||
void fog::set_color(const vec4&& value) {
|
||||
color = value;
|
||||
}
|
||||
|
||||
void fog::data_set(fog_id id) {
|
||||
fog_type type = get_type();
|
||||
if (type == FOG_NONE)
|
||||
return;
|
||||
|
||||
float_t density = get_density();
|
||||
float_t start = get_start();
|
||||
float_t end = get_end();
|
||||
if (start >= end)
|
||||
start = end - 0.01f;
|
||||
|
||||
vec4 params;
|
||||
params.x = density;
|
||||
params.y = start;
|
||||
params.z = end;
|
||||
params.w = 1.0f / (end - start);
|
||||
|
||||
extern render_context* rctx;
|
||||
|
||||
switch (id) {
|
||||
case FOG_DEPTH:
|
||||
get_color(rctx->obj_scene.g_fog_depth_color);
|
||||
rctx->obj_scene.g_fog_state_params = params;
|
||||
break;
|
||||
case FOG_HEIGHT:
|
||||
get_color(rctx->obj_scene.g_fog_height_color);
|
||||
rctx->obj_scene.g_fog_height_params = params;
|
||||
break;
|
||||
case FOG_BUMP:
|
||||
rctx->obj_scene.g_fog_bump_params = params;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../KKdLib/default.hpp"
|
||||
#include "../../KKdLib/light_param/fog.hpp"
|
||||
#include "../../KKdLib/vec.hpp"
|
||||
|
||||
struct fog {
|
||||
fog_type type;
|
||||
float_t density;
|
||||
float_t start;
|
||||
float_t end;
|
||||
int32_t index;
|
||||
vec4 color;
|
||||
|
||||
fog_type get_type() const;
|
||||
void set_type(fog_type value);
|
||||
float_t get_density() const;
|
||||
void set_density(float_t value);
|
||||
float_t get_start() const;
|
||||
void set_start(float_t value);
|
||||
float_t get_end() const;
|
||||
void set_end(float_t value);
|
||||
int32_t get_index() const;
|
||||
void set_index(int32_t value);
|
||||
void get_color(vec4& value) const;
|
||||
void set_color(const vec4& value);
|
||||
void set_color(const vec4&& value);
|
||||
void data_set(fog_id id);
|
||||
};
|
||||
|
||||
static_assert(sizeof(fog) == 0x24, "\"fog\" struct should have a size of 0x24");
|
||||
|
||||
extern fog* fog_data;
|
||||
@@ -0,0 +1,497 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "light.hpp"
|
||||
#include "../../KKdLib/mat.hpp"
|
||||
#include "../render_context.hpp"
|
||||
#include "../uniform.hpp"
|
||||
|
||||
light_set* light_set_data = (light_set*)0x00000001411A00A0;
|
||||
|
||||
static vec4* npr_cloth_spec_color = (vec4*)0x0000000140C9B2A0;
|
||||
|
||||
static void light_get_direction_from_position(vec4* pos_dir, light_data* light, bool force = false);
|
||||
|
||||
light_type light_data::get_type() const {
|
||||
return type;
|
||||
}
|
||||
|
||||
void light_data::set_type(light_type value) {
|
||||
type = value;
|
||||
if (value < LIGHT_POINT)
|
||||
position.w = 0.0f;
|
||||
else
|
||||
position.w = 1.0f;
|
||||
}
|
||||
|
||||
void light_data::get_ambient(vec4& value) const {
|
||||
value = ambient;
|
||||
}
|
||||
|
||||
void light_data::set_ambient(const vec4& value) {
|
||||
ambient = value;
|
||||
}
|
||||
|
||||
void light_data::set_ambient(const vec4&& value) {
|
||||
ambient = value;
|
||||
}
|
||||
|
||||
void light_data::set_ambient(const vec4& value, bool set[4]) {
|
||||
if (set[0])
|
||||
ambient.x = value.x;
|
||||
if (set[1])
|
||||
ambient.y = value.y;
|
||||
if (set[2])
|
||||
ambient.z = value.z;
|
||||
if (set[3])
|
||||
ambient.w = value.w;
|
||||
}
|
||||
|
||||
void light_data::set_ambient(const vec4&& value, bool set[4]) {
|
||||
if (set[0])
|
||||
ambient.x = value.x;
|
||||
if (set[1])
|
||||
ambient.y = value.y;
|
||||
if (set[2])
|
||||
ambient.z = value.z;
|
||||
if (set[3])
|
||||
ambient.w = value.w;
|
||||
}
|
||||
|
||||
void light_data::get_diffuse(vec4& value) const {
|
||||
value = diffuse;
|
||||
}
|
||||
|
||||
void light_data::set_diffuse(const vec4& value) {
|
||||
diffuse = value;
|
||||
}
|
||||
|
||||
void light_data::set_diffuse(const vec4&& value) {
|
||||
diffuse = value;
|
||||
}
|
||||
|
||||
void light_data::set_diffuse(const vec4& value, bool set[4]) {
|
||||
if (set[0])
|
||||
diffuse.x = value.x;
|
||||
if (set[1])
|
||||
diffuse.y = value.y;
|
||||
if (set[2])
|
||||
diffuse.z = value.z;
|
||||
if (set[3])
|
||||
diffuse.w = value.w;
|
||||
}
|
||||
|
||||
void light_data::set_diffuse(const vec4&& value, bool set[4]) {
|
||||
if (set[0])
|
||||
diffuse.x = value.x;
|
||||
if (set[1])
|
||||
diffuse.y = value.y;
|
||||
if (set[2])
|
||||
diffuse.z = value.z;
|
||||
if (set[3])
|
||||
diffuse.w = value.w;
|
||||
}
|
||||
|
||||
void light_data::get_specular(vec4& value) const {
|
||||
value = specular;
|
||||
}
|
||||
|
||||
void light_data::set_specular(const vec4& value) {
|
||||
specular = value;
|
||||
}
|
||||
|
||||
void light_data::set_specular(const vec4&& value) {
|
||||
specular = value;
|
||||
}
|
||||
|
||||
void light_data::set_specular(const vec4& value, bool set[4]) {
|
||||
if (set[0])
|
||||
specular.x = value.x;
|
||||
if (set[1])
|
||||
specular.y = value.y;
|
||||
if (set[2])
|
||||
specular.z = value.z;
|
||||
if (set[3])
|
||||
specular.w = value.w;
|
||||
}
|
||||
|
||||
void light_data::set_specular(const vec4&& value, bool set[4]) {
|
||||
if (set[0])
|
||||
specular.x = value.x;
|
||||
if (set[1])
|
||||
specular.y = value.y;
|
||||
if (set[2])
|
||||
specular.z = value.z;
|
||||
if (set[3])
|
||||
specular.w = value.w;
|
||||
}
|
||||
|
||||
void light_data::get_position(vec3& value) const {
|
||||
value = *(vec3*)&position;
|
||||
}
|
||||
|
||||
void light_data::set_position(const vec3& value) {
|
||||
*(vec3*)&position = value;
|
||||
}
|
||||
|
||||
void light_data::set_position(const vec3&& value) {
|
||||
*(vec3*)&position = value;
|
||||
}
|
||||
|
||||
void light_data::get_position(vec4& value) const {
|
||||
value = position;
|
||||
}
|
||||
|
||||
void light_data::set_position(const vec4& value) {
|
||||
position = value;
|
||||
}
|
||||
|
||||
void light_data::set_position(const vec4&& value) {
|
||||
position = value;
|
||||
}
|
||||
|
||||
void light_data::get_spot_direction(vec3& value) const {
|
||||
value = spot_direction;
|
||||
}
|
||||
|
||||
void light_data::set_spot_direction(const vec3& value) {
|
||||
spot_direction = value;
|
||||
}
|
||||
|
||||
void light_data::set_spot_direction(const vec3&& value) {
|
||||
spot_direction = value;
|
||||
}
|
||||
|
||||
float_t light_data::get_spot_exponent() const {
|
||||
return spot_exponent;
|
||||
}
|
||||
|
||||
void light_data::set_spot_exponent(float_t value) {
|
||||
spot_exponent = value;
|
||||
}
|
||||
|
||||
float_t light_data::get_spot_cutoff() const {
|
||||
return spot_cutoff;
|
||||
}
|
||||
|
||||
void light_data::set_spot_cutoff(float_t value) {
|
||||
spot_cutoff = value;
|
||||
}
|
||||
|
||||
float_t light_data::get_constant() const {
|
||||
return attenuation.constant;
|
||||
}
|
||||
|
||||
void light_data::set_constant(float_t value) {
|
||||
attenuation.constant = value;
|
||||
}
|
||||
|
||||
float_t light_data::get_linear() const {
|
||||
return attenuation.linear;
|
||||
}
|
||||
|
||||
void light_data::set_linear(float_t value) {
|
||||
attenuation.linear = value;
|
||||
}
|
||||
|
||||
float_t light_data::get_quadratic() const {
|
||||
return attenuation.quadratic;
|
||||
}
|
||||
|
||||
void light_data::set_quadratic(float_t value) {
|
||||
attenuation.quadratic = value;
|
||||
}
|
||||
|
||||
void light_data::get_attenuation(light_attenuation& value) const {
|
||||
value = attenuation;
|
||||
}
|
||||
|
||||
void light_data::set_attenuation(const light_attenuation& value) {
|
||||
attenuation = value;
|
||||
}
|
||||
|
||||
void light_data::set_attenuation(const light_attenuation&& value) {
|
||||
attenuation = value;
|
||||
}
|
||||
|
||||
void light_data::get_ibl_color0(vec4& value) const {
|
||||
value = ibl_color0;
|
||||
}
|
||||
|
||||
void light_data::set_ibl_color0(const vec4& value) {
|
||||
ibl_color0 = value;
|
||||
}
|
||||
|
||||
void light_data::set_ibl_color0(const vec4&& value) {
|
||||
ibl_color0 = value;
|
||||
}
|
||||
|
||||
void light_data::get_ibl_color1(vec4& value) const {
|
||||
value = ibl_color1;
|
||||
}
|
||||
|
||||
void light_data::set_ibl_color1(const vec4& value) {
|
||||
ibl_color1 = value;
|
||||
}
|
||||
|
||||
void light_data::set_ibl_color1(const vec4&& value) {
|
||||
ibl_color1 = value;
|
||||
}
|
||||
|
||||
void light_data::get_ibl_direction(vec4& value) const {
|
||||
value = ibl_direction;
|
||||
}
|
||||
|
||||
void light_data::set_ibl_direction(const vec4& value) {
|
||||
ibl_direction = value;
|
||||
}
|
||||
|
||||
void light_data::set_ibl_direction(const vec4&& value) {
|
||||
ibl_direction = value;
|
||||
}
|
||||
|
||||
void light_data::get_tone_curve(light_tone_curve& value) const {
|
||||
value = tone_curve;
|
||||
}
|
||||
|
||||
void light_data::set_tone_curve(const light_tone_curve& value) {
|
||||
tone_curve = value;
|
||||
}
|
||||
|
||||
void light_data::set_tone_curve(const light_tone_curve&& value) {
|
||||
tone_curve = value;
|
||||
}
|
||||
|
||||
void light_data::get_clip_plane(light_clip_plane& value) const {
|
||||
value = clip_plane;
|
||||
}
|
||||
|
||||
void light_data::set_clip_plane(const light_clip_plane& value) {
|
||||
clip_plane = value;
|
||||
}
|
||||
|
||||
void light_data::set_clip_plane(const light_clip_plane&& value) {
|
||||
clip_plane = value;
|
||||
}
|
||||
|
||||
void light_set::get_ambient_intensity(vec4& value) {
|
||||
value = ambient_intensity;
|
||||
}
|
||||
|
||||
void light_set::set_ambient_intensity(const vec4& value) {
|
||||
ambient_intensity = value;
|
||||
}
|
||||
|
||||
void light_set::set_ambient_intensity(const vec4&& value) {
|
||||
ambient_intensity = value;
|
||||
}
|
||||
|
||||
void light_set::get_irradiance(mat4& r, mat4& g, mat4& b) {
|
||||
r = irradiance_r;
|
||||
g = irradiance_g;
|
||||
b = irradiance_b;
|
||||
}
|
||||
|
||||
void light_set::set_irradiance(const mat4& r, const mat4& g, const mat4& b) {
|
||||
irradiance_r = r;
|
||||
irradiance_g = g;
|
||||
irradiance_b = b;
|
||||
}
|
||||
|
||||
void light_set::set_irradiance(const mat4&& r, const mat4&& g, const mat4&& b) {
|
||||
irradiance_r = r;
|
||||
irradiance_g = g;
|
||||
irradiance_b = b;
|
||||
}
|
||||
|
||||
void light_set::data_set(light_set_id id) {
|
||||
static const float_t spec_coef = (float_t)(1.0 / (1.0 - cos(18.0 * DEG_TO_RAD)));
|
||||
static const float_t luce_coef = (float_t)(1.0 / (1.0 - cos(45.0 * DEG_TO_RAD)));
|
||||
|
||||
extern render_context* rctx;
|
||||
obj_scene_shader_data& obj_scene = rctx->obj_scene;
|
||||
|
||||
lights[LIGHT_STAGE].get_diffuse(obj_scene.g_light_env_stage_diffuse);
|
||||
lights[LIGHT_STAGE].get_specular(obj_scene.g_light_env_stage_specular);
|
||||
|
||||
lights[LIGHT_CHARA].get_diffuse(obj_scene.g_light_env_chara_diffuse);
|
||||
lights[LIGHT_CHARA].get_ambient(obj_scene.g_light_env_chara_ambient);
|
||||
lights[LIGHT_CHARA].get_specular(obj_scene.g_light_env_chara_specular);
|
||||
|
||||
lights[LIGHT_REFLECT].get_diffuse(obj_scene.g_light_env_reflect_diffuse);
|
||||
lights[LIGHT_REFLECT].get_ambient(obj_scene.g_light_env_reflect_ambient);
|
||||
|
||||
lights[LIGHT_PROJECTION].get_diffuse(obj_scene.g_light_env_proj_diffuse);
|
||||
lights[LIGHT_PROJECTION].get_specular(obj_scene.g_light_env_proj_specular);
|
||||
lights[LIGHT_PROJECTION].get_position(obj_scene.g_light_env_proj_position);
|
||||
if (lights[LIGHT_PROJECTION].get_type() == LIGHT_PARALLEL)
|
||||
light_get_direction_from_position(&obj_scene.g_light_env_proj_position, 0, true);
|
||||
|
||||
vec4 light_chara_dir;
|
||||
vec4 light_chara_ibl_color0;
|
||||
vec4 light_chara_ibl_color1;
|
||||
vec4 light_chara_specular;
|
||||
lights[LIGHT_CHARA].get_position(light_chara_dir);
|
||||
light_get_direction_from_position(&light_chara_dir, &lights[LIGHT_CHARA]);
|
||||
lights[LIGHT_CHARA].get_ibl_color0(light_chara_ibl_color0);
|
||||
lights[LIGHT_CHARA].get_ibl_color1(light_chara_ibl_color1);
|
||||
lights[LIGHT_CHARA].get_specular(light_chara_specular);
|
||||
|
||||
obj_scene.g_light_chara_dir = light_chara_dir;
|
||||
obj_scene.g_light_chara_spec = light_chara_specular * light_chara_ibl_color0 * spec_coef;
|
||||
obj_scene.g_light_chara_luce = light_chara_ibl_color0 * luce_coef;
|
||||
obj_scene.g_light_chara_back = light_chara_specular * light_chara_ibl_color1 * spec_coef;
|
||||
|
||||
vec4 light_stage_dir;
|
||||
vec4 light_stage_ibl_color;
|
||||
vec4 light_stage_diffuse;
|
||||
vec4 light_stage_specular;
|
||||
lights[LIGHT_STAGE].get_position(light_stage_dir);
|
||||
light_get_direction_from_position(&light_stage_dir, &lights[LIGHT_STAGE]);
|
||||
lights[LIGHT_STAGE].get_ibl_color0(light_stage_ibl_color);
|
||||
lights[LIGHT_STAGE].get_diffuse(light_stage_diffuse);
|
||||
lights[LIGHT_STAGE].get_specular(light_stage_specular);
|
||||
|
||||
obj_scene.g_light_stage_dir = light_stage_dir;
|
||||
obj_scene.g_light_stage_diff = light_stage_diffuse * light_stage_ibl_color;
|
||||
obj_scene.g_light_stage_spec = light_stage_specular * light_stage_ibl_color * spec_coef;
|
||||
|
||||
mat4 irradiance_r_transforms;
|
||||
mat4 irradiance_g_transforms;
|
||||
mat4 irradiance_b_transforms;
|
||||
get_irradiance(irradiance_r_transforms, irradiance_g_transforms, irradiance_b_transforms);
|
||||
obj_scene.set_g_irradiance_r_transforms(irradiance_r_transforms);
|
||||
obj_scene.set_g_irradiance_g_transforms(irradiance_g_transforms);
|
||||
obj_scene.set_g_irradiance_b_transforms(irradiance_b_transforms);
|
||||
|
||||
|
||||
float_t* (FASTCALL * face_data_get)() = (float_t * (FASTCALL*)())0x00000001403D8310;
|
||||
float_t offset = face_data_get()[0];
|
||||
float_t v28 = (float_t)(1.0 - exp(offset * -0.44999999)) * 2.0f;
|
||||
offset = max_def(offset, 0.0f);
|
||||
obj_scene.g_light_face_diff = { v28 * 0.1f, offset * 0.06f, 1.0f, 1.0f };
|
||||
|
||||
if (lights[LIGHT_CHARA_COLOR].get_type() == LIGHT_PARALLEL) {
|
||||
lights[LIGHT_CHARA_COLOR].get_ambient(obj_scene.g_chara_color_rim);
|
||||
lights[LIGHT_CHARA_COLOR].get_diffuse(obj_scene.g_chara_color0);
|
||||
lights[LIGHT_CHARA_COLOR].get_specular(obj_scene.g_chara_color1);
|
||||
if (obj_scene.g_chara_color1.w > 1.0f)
|
||||
obj_scene.g_chara_color1.w = 1.0f;
|
||||
}
|
||||
else {
|
||||
obj_scene.g_chara_color_rim = 0.0f;
|
||||
obj_scene.g_chara_color0 = 0.0f;
|
||||
obj_scene.g_chara_color1 = 0.0f;
|
||||
}
|
||||
|
||||
if (lights[LIGHT_TONE_CURVE].get_type() == LIGHT_PARALLEL) {
|
||||
uniform->arr[U_TONE_CURVE] = 1;
|
||||
vec4 chara_f_dir;
|
||||
vec4 chara_f_ambient;
|
||||
vec4 chara_f_diffuse;
|
||||
vec4 chara_tc_param;
|
||||
lights[LIGHT_TONE_CURVE].get_position(chara_f_dir);
|
||||
light_get_direction_from_position(&chara_f_dir, &lights[LIGHT_TONE_CURVE]);
|
||||
lights[LIGHT_TONE_CURVE].get_ambient(chara_f_ambient);
|
||||
lights[LIGHT_TONE_CURVE].get_diffuse(chara_f_diffuse);
|
||||
|
||||
light_tone_curve tone_curve;
|
||||
lights[LIGHT_TONE_CURVE].get_tone_curve(tone_curve);
|
||||
chara_tc_param.x = tone_curve.start_point;
|
||||
float_t end_point = min_def(tone_curve.end_point, 1.0f) - tone_curve.start_point;
|
||||
if (end_point > 0.0f)
|
||||
chara_tc_param.y = 1.0f / end_point;
|
||||
else
|
||||
chara_tc_param.y = 0.0f;
|
||||
chara_tc_param.z = tone_curve.coefficient;
|
||||
chara_tc_param.w = 0.0f;
|
||||
|
||||
obj_scene.g_chara_f_dir = chara_f_dir;
|
||||
obj_scene.g_chara_f_ambient = chara_f_ambient;
|
||||
obj_scene.g_chara_f_diffuse = chara_f_diffuse;
|
||||
obj_scene.g_chara_tc_param = chara_tc_param;
|
||||
}
|
||||
else {
|
||||
uniform->arr[U_TONE_CURVE] = 0;
|
||||
obj_scene.g_chara_f_dir = { 0.0f, 1.0f, 0.0f, 0.0f };
|
||||
obj_scene.g_chara_f_ambient = 0.0f;
|
||||
obj_scene.g_chara_f_diffuse = 0.0f;
|
||||
obj_scene.g_chara_tc_param = 0.0f;
|
||||
}
|
||||
|
||||
vec4 light_reflect_dir;
|
||||
lights[LIGHT_CHARA].get_position(light_reflect_dir);
|
||||
if (fabsf(light_reflect_dir.x) <= 0.000001f && fabsf(light_reflect_dir.y) <= 0.000001f
|
||||
&& fabsf(light_reflect_dir.z) <= 0.000001f)
|
||||
*(vec3*)&light_reflect_dir = vec3(0.0f, 1.0f, 0.0f);
|
||||
else {
|
||||
float_t length = vec3::length(*(vec3*)&light_reflect_dir);
|
||||
if (length != 0.0f)
|
||||
*(vec3*)&light_reflect_dir *= 1.0f / length;
|
||||
}
|
||||
light_reflect_dir.w = 1.0f;
|
||||
|
||||
obj_scene.g_light_reflect_dir = light_reflect_dir;
|
||||
|
||||
if (lights[LIGHT_REFLECT].get_type() == LIGHT_SPOT) {
|
||||
vec3 spot_direction;
|
||||
vec4 position;
|
||||
lights[LIGHT_REFLECT].get_spot_direction(spot_direction);
|
||||
lights[LIGHT_REFLECT].get_position(position);
|
||||
vec4 clip_plane;
|
||||
*(vec3*)&clip_plane = -spot_direction;
|
||||
light_get_direction_from_position(&clip_plane, &lights[LIGHT_REFLECT], true);
|
||||
clip_plane.w = -vec3::dot(*(vec3*)&position, *(vec3*)&clip_plane);
|
||||
|
||||
obj_scene.g_clip_plane = clip_plane;
|
||||
}
|
||||
else if (lights[LIGHT_REFLECT].get_type() == LIGHT_POINT)
|
||||
obj_scene.g_clip_plane = { 0.0f, -1.0f, 0.0f, 9999.0f };
|
||||
else
|
||||
obj_scene.g_clip_plane = { 0.0f, -1.0f, 0.0f, 0.0f };
|
||||
|
||||
vec4 light_chara_ibl_direction;
|
||||
vec4 light_chara_position;
|
||||
lights[LIGHT_CHARA].get_ibl_direction(light_chara_ibl_direction);
|
||||
lights[LIGHT_CHARA].get_position(light_chara_position);
|
||||
|
||||
mat4 normal_tangent_transforms = mat4_identity;
|
||||
|
||||
float_t length = vec3::length(*(vec3*)&light_chara_ibl_direction);
|
||||
if (length >= 0.000001f) {
|
||||
vec3 ibl_direction = *(vec3*)&light_chara_ibl_direction * (1.0f / length);
|
||||
|
||||
length = vec3::length(*(vec3*)&light_chara_position);
|
||||
if (length >= 0.000001f) {
|
||||
vec3 position = *(vec3*)&light_chara_position * (1.0f / length);
|
||||
|
||||
vec3 axis = vec3::cross(ibl_direction, position);
|
||||
length = vec3::length(axis);
|
||||
|
||||
float_t v52 = vec3::dot(ibl_direction, position);
|
||||
float_t angle = fabsf(atan2f(length, v52));
|
||||
if (angle >= 0.01f && angle <= 3.131592653589793f) {
|
||||
if (length != 0.0f)
|
||||
axis *= 1.0f / length;
|
||||
|
||||
mat4_set(&axis, -angle, &normal_tangent_transforms);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
obj_scene.set_g_normal_tangent_transforms(normal_tangent_transforms);
|
||||
obj_scene.g_npr_cloth_spec_color = *npr_cloth_spec_color;
|
||||
}
|
||||
|
||||
static void light_get_direction_from_position(vec4* pos_dir, light_data* light, bool force) {
|
||||
if (force || light->get_type() == LIGHT_PARALLEL) {
|
||||
float_t length = vec3::length(*(vec3*)pos_dir);
|
||||
if (length <= 0.000001)
|
||||
*(vec3*)pos_dir = vec3(0.0f, 1.0f, 0.0f);
|
||||
else
|
||||
*(vec3*)pos_dir *= 1.0f / length;
|
||||
pos_dir->w = 0.0f;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../KKdLib/default.hpp"
|
||||
#include "../../KKdLib/light_param/light.hpp"
|
||||
#include "../../KKdLib/mat.hpp"
|
||||
#include "../../KKdLib/vec.hpp"
|
||||
|
||||
struct light_data {
|
||||
light_type type;
|
||||
vec4 ambient;
|
||||
vec4 diffuse;
|
||||
vec4 specular;
|
||||
vec4 position;
|
||||
vec3 spot_direction;
|
||||
float_t spot_exponent;
|
||||
float_t spot_cutoff;
|
||||
light_attenuation attenuation;
|
||||
vec4 ibl_color0;
|
||||
vec4 ibl_color1;
|
||||
vec4 ibl_direction;
|
||||
light_tone_curve tone_curve;
|
||||
light_clip_plane clip_plane;
|
||||
|
||||
light_type get_type() const;
|
||||
void set_type(light_type value);
|
||||
void get_ambient(vec4& value) const;
|
||||
void set_ambient(const vec4& value);
|
||||
void set_ambient(const vec4&& value);
|
||||
void set_ambient(const vec4& value, bool set[4]);
|
||||
void set_ambient(const vec4&& value, bool set[4]);
|
||||
void get_diffuse(vec4& value) const;
|
||||
void set_diffuse(const vec4& value);
|
||||
void set_diffuse(const vec4&& value);
|
||||
void set_diffuse(const vec4& value, bool set[4]);
|
||||
void set_diffuse(const vec4&& value, bool set[4]);
|
||||
void get_specular(vec4& value) const;
|
||||
void set_specular(const vec4& value);
|
||||
void set_specular(const vec4&& value);
|
||||
void set_specular(const vec4& value, bool set[4]);
|
||||
void set_specular(const vec4&& value, bool set[4]);
|
||||
void get_position(vec3& value) const;
|
||||
void set_position(const vec3& value);
|
||||
void set_position(const vec3&& value);
|
||||
void get_position(vec4& value) const;
|
||||
void set_position(const vec4& value);
|
||||
void set_position(const vec4&& value);
|
||||
void get_spot_direction(vec3& value) const;
|
||||
void set_spot_direction(const vec3& value);
|
||||
void set_spot_direction(const vec3&& value);
|
||||
float_t get_spot_exponent() const;
|
||||
void set_spot_exponent(float_t value);
|
||||
float_t get_spot_cutoff() const;
|
||||
void set_spot_cutoff(float_t value);
|
||||
float_t get_constant() const;
|
||||
void set_constant(float_t value);
|
||||
float_t get_linear() const;
|
||||
void set_linear(float_t value);
|
||||
float_t get_quadratic() const;
|
||||
void set_quadratic(float_t value);
|
||||
void get_attenuation(light_attenuation& value) const;
|
||||
void set_attenuation(const light_attenuation& value);
|
||||
void set_attenuation(const light_attenuation&& value);
|
||||
void get_ibl_color0(vec4& value) const;
|
||||
void set_ibl_color0(const vec4& value);
|
||||
void set_ibl_color0(const vec4&& value);
|
||||
void get_ibl_color1(vec4& value) const;
|
||||
void set_ibl_color1(const vec4& value);
|
||||
void set_ibl_color1(const vec4&& value);
|
||||
void get_ibl_direction(vec4& value) const;
|
||||
void set_ibl_direction(const vec4& value);
|
||||
void set_ibl_direction(const vec4&& value);
|
||||
void get_tone_curve(light_tone_curve& value) const;
|
||||
void set_tone_curve(const light_tone_curve& value);
|
||||
void set_tone_curve(const light_tone_curve&& value);
|
||||
void get_clip_plane(light_clip_plane& value) const;
|
||||
void set_clip_plane(const light_clip_plane& value);
|
||||
void set_clip_plane(const light_clip_plane&& value);
|
||||
};
|
||||
|
||||
static_assert(sizeof(light_data) == 0xA4, "\"light\" struct should have a size of 0xA4");
|
||||
|
||||
struct light_set {
|
||||
light_data lights[LIGHT_MAX];
|
||||
vec4 ambient_intensity;
|
||||
mat4 irradiance_r;
|
||||
mat4 irradiance_g;
|
||||
mat4 irradiance_b;
|
||||
|
||||
void get_ambient_intensity(vec4& value);
|
||||
void set_ambient_intensity(const vec4& value);
|
||||
void set_ambient_intensity(const vec4&& value);
|
||||
void get_irradiance(mat4& r, mat4& g, mat4& b);
|
||||
void set_irradiance(const mat4& r, const mat4& g, const mat4& b);
|
||||
void set_irradiance(const mat4&& r, const mat4&& g, const mat4&& b);
|
||||
void data_set(light_set_id id);
|
||||
};
|
||||
|
||||
static_assert(sizeof(light_set) == 0x5F0, "\"light_set\" struct should have a size of 0x5F0");
|
||||
|
||||
extern light_set* light_set_data;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,449 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../KKdLib/default.hpp"
|
||||
#include "../../KKdLib/mat.hpp"
|
||||
#include "../../KKdLib/vec.hpp"
|
||||
#include "../gl_array_buffer.hpp"
|
||||
#include "../gl_element_array_buffer.hpp"
|
||||
#include "../color.hpp"
|
||||
#include "../object.hpp"
|
||||
#include "../shadow.hpp"
|
||||
|
||||
#define TEXTURE_PATTERN_COUNT 24
|
||||
#define TEXTURE_TRANSFORM_COUNT 24
|
||||
|
||||
namespace mdl {
|
||||
enum EtcObjType {
|
||||
ETC_OBJ_TEAPOT = 0,
|
||||
ETC_OBJ_GRID,
|
||||
ETC_OBJ_CUBE,
|
||||
ETC_OBJ_SPHERE,
|
||||
ETC_OBJ_PLANE,
|
||||
ETC_OBJ_CONE,
|
||||
ETC_OBJ_LINE,
|
||||
ETC_OBJ_CROSS,
|
||||
ETC_OBJ_MAX,
|
||||
};
|
||||
|
||||
enum ObjKind {
|
||||
OBJ_KIND_NORMAL = 0,
|
||||
OBJ_KIND_ETC,
|
||||
OBJ_KIND_USER,
|
||||
OBJ_KIND_TRANSLUCENT,
|
||||
OBJ_KIND_MAX,
|
||||
};
|
||||
|
||||
enum ObjFlags : uint32_t {
|
||||
OBJ_SHADOW = 0x00000001,
|
||||
OBJ_2 = 0x00000002,
|
||||
OBJ_4 = 0x00000004,
|
||||
OBJ_8 = 0x00000008,
|
||||
OBJ_10 = 0x00000010,
|
||||
OBJ_20 = 0x00000020,
|
||||
OBJ_40 = 0x00000040,
|
||||
OBJ_SHADOW_OBJECT = 0x00000080,
|
||||
OBJ_CHARA_REFLECT = 0x00000100,
|
||||
OBJ_REFLECT = 0x00000200,
|
||||
OBJ_REFRACT = 0x00000400,
|
||||
OBJ_800 = 0x00000800,
|
||||
OBJ_TRANSLUCENT_NO_SHADOW = 0x00001000,
|
||||
OBJ_SSS = 0x00002000,
|
||||
OBJ_4000 = 0x00004000,
|
||||
OBJ_8000 = 0x00008000,
|
||||
OBJ_ALPHA_ORDER_1 = 0x00010000,
|
||||
OBJ_ALPHA_ORDER_2 = 0x00020000,
|
||||
OBJ_ALPHA_ORDER_3 = 0x00040000,
|
||||
OBJ_80000 = 0x00080000,
|
||||
OBJ_100000 = 0x00100000,
|
||||
OBJ_200000 = 0x00200000,
|
||||
OBJ_400000 = 0x00400000,
|
||||
OBJ_800000 = 0x00800000,
|
||||
OBJ_USER = 0x01000000,
|
||||
OBJ_2000000 = 0x02000000,
|
||||
OBJ_4000000 = 0x04000000,
|
||||
OBJ_8000000 = 0x08000000,
|
||||
OBJ_10000000 = 0x10000000,
|
||||
OBJ_20000000 = 0x20000000,
|
||||
OBJ_40000000 = 0x40000000,
|
||||
OBJ_NO_TRANSLUCENCY = 0x80000000,
|
||||
};
|
||||
|
||||
enum ObjType {
|
||||
OBJ_TYPE_OPAQUE = 0,
|
||||
OBJ_TYPE_TRANSLUCENT,
|
||||
OBJ_TYPE_TRANSLUCENT_NO_SHADOW,
|
||||
OBJ_TYPE_TRANSPARENT,
|
||||
OBJ_TYPE_SHADOW_CHARA,
|
||||
OBJ_TYPE_SHADOW_STAGE,
|
||||
OBJ_TYPE_TYPE_6,
|
||||
OBJ_TYPE_TYPE_7,
|
||||
OBJ_TYPE_SHADOW_OBJECT_CHARA,
|
||||
OBJ_TYPE_SHADOW_OBJECT_STAGE,
|
||||
OBJ_TYPE_REFLECT_CHARA_OPAQUE,
|
||||
OBJ_TYPE_REFLECT_CHARA_TRANSLUCENT,
|
||||
OBJ_TYPE_REFLECT_CHARA_TRANSPARENT,
|
||||
OBJ_TYPE_REFLECT_OPAQUE,
|
||||
OBJ_TYPE_REFLECT_TRANSLUCENT,
|
||||
OBJ_TYPE_REFLECT_TRANSPARENT,
|
||||
OBJ_TYPE_REFRACT_OPAQUE,
|
||||
OBJ_TYPE_REFRACT_TRANSLUCENT,
|
||||
OBJ_TYPE_REFRACT_TRANSPARENT,
|
||||
OBJ_TYPE_SSS,
|
||||
OBJ_TYPE_OPAQUE_ALPHA_ORDER_1,
|
||||
OBJ_TYPE_TRANSPARENT_ALPHA_ORDER_1,
|
||||
OBJ_TYPE_TRANSLUCENT_ALPHA_ORDER_1,
|
||||
OBJ_TYPE_OPAQUE_ALPHA_ORDER_2,
|
||||
OBJ_TYPE_TRANSPARENT_ALPHA_ORDER_2,
|
||||
OBJ_TYPE_TRANSLUCENT_ALPHA_ORDER_2,
|
||||
OBJ_TYPE_OPAQUE_ALPHA_ORDER_3,
|
||||
OBJ_TYPE_TRANSPARENT_ALPHA_ORDER_3,
|
||||
OBJ_TYPE_TRANSLUCENT_ALPHA_ORDER_3,
|
||||
OBJ_TYPE_USER,
|
||||
OBJ_TYPE_MAX,
|
||||
};
|
||||
}
|
||||
|
||||
struct morph_struct {
|
||||
object_info object;
|
||||
float_t weight;
|
||||
};
|
||||
|
||||
static_assert(sizeof(morph_struct) == 0x08, "\"morph_struct\" struct should have a size of 0x08");
|
||||
|
||||
struct texture_pattern_struct {
|
||||
uint32_t src;
|
||||
uint32_t dst;
|
||||
};
|
||||
|
||||
static_assert(sizeof(texture_pattern_struct) == 0x08, "\"texture_pattern_struct\" struct should have a size of 0x08");
|
||||
|
||||
struct texture_transform_struct {
|
||||
uint32_t id;
|
||||
mat4 mat;
|
||||
};
|
||||
|
||||
static_assert(sizeof(texture_transform_struct) == 0x44, "\"texture_pattern_struct\" struct should have a size of 0x44");
|
||||
|
||||
struct texture_data_struct {
|
||||
int32_t field_0;
|
||||
vec3 texture_color_coefficients;
|
||||
vec3 texture_color_offset;
|
||||
vec3 texture_specular_coefficients;
|
||||
vec3 texture_specular_offset;
|
||||
};
|
||||
|
||||
static_assert(sizeof(texture_data_struct) == 0x34, "\"texture_pattern_struct\" struct should have a size of 0x34");
|
||||
|
||||
namespace mdl {
|
||||
struct ObjSubMeshArgs {
|
||||
obj_sub_mesh* sub_mesh;
|
||||
obj_mesh* mesh;
|
||||
obj_material_data* material;
|
||||
prj::vector<GLuint>* textures;
|
||||
int32_t mat_count;
|
||||
mat4* mats;
|
||||
GLuint vertex_buffer;
|
||||
GLuint index_buffer;
|
||||
bool set_blend_color;
|
||||
bool chara_color;
|
||||
vec4 blend_color;
|
||||
int32_t self_shadow;
|
||||
shadow_type_enum shadow;
|
||||
GLuint morph_vertex_buffer;
|
||||
float_t morph_weight;
|
||||
int32_t texture_pattern_count;
|
||||
texture_pattern_struct texture_pattern_array[TEXTURE_PATTERN_COUNT];
|
||||
vec4 texture_color_coefficients;
|
||||
vec4 texture_color_offset;
|
||||
vec4 texture_specular_coefficients;
|
||||
vec4 texture_specular_offset;
|
||||
int32_t texture_transform_count;
|
||||
texture_transform_struct texture_transform_array[TEXTURE_TRANSFORM_COUNT];
|
||||
int32_t field_7C4;
|
||||
int32_t field_7C8;
|
||||
int32_t instances_count;
|
||||
mat4* instances_mat;
|
||||
void(FASTCALL* func)(const ObjSubMeshArgs*);
|
||||
const ObjSubMeshArgs* func_data;
|
||||
};
|
||||
|
||||
static_assert(sizeof(mdl::ObjSubMeshArgs) == 0x7E8, "\"mdl::ObjSubMeshArgs\" struct should have a size of 0x7F8");
|
||||
|
||||
struct EtcObjTeapot {
|
||||
float_t size;
|
||||
};
|
||||
|
||||
static_assert(sizeof(mdl::EtcObjTeapot) == 0x04, "\"mdl::EtcObjTeapot\" struct should have a size of 0x04");
|
||||
|
||||
struct EtcObjGrid {
|
||||
int32_t w;
|
||||
int32_t h;
|
||||
int32_t ws;
|
||||
int32_t hs;
|
||||
};
|
||||
|
||||
static_assert(sizeof(mdl::EtcObjGrid) == 0x10, "\"mdl::EtcObjGrid\" struct should have a size of 0x10");
|
||||
|
||||
struct EtcObjCube {
|
||||
vec3 size;
|
||||
bool wire;
|
||||
};
|
||||
|
||||
static_assert(sizeof(mdl::EtcObjCube) == 0x10, "\"mdl::EtcObjCube\" struct should have a size of 0x10");
|
||||
|
||||
struct EtcObjSphere {
|
||||
float_t radius;
|
||||
int32_t slices;
|
||||
int32_t stacks;
|
||||
bool wire;
|
||||
};
|
||||
|
||||
static_assert(sizeof(mdl::EtcObjSphere) == 0x10, "\"mdl::EtcObjSphere\" struct should have a size of 0x10");
|
||||
|
||||
struct EtcObjPlane {
|
||||
int32_t w;
|
||||
int32_t h;
|
||||
};
|
||||
|
||||
static_assert(sizeof(mdl::EtcObjPlane) == 0x08, "\"mdl::EtcObjPlane\" struct should have a size of 0x08");
|
||||
|
||||
struct EtcObjCone {
|
||||
float_t base;
|
||||
float_t height;
|
||||
int32_t slices;
|
||||
int32_t stacks;
|
||||
bool wire;
|
||||
};
|
||||
|
||||
static_assert(sizeof(mdl::EtcObjCone) == 0x14, "\"mdl::EtcObjCone\" struct should have a size of 0x14");
|
||||
|
||||
struct EtcObjLine {
|
||||
vec3 pos[2];
|
||||
};
|
||||
|
||||
static_assert(sizeof(mdl::EtcObjLine) == 0x18, "\"mdl::EtcObjLine\" struct should have a size of 0x18");
|
||||
|
||||
struct EtcObjCross {
|
||||
float_t size;
|
||||
};
|
||||
|
||||
static_assert(sizeof(mdl::EtcObjCross) == 0x04, "\"mdl::EtcObjCross\" struct should have a size of 0x04");
|
||||
|
||||
struct EtcObj {
|
||||
union Data {
|
||||
EtcObjTeapot teapot;
|
||||
EtcObjGrid grid;
|
||||
EtcObjCube cube;
|
||||
EtcObjSphere sphere;
|
||||
EtcObjPlane plane;
|
||||
EtcObjCone cone;
|
||||
EtcObjLine line;
|
||||
EtcObjCross cross;
|
||||
};
|
||||
|
||||
EtcObjType type;
|
||||
color4u8_bgra color;
|
||||
bool fog;
|
||||
Data data;
|
||||
GLsizei count; // Added
|
||||
size_t offset; // Added
|
||||
|
||||
void init(EtcObjType type);
|
||||
};
|
||||
|
||||
static_assert(sizeof(mdl::EtcObj) == 0x30, "\"mdl::EtcObj\" struct should have a size of 0x30");
|
||||
|
||||
typedef void(*UserArgsFunc)(void* data);
|
||||
|
||||
struct UserArgs {
|
||||
UserArgsFunc func;
|
||||
void* data;
|
||||
};
|
||||
|
||||
static_assert(sizeof(mdl::UserArgs) == 0x10, "\"mdl::UserArgs\" struct should have a size of 0x10");
|
||||
|
||||
struct ObjTranslucentArgs {
|
||||
uint32_t count;
|
||||
ObjSubMeshArgs* sub_mesh[40];
|
||||
};
|
||||
|
||||
static_assert(sizeof(mdl::ObjTranslucentArgs) == 0x148, "\"mdl::ObjTranslucentArgs\" struct should have a size of 0x148");
|
||||
|
||||
struct ObjData {
|
||||
union Args {
|
||||
ObjSubMeshArgs sub_mesh;
|
||||
EtcObj etc;
|
||||
UserArgs user;
|
||||
ObjTranslucentArgs translucent;
|
||||
};
|
||||
|
||||
ObjKind kind;
|
||||
mat4 mat;
|
||||
float_t view_z;
|
||||
float_t radius;
|
||||
Args args;
|
||||
|
||||
void init_etc(const mat4* mat, mdl::EtcObj* etc);
|
||||
void init_sub_mesh(const mat4* mat,
|
||||
float_t radius, obj_sub_mesh* sub_mesh, obj_mesh* mesh, obj_material_data* material,
|
||||
prj::vector<GLuint>* textures, int32_t mat_count, mat4* mats, GLuint vertex_buffer,
|
||||
GLuint index_buffer, vec4* blend_color, GLuint morph_vertex_buffer,
|
||||
int32_t instances_count, mat4* instances_mat,
|
||||
void(FASTCALL* func)(const ObjSubMeshArgs*), const ObjSubMeshArgs* func_data);
|
||||
void init_translucent(const mat4* mat, ObjTranslucentArgs* translucent);
|
||||
void init_user(const mat4* mat, UserArgsFunc func, void* data);
|
||||
};
|
||||
|
||||
static_assert(sizeof(mdl::ObjData) == 0x838, "\"mdl::ObjData\" struct should have a size of 0x838");
|
||||
|
||||
struct CullingCheck {
|
||||
struct Info {
|
||||
int32_t objects;
|
||||
int32_t meshes;
|
||||
int32_t submesh_array;
|
||||
int pad;
|
||||
};
|
||||
|
||||
static_assert(sizeof(mdl::CullingCheck::Info) == 0x10, "\"mdl::CullingCheck::Info\" struct should have a size of 0x10");
|
||||
|
||||
Info passed;
|
||||
Info culled;
|
||||
Info passed_prev;
|
||||
Info culled_prev;
|
||||
};
|
||||
|
||||
static_assert(sizeof(mdl::CullingCheck) == 0x40, "\"mdl::CullingCheck\" struct should have a size of 0x40");
|
||||
|
||||
struct DispManager {
|
||||
struct vertex_array {
|
||||
GLuint vertex_buffer;
|
||||
GLuint morph_vertex_buffer;
|
||||
GLuint index_buffer;
|
||||
int32_t alive_time;
|
||||
GLuint vertex_array;
|
||||
bool vertex_attrib_array[16];
|
||||
obj_vertex_format vertex_format;
|
||||
GLsizei size_vertex;
|
||||
bool compressed;
|
||||
GLuint vertex_attrib_buffer_binding[16];
|
||||
int32_t texcoord_array[2];
|
||||
};
|
||||
|
||||
struct etc_vertex_array {
|
||||
GLArrayBuffer vertex_buffer;
|
||||
GLElementArrayBuffer index_buffer;
|
||||
int32_t alive_time;
|
||||
GLuint vertex_array;
|
||||
EtcObj::Data data;
|
||||
EtcObjType type;
|
||||
GLsizei count;
|
||||
size_t offset;
|
||||
GLsizei wire_count;
|
||||
size_t wire_offset;
|
||||
size_t max_vtx;
|
||||
size_t max_idx;
|
||||
};
|
||||
|
||||
mdl::ObjFlags obj_flags;
|
||||
shadow_type_enum shadow_type;
|
||||
int32_t field_8;
|
||||
int32_t field_C;
|
||||
prj::list<mdl::ObjData*> obj[mdl::OBJ_TYPE_MAX];
|
||||
mdl::CullingCheck culling;
|
||||
int32_t put_index;
|
||||
bool show_alpha_center;
|
||||
bool show_mat_center;
|
||||
bool object_culling;
|
||||
bool object_sort;
|
||||
bool chara_color;
|
||||
int32_t buff_offset;
|
||||
int32_t buff_max;
|
||||
int32_t buff_size;
|
||||
size_t buff;
|
||||
morph_struct morph;
|
||||
int32_t texture_pattern_count;
|
||||
texture_pattern_struct texture_pattern_array[TEXTURE_PATTERN_COUNT];
|
||||
vec4 texture_color_coefficients;
|
||||
vec4 texture_color_offset;
|
||||
vec4 texture_specular_coefficients;
|
||||
vec4 texture_specular_offset;
|
||||
float_t wet_param;
|
||||
int32_t texture_transform_count;
|
||||
texture_transform_struct texture_transform_array[TEXTURE_TRANSFORM_COUNT];
|
||||
bool(FASTCALL* culling_func)(obj_bounding_sphere*);
|
||||
|
||||
void add_vertex_array(ObjSubMeshArgs* args);
|
||||
void add_vertex_array(EtcObj* etc, mat4& mat);
|
||||
void* alloc_data(int32_t size);
|
||||
ObjData* alloc_obj_data(ObjKind kind);
|
||||
mat4* alloc_mat4_array(int32_t count);
|
||||
void buffer_reset();
|
||||
void check_vertex_arrays();
|
||||
void draw(mdl::ObjType type, int32_t depth_mask = 0, bool a4 = true);
|
||||
void draw_translucent(mdl::ObjType type, int32_t alpha);
|
||||
/*void draw_show_vector(mdl::ObjType type, int32_t show_vector);*/
|
||||
void entry_list(ObjType type, ObjData* data);
|
||||
bool entry_obj(::obj* object, obj_mesh_vertex_buffer* obj_vertex_buf,
|
||||
obj_mesh_index_buffer* obj_index_buf, const mat4* mat,
|
||||
prj::vector<GLuint>* textures, vec4* blend_color, mat4* bone_mat, ::obj* object_morph,
|
||||
obj_mesh_vertex_buffer* obj_morph_vertex_buf, int32_t instances_count, mat4* instances_mat,
|
||||
void(*func)(const mdl::ObjSubMeshArgs*), const ObjSubMeshArgs* func_data,
|
||||
bool enable_bone_mat, bool local = false);
|
||||
void entry_obj_by_obj(const mat4* mat,
|
||||
::obj* obj, prj::vector<GLuint>* textures, obj_mesh_vertex_buffer* obj_vert_buf,
|
||||
obj_mesh_index_buffer* obj_index_buf, mat4* bone_mat, float_t alpha);
|
||||
bool entry_obj_by_object_info(const mat4* mat, object_info obj_info, mat4* bone_mat = 0);
|
||||
bool entry_obj_by_object_info(const mat4* mat, object_info obj_info,
|
||||
vec4* blend_color, mat4* bone_mat, int32_t instances_count, mat4* instances_mat,
|
||||
void(*func)(const ObjSubMeshArgs*), const ObjSubMeshArgs* func_data, bool enable_bone_mat, bool local = false);
|
||||
bool entry_obj_by_object_info(const mat4* mat, object_info obj_info, float_t alpha, mat4* bone_mat = 0);
|
||||
bool entry_obj_by_object_info(const mat4* mat, object_info obj_info,
|
||||
float_t r, float_t g, float_t b, float_t a, mat4* bone_mat = 0, bool local = false);
|
||||
bool entry_obj_by_object_info(const mat4* mat, object_info obj_info,
|
||||
vec4* blend_color, mat4* bone_mat = 0, bool local = false);
|
||||
void entry_obj_by_object_info_object_skin(object_info obj_info,
|
||||
prj::vector<texture_pattern_struct>* texture_pattern, texture_data_struct* texture_data, float_t alpha,
|
||||
mat4* matrices, mat4* ex_data_matrices, const mat4* mat, const mat4* global_mat);
|
||||
void entry_obj_etc(const mat4* mat, EtcObj* etc, bool local = false);
|
||||
void entry_obj_user(const mat4* mat, UserArgsFunc func, void* data, ObjType type);
|
||||
GLuint get_vertex_array(const ObjSubMeshArgs* args);
|
||||
GLuint get_vertex_array(const mdl::EtcObj* etc);
|
||||
bool get_chara_color();
|
||||
ObjFlags get_obj_flags();
|
||||
void get_morph(object_info& object, float_t& weight);
|
||||
int32_t get_obj_count(ObjType type);
|
||||
shadow_type_enum get_shadow_type();
|
||||
void get_texture_color_coeff(vec4& value);
|
||||
void get_texture_color_offset(vec4& value);
|
||||
void get_texture_pattern(int32_t& count, texture_pattern_struct*& value);
|
||||
void get_texture_specular_coeff(vec4& value);
|
||||
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);
|
||||
void refresh();
|
||||
void set_chara_color(bool value = false);
|
||||
void set_culling_finc(bool(FASTCALL* func)(obj_bounding_sphere*) = 0);
|
||||
void set_obj_flags(ObjFlags flags = (ObjFlags)0);
|
||||
void set_morph(object_info object = {}, float_t weight = 0.0f);
|
||||
void set_shadow_type(shadow_type_enum type = SHADOW_CHARA);
|
||||
void set_texture_color_coefficients(vec4& value);
|
||||
void set_texture_color_offset(vec4& value);
|
||||
void set_texture_pattern(int32_t count = 0, texture_pattern_struct* value = 0);
|
||||
void set_texture_specular_coefficients(vec4& value);
|
||||
void set_texture_specular_offset(vec4& value);
|
||||
void set_texture_transform(int32_t count = 0, texture_transform_struct* value = 0);
|
||||
void set_wet_param(float_t value = 0.0f);
|
||||
};
|
||||
|
||||
static_assert(sizeof(mdl::DispManager) == 0x9D0, "\"mdl::DispManager\" struct should have a size of 0x9D0");
|
||||
|
||||
extern void disp_manager_patch();
|
||||
}
|
||||
|
||||
extern mdl::DispManager* disp_manager;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../KKdLib/default.hpp"
|
||||
#include "../../KKdLib/mat.hpp"
|
||||
#include "../../KKdLib/vec.hpp"
|
||||
#include "../object.hpp"
|
||||
#include "../render_context.hpp"
|
||||
|
||||
namespace mdl {
|
||||
extern void draw(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(mdl::EtcObj* etc);
|
||||
extern void draw_sub_mesh(const ObjSubMeshArgs* args, const mat4* model,
|
||||
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_object_model_mat_load(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);
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "object.hpp"
|
||||
#include "gl_state.hpp"
|
||||
#include "wrap.hpp"
|
||||
#include <Helpers.h>
|
||||
|
||||
uint32_t(FASTCALL* obj_database_get_object_info)(const char* name)
|
||||
= (uint32_t(FASTCALL*)(const char* name))0x0000000140459F80;
|
||||
obj* (FASTCALL* object_info_get_object)(object_info obj_info)
|
||||
= (obj * (FASTCALL*)(object_info obj_info))0x000000014045A140;
|
||||
obj_mesh_index_buffer* (FASTCALL* object_info_get_mesh_index_buffer)(object_info obj_info, int32_t a2)
|
||||
= (obj_mesh_index_buffer * (FASTCALL*)(object_info obj_info, int32_t a2))0x000000014045A250;
|
||||
obj_skin* (FASTCALL* obj_database_get_object_skin)(object_info obj_info)
|
||||
= (obj_skin * (FASTCALL*)(object_info obj_info))0x000000014045A3E0;
|
||||
obj_mesh_vertex_buffer* (FASTCALL* object_info_get_mesh_vertex_buffer)(object_info obj_info, int32_t a2)
|
||||
= (obj_mesh_vertex_buffer * (FASTCALL*)(object_info obj_info, int32_t a2))0x000000014045A480;
|
||||
GLuint(FASTCALL* obj_database_get_obj_set_texture)(int32_t set, int32_t tex_id)
|
||||
= (GLuint(FASTCALL*)(int32_t set, int32_t tex_id))0x000000014045A8F0;
|
||||
prj::vector<GLuint>* (FASTCALL* obj_database_get_obj_set_textures)(int32_t set)
|
||||
= (prj::vector<GLuint> * (FASTCALL*)(int32_t set))0x000000014045A9E0;
|
||||
|
||||
void obj_mesh_vertex_buffer::cycle_index() {
|
||||
if (++index >= count)
|
||||
index = 0;
|
||||
}
|
||||
|
||||
GLuint obj_mesh_vertex_buffer::get_buffer() {
|
||||
if (index < count)
|
||||
return buffers[index];
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLsizeiptr obj_mesh_vertex_buffer::get_size() {
|
||||
if (buffers[0]) {
|
||||
GLint buffer;
|
||||
GLint size;
|
||||
glGetIntegervDLL(GL_ARRAY_BUFFER_BINDING, &buffer);
|
||||
glBindBuffer(target, buffers[0]);
|
||||
glGetBufferParameterivARB(target, GL_BUFFER_SIZE, &size);
|
||||
glBindBuffer(target, buffer);
|
||||
return size;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline int32_t obj_material_texture_type_get_texcoord_index(
|
||||
obj_material_texture_type type, int32_t index) {
|
||||
switch (type) {
|
||||
case OBJ_MATERIAL_TEXTURE_COLOR:
|
||||
if (index < 2)
|
||||
return index;
|
||||
case OBJ_MATERIAL_TEXTURE_NORMAL:
|
||||
case OBJ_MATERIAL_TEXTURE_SPECULAR:
|
||||
return 0;
|
||||
case OBJ_MATERIAL_TEXTURE_TRANSLUCENCY:
|
||||
case OBJ_MATERIAL_TEXTURE_TRANSPARENCY:
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
inline int32_t obj_material_texture_type_get_texture_index(
|
||||
obj_material_texture_type type, int32_t base_index) {
|
||||
switch (type) {
|
||||
case OBJ_MATERIAL_TEXTURE_COLOR:
|
||||
if (base_index < 2)
|
||||
return base_index;
|
||||
case OBJ_MATERIAL_TEXTURE_NORMAL:
|
||||
return 2;
|
||||
case OBJ_MATERIAL_TEXTURE_SPECULAR:
|
||||
return 3;
|
||||
case OBJ_MATERIAL_TEXTURE_TRANSLUCENCY:
|
||||
return 1;
|
||||
case OBJ_MATERIAL_TEXTURE_TRANSPARENCY:
|
||||
return 4;
|
||||
case OBJ_MATERIAL_TEXTURE_ENVIRONMENT_SPHERE: // AFT
|
||||
case OBJ_MATERIAL_TEXTURE_ENVIRONMENT_CUBE:
|
||||
return 5;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void obj_skin_set_matrix_buffer(obj_skin* s, mat4* matrices,
|
||||
mat4* ex_data_matrices, mat4* matrix_buffer, const mat4* mat, const mat4* global_mat) {
|
||||
if (!s->num_bone)
|
||||
return;
|
||||
|
||||
if (mat)
|
||||
for (uint32_t i = 0; i < s->num_bone; i++) {
|
||||
mat4 temp;
|
||||
int32_t bone_id = s->bone_id_array[i];
|
||||
if (bone_id & 0x8000)
|
||||
mat4_mul(&ex_data_matrices[bone_id & 0x7FFF], mat, &temp);
|
||||
else
|
||||
mat4_mul(&matrices[bone_id], mat, &temp);
|
||||
|
||||
mat4_mul(global_mat, &temp, &temp);
|
||||
mat4_mul(&temp, &s->bone_matrix_array[i], &matrix_buffer[i]);
|
||||
}
|
||||
else
|
||||
for (uint32_t i = 0; i < s->num_bone; i++) {
|
||||
mat4 temp;
|
||||
int32_t bone_id = s->bone_id_array[i];
|
||||
if (bone_id & 0x8000)
|
||||
temp = ex_data_matrices[bone_id & 0x7FFF];
|
||||
else
|
||||
temp = matrices[bone_id];
|
||||
|
||||
mat4_mul(global_mat, &temp, &temp);
|
||||
mat4_mul(&temp, &s->bone_matrix_array[i], &matrix_buffer[i]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,529 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "../KKdLib/mat.hpp"
|
||||
#include "../KKdLib/vec.hpp"
|
||||
#include "texture.hpp"
|
||||
#include "types.hpp"
|
||||
|
||||
enum obj_index_format : uint32_t {
|
||||
OBJ_INDEX_U8 = 0x00,
|
||||
OBJ_INDEX_U16 = 0x01,
|
||||
OBJ_INDEX_U32 = 0x02,
|
||||
};
|
||||
|
||||
enum obj_material_aniso_direction : uint32_t {
|
||||
OBJ_MATERIAL_ANISO_DIRECTION_NORMAL = 0,
|
||||
OBJ_MATERIAL_ANISO_DIRECTION_U = 1,
|
||||
OBJ_MATERIAL_ANISO_DIRECTION_V = 2,
|
||||
OBJ_MATERIAL_ANISO_DIRECTION_RADIAL = 3,
|
||||
};
|
||||
|
||||
enum obj_material_blend_factor : uint32_t {
|
||||
OBJ_MATERIAL_BLEND_ZERO = 0,
|
||||
OBJ_MATERIAL_BLEND_ONE = 1,
|
||||
OBJ_MATERIAL_BLEND_SRC_COLOR = 2,
|
||||
OBJ_MATERIAL_BLEND_INVERSE_SRC_COLOR = 3,
|
||||
OBJ_MATERIAL_BLEND_SRC_ALPHA = 4,
|
||||
OBJ_MATERIAL_BLEND_INVERSE_SRC_ALPHA = 5,
|
||||
OBJ_MATERIAL_BLEND_DST_ALPHA = 6,
|
||||
OBJ_MATERIAL_BLEND_INVERSE_DST_ALPHA = 7,
|
||||
OBJ_MATERIAL_BLEND_DST_COLOR = 8,
|
||||
OBJ_MATERIAL_BLEND_INVERSE_DST_COLOR = 9,
|
||||
OBJ_MATERIAL_BLEND_ALPHA_SATURATE = 10,
|
||||
};
|
||||
|
||||
enum obj_material_bump_map_type : uint32_t {
|
||||
OBJ_MATERIAL_BUMP_MAP_NONE = 0,
|
||||
OBJ_MATERIAL_BUMP_MAP_DOT = 1,
|
||||
OBJ_MATERIAL_BUMP_MAP_ENV = 2,
|
||||
};
|
||||
|
||||
enum obj_material_color_source_type : uint32_t {
|
||||
OBJ_MATERIAL_COLOR_SOURCE_MATERIAL_COLOR = 0,
|
||||
OBJ_MATERIAL_COLOR_SOURCE_VERTEX_COLOR = 1,
|
||||
OBJ_MATERIAL_COLOR_SOURCE_VERTEX_MORPH = 2,
|
||||
};
|
||||
|
||||
enum obj_material_shader_lighting_type : uint32_t {
|
||||
OBJ_MATERIAL_SHADER_LIGHTING_LAMBERT = 0x00,
|
||||
OBJ_MATERIAL_SHADER_LIGHTING_CONSTANT = 0x01,
|
||||
OBJ_MATERIAL_SHADER_LIGHTING_PHONG = 0x02,
|
||||
};
|
||||
|
||||
enum obj_material_specular_quality : uint32_t {
|
||||
OBJ_MATERIAL_SPECULAR_QUALITY_LOW = 0,
|
||||
OBJ_MATERIAL_SPECULAR_QUALITY_HIGH = 1,
|
||||
};
|
||||
|
||||
enum obj_material_texture_type : uint32_t {
|
||||
OBJ_MATERIAL_TEXTURE_NONE = 0x00,
|
||||
OBJ_MATERIAL_TEXTURE_COLOR = 0x01,
|
||||
OBJ_MATERIAL_TEXTURE_NORMAL = 0x02,
|
||||
OBJ_MATERIAL_TEXTURE_SPECULAR = 0x03,
|
||||
OBJ_MATERIAL_TEXTURE_HEIGHT = 0x04,
|
||||
OBJ_MATERIAL_TEXTURE_REFLECTION = 0x05,
|
||||
OBJ_MATERIAL_TEXTURE_TRANSLUCENCY = 0x06,
|
||||
OBJ_MATERIAL_TEXTURE_TRANSPARENCY = 0x07,
|
||||
OBJ_MATERIAL_TEXTURE_ENVIRONMENT_SPHERE = 0x08,
|
||||
OBJ_MATERIAL_TEXTURE_ENVIRONMENT_CUBE = 0x09,
|
||||
};
|
||||
|
||||
enum obj_material_texture_coordinate_translation_type : uint32_t {
|
||||
OBJ_MATERIAL_TEXTURE_COORDINATE_TRANSLATION_NONE = 0x00,
|
||||
OBJ_MATERIAL_TEXTURE_COORDINATE_TRANSLATION_UV = 0x01,
|
||||
OBJ_MATERIAL_TEXTURE_COORDINATE_TRANSLATION_SPHERE = 0x02,
|
||||
OBJ_MATERIAL_TEXTURE_COORDINATE_TRANSLATION_CUBE = 0x03,
|
||||
};
|
||||
|
||||
enum obj_material_vertex_translation_type : uint32_t {
|
||||
OBJ_MATERIAL_VERTEX_TRANSLATION_DEFAULT = 0,
|
||||
OBJ_MATERIAL_VERTEX_TRANSLATION_ENVELOPE = 1,
|
||||
OBJ_MATERIAL_VERTEX_TRANSLATION_MORPHING = 2,
|
||||
};
|
||||
|
||||
enum obj_primitive_type : uint32_t {
|
||||
OBJ_PRIMITIVE_POINTS = 0x00,
|
||||
OBJ_PRIMITIVE_LINES = 0x01,
|
||||
OBJ_PRIMITIVE_LINE_STRIP = 0x02,
|
||||
OBJ_PRIMITIVE_LINE_LOOP = 0x03,
|
||||
OBJ_PRIMITIVE_TRIANGLES = 0x04,
|
||||
OBJ_PRIMITIVE_TRIANGLE_STRIP = 0x05,
|
||||
OBJ_PRIMITIVE_TRIANGLE_FAN = 0x06,
|
||||
OBJ_PRIMITIVE_QUADS = 0x07,
|
||||
OBJ_PRIMITIVE_QUAD_STRIP = 0x08,
|
||||
OBJ_PRIMITIVE_POLYGON = 0x09,
|
||||
};
|
||||
|
||||
enum obj_vertex_format : uint32_t {
|
||||
OBJ_VERTEX_NONE = 0x0000,
|
||||
OBJ_VERTEX_POSITION = 0x0001,
|
||||
OBJ_VERTEX_NORMAL = 0x0002,
|
||||
OBJ_VERTEX_TANGENT = 0x0004,
|
||||
OBJ_VERTEX_BINORMAL = 0x0008,
|
||||
OBJ_VERTEX_TEXCOORD0 = 0x0010,
|
||||
OBJ_VERTEX_TEXCOORD1 = 0x0020,
|
||||
OBJ_VERTEX_TEXCOORD2 = 0x0040,
|
||||
OBJ_VERTEX_TEXCOORD3 = 0x0080,
|
||||
OBJ_VERTEX_COLOR0 = 0x0100,
|
||||
OBJ_VERTEX_COLOR1 = 0x0200,
|
||||
OBJ_VERTEX_BONE_WEIGHT = 0x0400,
|
||||
OBJ_VERTEX_BONE_INDEX = 0x0800,
|
||||
OBJ_VERTEX_BONE_DATA = 0x0C00,
|
||||
OBJ_VERTEX_UNKNOWN = 0x1000,
|
||||
};
|
||||
|
||||
struct obj_axis_aligned_bounding_box {
|
||||
vec3 center;
|
||||
vec3 size;
|
||||
};
|
||||
|
||||
struct obj_bounding_box {
|
||||
vec3 center;
|
||||
vec3 size;
|
||||
};
|
||||
|
||||
struct obj_bounding_sphere {
|
||||
vec3 center;
|
||||
float_t radius;
|
||||
};
|
||||
|
||||
struct obj_shader_compo_member {
|
||||
uint32_t color : 1;
|
||||
uint32_t color_a : 1;
|
||||
uint32_t color_l1 : 1;
|
||||
uint32_t color_l1_a : 1;
|
||||
uint32_t color_l2 : 1;
|
||||
uint32_t color_l2_a : 1;
|
||||
uint32_t transparency : 1;
|
||||
uint32_t specular : 1;
|
||||
uint32_t normal_01 : 1;
|
||||
uint32_t normal_02 : 1;
|
||||
uint32_t envmap : 1;
|
||||
uint32_t color_l3 : 1;
|
||||
uint32_t color_l3_a : 1;
|
||||
uint32_t translucency : 1;
|
||||
uint32_t flag_14 : 1;
|
||||
uint32_t override_ibl : 1;
|
||||
uint32_t dummy : 16;
|
||||
};
|
||||
|
||||
union obj_shader_compo {
|
||||
obj_shader_compo_member m;
|
||||
uint32_t w;
|
||||
};
|
||||
|
||||
struct obj_material_shader_attrib_member {
|
||||
obj_material_vertex_translation_type vtx_trans_type : 2;
|
||||
obj_material_color_source_type col_src : 2;
|
||||
uint32_t is_lgt_diffuse : 1;
|
||||
uint32_t is_lgt_specular : 1;
|
||||
uint32_t is_lgt_per_pixel : 1;
|
||||
uint32_t is_lgt_double : 1;
|
||||
obj_material_bump_map_type bump_map_type : 2;
|
||||
uint32_t fresnel_type : 4;
|
||||
uint32_t line_light : 4;
|
||||
uint32_t recieve_shadow : 1;
|
||||
uint32_t cast_shadow : 1;
|
||||
obj_material_specular_quality specular_quality : 1;
|
||||
obj_material_aniso_direction aniso_direction : 2;
|
||||
uint32_t dummy : 9;
|
||||
};
|
||||
|
||||
union obj_material_shader_attrib {
|
||||
obj_material_shader_attrib_member m;
|
||||
uint32_t w;
|
||||
|
||||
obj_material_shader_lighting_type get_lighting_type() const;
|
||||
};
|
||||
|
||||
struct obj_texture_attrib_member {
|
||||
uint32_t repeat_u : 1;
|
||||
uint32_t repeat_v : 1;
|
||||
uint32_t mirror_u : 1;
|
||||
uint32_t mirror_v : 1;
|
||||
uint32_t ignore_alpha : 1;
|
||||
uint32_t blend : 5;
|
||||
uint32_t alpha_blend : 5;
|
||||
uint32_t border : 1;
|
||||
uint32_t clamp2edge : 1;
|
||||
uint32_t filter : 3;
|
||||
uint32_t mipmap : 2;
|
||||
uint32_t mipmap_bias : 7;
|
||||
uint32_t flag_29 : 1;
|
||||
uint32_t anisotropic_filter : 2;
|
||||
};
|
||||
|
||||
union obj_texture_attrib {
|
||||
obj_texture_attrib_member m;
|
||||
uint32_t w;
|
||||
|
||||
int32_t get_blend() const;
|
||||
};
|
||||
|
||||
struct obj_texture_shader_attrib_member {
|
||||
obj_material_texture_type tex_type : 4;
|
||||
int32_t uv_idx : 4;
|
||||
obj_material_texture_coordinate_translation_type texcoord_trans : 3;
|
||||
uint32_t dummy : 21;
|
||||
};
|
||||
|
||||
union obj_texture_shader_attrib {
|
||||
obj_texture_shader_attrib_member m;
|
||||
uint32_t w;
|
||||
};
|
||||
|
||||
struct obj_material_texture_data {
|
||||
obj_texture_attrib attrib;
|
||||
uint32_t tex_index;
|
||||
obj_texture_shader_attrib shader_info;
|
||||
char ex_shader[8];
|
||||
float_t weight;
|
||||
mat4 tex_coord_mat;
|
||||
uint32_t reserved[8];
|
||||
};
|
||||
|
||||
struct obj_material_attrib_member {
|
||||
uint32_t alpha_texture : 1;
|
||||
uint32_t alpha_material : 1;
|
||||
uint32_t punch_through : 1;
|
||||
uint32_t double_sided : 1;
|
||||
uint32_t normal_dir_light : 1;
|
||||
obj_material_blend_factor src_blend_factor : 4;
|
||||
obj_material_blend_factor dst_blend_factor : 4;
|
||||
uint32_t blend_operation : 3;
|
||||
uint32_t zbias : 4;
|
||||
uint32_t no_fog : 1;
|
||||
uint32_t translucent_priority : 6;
|
||||
uint32_t has_fog_height : 1;
|
||||
uint32_t flag_28 : 1;
|
||||
uint32_t fog_height : 1;
|
||||
uint32_t flag_30 : 1;
|
||||
uint32_t flag_31 : 1;
|
||||
};
|
||||
|
||||
union obj_material_attrib {
|
||||
obj_material_attrib_member m;
|
||||
uint32_t w;
|
||||
};
|
||||
|
||||
struct obj_material_color {
|
||||
vec4 diffuse;
|
||||
vec4 ambient;
|
||||
vec4 specular;
|
||||
vec4 emission;
|
||||
float_t shininess;
|
||||
float_t intensity;
|
||||
};
|
||||
|
||||
struct obj_material {
|
||||
obj_shader_compo shader_compo;
|
||||
union {
|
||||
char name[8];
|
||||
int32_t index;
|
||||
} shader;
|
||||
obj_material_shader_attrib shader_info;
|
||||
obj_material_texture_data texdata[8];
|
||||
obj_material_attrib attrib;
|
||||
obj_material_color color;
|
||||
vec3 center;
|
||||
float_t radius;
|
||||
char name[64];
|
||||
float_t bump_depth;
|
||||
uint32_t reserved[15];
|
||||
};
|
||||
|
||||
struct obj_material_data {
|
||||
uint32_t num_of_textures;
|
||||
obj_material material;
|
||||
};
|
||||
|
||||
struct obj_sub_mesh_attrib_member {
|
||||
uint32_t recieve_shadow : 1;
|
||||
uint32_t cast_shadow : 1;
|
||||
uint32_t transparent : 1;
|
||||
uint32_t cloth : 1;
|
||||
uint32_t dummy : 28;
|
||||
};
|
||||
|
||||
union obj_sub_mesh_attrib {
|
||||
obj_sub_mesh_attrib_member m;
|
||||
uint32_t w;
|
||||
};
|
||||
|
||||
struct obj_sub_mesh {
|
||||
uint32_t flags;
|
||||
obj_bounding_sphere bounding_sphere;
|
||||
uint32_t material_index;
|
||||
uint8_t uv_index[8];
|
||||
uint32_t num_bone_index;
|
||||
uint16_t* bone_index_array;
|
||||
uint32_t bones_per_vertex;
|
||||
obj_primitive_type primitive_type;
|
||||
obj_index_format index_format;
|
||||
uint32_t num_index;
|
||||
uint16_t* index_array;
|
||||
obj_sub_mesh_attrib attrib;
|
||||
uint32_t reserved[4];
|
||||
obj_axis_aligned_bounding_box* axis_aligned_bounding_box;
|
||||
uint16_t first_index;
|
||||
uint16_t last_index;
|
||||
uint32_t index_offset;
|
||||
};
|
||||
|
||||
static_assert(sizeof(obj_sub_mesh) == 0x70, "\"obj_sub_mesh\" struct should have a size of 0x70");
|
||||
|
||||
struct obj_vertex_data {
|
||||
vec3 position;
|
||||
vec3 normal;
|
||||
vec4 tangent;
|
||||
vec3 binormal;
|
||||
vec2 texcoord0;
|
||||
vec2 texcoord1;
|
||||
vec2 texcoord2;
|
||||
vec2 texcoord3;
|
||||
vec4 color0;
|
||||
vec4 color1;
|
||||
vec4 bone_weight;
|
||||
vec4i16 bone_index;
|
||||
vec4 unknown;
|
||||
};
|
||||
|
||||
struct obj_mesh_attrib_member {
|
||||
uint32_t double_buffer : 1;
|
||||
uint32_t billboard_y_axis : 1;
|
||||
uint32_t translucent_no_shadow : 1;
|
||||
uint32_t billboard : 1;
|
||||
uint32_t dummy : 28;
|
||||
};
|
||||
|
||||
union obj_mesh_attrib {
|
||||
obj_mesh_attrib_member m;
|
||||
uint32_t w;
|
||||
};
|
||||
|
||||
struct obj_mesh_vertex_array {
|
||||
vec3* position;
|
||||
vec3* normal;
|
||||
vec4* tangent;
|
||||
vec3* binormal;
|
||||
vec2* texcoord0;
|
||||
vec2* texcoord1;
|
||||
vec2* texcoord2;
|
||||
vec2* texcoord3;
|
||||
vec4* color0;
|
||||
vec4* color1;
|
||||
vec4* bone_weight;
|
||||
vec4* bone_index;
|
||||
void* field_60;
|
||||
void* field_68;
|
||||
void* field_70;
|
||||
void* field_78;
|
||||
void* field_80;
|
||||
void* field_88;
|
||||
void* field_90;
|
||||
void* field_98;
|
||||
};
|
||||
|
||||
struct obj_mesh {
|
||||
uint32_t flags;
|
||||
obj_bounding_sphere bounding_sphere;
|
||||
uint32_t num_submesh;
|
||||
obj_sub_mesh* submesh_array;
|
||||
obj_vertex_format vertex_format;
|
||||
uint32_t size_vertex;
|
||||
uint32_t num_vertex;
|
||||
union {
|
||||
obj_mesh_vertex_array vertex_array;
|
||||
void* vertex_array_ptr[20];
|
||||
};
|
||||
obj_mesh_attrib attrib;
|
||||
uint32_t vertex_flags;
|
||||
uint32_t reserved[6];
|
||||
char name[0x40];
|
||||
};
|
||||
|
||||
static_assert(sizeof(obj_mesh) == 0x130, "\"obj_mesh\" struct should have a size of 0x130");
|
||||
|
||||
struct obj {
|
||||
uint32_t version;
|
||||
uint32_t flags;
|
||||
obj_bounding_sphere bounding_sphere;
|
||||
uint32_t num_mesh;
|
||||
obj_mesh* mesh_array;
|
||||
uint32_t num_material;
|
||||
obj_material_data* material_array;
|
||||
uint32_t reserved[10];
|
||||
};
|
||||
|
||||
struct obj_skin_ex_data {
|
||||
uint32_t num_osage_name;
|
||||
uint32_t num_osage_node;
|
||||
const char** field_8;
|
||||
struct obj_skin_osage_node* osage_node_array;
|
||||
const char** osage_name_array;
|
||||
struct obj_skin_block* block_array;
|
||||
uint32_t num_bone_name;
|
||||
const char** bone_name_array;
|
||||
struct obj_skin_osage_sibling_info* osage_sibling_infos;
|
||||
uint32_t cloth_count;
|
||||
uint32_t reserved[7];
|
||||
};
|
||||
|
||||
struct obj_skin {
|
||||
uint32_t* bone_id_array;
|
||||
mat4* bone_matrix_array;
|
||||
const char** bone_name_array;
|
||||
obj_skin_ex_data* ex_data;
|
||||
uint32_t num_bone;
|
||||
int32_t bone_parent_ids_offset;
|
||||
int32_t field_28;
|
||||
int32_t field_2C;
|
||||
int32_t field_30;
|
||||
};
|
||||
|
||||
struct object_info {
|
||||
uint16_t id;
|
||||
uint16_t set_id;
|
||||
|
||||
inline object_info() {
|
||||
this->id = (uint16_t)-1;
|
||||
this->set_id = (uint16_t)-1;
|
||||
}
|
||||
|
||||
inline object_info(uint16_t id, uint16_t set_id) {
|
||||
this->id = id;
|
||||
this->set_id = set_id;
|
||||
}
|
||||
|
||||
inline object_info(uint32_t data) {
|
||||
this->id = (uint16_t)data;
|
||||
this->set_id = (uint16_t)(data >> 16);
|
||||
}
|
||||
|
||||
inline bool is_null() const {
|
||||
return id == (uint16_t)-1 && set_id == (uint16_t)-1;
|
||||
}
|
||||
|
||||
inline bool not_null() const {
|
||||
return id != (uint16_t)-1 || set_id != (uint16_t)-1;
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator >(const object_info& left, const object_info& right) {
|
||||
return *(uint32_t*)&left > *(uint32_t*)&right;
|
||||
}
|
||||
|
||||
inline bool operator <(const object_info& left, const object_info& right) {
|
||||
return *(uint32_t*)&left < *(uint32_t*)&right;
|
||||
}
|
||||
|
||||
inline bool operator >=(const object_info& left, const object_info& right) {
|
||||
return *(uint32_t*)&left >= *(uint32_t*)&right;
|
||||
}
|
||||
|
||||
inline bool operator <=(const object_info& left, const object_info& right) {
|
||||
return *(uint32_t*)&left <= *(uint32_t*)&right;
|
||||
}
|
||||
|
||||
inline bool operator ==(const object_info& left, const object_info& right) {
|
||||
return *(uint32_t*)&left == *(uint32_t*)&right;
|
||||
}
|
||||
|
||||
inline bool operator !=(const object_info& left, const object_info& right) {
|
||||
return *(uint32_t*)&left != *(uint32_t*)&right;
|
||||
}
|
||||
|
||||
struct obj_mesh_index_buffer {
|
||||
GLuint buffer;
|
||||
};
|
||||
|
||||
static_assert(sizeof(obj_mesh_index_buffer) == 0x04, "\"obj_mesh_index_buffer\" struct should have a size of 0x04");
|
||||
|
||||
struct obj_mesh_vertex_buffer {
|
||||
int32_t count;
|
||||
GLuint buffers[3];
|
||||
int32_t index;
|
||||
GLenum target;
|
||||
|
||||
void cycle_index();
|
||||
GLuint get_buffer();
|
||||
GLsizeiptr get_size();
|
||||
};
|
||||
|
||||
static_assert(sizeof(obj_mesh_vertex_buffer) == 0x18, "\"obj_mesh_vertex_buffer\" struct should have a size of 0x18");
|
||||
|
||||
struct obj_index_buffer {
|
||||
uint32_t mesh_num;
|
||||
obj_mesh_index_buffer* mesh_data;
|
||||
};
|
||||
|
||||
static_assert(sizeof(obj_index_buffer) == 0x10, "\"obj_index_buffer\" struct should have a size of 0x10");
|
||||
|
||||
struct obj_vertex_buffer {
|
||||
uint32_t mesh_num;
|
||||
obj_mesh_vertex_buffer* mesh_data;
|
||||
};
|
||||
|
||||
static_assert(sizeof(obj_vertex_buffer) == 0x10, "\"obj_vertex_buffer\" struct should have a size of 0x10");
|
||||
|
||||
extern uint32_t(FASTCALL* obj_database_get_object_info)(const char* name);
|
||||
extern obj* (FASTCALL* object_info_get_object)(object_info obj_info);
|
||||
extern obj_mesh_index_buffer* (FASTCALL* object_info_get_mesh_index_buffer)(object_info obj_info, int32_t a2);
|
||||
extern obj_skin* (FASTCALL* obj_database_get_object_skin)(object_info obj_info);
|
||||
extern obj_mesh_vertex_buffer* (FASTCALL* object_info_get_mesh_vertex_buffer)(object_info obj_info, int32_t a2);
|
||||
extern GLuint(FASTCALL* obj_database_get_obj_set_texture)(int32_t set, int32_t tex_id);
|
||||
extern prj::vector<GLuint>* (FASTCALL* obj_database_get_obj_set_textures)(int32_t set);
|
||||
|
||||
extern int32_t obj_material_texture_type_get_texcoord_index(
|
||||
obj_material_texture_type type, int32_t index);
|
||||
extern int32_t obj_material_texture_type_get_texture_index(
|
||||
obj_material_texture_type type, int32_t base_index);
|
||||
|
||||
extern void obj_skin_set_matrix_buffer(obj_skin* s, mat4* matrices,
|
||||
mat4* ex_data_matrices, mat4* matrix_buffer, const mat4* mat, const mat4* global_mat);
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "print.hpp"
|
||||
|
||||
void printf_divagl(const char* fmt, ...) {
|
||||
printf("[DivaGL] ");
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vprintf(fmt, args);
|
||||
va_end(args);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void printf_proxy(const char* fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vprintf(fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
|
||||
extern void printf_divagl(const char* fmt, ...);
|
||||
extern void printf_proxy(const char* fmt, ...);
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,204 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "../KKdLib/light_param/glow.hpp"
|
||||
#include "../KKdLib/vec.hpp"
|
||||
#include "renderer/dof.hpp"
|
||||
#include "renderer/transparency.hpp"
|
||||
#include "camera.hpp"
|
||||
#include "gl_uniform_buffer.hpp"
|
||||
|
||||
namespace rndr {
|
||||
struct Render {
|
||||
enum MagFilterType {
|
||||
MAG_FILTER_NEAREST = 0,
|
||||
MAG_FILTER_BILINEAR,
|
||||
MAG_FILTER_SHARPEN_5_TAP,
|
||||
MAG_FILTER_SHARPEN_4_TAP,
|
||||
MAG_FILTER_CONE_4_TAP,
|
||||
MAG_FILTER_CONE_2_TAP,
|
||||
MAG_FILTER_MAX,
|
||||
};
|
||||
|
||||
enum FrameTextureType {
|
||||
FRAME_TEXTURE_PRE_PP = 0,
|
||||
FRAME_TEXTURE_POST_PP,
|
||||
FRAME_TEXTURE_FB,
|
||||
FRAME_TEXTURE_MAX,
|
||||
};
|
||||
|
||||
struct ExposureCharaData {
|
||||
vec4 spot_coefficients[8];
|
||||
float_t spot_weight;
|
||||
GLuint query[3];
|
||||
GLuint query_data[3];
|
||||
|
||||
void reset();
|
||||
};
|
||||
|
||||
struct FrameTextureData {
|
||||
texture* texture;
|
||||
RenderTexture render_texture;
|
||||
FrameTextureType type;
|
||||
};
|
||||
|
||||
struct FrameTexture {
|
||||
FrameTextureData data[4];
|
||||
bool capture;
|
||||
};
|
||||
|
||||
int32_t downsample_count;
|
||||
int32_t downsample_max_count;
|
||||
int32_t ssaa;
|
||||
int32_t taa;
|
||||
int32_t mlaa;
|
||||
int32_t cam_blur;
|
||||
int32_t hd_res;
|
||||
int32_t base_downsample;
|
||||
int32_t ss_alpha_mask;
|
||||
RenderTexture rend_texture[5];
|
||||
RenderTexture taa_buffer[3];
|
||||
texture* taa_tex[3];
|
||||
RenderTexture aet_back_texture;
|
||||
texture* aet_back_tex;
|
||||
RenderTexture downsample_texture;
|
||||
RenderTexture reduce_texture[5];
|
||||
texture* reduce_tex[5];
|
||||
RenderTexture field_340;
|
||||
GLuint reduce_tex_draw;
|
||||
RenderTexture exposure_texture;
|
||||
GLuint exposure_tex;
|
||||
texture* exposure_history;
|
||||
RenderTexture field_3B8;
|
||||
RenderTexture field_3E8;
|
||||
GLuint tonemap_lut_texture;
|
||||
RenderTexture mlaa_buffer;
|
||||
RenderTexture temp_buffer;
|
||||
GLuint mlaa_area_texture;
|
||||
RenderTexture* sss_contour_texture;
|
||||
int32_t texture_counter;
|
||||
GLuint lens_shaft_query[3];
|
||||
GLuint lens_flare_query[3];
|
||||
GLuint lens_shaft_query_data[3];
|
||||
GLuint lens_flare_query_data[3];
|
||||
int32_t lens_flare_query_index;
|
||||
GLuint lens_flare_texture;
|
||||
GLuint lens_shaft_texture;
|
||||
GLuint lens_ghost_texture;
|
||||
int32_t lens_ghost_count;
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
int32_t inner_width;
|
||||
int32_t inner_height;
|
||||
int32_t render_width[5];
|
||||
int32_t render_height[5];
|
||||
int32_t render_post_width[5];
|
||||
int32_t render_post_height[5];
|
||||
float_t render_post_width_scale;
|
||||
float_t render_post_height_scale;
|
||||
int32_t reduce_width[5];
|
||||
int32_t reduce_height[5];
|
||||
int32_t taa_texture_selector;
|
||||
int32_t taa_texture;
|
||||
float_t taa_blend;
|
||||
vec3 view_point;
|
||||
vec3 interest;
|
||||
vec3 view_point_prev;
|
||||
vec3 interest_prev;
|
||||
mat4 cam_view_projection;
|
||||
mat4 cam_view_projection_prev;
|
||||
int32_t stage_index;
|
||||
int32_t stage_index_prev;
|
||||
bool reset_exposure;
|
||||
int32_t screen_x_offset;
|
||||
int32_t screen_y_offset;
|
||||
int32_t screen_width;
|
||||
int32_t screen_height;
|
||||
int32_t update_lut;
|
||||
int32_t saturate_lock;
|
||||
ExposureCharaData exposure_chara_data[6];
|
||||
int32_t exposure_history_counter;
|
||||
int32_t exposure_query_index;
|
||||
vec3 lens_flare_pos;
|
||||
float_t lens_shaft_scale;
|
||||
float_t lens_shaft_inv_scale;
|
||||
float_t lens_flare_power;
|
||||
float_t field_A10;
|
||||
float_t lens_flare_appear_power;
|
||||
texture* render_textures_data[16];
|
||||
RenderTexture render_textures[16];
|
||||
texture* movie_textures_data[1];
|
||||
RenderTexture movie_textures[1];
|
||||
int32_t aet_back;
|
||||
renderer::DOF3* dof;
|
||||
texture* transparency_tex[1];
|
||||
renderer::Transparency* transparency;
|
||||
int32_t saturate_index;
|
||||
int32_t scene_fade_index;
|
||||
int32_t tone_trans_index;
|
||||
float_t saturate_coeff[2];
|
||||
vec3 scene_fade_color[2];
|
||||
float_t scene_fade_alpha[2];
|
||||
int32_t scene_fade_blend_func[2];
|
||||
vec3 tone_trans_scale[2];
|
||||
vec3 tone_trans_offset[2];
|
||||
vec3 tone_trans_start[2];
|
||||
vec3 tone_trans_end[2];
|
||||
tone_map_method tone_map;
|
||||
float_t exposure;
|
||||
float_t exposure_rate;
|
||||
int32_t auto_exposure;
|
||||
float_t gamma;
|
||||
float_t gamma_rate;
|
||||
int32_t saturate_power;
|
||||
MagFilterType mag_filter;
|
||||
float_t fade_alpha;
|
||||
int32_t fade;
|
||||
float_t lens_flare;
|
||||
float_t lens_shaft;
|
||||
float_t lens_ghost;
|
||||
vec3 radius;
|
||||
vec3 intensity;
|
||||
int32_t update;
|
||||
FrameTexture frame_texture[6];
|
||||
|
||||
void apply_post_process();
|
||||
void bind_render_texture(bool aet_back = false);
|
||||
void calc_exposure_chara_data();
|
||||
void calc_projection_matrix(mat4* mat, double_t fov, double_t aspect, double_t z_near, double_t z_far,
|
||||
double_t left_scale, double_t right_scale, double_t bottom_scale, double_t top_scale);
|
||||
void ctrl();
|
||||
void draw_quad(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 free();
|
||||
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 resize(int32_t width, int32_t height);
|
||||
void transparency_combine(float_t alpha);
|
||||
void transparency_copy();
|
||||
void update_res(bool set, int32_t base_downsample);
|
||||
|
||||
private:
|
||||
void apply_mlaa(int32_t ss_alpha_mask);
|
||||
void apply_tone_map();
|
||||
void calc_exposure();
|
||||
void calc_gaussian_blur(float_t start, float_t step,
|
||||
int32_t kernel_size, float_t radius_scale, float_t intensity_scale);
|
||||
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 get_blur();
|
||||
void update_tone_map_lut();
|
||||
};
|
||||
|
||||
static_assert(sizeof(rndr::Render) == 0x1510, "\"rndr::Render\" struct should have a size of 0x1510");
|
||||
}
|
||||
|
||||
extern rndr::Render* render;
|
||||
@@ -0,0 +1,516 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "render_context.hpp"
|
||||
#include "render_manager.hpp"
|
||||
|
||||
void draw_state_stats::reset() {
|
||||
object_draw_count = 0;
|
||||
object_translucent_draw_count = 0;
|
||||
object_reflect_draw_count = 0;
|
||||
field_C = 0;
|
||||
field_10 = 0;
|
||||
draw_count = 0;
|
||||
draw_triangle_count = 0;
|
||||
field_1C = 0;
|
||||
}
|
||||
|
||||
draw_state_struct* draw_state = (draw_state_struct*)0x00000001411A32B0;
|
||||
|
||||
render_context* rctx;
|
||||
|
||||
sss_data* (FASTCALL* sss_data_get)()
|
||||
= (sss_data * (FASTCALL*)())0x0000000140641B70;
|
||||
|
||||
void obj_scene_shader_data::set_g_irradiance_r_transforms(const mat4& mat) {
|
||||
mat4 temp;
|
||||
mat4_transpose(&mat, &temp);
|
||||
g_irradiance_r_transforms[0] = temp.row0;
|
||||
g_irradiance_r_transforms[1] = temp.row1;
|
||||
g_irradiance_r_transforms[2] = temp.row2;
|
||||
g_irradiance_r_transforms[3] = temp.row3;
|
||||
}
|
||||
|
||||
void obj_scene_shader_data::set_g_irradiance_g_transforms(const mat4& mat) {
|
||||
mat4 temp;
|
||||
mat4_transpose(&mat, &temp);
|
||||
g_irradiance_g_transforms[0] = temp.row0;
|
||||
g_irradiance_g_transforms[1] = temp.row1;
|
||||
g_irradiance_g_transforms[2] = temp.row2;
|
||||
g_irradiance_g_transforms[3] = temp.row3;
|
||||
}
|
||||
|
||||
void obj_scene_shader_data::set_g_irradiance_b_transforms(const mat4& mat) {
|
||||
mat4 temp;
|
||||
mat4_transpose(&mat, &temp);
|
||||
g_irradiance_b_transforms[0] = temp.row0;
|
||||
g_irradiance_b_transforms[1] = temp.row1;
|
||||
g_irradiance_b_transforms[2] = temp.row2;
|
||||
g_irradiance_b_transforms[3] = temp.row3;
|
||||
}
|
||||
|
||||
void obj_scene_shader_data::set_g_normal_tangent_transforms(const mat4& mat) {
|
||||
mat4 temp;
|
||||
mat4_transpose(&mat, &temp);
|
||||
g_normal_tangent_transforms[0] = temp.row0;
|
||||
g_normal_tangent_transforms[1] = temp.row1;
|
||||
g_normal_tangent_transforms[2] = temp.row2;
|
||||
}
|
||||
|
||||
void obj_scene_shader_data::set_g_self_shadow_receivers(int32_t index, const mat4& mat) {
|
||||
size_t _index = index * 3LL;
|
||||
|
||||
mat4 temp;
|
||||
mat4_transpose(&mat, &temp);
|
||||
g_self_shadow_receivers[_index + 0] = temp.row0;
|
||||
g_self_shadow_receivers[_index + 1] = temp.row1;
|
||||
g_self_shadow_receivers[_index + 2] = temp.row2;
|
||||
}
|
||||
|
||||
void obj_scene_shader_data::set_g_light_projection(const mat4& mat) {
|
||||
mat4 temp;
|
||||
mat4_transpose(&mat, &temp);
|
||||
g_light_projection[0] = temp.row0;
|
||||
g_light_projection[1] = temp.row1;
|
||||
g_light_projection[2] = temp.row2;
|
||||
g_light_projection[3] = temp.row3;
|
||||
}
|
||||
|
||||
void obj_scene_shader_data::set_projection_view(const mat4& view, const mat4& proj) {
|
||||
mat4 temp;
|
||||
mat4_transpose(&view, &temp);
|
||||
g_view[0] = temp.row0;
|
||||
g_view[1] = temp.row1;
|
||||
g_view[2] = temp.row2;
|
||||
|
||||
mat4_invert(&view, &temp);
|
||||
mat4_transpose(&temp, &temp);
|
||||
g_view_inverse[0] = temp.row0;
|
||||
g_view_inverse[1] = temp.row1;
|
||||
g_view_inverse[2] = temp.row2;
|
||||
|
||||
mat4_mul(&view, &proj, &temp);
|
||||
mat4_transpose(&temp, &temp);
|
||||
g_projection_view[0] = temp.row0;
|
||||
g_projection_view[1] = temp.row1;
|
||||
g_projection_view[2] = temp.row2;
|
||||
g_projection_view[3] = temp.row3;
|
||||
}
|
||||
|
||||
void obj_batch_shader_data::set_g_joint(const mat4& mat) {
|
||||
mat4 temp;
|
||||
mat4_transpose(&mat, &temp);
|
||||
g_joint[0] = temp.row0;
|
||||
g_joint[1] = temp.row1;
|
||||
g_joint[2] = temp.row2;
|
||||
|
||||
mat4_invert(&mat, &temp);
|
||||
mat4_transpose(&temp, &temp);
|
||||
g_joint_inverse[0] = temp.row0;
|
||||
g_joint_inverse[1] = temp.row1;
|
||||
g_joint_inverse[2] = temp.row2;
|
||||
}
|
||||
|
||||
void obj_batch_shader_data::set_g_texcoord_transforms(int32_t index, const mat4& mat) {
|
||||
size_t _index = index * 2LL;
|
||||
|
||||
mat4 temp;
|
||||
mat4_transpose(&mat, &temp);
|
||||
g_texcoord_transforms[_index + 0] = temp.row0;
|
||||
g_texcoord_transforms[_index + 1] = temp.row1;
|
||||
}
|
||||
|
||||
void obj_batch_shader_data::set_transforms(const mat4& model, const mat4& view, const mat4& proj) {
|
||||
mat4 temp;
|
||||
mat4_transpose(&model, &temp);
|
||||
g_worlds[0] = temp.row0;
|
||||
g_worlds[1] = temp.row1;
|
||||
g_worlds[2] = temp.row2;
|
||||
|
||||
mat4_invert(&model, &temp);
|
||||
g_worlds_invtrans[0] = temp.row0;
|
||||
g_worlds_invtrans[1] = temp.row1;
|
||||
g_worlds_invtrans[2] = temp.row2;
|
||||
|
||||
mat4 mv;
|
||||
mat4_mul(&model, &view, &mv);
|
||||
|
||||
mat4_transpose(&mv, &temp);
|
||||
g_worldview[0] = temp.row0;
|
||||
g_worldview[1] = temp.row1;
|
||||
g_worldview[2] = temp.row2;
|
||||
|
||||
mat4_invert(&mv, &temp);
|
||||
mat4_transpose(&temp, &temp);
|
||||
g_worldview_inverse[0] = temp.row0;
|
||||
g_worldview_inverse[1] = temp.row1;
|
||||
g_worldview_inverse[2] = temp.row2;
|
||||
|
||||
mat4_mul(&mv, &proj, &temp);
|
||||
mat4_transpose(&temp, &temp);
|
||||
g_transforms[0] = temp.row0;
|
||||
g_transforms[1] = temp.row1;
|
||||
g_transforms[2] = temp.row2;
|
||||
g_transforms[3] = temp.row3;
|
||||
}
|
||||
|
||||
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(), sprite_width(),
|
||||
sprite_height(), screen_x_offset(), screen_y_offset(), screen_width(), screen_height() {
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
-0.5f, 0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||
-0.5f, 0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||
-0.5f, 0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||
-0.5f, 0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.5f, -1.5f, -1.5f, 0.5f, 1.5f, -0.5f, -0.5f, 1.5f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.5f, -1.5f, -1.5f, 0.5f, 1.5f, -0.5f, -0.5f, 1.5f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.5f, -1.5f, -1.5f, 0.5f, 1.5f, -0.5f, -0.5f, 1.5f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.5f, -1.5f, -1.5f, 0.5f, 1.5f, -0.5f, -0.5f, 1.5f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||
3.5f, -3.5f, -1.5f, -3.5f, 1.5f, -1.5f, -3.5f, -1.5f,
|
||||
3.5f, 1.5f, -1.5f, 1.5f, 1.5f, 3.5f, -3.5f, 3.5f,
|
||||
3.5f, -3.5f, -1.5f, -3.5f, 1.5f, -1.5f, -3.5f, -1.5f,
|
||||
3.5f, 1.5f, -1.5f, 1.5f, 1.5f, 3.5f, -3.5f, 3.5f,
|
||||
3.5f, -3.5f, -1.5f, -3.5f, 1.5f, -1.5f, -3.5f, -1.5f,
|
||||
3.5f, 1.5f, -1.5f, 1.5f, 1.5f, 3.5f, -3.5f, 3.5f,
|
||||
3.5f, -3.5f, -1.5f, -3.5f, 1.5f, -1.5f, -3.5f, -1.5f,
|
||||
3.5f, 1.5f, -1.5f, 1.5f, 1.5f, 3.5f, -3.5f, 3.5f,
|
||||
};
|
||||
|
||||
glGenVertexArrays(1, &box_vao);
|
||||
gl_state_bind_vertex_array(box_vao);
|
||||
|
||||
box_vbo.Create(sizeof(box_texcoords), box_texcoords);
|
||||
box_vbo.Bind();
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(float_t) * 16, (void*)0);
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, sizeof(float_t) * 16, (void*)(sizeof(float_t) * 4));
|
||||
glEnableVertexAttribArray(2);
|
||||
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(float_t) * 16, (void*)(sizeof(float_t) * 8));
|
||||
glEnableVertexAttribArray(3);
|
||||
glVertexAttribPointer(3, 4, GL_FLOAT, GL_FALSE, sizeof(float_t) * 16, (void*)(sizeof(float_t) * 12));
|
||||
|
||||
glGenVertexArrays(1, &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();
|
||||
|
||||
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_state_bind_array_buffer(0);
|
||||
gl_state_bind_vertex_array(0);
|
||||
|
||||
glGenVertexArrays(1, &common_vao);
|
||||
|
||||
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));
|
||||
|
||||
obj_scene = {};
|
||||
obj_batch = {};
|
||||
obj_skinning = {};
|
||||
obj_scene_ubo.Create(sizeof(obj_scene_shader_data));
|
||||
obj_batch_ubo.Create(sizeof(obj_batch_shader_data));
|
||||
obj_skinning_ubo.Create(sizeof(obj_skinning_shader_data));
|
||||
|
||||
static const uint8_t empty_texture_data[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
static const GLenum target_cube_map_array[] = {
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
|
||||
};
|
||||
|
||||
glGenTextures(1, &empty_texture_2d);
|
||||
gl_state_bind_texture_2d(empty_texture_2d);
|
||||
texture_set_params(GL_TEXTURE_2D, 0, false);
|
||||
glCompressedTexImage2D(GL_TEXTURE_2D, 0,
|
||||
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 4, 4, 0, 8, empty_texture_data);
|
||||
gl_state_bind_texture_2d(0);
|
||||
|
||||
glGenTextures(1, &empty_texture_cube_map);
|
||||
gl_state_bind_texture_cube_map(empty_texture_cube_map);
|
||||
texture_set_params(GL_TEXTURE_CUBE_MAP, 0, false);
|
||||
for (int32_t side = 0; side < 6; side++)
|
||||
glCompressedTexImage2D(target_cube_map_array[side], 0,
|
||||
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 4, 4, 0, 8, empty_texture_data);
|
||||
gl_state_bind_texture_cube_map(0);
|
||||
|
||||
static const vec4 border_color = 0.0f;
|
||||
|
||||
glGenSamplers(18, samplers);
|
||||
for (int32_t i = 0; i < 18; i++) {
|
||||
GLuint sampler = samplers[i];
|
||||
|
||||
glSamplerParameterfv(sampler, GL_TEXTURE_BORDER_COLOR, (GLfloat*)&border_color);
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER,
|
||||
i % 2 ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR);
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glSamplerParameterf(sampler, GL_TEXTURE_MAX_ANISOTROPY_EXT, 16.0f);
|
||||
|
||||
GLuint wrap_s;
|
||||
switch (i / 2 % 3) {
|
||||
case 0:
|
||||
wrap_s = GL_CLAMP_TO_EDGE;
|
||||
break;
|
||||
case 1:
|
||||
wrap_s = GL_REPEAT;
|
||||
break;
|
||||
case 2:
|
||||
wrap_s = GL_MIRRORED_REPEAT;
|
||||
break;
|
||||
}
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_WRAP_S, wrap_s);
|
||||
|
||||
GLenum wrap_t;
|
||||
switch (i / 6 % 3) {
|
||||
case 0:
|
||||
wrap_t = GL_CLAMP_TO_EDGE;
|
||||
break;
|
||||
case 1:
|
||||
wrap_t = GL_REPEAT;
|
||||
break;
|
||||
case 2:
|
||||
wrap_t = GL_MIRRORED_REPEAT;
|
||||
break;
|
||||
}
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_WRAP_T, wrap_t);
|
||||
}
|
||||
|
||||
GLuint sampler;
|
||||
glGenSamplers(3, render_samplers);
|
||||
sampler = render_samplers[0];
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
sampler = render_samplers[1];
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
sampler = render_samplers[2];
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
|
||||
glSamplerParameterfv(sampler, GL_TEXTURE_BORDER_COLOR, (GLfloat*)&border_color);
|
||||
|
||||
glGenSamplers(3, sprite_samplers);
|
||||
sampler = sprite_samplers[0];
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameterf(sampler, GL_TEXTURE_MAX_ANISOTROPY_EXT, 16.0f);
|
||||
|
||||
sampler = sprite_samplers[1];
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glSamplerParameterf(sampler, GL_TEXTURE_MAX_ANISOTROPY_EXT, 16.0f);
|
||||
|
||||
sampler = sprite_samplers[2];
|
||||
glSamplerParameterfv(sampler, GL_TEXTURE_BORDER_COLOR, (GLfloat*)&border_color);
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
|
||||
glSamplerParameteri(sampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
|
||||
glSamplerParameterf(sampler, GL_TEXTURE_MAX_ANISOTROPY_EXT, 16.0f);
|
||||
}
|
||||
|
||||
render_context::~render_context() {
|
||||
glDeleteSamplers(3, sprite_samplers);
|
||||
glDeleteSamplers(3, render_samplers);
|
||||
glDeleteSamplers(18, samplers);
|
||||
|
||||
glDeleteTextures(1, &empty_texture_cube_map);
|
||||
glDeleteTextures(1, &empty_texture_2d);
|
||||
|
||||
obj_skinning_ubo.Destroy();
|
||||
obj_batch_ubo.Destroy();
|
||||
obj_scene_ubo.Destroy();
|
||||
|
||||
tone_map_ubo.Destroy();
|
||||
transparency_batch_ubo.Destroy();
|
||||
sun_quad_ubo.Destroy();
|
||||
sss_filter_gaussian_coef_ubo.Destroy();
|
||||
sprite_scene_ubo.Destroy();
|
||||
quad_ubo.Destroy();
|
||||
glitter_batch_ubo.Destroy();
|
||||
glass_eye_batch_ubo.Destroy();
|
||||
gaussian_coef_ubo.Destroy();
|
||||
exposure_measure_ubo.Destroy();
|
||||
imgfilter_batch_ubo.Destroy();
|
||||
esm_filter_batch_ubo.Destroy();
|
||||
filter_scene_ubo.Destroy();
|
||||
contour_params_ubo.Destroy();
|
||||
contour_coef_ubo.Destroy();
|
||||
|
||||
if (common_vao) {
|
||||
glDeleteVertexArrays(1, &common_vao);
|
||||
common_vao = 0;
|
||||
}
|
||||
|
||||
if (lens_ghost_vao) {
|
||||
glDeleteVertexArrays(1, &lens_ghost_vao);
|
||||
lens_ghost_vao = 0;
|
||||
}
|
||||
|
||||
lens_ghost_vbo.Destroy();
|
||||
|
||||
if (box_vao) {
|
||||
glDeleteVertexArrays(1, &box_vao);
|
||||
box_vao = 0;
|
||||
}
|
||||
|
||||
box_vbo.Destroy();
|
||||
}
|
||||
|
||||
void render_context::ctrl(bool change_res) {
|
||||
RECT rect;
|
||||
extern size_t diva_handle;
|
||||
GetClientRect((HWND)diva_handle, &rect);
|
||||
|
||||
int32_t width = rect.right - rect.left;
|
||||
int32_t height = rect.bottom - rect.top;
|
||||
if (screen_width == width && screen_height == height)
|
||||
return;
|
||||
|
||||
static const double_t aspect = 16.0 / 9.0;
|
||||
|
||||
double_t res_width = (double_t)width;
|
||||
double_t res_height = (double_t)height;
|
||||
double_t view_aspect = res_width / res_height;
|
||||
if (view_aspect < aspect)
|
||||
res_height = round(res_width / aspect);
|
||||
else if (view_aspect > aspect)
|
||||
res_width = round(res_height * aspect);
|
||||
|
||||
int32_t render_width = (int32_t)res_width;
|
||||
int32_t render_height = (int32_t)res_height;
|
||||
int32_t sprite_width = (int32_t)res_width;
|
||||
int32_t sprite_height = (int32_t)res_height;
|
||||
int32_t screen_width = width;
|
||||
int32_t screen_height = height;
|
||||
|
||||
//bool render_res_change = render->inner_width != render_width || render->inner_height != render_height;
|
||||
bool sprite_res_change = this->sprite_width != sprite_width || this->sprite_height != sprite_height;
|
||||
bool screen_res_change = this->screen_width != screen_width || this->screen_height != screen_height;
|
||||
|
||||
this->sprite_width = sprite_width;
|
||||
this->sprite_height = sprite_height;
|
||||
|
||||
screen_x_offset = (screen_width - sprite_width) / 2 + (screen_width - sprite_width) % 2;
|
||||
screen_y_offset = (screen_height - sprite_height) / 2 + (screen_height - sprite_height) % 2;
|
||||
|
||||
this->screen_width = screen_width;
|
||||
this->screen_height = screen_height;
|
||||
|
||||
if (!change_res || /*!render_res_change && */!sprite_res_change && !screen_res_change)
|
||||
return;
|
||||
|
||||
/*if (render_res_change)
|
||||
render.resize(render_width, render_height);*/
|
||||
|
||||
if (sprite_res_change)
|
||||
render_manager->resize(sprite_width, sprite_height);
|
||||
|
||||
/*if (render_res_change)
|
||||
litproj_texture->Init(render_width, render_height, 0, GL_RGBA8, GL_DEPTH_COMPONENT32F);*/
|
||||
|
||||
/*sprite_manager_set_res((double_t)sprite_width / (double_t)sprite_height,
|
||||
sprite_width, sprite_height);*/
|
||||
|
||||
/*if (render_res_change) {
|
||||
auto init_copy_buffer = [&](RenderTexture& src, RenderTexture& dst) {
|
||||
dst.Init(src.GetWidth(),
|
||||
src.GetHeight(), 0, src.color_texture->internal_format,
|
||||
src.depth_texture ? src.depth_texture->internal_format : GL_ZERO);
|
||||
};
|
||||
|
||||
RenderTexture& render_buffer = render->rend_texture[0];
|
||||
RenderTexture& reflect_buffer = render_manager->get_render_texture(1);
|
||||
RenderTexture& shadow_buffer = shadow_ptr_get()->render_textures[1];
|
||||
init_copy_buffer(reflect_buffer, this->reflect_buffer);
|
||||
init_copy_buffer(render_buffer, this->render_buffer);
|
||||
init_copy_buffer(shadow_buffer, this->shadow_buffer);
|
||||
}*/
|
||||
|
||||
if (sprite_res_change)
|
||||
screen_buffer.Init(sprite_width, sprite_height, 0, GL_RGBA16F, 0); // Was GL_R11F_G11F_B10F
|
||||
}
|
||||
|
||||
void render_context::free() {
|
||||
shadow_buffer.Free();
|
||||
screen_buffer.Free();
|
||||
render_buffer.Free();
|
||||
reflect_buffer.Free();
|
||||
}
|
||||
|
||||
void render_context::init() {
|
||||
ctrl(false);
|
||||
|
||||
auto init_copy_buffer = [&](RenderTexture& src, RenderTexture& dst) {
|
||||
dst.Init(src.GetWidth(),
|
||||
src.GetHeight(), 0, src.color_texture->internal_format,
|
||||
src.depth_texture ? src.depth_texture->internal_format : GL_ZERO);
|
||||
};
|
||||
|
||||
RenderTexture& render_buffer = render->rend_texture[0];
|
||||
RenderTexture& reflect_buffer = render_manager->get_render_texture(1);
|
||||
RenderTexture& shadow_buffer = shadow_ptr_get()->render_textures[1];
|
||||
init_copy_buffer(reflect_buffer, this->reflect_buffer);
|
||||
init_copy_buffer(render_buffer, this->render_buffer);
|
||||
init_copy_buffer(shadow_buffer, this->shadow_buffer);
|
||||
|
||||
screen_buffer.Init(sprite_width, sprite_height, 0, GL_RGBA16F, 0); // Was GL_R11F_G11F_B10F
|
||||
}
|
||||
|
||||
void fbo_blit(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_state_bind_read_framebuffer(src_fbo);
|
||||
gl_state_bind_draw_framebuffer(dst_fbo);
|
||||
glBlitFramebuffer(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);
|
||||
}
|
||||
@@ -0,0 +1,331 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "../KKdLib/mat.hpp"
|
||||
#include "../KKdLib/vec.hpp"
|
||||
#include "light_param/fog.hpp"
|
||||
#include "light_param/light.hpp"
|
||||
#include "mdl/disp_manager.hpp"
|
||||
#include "camera.hpp"
|
||||
#include "gl_array_buffer.hpp"
|
||||
#include "gl_element_array_buffer.hpp"
|
||||
#include "gl_uniform_buffer.hpp"
|
||||
#include "render.hpp"
|
||||
#include "render_manager.hpp"
|
||||
#include "render_texture.hpp"
|
||||
|
||||
#define TEXTURE_PATTERN_COUNT 24
|
||||
#define TEXTURE_TRANSFORM_COUNT 24
|
||||
|
||||
struct draw_state_stats {
|
||||
int32_t object_draw_count;
|
||||
int32_t object_translucent_draw_count;
|
||||
int32_t object_reflect_draw_count;
|
||||
int32_t field_C;
|
||||
int32_t field_10;
|
||||
int32_t draw_count;
|
||||
int32_t draw_triangle_count;
|
||||
int32_t field_1C;
|
||||
|
||||
void reset();
|
||||
};
|
||||
|
||||
struct sss_data {
|
||||
bool init;
|
||||
bool enable;
|
||||
bool npr_contour;
|
||||
RenderTexture textures[4];
|
||||
vec4 param;
|
||||
};
|
||||
|
||||
struct draw_state_struct {
|
||||
draw_state_stats stats;
|
||||
draw_state_stats stats_prev;
|
||||
bool vertex_buffer;
|
||||
bool wireframe;
|
||||
bool wireframe_overlay;
|
||||
bool light;
|
||||
bool self_shadow;
|
||||
bool shader_debug_flag;
|
||||
bool use_global_material;
|
||||
bool fog_height;
|
||||
bool back_display;
|
||||
int32_t shader_index;
|
||||
int32_t show;
|
||||
float_t bump_depth;
|
||||
float_t intensity;
|
||||
float_t reflectivity;
|
||||
float_t reflect_uv_scale;
|
||||
float_t refract_uv_scale;
|
||||
int32_t field_68;
|
||||
void* curr_obj_sub_mesh_args;
|
||||
float_t fresnel;
|
||||
GLuint program_buffer_index;
|
||||
void* program_buffer_matrix_data;
|
||||
};
|
||||
|
||||
struct contour_coef_shader_data {
|
||||
vec4 g_contour;
|
||||
vec4 g_near_far;
|
||||
};
|
||||
|
||||
struct contour_params_shader_data {
|
||||
vec4 g_near_far;
|
||||
};
|
||||
|
||||
struct filter_scene_shader_data {
|
||||
vec4 g_transform;
|
||||
vec4 g_texcoord;
|
||||
};
|
||||
|
||||
struct exposure_measure_shader_data {
|
||||
vec4 g_spot_weight;
|
||||
vec4 g_spot_coefficients[32];
|
||||
};
|
||||
|
||||
struct gaussian_coef_shader_data {
|
||||
vec4 g_coef[8];
|
||||
};
|
||||
|
||||
struct esm_filter_batch_shader_data {
|
||||
vec4 g_params;
|
||||
vec4 g_gauss[2];
|
||||
};
|
||||
|
||||
struct imgfilter_batch_shader_data {
|
||||
vec4 g_texture_lod;
|
||||
vec4 g_color_scale;
|
||||
vec4 g_color_offset;
|
||||
};
|
||||
|
||||
struct glass_eye_batch_shader_data {
|
||||
vec4 g_ellipsoid_radius;
|
||||
vec4 g_ellipsoid_scale;
|
||||
vec4 g_tex_model_param;
|
||||
vec4 g_tex_offset;
|
||||
vec4 g_eb_radius;
|
||||
vec4 g_eb_tex_model_param;
|
||||
vec4 g_fresnel;
|
||||
vec4 g_refract1;
|
||||
vec4 g_refract2;
|
||||
vec4 g_iris_radius;
|
||||
vec4 g_cornea_radius;
|
||||
vec4 g_pupil_radius;
|
||||
vec4 g_tex_scale;
|
||||
};
|
||||
|
||||
struct glitter_batch_shader_data {
|
||||
vec4 g_mvp[4];
|
||||
vec4 g_glitter_blend_color;
|
||||
vec4 g_state_material_diffuse;
|
||||
vec4 g_state_material_emission;
|
||||
};
|
||||
|
||||
struct obj_scene_shader_data {
|
||||
vec4 g_irradiance_r_transforms[4];
|
||||
vec4 g_irradiance_g_transforms[4];
|
||||
vec4 g_irradiance_b_transforms[4];
|
||||
vec4 g_light_env_stage_diffuse;
|
||||
vec4 g_light_env_stage_specular;
|
||||
vec4 g_light_env_chara_diffuse;
|
||||
vec4 g_light_env_chara_ambient;
|
||||
vec4 g_light_env_chara_specular;
|
||||
vec4 g_light_env_reflect_diffuse;
|
||||
vec4 g_light_env_reflect_ambient;
|
||||
vec4 g_light_env_proj_diffuse;
|
||||
vec4 g_light_env_proj_specular;
|
||||
vec4 g_light_env_proj_position;
|
||||
vec4 g_light_stage_dir;
|
||||
vec4 g_light_stage_diff;
|
||||
vec4 g_light_stage_spec;
|
||||
vec4 g_light_chara_dir;
|
||||
vec4 g_light_chara_spec;
|
||||
vec4 g_light_chara_luce;
|
||||
vec4 g_light_chara_back;
|
||||
vec4 g_light_face_diff;
|
||||
vec4 g_chara_color_rim;
|
||||
vec4 g_chara_color0;
|
||||
vec4 g_chara_color1;
|
||||
vec4 g_chara_f_dir;
|
||||
vec4 g_chara_f_ambient;
|
||||
vec4 g_chara_f_diffuse;
|
||||
vec4 g_chara_tc_param;
|
||||
vec4 g_fog_depth_color;
|
||||
vec4 g_fog_height_params; //x=density, y=start, z=end, w=1/(end-start)
|
||||
vec4 g_fog_height_color;
|
||||
vec4 g_fog_bump_params; //x=density, y=start, z=end, w=1/(end-start)
|
||||
vec4 g_fog_state_params; //x=density, y=start, z=end, w=1/(end-start)
|
||||
vec4 g_normal_tangent_transforms[3];
|
||||
vec4 g_esm_param;
|
||||
vec4 g_self_shadow_receivers[6];
|
||||
vec4 g_shadow_ambient;
|
||||
vec4 g_shadow_ambient1;
|
||||
vec4 g_framebuffer_size;
|
||||
vec4 g_light_reflect_dir;
|
||||
vec4 g_clip_plane;
|
||||
vec4 g_npr_cloth_spec_color;
|
||||
vec4 g_view[3];
|
||||
vec4 g_view_inverse[3];
|
||||
vec4 g_projection_view[4];
|
||||
vec4 g_view_position;
|
||||
vec4 g_light_projection[4];
|
||||
|
||||
void set_g_irradiance_r_transforms(const mat4& mat);
|
||||
void set_g_irradiance_g_transforms(const mat4& mat);
|
||||
void set_g_irradiance_b_transforms(const mat4& mat);
|
||||
void set_g_normal_tangent_transforms(const mat4& mat);
|
||||
void set_g_self_shadow_receivers(int32_t index, const mat4& mat);
|
||||
void set_g_light_projection(const mat4& mat);
|
||||
|
||||
void set_projection_view(const mat4& view, const mat4& proj);
|
||||
};
|
||||
|
||||
struct obj_batch_shader_data {
|
||||
vec4 g_transforms[4];
|
||||
vec4 g_worlds[3];
|
||||
vec4 g_worlds_invtrans[3];
|
||||
vec4 g_worldview[3];
|
||||
vec4 g_worldview_inverse[3];
|
||||
vec4 g_joint[3];
|
||||
vec4 g_joint_inverse[3];
|
||||
vec4 g_texcoord_transforms[4];
|
||||
vec4 g_blend_color;
|
||||
vec4 g_offset_color;
|
||||
vec4 g_material_state_diffuse;
|
||||
vec4 g_material_state_ambient;
|
||||
vec4 g_material_state_emission;
|
||||
vec4 g_material_state_shininess;
|
||||
vec4 g_material_state_specular;
|
||||
vec4 g_fresnel_coefficients;
|
||||
vec4 g_texture_color_coefficients;
|
||||
vec4 g_texture_color_offset;
|
||||
vec4 g_texture_specular_coefficients;
|
||||
vec4 g_texture_specular_offset;
|
||||
vec4 g_shininess;
|
||||
vec4 g_max_alpha;
|
||||
vec4 g_morph_weight;
|
||||
vec4 g_sss_param;
|
||||
vec4 g_bump_depth;
|
||||
vec4 g_intensity;
|
||||
vec4 g_reflect_uv_scale;
|
||||
vec4 g_texture_blend;
|
||||
|
||||
void set_g_joint(const mat4& mat);
|
||||
void set_g_texcoord_transforms(int32_t index, const mat4& mat);
|
||||
|
||||
void set_transforms(const mat4& model, const mat4& view, const mat4& proj);
|
||||
};
|
||||
|
||||
struct obj_skinning_shader_data {
|
||||
vec4 g_joint_transforms[768];
|
||||
};
|
||||
|
||||
struct quad_shader_data {
|
||||
vec4 g_texcoord_modifier;
|
||||
vec4 g_texel_size;
|
||||
vec4 g_color;
|
||||
vec4 g_texture_lod;
|
||||
};
|
||||
|
||||
struct sprite_scene_shader_data {
|
||||
mat4 g_transform;
|
||||
vec4 g_framebuffer_size;
|
||||
};
|
||||
|
||||
struct sss_filter_gaussian_coef_shader_data {
|
||||
vec4 g_param;
|
||||
vec4 g_coef[64];
|
||||
};
|
||||
|
||||
struct sun_quad_shader_data {
|
||||
vec4 g_transform[4];
|
||||
vec4 g_emission;
|
||||
};
|
||||
|
||||
struct tone_map_shader_data {
|
||||
vec4 g_exposure;
|
||||
vec4 g_flare_coef;
|
||||
vec4 g_fade_color;
|
||||
vec4 g_tone_scale; //xyz=tone_scale, w=fade_func
|
||||
vec4 g_tone_offset; //xyz=tone_offset, w=inv_tone
|
||||
vec4 g_texcoord_transforms[8];
|
||||
};
|
||||
|
||||
struct render_context {
|
||||
mat4 view_mat;
|
||||
mat4 proj_mat;
|
||||
mat4 vp_mat;
|
||||
vec4 g_near_far;
|
||||
|
||||
GLuint box_vao;
|
||||
GLArrayBuffer box_vbo;
|
||||
|
||||
GLuint lens_ghost_vao;
|
||||
GLArrayBuffer lens_ghost_vbo;
|
||||
|
||||
GLuint common_vao;
|
||||
|
||||
RenderTexture reflect_buffer;
|
||||
RenderTexture render_buffer;
|
||||
RenderTexture screen_buffer;
|
||||
RenderTexture shadow_buffer;
|
||||
|
||||
GLUniformBuffer contour_coef_ubo;
|
||||
GLUniformBuffer contour_params_ubo;
|
||||
GLUniformBuffer filter_scene_ubo;
|
||||
GLUniformBuffer esm_filter_batch_ubo;
|
||||
GLUniformBuffer imgfilter_batch_ubo;
|
||||
GLUniformBuffer exposure_measure_ubo;
|
||||
GLUniformBuffer gaussian_coef_ubo;
|
||||
GLUniformBuffer glass_eye_batch_ubo;
|
||||
GLUniformBuffer glitter_batch_ubo;
|
||||
GLUniformBuffer quad_ubo;
|
||||
GLUniformBuffer sprite_scene_ubo;
|
||||
GLUniformBuffer sss_filter_gaussian_coef_ubo;
|
||||
GLUniformBuffer sun_quad_ubo;
|
||||
GLUniformBuffer transparency_batch_ubo;
|
||||
GLUniformBuffer tone_map_ubo;
|
||||
|
||||
obj_scene_shader_data obj_scene;
|
||||
obj_batch_shader_data obj_batch;
|
||||
obj_skinning_shader_data obj_skinning;
|
||||
GLUniformBuffer obj_scene_ubo;
|
||||
GLUniformBuffer obj_batch_ubo;
|
||||
GLUniformBuffer obj_skinning_ubo;
|
||||
|
||||
GLuint empty_texture_2d;
|
||||
GLuint empty_texture_cube_map;
|
||||
|
||||
GLuint samplers[18];
|
||||
GLuint render_samplers[3];
|
||||
GLuint sprite_samplers[3];
|
||||
|
||||
int32_t sprite_width;
|
||||
int32_t sprite_height;
|
||||
int32_t screen_x_offset;
|
||||
int32_t screen_y_offset;
|
||||
int32_t screen_width;
|
||||
int32_t screen_height;
|
||||
|
||||
render_context();
|
||||
~render_context();
|
||||
|
||||
void ctrl(bool change_res = true);
|
||||
void free();
|
||||
void init();
|
||||
};
|
||||
|
||||
extern draw_state_struct* draw_state;
|
||||
|
||||
extern render_context* rctx;
|
||||
|
||||
extern sss_data* (FASTCALL* sss_data_get)();
|
||||
|
||||
void fbo_blit(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);
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "../KKdLib/vec.hpp"
|
||||
#include "render.hpp"
|
||||
#include "shadow.hpp"
|
||||
#include "types.hpp"
|
||||
#include "wrap.hpp"
|
||||
|
||||
enum draw_pass_3d_type {
|
||||
DRAW_PASS_3D_OPAQUE = 0,
|
||||
DRAW_PASS_3D_TRANSLUCENT,
|
||||
DRAW_PASS_3D_TRANSPARENT,
|
||||
DRAW_PASS_3D_MAX,
|
||||
};
|
||||
|
||||
enum reflect_refract_resolution_mode {
|
||||
REFLECT_REFRACT_RESOLUTION_256x256 = 0,
|
||||
REFLECT_REFRACT_RESOLUTION_512x256,
|
||||
REFLECT_REFRACT_RESOLUTION_512x512,
|
||||
REFLECT_REFRACT_RESOLUTION_MAX,
|
||||
};
|
||||
|
||||
enum stage_data_reflect_type {
|
||||
STAGE_DATA_REFLECT_DISABLE = 0x00,
|
||||
STAGE_DATA_REFLECT_NORMAL = 0x01,
|
||||
STAGE_DATA_REFLECT_REFLECT_MAP = 0x02,
|
||||
};
|
||||
|
||||
struct draw_pre_process {
|
||||
int32_t type;
|
||||
void(FASTCALL* func)(void*);
|
||||
void* data;
|
||||
};
|
||||
|
||||
namespace rndr {
|
||||
enum RenderPassID {
|
||||
RND_PASSID_SHADOW = 0,
|
||||
RND_PASSID_SS_SSS,
|
||||
RND_PASSID_2,
|
||||
RND_PASSID_REFLECT,
|
||||
RND_PASSID_REFRACT,
|
||||
RND_PASSID_PRE_PROCESS,
|
||||
RND_PASSID_CLEAR,
|
||||
RND_PASSID_PRE_SPRITE,
|
||||
RND_PASSID_3D,
|
||||
RND_PASSID_SHOW_VECTOR,
|
||||
RND_PASSID_POST_PROCESS,
|
||||
RND_PASSID_SPRITE,
|
||||
RND_PASSID_12,
|
||||
RND_PASSID_NUM,
|
||||
};
|
||||
|
||||
struct RenderManager {
|
||||
bool pass_sw[RND_PASSID_NUM];
|
||||
struct Shadow* shadow_ptr;
|
||||
bool reflect;
|
||||
bool refract;
|
||||
int32_t reflect_blur_num;
|
||||
blur_filter_mode reflect_blur_filter;
|
||||
rndr::Render* render;
|
||||
bool sync_gpu;
|
||||
double_t cpu_time[RND_PASSID_NUM];
|
||||
double_t gpu_time[RND_PASSID_NUM];
|
||||
time_struct time;
|
||||
bool shadow;
|
||||
bool opaque_z_sort;
|
||||
bool alpha_z_sort;
|
||||
bool draw_pass_3d[DRAW_PASS_3D_MAX];
|
||||
bool field_11E;
|
||||
bool field_11F;
|
||||
bool field_120;
|
||||
bool show_ref_map;
|
||||
stage_data_reflect_type reflect_type;
|
||||
bool clear;
|
||||
int32_t tex_index[11];
|
||||
RenderTexture render_textures[8];
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
GLuint multisample_framebuffer;
|
||||
GLuint multisample_renderbuffer;
|
||||
bool multisample;
|
||||
bool check_state;
|
||||
int32_t show_vector_flags;
|
||||
float_t show_vector_length;
|
||||
float_t show_vector_z_offset;
|
||||
bool field_2F8;
|
||||
prj::list<draw_pre_process> pre_process;
|
||||
texture* effect_texture;
|
||||
int32_t npr_param;
|
||||
bool field_31C;
|
||||
bool field_31D;
|
||||
bool field_31E;
|
||||
bool field_31F;
|
||||
bool field_320;
|
||||
bool npr;
|
||||
|
||||
void add_pre_process(int32_t type, void(*func)(void*), void* data);
|
||||
void clear_pre_process(int32_t type);
|
||||
RenderTexture& get_render_texture(int32_t index);
|
||||
void resize(int32_t width, int32_t height);
|
||||
void set_effect_texture(texture* value);
|
||||
void set_multisample(bool value);
|
||||
void set_npr_param(int32_t value);
|
||||
void set_pass_sw(rndr::RenderPassID id, bool value);
|
||||
void set_reflect(bool value);
|
||||
void set_reflect_blur(int32_t reflect_blur_num, blur_filter_mode reflect_blur_filter);
|
||||
void set_reflect_resolution_mode(reflect_refract_resolution_mode mode);
|
||||
void set_reflect_type(stage_data_reflect_type type);
|
||||
void set_refract(bool value);
|
||||
void set_refract_resolution_mode(reflect_refract_resolution_mode mode);
|
||||
void set_shadow_false();
|
||||
void set_shadow_true();
|
||||
|
||||
void render_all();
|
||||
|
||||
void render_single_pass(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_3d_contour();
|
||||
void pass_sprite_surf();
|
||||
};
|
||||
|
||||
static_assert(sizeof(rndr::RenderManager) == 0x328, "\"rndr::RenderManager\" struct should have a size of 0x328");
|
||||
}
|
||||
|
||||
extern RenderTexture* litproj_shadow;
|
||||
extern RenderTexture* litproj_texture;
|
||||
extern rndr::RenderManager* render_manager;
|
||||
|
||||
extern void image_filter_scale(GLuint dst, GLuint src, const vec4 scale);
|
||||
|
||||
extern void draw_pass_set_camera();
|
||||
|
||||
extern void render_manager_patch();
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "render_texture.hpp"
|
||||
#include "gl_state.hpp"
|
||||
|
||||
int32_t RenderTexture::Bind(int32_t index) {
|
||||
if (index < 0 || index > max_level)
|
||||
return -1;
|
||||
|
||||
gl_state_bind_framebuffer(fbos[index]);
|
||||
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
||||
return -1;
|
||||
|
||||
gl_state_get_error();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RenderTexture::Free() {
|
||||
static void (FASTCALL * RenderTexture__Free)(RenderTexture * rt)
|
||||
= (void (FASTCALL*)(RenderTexture * rt))0x00000001405035C0;
|
||||
RenderTexture__Free(this);
|
||||
}
|
||||
|
||||
int32_t RenderTexture::Init(int32_t width, int32_t height,
|
||||
int32_t max_level, GLenum color_format, GLenum depth_format) {
|
||||
static int32_t(FASTCALL * RenderTexture__Init)(RenderTexture * rt, int32_t width, int32_t height,
|
||||
int32_t max_level, GLenum color_format, GLenum depth_format)
|
||||
= (int32_t(FASTCALL*)(RenderTexture * rt, int32_t width, int32_t height,
|
||||
int32_t max_level, GLenum color_format, GLenum depth_format))0x0000000140503420;
|
||||
return RenderTexture__Init(this, width, height, max_level, color_format, depth_format);
|
||||
}
|
||||
|
||||
int32_t RenderTexture::SetColorDepthTextures(GLuint color_texture,
|
||||
int32_t max_level, GLuint depth_texture) {
|
||||
int32_t(FASTCALL * RenderTexture__SetColorDepthTextures)(RenderTexture * rt,
|
||||
GLuint color_texture, int32_t level, GLuint depth_texture)
|
||||
= (int32_t(FASTCALL*)(RenderTexture * rt,
|
||||
GLuint color_texture, int32_t level, GLuint depth_texture))0x0000000140503130;
|
||||
return RenderTexture__SetColorDepthTextures(this, color_texture, max_level, depth_texture);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared.hpp"
|
||||
#include "texture.hpp"
|
||||
|
||||
struct RenderTexture {
|
||||
void* __vftable;
|
||||
texture* color_texture;
|
||||
texture* depth_texture;
|
||||
int32_t binding;
|
||||
int32_t max_level;
|
||||
GLuint* fbos;
|
||||
GLuint rbo;
|
||||
GLuint field_2C;
|
||||
|
||||
int32_t Bind(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);
|
||||
int32_t SetColorDepthTextures(GLuint color_texture,
|
||||
int32_t max_level = 0, GLuint depth_texture = 0);
|
||||
|
||||
inline GLuint GetColorTex() {
|
||||
return color_texture->tex;
|
||||
};
|
||||
|
||||
inline GLuint GetDepthTex() {
|
||||
return depth_texture->tex;
|
||||
};
|
||||
|
||||
inline int32_t GetHeight() {
|
||||
return color_texture->height;
|
||||
};
|
||||
|
||||
inline int32_t GetWidth() {
|
||||
return color_texture->width;
|
||||
};
|
||||
|
||||
inline void SetViewport() {
|
||||
glViewportDLL(0, 0, GetWidth(), GetHeight());
|
||||
};
|
||||
};
|
||||
|
||||
static_assert(sizeof(RenderTexture) == 0x30, "\"RenderTexture\" struct should have a size of 0x30");
|
||||
@@ -0,0 +1,273 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "dof.hpp"
|
||||
#include "../rob/rob.hpp"
|
||||
#include "../camera.hpp"
|
||||
#include "../gl_state.hpp"
|
||||
#include "../render_context.hpp"
|
||||
|
||||
struct dof_common_shader_data {
|
||||
vec4 g_depth_params; //x=(n-f)/(nf), y=1/n, z=coc_from_z_scale, w=coc_from_z_offset
|
||||
vec4 g_spread_scale; //x=scale_from_meter_to_pixel, y=scale_from_meter_to_sample,
|
||||
// z=scale_from_pixel_to_sample, w=scale_from_sample_to_pixel
|
||||
vec4 g_depth_params2; //x=distance_to_focus_m, y=focus_range,
|
||||
// z=k/(fuzzing_range*fuzzing_range), w=max_coc_radius_in_pixel //yzw=for_f2
|
||||
};
|
||||
|
||||
dof_debug* dof_debug_data = (dof_debug*)0x00000001411AB650;
|
||||
dof_pv* dof_pv_data = (dof_pv*)0x0000001411AB630;
|
||||
|
||||
namespace renderer {
|
||||
void DOF3::apply(RenderTexture* 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) {
|
||||
float_t focus = dof_debug_data->focus;
|
||||
if (dof_debug_data->flags & DOF_DEBUG_AUTO_FOCUS) {
|
||||
size_t rob_chara_smth = get_rob_chara_smth();
|
||||
|
||||
size_t rob_chr = 0;
|
||||
for (int32_t i = 0; i < ROB_CHARA_COUNT; i++) {
|
||||
size_t rob_chr = rob_chara_array_get(rob_chara_smth, i);
|
||||
if (!rob_chr || !(*(uint8_t*)(rob_chara_smth + 0x440) & 1))
|
||||
continue;
|
||||
|
||||
mat4 mat;
|
||||
sub_1405163C0(rob_chr, 4, &mat);
|
||||
mat4_transpose(&mat, &mat);
|
||||
|
||||
vec3 chara_trans = 0.0f;
|
||||
mat4_get_translation(&mat, &chara_trans);
|
||||
|
||||
mat4 view_transpose;
|
||||
mat4_transpose(&camera_data->view_matrix, &view_transpose);
|
||||
focus = -vec3::dot(*(vec3*)&view_transpose.row2, chara_trans)
|
||||
- view_transpose.row2.w - 0.1f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
focus = max_def(focus, camera_data->min_distance);
|
||||
apply_physical(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,
|
||||
dof_debug_data->f_number);
|
||||
}
|
||||
else {
|
||||
float_t fuzzing_range = max_def(dof_debug_data->f2.fuzzing_range, 0.01f);
|
||||
apply_f2(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,
|
||||
fuzzing_range, dof_debug_data->f2.ratio);
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
if (dof_pv_data->f2.fuzzing_range >= 0.0099999998)
|
||||
apply_f2(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,
|
||||
fuzzing_range, dof_pv_data->f2.ratio);
|
||||
enum_or(dof_debug_data->flags, DOF_DEBUG_ENABLE_DOF);
|
||||
dof_debug_data->f2 = dof_pv_data->f2;
|
||||
}
|
||||
else
|
||||
enum_and(dof_debug_data->flags, ~DOF_DEBUG_ENABLE_DOF);
|
||||
}
|
||||
|
||||
void DOF3::resize(int32_t width, int32_t height) {
|
||||
if (textures[0]) {
|
||||
glDeleteTextures(6, textures);
|
||||
textures[0] = 0;
|
||||
}
|
||||
|
||||
void(FASTCALL * renderer__FBO__init)(void* fbo, int32_t width, int32_t height,
|
||||
GLuint * color_textures, int32_t count, GLuint depth_texture)
|
||||
= (void(FASTCALL*)(void* fbo, int32_t width, int32_t height,
|
||||
GLuint * color_textures, int32_t count, GLuint depth_texture))0x00000001404AEF40;
|
||||
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
int32_t w20 = max_def(width / 20, 1);
|
||||
int32_t h20 = max_def(height / 20, 1);
|
||||
int32_t w2 = max_def(width / 2, 1);
|
||||
int32_t h2 = max_def(height / 2, 1);
|
||||
glGenTextures(6, textures);
|
||||
gl_state_bind_texture_2d(textures[0]);
|
||||
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RG16F, w20, h20);
|
||||
renderer__FBO__init(&fbo[0], w20, h20, &textures[0], 1, 0);
|
||||
gl_state_bind_texture_2d(textures[1]);
|
||||
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RG16F, w20, h20);
|
||||
renderer__FBO__init(&fbo[1], w20, h20, &textures[1], 1, 0);
|
||||
gl_state_bind_texture_2d(textures[2]);
|
||||
glTexStorage2D(GL_TEXTURE_2D, 1, GL_R11F_G11F_B10F, w2, h2);
|
||||
gl_state_bind_texture_2d(textures[3]);
|
||||
glTexStorage2D(GL_TEXTURE_2D, 1, GL_R11F_G11F_B10F, w2, h2);
|
||||
renderer__FBO__init(&fbo[2], w2, h2, &textures[2], 2, 0);
|
||||
gl_state_bind_texture_2d(textures[4]);
|
||||
glTexStorage2D(GL_TEXTURE_2D, 1, GL_R11F_G11F_B10F, w2, h2);
|
||||
gl_state_bind_texture_2d(textures[5]);
|
||||
glTexStorage2D(GL_TEXTURE_2D, 1, GL_R8, w2, h2);
|
||||
renderer__FBO__init(&fbo[3], w2, h2, &textures[4], 2, 0);
|
||||
}
|
||||
|
||||
void DOF3::apply_f2(RenderTexture* rt, GLuint color_texture,
|
||||
GLuint depth_texture, float_t min_distance, float_t max_distance, float_t fov,
|
||||
float_t focus, float_t focus_range, float_t fuzzing_range, float_t ratio) {
|
||||
gl_state_begin_event("renderer::DOF3::apply_f2");
|
||||
gl_state_disable_blend();
|
||||
gl_state_set_depth_mask(GL_FALSE);
|
||||
gl_state_set_depth_func(GL_ALWAYS);
|
||||
update_data(min_distance, max_distance,
|
||||
fov, focus, 0.0f, 1.0f, focus_range, fuzzing_range, ratio);
|
||||
|
||||
gl_state_bind_vertex_array(vao);
|
||||
render_tiles(depth_texture, true);
|
||||
downsample(color_texture, depth_texture, true);
|
||||
main_filter(true);
|
||||
upsample(rt, color_texture, depth_texture, true);
|
||||
|
||||
gl_state_use_program(0);
|
||||
for (int32_t i = 0; i < 8; i++) {
|
||||
gl_state_bind_sampler(i, 0);
|
||||
gl_state_active_bind_texture_2d(i, 0);
|
||||
}
|
||||
gl_state_bind_vertex_array(0);
|
||||
gl_state_end_event();
|
||||
}
|
||||
|
||||
void DOF3::apply_physical(RenderTexture* 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_state_begin_event("renderer::DOF3::apply_physical");
|
||||
gl_state_disable_blend();
|
||||
gl_state_set_depth_mask(GL_FALSE);
|
||||
gl_state_set_depth_func(GL_ALWAYS);
|
||||
update_data(min_distance, max_distance,
|
||||
fov, focus, focal_length, f_number, 0.0f, 0.1f, 0.0f);
|
||||
|
||||
gl_state_bind_vertex_array(vao);
|
||||
render_tiles(depth_texture, false);
|
||||
downsample(color_texture, depth_texture, false);
|
||||
main_filter(false);
|
||||
upsample(rt, color_texture, depth_texture, false);
|
||||
|
||||
gl_state_use_program(0);
|
||||
for (int32_t i = 0; i < 8; i++) {
|
||||
gl_state_bind_sampler(i, 0);
|
||||
gl_state_active_bind_texture_2d(i, 0);
|
||||
}
|
||||
gl_state_bind_vertex_array(0);
|
||||
gl_state_end_event();
|
||||
}
|
||||
|
||||
void DOF3::render_tiles(GLuint depth_texture, bool f2) {
|
||||
gl_state_begin_event("renderer::DOF3::render_tiles");
|
||||
gl_state_bind_framebuffer(fbo[0].buffer);
|
||||
glViewportDLL(0, 0, fbo[0].width, fbo[0].height);
|
||||
gl_state_use_program(program[f2 ? 5 : 1]);
|
||||
common_ubo.Bind(0);
|
||||
gl_state_active_bind_texture_2d(0, depth_texture);
|
||||
gl_state_bind_sampler(0, samplers[1]);
|
||||
glDrawArraysDLL(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
gl_state_bind_framebuffer(fbo[1].buffer);
|
||||
glViewportDLL(0, 0, fbo[1].width, fbo[1].height);
|
||||
gl_state_use_program(program[0]);
|
||||
gl_state_active_bind_texture_2d(0, textures[0]);
|
||||
gl_state_bind_sampler(0, samplers[1]);
|
||||
glDrawArraysDLL(GL_TRIANGLE_STRIP, 0, 4);
|
||||
gl_state_end_event();
|
||||
|
||||
}
|
||||
|
||||
void DOF3::downsample(GLuint color_texture, GLuint depth_texture, bool f2) {
|
||||
gl_state_begin_event("renderer::DOF3::downsample");
|
||||
gl_state_bind_framebuffer(fbo[2].buffer);
|
||||
glViewportDLL(0, 0, fbo[2].width, fbo[2].height);
|
||||
gl_state_use_program(program[f2 ? 6 : 2]);
|
||||
common_ubo.Bind(0);
|
||||
gl_state_active_bind_texture_2d(0, depth_texture);
|
||||
gl_state_bind_sampler(0, samplers[1]);
|
||||
gl_state_active_bind_texture_2d(1, color_texture);
|
||||
gl_state_bind_sampler(1, samplers[0]);
|
||||
gl_state_active_bind_texture_2d(2, textures[1]);
|
||||
gl_state_bind_sampler(2, samplers[1]);
|
||||
glDrawArraysDLL(GL_TRIANGLE_STRIP, 0, 4);
|
||||
gl_state_end_event();
|
||||
}
|
||||
|
||||
void DOF3::main_filter(bool f2) {
|
||||
gl_state_begin_event("renderer::DOF3::main_filter");
|
||||
gl_state_bind_framebuffer(fbo[3].buffer);
|
||||
glViewportDLL(0, 0, fbo[3].width, fbo[3].height);
|
||||
gl_state_use_program(program[f2 ? 7 : 3]);
|
||||
common_ubo.Bind(0);
|
||||
texcoords_ubo.Bind(1);
|
||||
gl_state_active_bind_texture_2d(0, textures[3]);
|
||||
gl_state_bind_sampler(0, samplers[1]);
|
||||
gl_state_active_bind_texture_2d(1, textures[2]);
|
||||
gl_state_bind_sampler(1, samplers[1]);
|
||||
gl_state_active_bind_texture_2d(2, textures[1]);
|
||||
gl_state_bind_sampler(2, samplers[1]);
|
||||
glDrawArraysDLL(GL_TRIANGLE_STRIP, 0, 4);
|
||||
gl_state_end_event();
|
||||
}
|
||||
|
||||
void DOF3::upsample(RenderTexture* rt, GLuint color_texture, GLuint depth_texture, bool f2) {
|
||||
gl_state_begin_event("renderer::DOF3::upsample");
|
||||
rctx->render_buffer.Bind();
|
||||
glViewportDLL(0, 0, width, height);
|
||||
gl_state_use_program(program[f2 ? 8 : 4]);
|
||||
common_ubo.Bind(0);
|
||||
gl_state_active_bind_texture_2d(0, textures[4]);
|
||||
gl_state_bind_sampler(0, samplers[1]);
|
||||
gl_state_active_bind_texture_2d(1, textures[5]);
|
||||
gl_state_bind_sampler(1, samplers[1]);
|
||||
gl_state_active_bind_texture_2d(2, textures[1]);
|
||||
gl_state_bind_sampler(2, samplers[1]);
|
||||
gl_state_active_bind_texture_2d(3, color_texture);
|
||||
gl_state_bind_sampler(3, samplers[1]);
|
||||
gl_state_active_bind_texture_2d(4, depth_texture);
|
||||
gl_state_bind_sampler(4, samplers[1]);
|
||||
glDrawArraysDLL(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
glCopyImageSubData(
|
||||
rctx->render_buffer.GetColorTex(), GL_TEXTURE_2D, 0, 0, 0, 0,
|
||||
rt->GetColorTex(), GL_TEXTURE_2D, 0, 0, 0, 0, width, height, 1);
|
||||
gl_state_end_event();
|
||||
}
|
||||
|
||||
void DOF3::update_data(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)
|
||||
fl = dist + 0.1f;
|
||||
fl = fl / (dist - fl) * fl / f_number;
|
||||
|
||||
dof_common_shader_data shader_data = {};
|
||||
shader_data.g_depth_params.x = 1.0f / (min_dist * max_dist) * (min_dist - max_dist);
|
||||
shader_data.g_depth_params.y = 1.0f / min_dist;
|
||||
shader_data.g_depth_params.z = -((fl * dist * (min_dist - max_dist)) * (1.0f / (min_dist * max_dist)));
|
||||
shader_data.g_depth_params.w = (1.0f - 1.0f / min_dist * dist) * fl;
|
||||
shader_data.g_spread_scale.x = 720.0f / (tanf(fov * 0.5f) * (min_dist * 2.0f));
|
||||
shader_data.g_spread_scale.y = shader_data.g_spread_scale.x * (float_t)(1.0 / 3.0);
|
||||
shader_data.g_spread_scale.z = (float_t)(1.0 / 3.0);
|
||||
shader_data.g_spread_scale.w = 3.0f;
|
||||
shader_data.g_depth_params2.x = dist;
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../KKdLib/default.hpp"
|
||||
#include "../gl_uniform_buffer.hpp"
|
||||
#include "../render_texture.hpp"
|
||||
#include "fbo.hpp"
|
||||
|
||||
enum dof_debug_flags {
|
||||
DOF_DEBUG_USE_UI_PARAMS = 0x01,
|
||||
DOF_DEBUG_ENABLE_DOF = 0x02,
|
||||
DOF_DEBUG_ENABLE_PHYS_DOF = 0x04,
|
||||
DOF_DEBUG_AUTO_FOCUS = 0x08,
|
||||
};
|
||||
|
||||
struct dof_f2 {
|
||||
float_t focus;
|
||||
float_t focus_range;
|
||||
float_t fuzzing_range;
|
||||
float_t ratio;
|
||||
};
|
||||
|
||||
static_assert(sizeof(dof_f2) == 0x10, "\"dof_f2\" struct should have a size of 0x10");
|
||||
|
||||
struct dof_debug {
|
||||
dof_debug_flags flags;
|
||||
float_t focus;
|
||||
float_t focal_length;
|
||||
float_t f_number;
|
||||
dof_f2 f2;
|
||||
};
|
||||
|
||||
static_assert(sizeof(dof_debug) == 0x20, "\"dof_debug\" struct should have a size of 0x14");
|
||||
|
||||
struct dof_pv {
|
||||
bool enable;
|
||||
dof_f2 f2;
|
||||
};
|
||||
|
||||
static_assert(sizeof(dof_pv) == 0x14, "\"dof_pv\" struct should have a size of 0x14");
|
||||
|
||||
namespace renderer {
|
||||
struct DOF3 {
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
GLuint textures[6];
|
||||
FBO fbo[4];
|
||||
GLuint samplers[2];
|
||||
GLuint vao;
|
||||
GLuint program[9];
|
||||
GLUniformBuffer common_ubo;
|
||||
GLUniformBuffer texcoords_ubo;
|
||||
|
||||
void apply(RenderTexture* rt);
|
||||
void resize(int32_t width, int32_t height);
|
||||
|
||||
private:
|
||||
void apply_f2(RenderTexture* rt, GLuint color_texture,
|
||||
GLuint depth_texture, float_t min_distance, float_t max_distance, float_t fov,
|
||||
float_t focus, float_t focus_range, float_t fuzzing_range, float_t ratio);
|
||||
void apply_physical(RenderTexture* 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 main_filter(bool f2);
|
||||
void upsample(RenderTexture* rt, GLuint color_texture, GLuint depth_texture, bool f2);
|
||||
|
||||
void update_data(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_assert(sizeof(renderer::DOF3) == 0xD8, "\"renderer::DOF3\" struct should have a size of 0xD8");
|
||||
}
|
||||
|
||||
extern dof_debug* dof_debug_data;
|
||||
extern dof_pv* dof_pv_data;
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "fbo.hpp"
|
||||
#include "../gl_state.hpp"
|
||||
|
||||
namespace renderer {
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 6385)
|
||||
#pragma warning(disable: 6386)
|
||||
void FBO::init(int32_t width, int32_t height,
|
||||
GLuint* color_textures, int32_t count, GLuint depth_texture) {
|
||||
free();
|
||||
|
||||
count = min_def(count, 8);
|
||||
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
this->count = count;
|
||||
flags = (Flags)0;
|
||||
if (depth_texture) {
|
||||
this->flags = DEPTH_ATTACHMENT;
|
||||
this->count++;
|
||||
}
|
||||
|
||||
textures = new GLuint[this->count];
|
||||
for (int32_t i = 0; i < count; i++)
|
||||
textures[i] = color_textures[i];
|
||||
|
||||
if (flags & DEPTH_ATTACHMENT)
|
||||
textures[count] = depth_texture;
|
||||
|
||||
glGenFramebuffers(1, &buffer);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, buffer);
|
||||
for (int32_t i = 0; i < count; i++)
|
||||
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, textures[i], 0);
|
||||
|
||||
if (flags & DEPTH_ATTACHMENT)
|
||||
glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, textures[count], 0);
|
||||
|
||||
GLenum color_attachments[8];
|
||||
for (int32_t i = 0; i < count; i++)
|
||||
color_attachments[i] = GL_COLOR_ATTACHMENT0 + i;
|
||||
glDrawBuffers(count, color_attachments);
|
||||
glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
}
|
||||
#pragma warning(pop)
|
||||
|
||||
void FBO::free() {
|
||||
if (buffer) {
|
||||
glDeleteFramebuffers(1, &buffer);
|
||||
buffer = 0;
|
||||
}
|
||||
|
||||
if (textures) {
|
||||
delete[] textures;
|
||||
textures = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../shared.hpp"
|
||||
|
||||
namespace renderer {
|
||||
struct FBO {
|
||||
enum Flags {
|
||||
DEPTH_ATTACHMENT = 0x01,
|
||||
};
|
||||
|
||||
Flags flags;
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
GLuint buffer;
|
||||
int32_t count;
|
||||
GLuint* textures;
|
||||
|
||||
void init(int32_t width, int32_t height,
|
||||
GLuint* color_textures, int32_t count, GLuint depth_texture);
|
||||
void free();
|
||||
};
|
||||
|
||||
static_assert(sizeof(renderer::FBO) == 0x20, "\"renderer::FBO\" struct should have a size of 0x20");
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "transparency.hpp"
|
||||
#include "../../KKdLib/str_utils.hpp"
|
||||
#include "../render_context.hpp"
|
||||
#include "../gl_state.hpp"
|
||||
|
||||
extern render_context* rctx;
|
||||
|
||||
namespace renderer {
|
||||
void Transparency::combine(RenderTexture* rt, float_t alpha) {
|
||||
vec4 g_opacity = { alpha, 0.0f, 0.0f, 0.0f };
|
||||
|
||||
gl_state_disable_blend();
|
||||
gl_state_disable_depth_test();
|
||||
rctx->render_buffer.Bind();
|
||||
gl_state_use_program(program);
|
||||
glUniform4fv(0, 1, (GLfloat*)&g_opacity.x);
|
||||
gl_state_active_bind_texture_2d(0, fbo.textures[0]);
|
||||
gl_state_active_bind_texture_2d(1, rt->GetColorTex());
|
||||
gl_state_bind_vertex_array(vao);
|
||||
glDrawArraysDLL(GL_TRIANGLE_STRIP, 0, 4);
|
||||
gl_state_enable_depth_test();
|
||||
|
||||
glCopyImageSubData(
|
||||
rctx->render_buffer.GetColorTex(), GL_TEXTURE_2D, 0, 0, 0, 0,
|
||||
rt->GetColorTex(), GL_TEXTURE_2D, 0, 0, 0, 0, fbo.width, fbo.height, 1);
|
||||
}
|
||||
|
||||
void Transparency::copy(GLuint texture) {
|
||||
glCopyImageSubData(
|
||||
texture, GL_TEXTURE_2D, 0, 0, 0, 0,
|
||||
fbo.textures[0], GL_TEXTURE_2D, 0, 0, 0, 0, fbo.width, fbo.height, 1);
|
||||
gl_state_bind_framebuffer(fbo.buffer);
|
||||
glViewportDLL(0, 0, fbo.width, fbo.height);
|
||||
}
|
||||
|
||||
void Transparency::resize(GLuint color_texture, GLuint depth_texture, int32_t width, int32_t height) {
|
||||
GLuint color_textures[1];
|
||||
color_textures[0] = color_texture;
|
||||
fbo.init(width, height, color_textures, 1, depth_texture);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../KKdLib/default.hpp"
|
||||
#include "../../KKdLib/vec.hpp"
|
||||
#include "../render_texture.hpp"
|
||||
#include "fbo.hpp"
|
||||
|
||||
namespace renderer {
|
||||
struct Transparency {
|
||||
private:
|
||||
FBO fbo;
|
||||
GLuint program;
|
||||
GLuint sampler;
|
||||
GLuint vao;
|
||||
|
||||
public:
|
||||
void combine(RenderTexture* rt, float_t alpha);
|
||||
void copy(GLuint texture);
|
||||
|
||||
void resize(GLuint color_texture, GLuint depth_texture, int32_t width, int32_t height);
|
||||
};
|
||||
|
||||
static_assert(sizeof(renderer::Transparency) == 0x30, "\"renderer::Transparency\" struct should have a size of 0x30");
|
||||
};
|
||||
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "resolution_mode.hpp"
|
||||
|
||||
const resolution_table_struct resolution_table[] = {
|
||||
{ 320, 240, 0, 0, 0, 320, 225 }, // QVGA
|
||||
{ 640, 480, 0, 0, 60, 640, 360 }, // VGA
|
||||
{ 800, 600, 0, 0, 75, 800, 450 }, // SVGA
|
||||
{ 1024, 768, 0, 0, 96, 1024, 576 }, // XGA
|
||||
{ 1280, 1024, 1, 0, 152, 1280, 720 }, // SXGA
|
||||
{ 1400, 1050, 0, 0, 131, 1400, 788 }, // SXGA+
|
||||
{ 1600, 1200, 0, 0, 150, 1600, 900 }, // UXGA
|
||||
{ 800, 480, 2, 0, 15, 800, 450 }, // WVGA
|
||||
{ 1024, 600, 2, 0, 12, 1024, 576 }, // WSVGA
|
||||
{ 1280, 768, 2, 0, 24, 1280, 720 }, // WXGA
|
||||
{ 1360, 768, 3, 0, 2, 1360, 765 }, // FWXGA
|
||||
{ 1920, 1200, 2, 0, 60, 1920, 1200 }, // WUXGA
|
||||
{ 2560, 1536, 2, 0, 48, 2560, 1440 }, // WQXGA
|
||||
{ 1280, 720, 3, 0, 0, 1280, 720 }, // HD
|
||||
{ 1920, 1080, 3, 0, 0, 1920, 1080 }, // FHD
|
||||
{ 2560, 1440, 3, 0, 0, 2560, 1440 }, // QHD
|
||||
{ 480, 272, 3, 0, 0, 480, 272 }, // WQVGA
|
||||
{ 960, 544, 3, 0, 0, 960, 544 }, // qHD
|
||||
|
||||
// MM+
|
||||
/*{ 320, 240, 0, 0, 0, 320, 225 }, // QVGA
|
||||
{ 640, 480, 0, 0, 60, 640, 360 }, // VGA
|
||||
{ 800, 600, 0, 0, 75, 800, 450 }, // SVGA
|
||||
{ 1024, 768, 0, 0, 96, 1024, 576 }, // XGA
|
||||
{ 1280, 1024, 1, 0, 152, 1280, 720 }, // SXGA
|
||||
{ 1400, 1050, 0, 0, 131, 1400, 788 }, // SXGA+
|
||||
{ 1600, 1200, 0, 0, 150, 1600, 900 }, // UXGA
|
||||
{ 800, 480, 2, 0, 15, 800, 450 }, // WVGA
|
||||
{ 1024, 600, 2, 0, 12, 1024, 576 }, // WSVGA
|
||||
{ 1280, 768, 2, 0, 24, 1280, 720 }, // WXGA
|
||||
{ 1360, 768, 3, 0, 2, 1360, 765 }, // FWXGA
|
||||
{ 1920, 1200, 2, 0, 60, 1920, 1200 }, // WUXGA
|
||||
{ 2560, 1536, 2, 0, 48, 2560, 1440 }, // WQXGA
|
||||
{ 1280, 720, 3, 0, 0, 1280, 720 }, // HD
|
||||
{ 1920, 1080, 3, 0, 0, 1920, 1080 }, // FHD
|
||||
{ 3840, 2160, 3, 0, 0, 3840, 2160 }, // UHD
|
||||
{ 3840, 2160, 3, 0, 0, 2880, 1620 }, // 3K at UHD
|
||||
{ 2880, 1620, 3, 0, 0, 2880, 1620 }, // 3K
|
||||
{ 2560, 1440, 3, 0, 0, 2560, 1440 }, // QHD
|
||||
{ 480, 272, 3, 0, 0, 480, 272 }, // WQVGA
|
||||
{ 960, 544, 3, 0, 0, 960, 544 }, // qHD
|
||||
{ 1152, 864, 0, 0, 0, 1152, 864 }, // XGA+
|
||||
{ 1176, 664, 3, 0, 0, 1176, 664 }, // 1176x664
|
||||
{ 1200, 960, 1, 0, 0, 1200, 960 }, // 1200x960
|
||||
{ 1280, 800, 2, 0, 0, 1280, 800 }, // WXGA1280x900
|
||||
{ 1280, 960, 0, 0, 0, 1280, 960 }, // SXGA-
|
||||
{ 1366, 768, 3, 0, 0, 1366, 768 }, // FWXGA1366x766
|
||||
{ 1440, 900, 2, 0, 0, 1440, 900 }, // WXGA+
|
||||
{ 1600, 900, 0, 0, 0, 1600, 900 }, // HD+
|
||||
{ 1600, 1024, 2, 0, 0, 1600, 1024 }, // WSXGA
|
||||
{ 1680, 1050, 2, 0, 0, 1680, 1050 }, // WSXGA+
|
||||
{ 1920, 1440, 0, 0, 0, 1920, 1440 }, // 1920x1440
|
||||
{ 2048, 1152, 0, 0, 0, 2048, 1152 }, // QWXGA*/
|
||||
};
|
||||
|
||||
resolution_struct* res_window = (resolution_struct*)0x0000000140EDA8B0;
|
||||
resolution_struct* res_window_internal = (resolution_struct*)0x0000000140EDA8D8;
|
||||
|
||||
resolution_struct::resolution_struct(::resolution_mode mode) {
|
||||
resolution_mode = mode;
|
||||
x_offset = 0;
|
||||
y_offset = 0;
|
||||
if (mode == RESOLUTION_MODE_MAX) {
|
||||
width = res_window->width;
|
||||
height = res_window->height;
|
||||
aspect = res_window->aspect;
|
||||
field_20 = res_window->field_20;
|
||||
}
|
||||
else {
|
||||
width = resolution_table[mode].width_full;
|
||||
height = resolution_table[mode].height_full;
|
||||
aspect = (double_t)width / (double_t)height;
|
||||
field_20 = resolution_table[mode].field_8;
|
||||
}
|
||||
}
|
||||
|
||||
resolution_mode_scale_data::resolution_mode_scale_data(
|
||||
resolution_mode src_mode, resolution_mode dst_mode) {
|
||||
scale = 1.0f;
|
||||
src_res = 0.0f;
|
||||
dst_res = 0.0f;
|
||||
this->src_mode = src_mode;
|
||||
this->dst_mode = dst_mode;
|
||||
scale = resolution_mode_get_scale(dst_mode, src_mode);
|
||||
if (dst_mode != RESOLUTION_MODE_MAX && src_mode != RESOLUTION_MODE_MAX
|
||||
&& dst_mode >= RESOLUTION_MODE_QVGA && src_mode >= RESOLUTION_MODE_MAX
|
||||
&& dst_mode < RESOLUTION_MODE_MAX && src_mode < RESOLUTION_MODE_MAX) {
|
||||
src_res.x = (float_t)resolution_table[src_mode].width_full * 0.5f;
|
||||
src_res.y = (float_t)resolution_table[src_mode].height_full * 0.5f;
|
||||
dst_res.x = (float_t)resolution_table[dst_mode].width_full * 0.5f;
|
||||
dst_res.y = (float_t)resolution_table[dst_mode].height_full * 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
resolution_struct* res_window_get() {
|
||||
return res_window;
|
||||
}
|
||||
|
||||
resolution_struct* res_window_internal_get() {
|
||||
return res_window_internal;
|
||||
}
|
||||
|
||||
void res_window_set(resolution_mode mode) {
|
||||
*res_window = resolution_struct(mode);
|
||||
|
||||
int32_t width = resolution_table[mode].width;
|
||||
int32_t height = resolution_table[mode].height;
|
||||
|
||||
res_window_internal->resolution_mode = RESOLUTION_MODE_MAX;
|
||||
res_window_internal->x_offset = resolution_table[mode].x_offset;
|
||||
res_window_internal->y_offset = resolution_table[mode].y_offset;
|
||||
res_window_internal->width = width;
|
||||
res_window_internal->height = height;
|
||||
res_window_internal->aspect = (double_t)width / (double_t)height;
|
||||
res_window_internal->field_20 = 4;
|
||||
|
||||
for (int32_t i = 0; i < RESOLUTION_MODE_MAX; i++)
|
||||
if (resolution_table[i].width_full == width && resolution_table[i].height_full == height) {
|
||||
res_window_internal->resolution_mode = (resolution_mode)i;
|
||||
res_window_internal->field_20 = resolution_table[i].field_8;
|
||||
}
|
||||
}
|
||||
|
||||
vec2 resolution_mode_get_scale(const resolution_mode dst_mode, const resolution_mode src_mode) {
|
||||
if (dst_mode == RESOLUTION_MODE_MAX || src_mode == RESOLUTION_MODE_MAX
|
||||
|| dst_mode < RESOLUTION_MODE_QVGA || src_mode < RESOLUTION_MODE_QVGA
|
||||
|| dst_mode >= RESOLUTION_MODE_MAX || src_mode >= RESOLUTION_MODE_MAX)
|
||||
return 1.0f;
|
||||
|
||||
float_t scale_x = (float_t)resolution_table[dst_mode].width_full / (float_t)resolution_table[src_mode].width_full;
|
||||
float_t scale_y = (float_t)resolution_table[dst_mode].height_full / (float_t)resolution_table[src_mode].height_full;
|
||||
int32_t v9 = resolution_table[src_mode].field_8;
|
||||
int32_t v10 = resolution_table[dst_mode].field_8;
|
||||
if (v9 != v10) {
|
||||
if (!v9 && 10 == 1)
|
||||
return scale_x;
|
||||
|
||||
if (v9 == 2 || v9 == 3)
|
||||
switch (v10) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
return scale_x;
|
||||
}
|
||||
}
|
||||
|
||||
if (src_mode == RESOLUTION_MODE_qHD && dst_mode != RESOLUTION_MODE_qHD && v10 == 3)
|
||||
return scale_x;
|
||||
else
|
||||
return scale_y;
|
||||
}
|
||||
|
||||
void resolution_mode_scale_pos(vec2& dst_pos, const resolution_mode dst_mode,
|
||||
const vec2& src_pos, const resolution_mode src_mode) {
|
||||
if (dst_mode == RESOLUTION_MODE_MAX || src_mode == RESOLUTION_MODE_MAX
|
||||
|| dst_mode < RESOLUTION_MODE_QVGA || src_mode < RESOLUTION_MODE_QVGA
|
||||
|| dst_mode >= RESOLUTION_MODE_MAX || src_mode >= RESOLUTION_MODE_MAX) {
|
||||
dst_pos = src_pos;
|
||||
return;
|
||||
}
|
||||
|
||||
const resolution_table_struct* src = &resolution_table[src_mode];
|
||||
const resolution_table_struct* dst = &resolution_table[dst_mode];
|
||||
|
||||
vec2 src_size((float_t)src->width_full, (float_t)src->height_full);
|
||||
vec2 dst_size((float_t)dst->width_full, (float_t)dst->height_full);
|
||||
vec2 scale = resolution_mode_get_scale(dst_mode, src_mode);
|
||||
dst_pos = dst_size * 0.5f + (src_pos - src_size * 0.5f) * scale;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "../KKdLib/spr.hpp"
|
||||
#include "../KKdLib/vec.hpp"
|
||||
|
||||
struct resolution_table_struct {
|
||||
int32_t width_full;
|
||||
int32_t height_full;
|
||||
int32_t field_8;
|
||||
int32_t x_offset;
|
||||
int32_t y_offset;
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
};
|
||||
|
||||
struct resolution_struct {
|
||||
resolution_mode resolution_mode;
|
||||
int32_t x_offset;
|
||||
int32_t y_offset;
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
double_t aspect;
|
||||
int32_t field_20;
|
||||
|
||||
inline resolution_struct() : resolution_struct(RESOLUTION_MODE_MAX) {
|
||||
|
||||
}
|
||||
|
||||
resolution_struct(::resolution_mode mode);
|
||||
};
|
||||
|
||||
struct resolution_mode_scale_data {
|
||||
vec2 scale;
|
||||
vec2 src_res;
|
||||
vec2 dst_res;
|
||||
resolution_mode src_mode;
|
||||
resolution_mode dst_mode;
|
||||
|
||||
resolution_mode_scale_data(resolution_mode src_mode, resolution_mode dst_mode);
|
||||
};
|
||||
|
||||
extern const resolution_table_struct resolution_table[];
|
||||
|
||||
extern resolution_struct* res_window_get();
|
||||
extern resolution_struct* res_window_internal_get();
|
||||
extern void res_window_set(resolution_mode mode);
|
||||
extern vec2 resolution_mode_get_scale(const resolution_mode dst_mode, const resolution_mode src_mode);
|
||||
extern void resolution_mode_scale_pos(vec2& dst_pos, const resolution_mode dst_mode,
|
||||
const vec2& src_pos, const resolution_mode src_mode);
|
||||
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "rob.hpp"
|
||||
#include "../mdl/disp_manager.hpp"
|
||||
#include "../gl_state.hpp"
|
||||
#include "../object.hpp"
|
||||
#include <Helpers.h>
|
||||
#include <algorithm>
|
||||
|
||||
struct rob_chara_age_age_object_vertex {
|
||||
vec3 position;
|
||||
vec3 normal;
|
||||
vec4 tangent;
|
||||
vec2 texcoord;
|
||||
};
|
||||
|
||||
struct rob_chara_age_age_object {
|
||||
void* obj_set_handler; // obj_set_handler
|
||||
int32_t obj_index;
|
||||
int32_t field_C;
|
||||
int32_t num_vertex;
|
||||
int32_t num_index;
|
||||
obj obj;
|
||||
obj_mesh mesh;
|
||||
obj_sub_mesh sub_mesh;
|
||||
obj_material_data material[2];
|
||||
obj_axis_aligned_bounding_box axis_aligned_bounding_box;
|
||||
rob_chara_age_age_object_vertex* vertex_data;
|
||||
int32_t vertex_data_size;
|
||||
int32_t vertex_array_size;
|
||||
obj_mesh_vertex_buffer obj_vert_buf;
|
||||
obj_mesh_index_buffer obj_index_buf;
|
||||
vec3 trans[10];
|
||||
int32_t disp_count;
|
||||
int32_t count;
|
||||
bool field_C3C;
|
||||
};
|
||||
|
||||
mat4* (FASTCALL* rob_chara_bone_data_get_mats_mat)(size_t rob_bone_data, size_t index)
|
||||
= (mat4 * (FASTCALL*)(size_t rob_bone_data, size_t index))0x0000000140419520;
|
||||
void(FASTCALL* sub_1405163C0)(size_t rob_chr, int32_t index, mat4* mat)
|
||||
= (void(FASTCALL*)(size_t rob_chr, int32_t index, mat4 * mat))0x00000001405163C0;
|
||||
float_t(FASTCALL* rob_chara_get_max_face_depth)(size_t rob_chr)
|
||||
= (float_t(FASTCALL*)(size_t rob_chr))0x0000000140516510;
|
||||
mat4* (FASTCALL* sub_140516740)(size_t rob_chr)
|
||||
= (mat4 * (FASTCALL*)(size_t rob_chr))0x0000000140516740;
|
||||
mat4* (FASTCALL* rob_chara_get_adjust_data_mat)(size_t rob_chr)
|
||||
= (mat4 * (FASTCALL*)(size_t rob_chr))0x0000000140516750;
|
||||
bool(FASTCALL* rob_chara_array_check_visibility)(size_t rob_chr, int32_t chara_id)
|
||||
= (bool(FASTCALL*)(size_t rob_chr, int32_t chara_id))0x0000000140531F50;
|
||||
size_t(FASTCALL* get_rob_chara_smth)() = (size_t(FASTCALL*)())0x00000001405320E0;
|
||||
size_t(FASTCALL* rob_chara_array_get)(size_t rob_chr_smth, int32_t chara_id)
|
||||
= (size_t(FASTCALL*)(size_t rob_chr_smth, int32_t chara_id))0x0000000140532030;
|
||||
size_t(FASTCALL* rob_chara_array_get_bone_data)(size_t rob_chr_smth, int32_t chara_id)
|
||||
= (size_t(FASTCALL*)(size_t rob_chr_smth, int32_t chara_id))0x00000001405320F0;
|
||||
bool (FASTCALL* rob_chara_pv_data_array_check_chara_id)(size_t rob_chr_smth, int32_t chara_id)
|
||||
= (bool (FASTCALL*)(size_t rob_chr_smth, int32_t chara_id))0x00000001405327B0;
|
||||
|
||||
HOOK(void, FASTCALL, rob_chara_age_age_object__disp, 0x0000000140541D50,
|
||||
rob_chara_age_age_object* rob_age_age_obj, size_t chara_index, bool npr, bool reflect, vec3* a5, bool chara_color) {
|
||||
int32_t disp_count = rob_age_age_obj->disp_count;
|
||||
if (!rob_age_age_obj->obj_set_handler || !disp_count)
|
||||
return;
|
||||
|
||||
disp_count = min_def(disp_count, 10);
|
||||
|
||||
std::pair<float_t, int32_t> v44[10];
|
||||
for (int32_t i = 0; i < disp_count; i++) {
|
||||
v44[i].first = vec3::dot(rob_age_age_obj->trans[i], *a5);
|
||||
v44[i].second = i;
|
||||
}
|
||||
|
||||
if (disp_count >= 2)
|
||||
std::sort(v44, v44 + disp_count,
|
||||
[](const std::pair<float_t, int32_t>& a, const std::pair<float_t, int32_t>& b) {
|
||||
return a.first < b.first;
|
||||
});
|
||||
|
||||
rob_age_age_obj->obj_vert_buf.cycle_index();
|
||||
|
||||
GLuint buffer = rob_age_age_obj->obj_vert_buf.get_buffer();
|
||||
size_t vtx_data;
|
||||
if (GL_VERSION_4_5) {
|
||||
vtx_data = (size_t)glMapNamedBuffer(buffer, GL_WRITE_ONLY);
|
||||
if (!vtx_data) {
|
||||
glUnmapNamedBuffer(buffer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
gl_state_bind_array_buffer(buffer);
|
||||
vtx_data = (size_t)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
|
||||
if (!vtx_data) {
|
||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||
gl_state_bind_array_buffer(0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
size_t vertex_array_size = rob_age_age_obj->vertex_array_size;
|
||||
for (int32_t i = 0; i < disp_count; i++)
|
||||
memmove((void*)(vtx_data + vertex_array_size * i),
|
||||
(void*)((size_t)rob_age_age_obj->vertex_data + vertex_array_size * v44[i].second), vertex_array_size);
|
||||
|
||||
if (GL_VERSION_4_5)
|
||||
glUnmapNamedBuffer(buffer);
|
||||
else {
|
||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||
gl_state_bind_array_buffer(0);
|
||||
}
|
||||
|
||||
rob_age_age_obj->mesh.num_vertex = disp_count * rob_age_age_obj->num_vertex;
|
||||
rob_age_age_obj->sub_mesh.num_index = disp_count * rob_age_age_obj->num_index;
|
||||
rob_age_age_obj->sub_mesh.material_index = npr ? 1 : 0;
|
||||
|
||||
mdl::ObjFlags flags = (mdl::ObjFlags)(mdl::OBJ_SSS | mdl::OBJ_4 | mdl::OBJ_SHADOW);
|
||||
if (reflect)
|
||||
enum_or(flags, mdl::OBJ_CHARA_REFLECT);
|
||||
disp_manager->set_obj_flags(flags);
|
||||
disp_manager->set_chara_color(chara_color);
|
||||
disp_manager->set_shadow_type(chara_index ? SHADOW_STAGE : SHADOW_CHARA);
|
||||
|
||||
static prj::vector<GLuint>*(FASTCALL * rob_chara_age_age_object__get_obj_set_texture)(rob_chara_age_age_object * rob_age_age_obj)
|
||||
= (prj::vector<GLuint>*(FASTCALL*)(rob_chara_age_age_object* rob_age_age_obj))0x000000014045A8E0;
|
||||
disp_manager->entry_obj_by_obj(&mat4_identity, &rob_age_age_obj->obj,
|
||||
rob_chara_age_age_object__get_obj_set_texture(rob_age_age_obj),
|
||||
&rob_age_age_obj->obj_vert_buf, &rob_age_age_obj->obj_index_buf, 0, 1.0f);
|
||||
}
|
||||
|
||||
|
||||
void rob_patch() {
|
||||
INSTALL_HOOK(rob_chara_age_age_object__disp);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../KKdLib/default.hpp"
|
||||
#include "../../KKdLib/mat.hpp"
|
||||
#include "../../KKdLib/vec.hpp"
|
||||
|
||||
#define ROB_CHARA_COUNT 6
|
||||
|
||||
extern mat4* (FASTCALL* rob_chara_bone_data_get_mats_mat)(size_t rob_bone_data, size_t index);
|
||||
extern void(FASTCALL* sub_1405163C0)(size_t rob_chr, int32_t index, mat4* mat);
|
||||
extern float_t(FASTCALL* rob_chara_get_max_face_depth)(size_t rob_chr);
|
||||
extern mat4* (FASTCALL* sub_140516740)(size_t rob_chr);
|
||||
extern mat4* (FASTCALL* rob_chara_get_adjust_data_mat)(size_t rob_chr);
|
||||
extern bool(FASTCALL* rob_chara_array_check_visibility)(size_t rob_chr, int32_t chara_id);
|
||||
extern size_t(FASTCALL* get_rob_chara_smth)();
|
||||
extern size_t(FASTCALL* rob_chara_array_get)(size_t rob_chr_smth, int32_t chara_id);
|
||||
extern size_t(FASTCALL* rob_chara_array_get_bone_data)(size_t rob_chr_smth, int32_t chara_id);
|
||||
extern bool (FASTCALL* rob_chara_pv_data_array_check_chara_id)(size_t rob_chr_smth, int32_t chara_id);
|
||||
|
||||
extern void rob_patch();
|
||||
@@ -0,0 +1,993 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "shader_glsl.hpp"
|
||||
#include "../KKdLib/io/file_stream.hpp"
|
||||
#include "../KKdLib/io/path.hpp"
|
||||
#include "../KKdLib/hash.hpp"
|
||||
#include "../KKdLib/str_utils.hpp"
|
||||
#include "gl_state.hpp"
|
||||
#include "print.hpp"
|
||||
#include "uniform.hpp"
|
||||
#include "wrap.hpp"
|
||||
#include <shlobj_core.h>
|
||||
|
||||
struct program_binary {
|
||||
GLsizei length;
|
||||
GLenum binary_format;
|
||||
size_t binary;
|
||||
};
|
||||
|
||||
struct program_spv {
|
||||
size_t size;
|
||||
size_t spv;
|
||||
};
|
||||
|
||||
extern bool vulkan_render;
|
||||
|
||||
static GLuint shader_compile_shader(GLenum type, const char* data, const char* file);
|
||||
static GLuint shader_compile(const char* vert, const char* frag, const char* vp, const char* fp);
|
||||
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);
|
||||
static void shader_glsl_update_data(shader_glsl_set_data* set);
|
||||
|
||||
int32_t shader_glsl::bind(shader_glsl_set_data* set, uint32_t sub_index) {
|
||||
set->curr_shader = 0;
|
||||
|
||||
if (num_sub < 1)
|
||||
return -1;
|
||||
|
||||
int32_t sub_shader_index = 0;
|
||||
for (shader_glsl_sub* i = sub; i->sub_index != sub_index; i++)
|
||||
if (++sub_shader_index >= num_sub)
|
||||
return -1;
|
||||
|
||||
shader_glsl_sub* sub_shader = &sub[sub_shader_index];
|
||||
|
||||
int32_t unival_shad_curr = 1;
|
||||
int32_t unival_shad = 0;
|
||||
int32_t uniform_val[SHADER_MAX_UNIFORM_VALUES] = {};
|
||||
if (num_uniform > 0) {
|
||||
const int32_t* vp_unival_max = sub_shader->vp_unival_max;
|
||||
const int32_t* fp_unival_max = sub_shader->fp_unival_max;
|
||||
|
||||
int32_t i = 0;
|
||||
for (i = 0; i < num_uniform && i < sizeof(uniform_val) / sizeof(int32_t); i++) {
|
||||
const int32_t unival = uniform->arr[use_uniform[i]];
|
||||
const int32_t unival_max = use_permut[i]
|
||||
? max_def(vp_unival_max[i], fp_unival_max[i]) : 0;
|
||||
unival_shad += unival_shad_curr * min_def(unival, unival_max);
|
||||
unival_shad_curr *= unival_max + 1;
|
||||
|
||||
int32_t unival_max_glsl = max_def(vp_unival_max[i], fp_unival_max[i]);
|
||||
uniform_val[i] = min_def(unival, unival_max_glsl);
|
||||
}
|
||||
}
|
||||
|
||||
shader_glsl_sub_shader* shader = &sub_shader->shaders[unival_shad];
|
||||
set->curr_shader = shader;
|
||||
|
||||
gl_state_use_program(shader->program);
|
||||
if (memcmp(shader->uniform_val, uniform_val, sizeof(uniform_val))) {
|
||||
memcpy(shader->uniform_val, uniform_val, sizeof(uniform_val));
|
||||
shader->uniform_val_update = true;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool shader_glsl::parse_define(const char* data, char** temp, size_t* temp_size) {
|
||||
if (!data)
|
||||
return false;
|
||||
|
||||
const char* def = strstr(data, "//DEF\n");
|
||||
if (!def) {
|
||||
size_t len = utf8_length(data);
|
||||
if (len + 1 > *temp_size) {
|
||||
free_def(*temp);
|
||||
*temp_size = len + 1;
|
||||
*temp = force_malloc<char>(*temp_size);
|
||||
}
|
||||
|
||||
memcpy(*temp, data, len);
|
||||
(*temp)[len] = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t len_a = def - data;
|
||||
def += 5;
|
||||
if (*def == '\n')
|
||||
def++;
|
||||
|
||||
size_t len_b = utf8_length(def);
|
||||
size_t len = 0;
|
||||
len += len_a + len_b;
|
||||
|
||||
if (len + 1 > *temp_size) {
|
||||
free_def(*temp);
|
||||
*temp_size = len + 1;
|
||||
*temp = force_malloc<char>(*temp_size);
|
||||
}
|
||||
|
||||
size_t pos = 0;
|
||||
memcpy(*temp + pos, data, len_a);
|
||||
pos += len_a;
|
||||
memcpy(*temp + pos, def, len_b);
|
||||
pos += len_b;
|
||||
(*temp)[pos] = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool shader_glsl::parse_define(const char* data, int32_t num_uniform,
|
||||
int32_t* uniform_value, char** temp, size_t* temp_size) {
|
||||
if (!data)
|
||||
return false;
|
||||
|
||||
const char* def = strstr(data, "//DEF\n");
|
||||
if (!def) {
|
||||
size_t len = utf8_length(data);
|
||||
if (len + 1 > *temp_size) {
|
||||
free_def(*temp);
|
||||
*temp_size = len + 1;
|
||||
*temp = force_malloc<char>(*temp_size);
|
||||
}
|
||||
|
||||
memcpy(*temp, data, len);
|
||||
(*temp)[len] = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
const int32_t s = min_def(0x100, num_uniform);
|
||||
|
||||
size_t t_len[0x100];
|
||||
char t[0x100] = {};
|
||||
|
||||
for (int32_t i = 0; i < s; i++) {
|
||||
sprintf_s(t, sizeof(t), "#define _%d %d\n", i, uniform_value[i]);
|
||||
t_len[i] = utf8_length(t);
|
||||
}
|
||||
|
||||
size_t len_a = def - data;
|
||||
def += 5;
|
||||
size_t len_b = utf8_length(def);
|
||||
size_t len = 0;
|
||||
for (int32_t i = 0; i < s; i++)
|
||||
len += t_len[i];
|
||||
if (!len)
|
||||
def++;
|
||||
len += len_a + len_b;
|
||||
|
||||
if (len + 1 > *temp_size) {
|
||||
free_def(*temp);
|
||||
*temp_size = len + 1;
|
||||
*temp = force_malloc<char>(*temp_size);
|
||||
}
|
||||
|
||||
size_t pos = 0;
|
||||
memcpy(*temp + pos, data, len_a);
|
||||
pos += len_a;
|
||||
for (int32_t i = 0; i < s; i++) {
|
||||
sprintf_s(t, sizeof(t), "#define _%d %d\n", i, uniform_value[i]);
|
||||
memcpy(*temp + pos, t, t_len[i]);
|
||||
pos += t_len[i];
|
||||
}
|
||||
memcpy(*temp + pos, def, len_b);
|
||||
pos += len_b;
|
||||
(*temp)[pos] = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
char* shader_glsl::parse_include(char* data, farc* f) {
|
||||
if (!data || !f)
|
||||
return data;
|
||||
|
||||
char* data_end = data + utf8_length(data);
|
||||
char* i0 = strstr(data, "#include \"");
|
||||
char* i1 = i0 ? strstr(i0, "\"\n") : 0;
|
||||
if (!i0 || !i1)
|
||||
return data;
|
||||
|
||||
size_t count = 1;
|
||||
while (i1 && (i0 = strstr(i1, "#include \""))) {
|
||||
i0 += 10;
|
||||
i1 = strstr(i0, "\"\n");
|
||||
if (i1)
|
||||
i1 += 1;
|
||||
count++;
|
||||
}
|
||||
|
||||
char** temp = force_malloc<char*>(count);
|
||||
size_t* temp_len = force_malloc<size_t>(count);
|
||||
char** temp_ptr0 = force_malloc<char*>(count);
|
||||
char** temp_ptr1 = force_malloc<char*>(count);
|
||||
if (!temp || !temp_len || !temp_ptr0 || !temp_ptr1) {
|
||||
free_def(temp);
|
||||
free_def(temp_len);
|
||||
free_def(temp_ptr0);
|
||||
free_def(temp_ptr1);
|
||||
return data;
|
||||
}
|
||||
|
||||
i1 = data;
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
temp[i] = 0;
|
||||
i0 = i1 ? strstr(i1, "#include \"") : 0;
|
||||
i1 = i0 ? strstr(i0, "\"\n") : 0;
|
||||
if (!i0 || !i1)
|
||||
continue;
|
||||
|
||||
temp_ptr0[i] = i0;
|
||||
temp_ptr1[i] = i1 + 1;
|
||||
i0 += 10;
|
||||
size_t s = i1 - i0;
|
||||
i1 += 2;
|
||||
char* t = force_malloc<char>(s + 1);
|
||||
if (!t)
|
||||
continue;
|
||||
|
||||
memcpy(t, i0, s);
|
||||
t[s] = 0;
|
||||
|
||||
farc_file* ff = f->read_file(t);
|
||||
free_def(t);
|
||||
if (!ff)
|
||||
continue;
|
||||
|
||||
t = force_malloc<char>(ff->size + 1);
|
||||
if (t) {
|
||||
memcpy(t, ff->data, ff->size);
|
||||
t[ff->size] = 0;
|
||||
}
|
||||
temp[i] = t;
|
||||
temp_len[i] = ff->size;
|
||||
}
|
||||
|
||||
size_t len = data_end - data;
|
||||
i1 = data;
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
i0 = temp_ptr0[i];
|
||||
i1 = temp_ptr1[i];
|
||||
if (!i0 || !i1)
|
||||
continue;
|
||||
|
||||
len -= i1 - i0;
|
||||
len += temp_len[i];
|
||||
}
|
||||
|
||||
char* temp_data = force_malloc<char>(len + 1);
|
||||
size_t pos = 0;
|
||||
memcpy(temp_data + pos, data, temp_ptr0[0] - data);
|
||||
pos += temp_ptr0[0] - data;
|
||||
for (int32_t i = 0; i < count; i++) {
|
||||
if (temp[i]) {
|
||||
size_t s = temp_len[i];
|
||||
memcpy(temp_data + pos, temp[i], s);
|
||||
pos += s;
|
||||
}
|
||||
|
||||
if (i < count - 1 && temp_ptr1[i]) {
|
||||
size_t s = temp_ptr0[i + 1] - temp_ptr1[i];
|
||||
memcpy(temp_data + pos, temp_ptr1[i], s);
|
||||
pos += s;
|
||||
}
|
||||
else if (temp_ptr1[i]) {
|
||||
size_t s = data_end - temp_ptr1[i];
|
||||
memcpy(temp_data + pos, temp_ptr1[i], s);
|
||||
pos += s;
|
||||
}
|
||||
}
|
||||
temp_data[pos] = 0;
|
||||
|
||||
free_def(data);
|
||||
for (size_t i = 0; i < count; i++)
|
||||
free_def(temp[i]);
|
||||
free_def(temp);
|
||||
free_def(temp_len);
|
||||
free_def(temp_ptr0);
|
||||
free_def(temp_ptr1);
|
||||
return temp_data;
|
||||
}
|
||||
|
||||
void shader_glsl::unbind() {
|
||||
gl_state_use_program(0);
|
||||
}
|
||||
|
||||
shader_glsl_set_data::shader_glsl_set_data() : size(), shaders(), curr_shader(),
|
||||
primitive_restart(), primitive_restart_index(), get_index_by_name_func() {
|
||||
|
||||
}
|
||||
|
||||
void shader_glsl_set_data::disable_primitive_restart() {
|
||||
primitive_restart = false;
|
||||
}
|
||||
|
||||
void shader_glsl_set_data::draw_arrays(GLenum mode, GLint first, GLsizei count) {
|
||||
shader_glsl_update_data(this);
|
||||
glDrawArraysDLL(mode, first, count);
|
||||
}
|
||||
|
||||
void shader_glsl_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;
|
||||
}
|
||||
|
||||
shader_glsl_update_data(this);
|
||||
glDrawElementsDLL(mode, count, type, indices);
|
||||
|
||||
switch (mode) {
|
||||
case GL_TRIANGLE_STRIP:
|
||||
disable_primitive_restart();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void shader_glsl_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;
|
||||
}
|
||||
|
||||
shader_glsl_update_data(this);
|
||||
glDrawRangeElements(mode, start, end, count, type, indices);
|
||||
|
||||
switch (mode) {
|
||||
case GL_TRIANGLE_STRIP:
|
||||
disable_primitive_restart();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void shader_glsl_set_data::enable_primitive_restart() {
|
||||
primitive_restart = true;
|
||||
}
|
||||
|
||||
int32_t shader_glsl_set_data::get_index_by_name(const char* name) {
|
||||
if (get_index_by_name_func) {
|
||||
int32_t index = get_index_by_name_func(name);
|
||||
if (index != -1)
|
||||
return index;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < size; i++)
|
||||
if (!str_utils_compare(shaders[i].name, name))
|
||||
return (int32_t)shaders[i].name_index;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void shader_glsl_set_data::load(farc* f, bool ignore_cache,
|
||||
const char* name, const shader_glsl_table* shaders_table, const size_t size,
|
||||
const shader_glsl_bind_func* bind_func_table, const size_t bind_func_table_size,
|
||||
PFNSHADERGLSLGETINDEXFUNCPROC get_index_by_name) {
|
||||
if (!this || !f || !shaders_table || !size)
|
||||
return;
|
||||
|
||||
wchar_t temp_buf[MAX_PATH];
|
||||
if (FAILED(SHGetFolderPathW(0, CSIDL_LOCAL_APPDATA, 0, 0, temp_buf)))
|
||||
return;
|
||||
|
||||
wcscat_s(temp_buf, sizeof(temp_buf) / sizeof(wchar_t), L"\\PDAFT");
|
||||
CreateDirectoryW(temp_buf, 0);
|
||||
|
||||
wchar_t buf[MAX_PATH];
|
||||
swprintf_s(buf, sizeof(buf) / sizeof(wchar_t), L"\\%hs_shader_cache", name);
|
||||
wcscat_s(temp_buf, sizeof(temp_buf) / sizeof(wchar_t), buf);
|
||||
|
||||
bool shader_cache_changed = false;
|
||||
farc shader_cache_farc;
|
||||
swprintf_s(buf, sizeof(buf) / sizeof(wchar_t), L"%ls.farc", temp_buf);
|
||||
if (!ignore_cache && path_check_file_exists(buf))
|
||||
shader_cache_farc.read(buf, true, false);
|
||||
|
||||
char vert_buf[MAX_PATH];
|
||||
char frag_buf[MAX_PATH];
|
||||
char vert_file_buf[MAX_PATH];
|
||||
char frag_file_buf[MAX_PATH];
|
||||
|
||||
GLsizei buffer_size = 0x100000;
|
||||
void* binary = force_malloc(buffer_size);
|
||||
size_t temp_vert_size = 0x10000;
|
||||
char* temp_vert = force_malloc<char>(temp_vert_size);
|
||||
size_t temp_frag_size = 0x10000;
|
||||
char* temp_frag = force_malloc<char>(temp_frag_size);
|
||||
std::vector<int32_t> vec_vert;
|
||||
std::vector<int32_t> vec_frag;
|
||||
std::vector<program_binary> program_data_binary;
|
||||
shader_glsl* shaders = force_malloc<shader_glsl>(size);
|
||||
this->shaders = shaders;
|
||||
this->size = size;
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
shader_glsl* shader = &shaders[i];
|
||||
shader->name = shaders_table[i].name;
|
||||
shader->name_index = shaders_table[i].name_index;
|
||||
shader->num_sub = shaders_table[i].num_sub;
|
||||
shader->sub = force_malloc<shader_glsl_sub>(shader->num_sub);
|
||||
shader->num_uniform = shaders_table[i].num_uniform;
|
||||
shader->use_uniform = shaders_table[i].use_uniform;
|
||||
shader->use_permut = shaders_table[i].use_permut;
|
||||
|
||||
int32_t num_sub = shader->num_sub;
|
||||
const shader_glsl_sub_table* sub_table = shaders_table[i].sub;
|
||||
shader_glsl_sub* sub = shader->sub;
|
||||
vec_vert.resize(shader->num_uniform);
|
||||
vec_frag.resize(shader->num_uniform);
|
||||
int32_t* vec_vert_data = vec_vert.data();
|
||||
int32_t* vec_frag_data = vec_frag.data();
|
||||
for (size_t j = 0; j < num_sub; j++, sub++, sub_table++) {
|
||||
sub->sub_index = sub_table->sub_index;
|
||||
sub->vp_unival_max = sub_table->vp_unival_max;
|
||||
sub->fp_unival_max = sub_table->fp_unival_max;
|
||||
|
||||
strcpy_s(vert_file_buf, sizeof(vert_file_buf), sub_table->vp);
|
||||
strcat_s(vert_file_buf, sizeof(vert_file_buf), ".vert");
|
||||
farc_file* vert_ff = f->read_file(vert_file_buf);
|
||||
|
||||
char* vert_data = 0;
|
||||
if (vert_ff && vert_ff->data) {
|
||||
vert_data = force_malloc<char>(vert_ff->size + 1);
|
||||
if (vert_data) {
|
||||
memcpy(vert_data, vert_ff->data, vert_ff->size);
|
||||
vert_data[vert_ff->size] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
strcpy_s(frag_file_buf, sizeof(frag_file_buf), sub_table->fp);
|
||||
strcat_s(frag_file_buf, sizeof(frag_file_buf), ".frag");
|
||||
farc_file* frag_ff = f->read_file(frag_file_buf);
|
||||
|
||||
char* frag_data = 0;
|
||||
if (frag_ff && frag_ff->data) {
|
||||
frag_data = force_malloc<char>(frag_ff->size + 1);
|
||||
if (frag_data) {
|
||||
memcpy(frag_data, frag_ff->data, frag_ff->size);
|
||||
frag_data[frag_ff->size] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!vert_data || !frag_data) {
|
||||
free_def(vert_data);
|
||||
free_def(frag_data);
|
||||
continue;
|
||||
}
|
||||
|
||||
uint64_t vert_file_name_cache = hash_utf8_fnv1a64m(vert_file_buf);
|
||||
uint64_t frag_file_name_cache = hash_utf8_fnv1a64m(frag_file_buf);
|
||||
for (int32_t i = 0; i < 64; i += 8)
|
||||
if (((vert_file_name_cache >> i) & 0xFF) == 0)
|
||||
vert_file_name_cache |= 0xFFULL << i;
|
||||
|
||||
for (int32_t i = 0; i < 64; i += 8)
|
||||
if (((frag_file_name_cache >> i) & 0xFF) == 0)
|
||||
frag_file_name_cache |= 0xFFULL << i;
|
||||
|
||||
char shader_cache_file_name[MAX_PATH];
|
||||
strcpy_s(shader_cache_file_name, sizeof(shader_cache_file_name), sub_table->vp);
|
||||
if (str_utils_compare(sub_table->vp, sub_table->fp)) {
|
||||
strcat_s(shader_cache_file_name, sizeof(shader_cache_file_name), ".");
|
||||
strcat_s(shader_cache_file_name, sizeof(shader_cache_file_name), sub_table->fp);
|
||||
}
|
||||
strcat_s(shader_cache_file_name, sizeof(shader_cache_file_name), ".bin");
|
||||
|
||||
vert_data = shader_glsl::parse_include(vert_data, f);
|
||||
frag_data = shader_glsl::parse_include(frag_data, f);
|
||||
uint64_t vert_data_hash = hash_utf8_fnv1a64m(vert_data);
|
||||
uint64_t frag_data_hash = hash_utf8_fnv1a64m(frag_data);
|
||||
|
||||
farc_file* shader_cache_file = shader_cache_farc.read_file(shader_cache_file_name);
|
||||
program_binary* bin = 0;
|
||||
if (!ignore_cache) {
|
||||
if (!shader_cache_file || !shader_cache_file->data)
|
||||
printf_debug("Shader not compiled: %s %s\n", vert_file_buf, frag_file_buf);
|
||||
else if (vert_data_hash != ((uint64_t*)shader_cache_file->data)[0]
|
||||
|| frag_data_hash != ((uint64_t*)shader_cache_file->data)[1])
|
||||
printf_debug("Shader hash not equal: %s %s\n", vert_file_buf, frag_file_buf);
|
||||
else
|
||||
bin = (program_binary*)&((uint64_t*)shader_cache_file->data)[2];
|
||||
}
|
||||
|
||||
if (shader->num_uniform > 0
|
||||
&& (sub_table->vp_unival_max[0] != -1 || sub_table->fp_unival_max[0] != -1)) {
|
||||
int32_t num_uniform = shader->num_uniform;
|
||||
int32_t unival_shad_curr = 1;
|
||||
int32_t unival_shad_count = 1;
|
||||
const int32_t* vp_unival_max = sub_table->vp_unival_max;
|
||||
const int32_t* fp_unival_max = sub_table->fp_unival_max;
|
||||
for (size_t k = 0; k < num_uniform; k++) {
|
||||
const int32_t unival_max = shader->use_permut[k]
|
||||
? max_def(vp_unival_max[k], fp_unival_max[k]) : 0;
|
||||
unival_shad_count += unival_shad_curr * unival_max;
|
||||
unival_shad_curr *= unival_max + 1;
|
||||
}
|
||||
|
||||
if (!ignore_cache)
|
||||
program_data_binary.reserve(unival_shad_count);
|
||||
shader_glsl_sub_shader* shaders = force_malloc<shader_glsl_sub_shader>(unival_shad_count);
|
||||
sub->shaders = shaders;
|
||||
if (shaders) {
|
||||
strcpy_s(vert_buf, sizeof(vert_buf), sub_table->vp);
|
||||
size_t vert_buf_pos = utf8_length(vert_buf);
|
||||
vert_buf[vert_buf_pos++] = '.';
|
||||
vert_buf[vert_buf_pos] = 0;
|
||||
memset(&vert_buf[vert_buf_pos], '0', num_uniform);
|
||||
vert_buf[vert_buf_pos + num_uniform] = 0;
|
||||
strcat_s(vert_buf, sizeof(vert_buf), ".vert");
|
||||
|
||||
strcpy_s(frag_buf, sizeof(frag_buf), sub_table->fp);
|
||||
size_t frag_buf_pos = utf8_length(frag_buf);
|
||||
frag_buf[frag_buf_pos++] = '.';
|
||||
frag_buf[frag_buf_pos] = 0;
|
||||
memset(&frag_buf[frag_buf_pos], '0', num_uniform);
|
||||
frag_buf[frag_buf_pos + num_uniform] = 0;
|
||||
strcat_s(frag_buf, sizeof(frag_buf), ".frag");
|
||||
|
||||
for (size_t k = 0; k < unival_shad_count; k++) {
|
||||
for (size_t l = 0, m = k; l < num_uniform; l++) {
|
||||
size_t unival_max = (size_t)(shader->use_permut[l]
|
||||
? max_def(vp_unival_max[l], fp_unival_max[l]) : 0) + 1;
|
||||
vec_vert_data[l] = (uint32_t)(min_def(m % unival_max, vp_unival_max[l]));
|
||||
m /= unival_max;
|
||||
vert_buf[vert_buf_pos + l] = (char)('0' + vec_vert_data[l]);
|
||||
}
|
||||
|
||||
for (size_t l = 0, m = k; l < num_uniform; l++) {
|
||||
size_t unival_max = (size_t)(shader->use_permut[l]
|
||||
? max_def(vp_unival_max[l], fp_unival_max[l]) : 0) + 1;
|
||||
vec_frag_data[l] = (uint32_t)(min_def(m % unival_max, fp_unival_max[l]));
|
||||
m /= unival_max;
|
||||
frag_buf[frag_buf_pos + l] = (char)('0' + vec_frag_data[l]);
|
||||
}
|
||||
|
||||
if (!bin || !shader_load_binary_shader(bin, &shaders[k].program)) {
|
||||
bool vert_succ = shader_glsl::parse_define(vert_data, num_uniform,
|
||||
vec_vert_data, &temp_vert, &temp_vert_size);
|
||||
bool frag_succ = shader_glsl::parse_define(frag_data, num_uniform,
|
||||
vec_frag_data, &temp_frag, &temp_frag_size);
|
||||
|
||||
if (ignore_cache)
|
||||
shaders[k].program = shader_compile(vert_succ ? temp_vert : 0,
|
||||
frag_succ ? temp_frag : 0, vert_buf, frag_buf);
|
||||
else {
|
||||
program_data_binary.push_back({});
|
||||
shaders[k].program = shader_compile_binary(vert_succ ? temp_vert : 0,
|
||||
frag_succ ? temp_frag : 0, vert_buf, frag_buf,
|
||||
&program_data_binary.back(), &buffer_size, &binary);
|
||||
}
|
||||
shader_cache_changed |= shaders[k].program ? true : false;
|
||||
}
|
||||
else {
|
||||
program_data_binary.push_back({});
|
||||
program_binary* b = &program_data_binary.back();
|
||||
b->length = bin->length;
|
||||
b->binary_format = bin->binary_format;
|
||||
b->binary = (size_t)force_malloc(bin->length);
|
||||
memcpy((void*)b->binary, (void*)((size_t)bin + bin->binary), bin->length);
|
||||
}
|
||||
|
||||
if (!ignore_cache && bin)
|
||||
bin++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
program_data_binary.reserve(1);
|
||||
shader_glsl_sub_shader* shaders = force_malloc<shader_glsl_sub_shader>();
|
||||
sub->shaders = shaders;
|
||||
if (shaders) {
|
||||
strcpy_s(vert_buf, sizeof(vert_buf), sub_table->vp);
|
||||
strcpy_s(frag_buf, sizeof(vert_buf), sub_table->fp);
|
||||
strcat_s(vert_buf, sizeof(vert_buf), "..vert");
|
||||
strcat_s(frag_buf, sizeof(vert_buf), "..frag");
|
||||
|
||||
if (!bin || !shader_load_binary_shader(bin, &shaders[0].program)) {
|
||||
bool vert_succ = shader_glsl::parse_define(vert_data, &temp_vert, &temp_vert_size);
|
||||
bool frag_succ = shader_glsl::parse_define(frag_data, &temp_frag, &temp_frag_size);
|
||||
|
||||
if (ignore_cache)
|
||||
shaders[0].program = shader_compile(vert_succ ? temp_vert : 0,
|
||||
frag_succ ? temp_frag : 0, vert_buf, frag_buf);
|
||||
else {
|
||||
program_data_binary.push_back({});
|
||||
shaders[0].program = shader_compile_binary(vert_succ ? temp_vert : 0,
|
||||
frag_succ ? temp_frag : 0, vert_buf, frag_buf,
|
||||
&program_data_binary.back(), &buffer_size, &binary);
|
||||
}
|
||||
shader_cache_changed |= shaders[0].program ? true : false;
|
||||
}
|
||||
else {
|
||||
program_data_binary.push_back({});
|
||||
program_binary* b = &program_data_binary.back();
|
||||
b->length = bin->length;
|
||||
b->binary_format = bin->binary_format;
|
||||
b->binary = (size_t)force_malloc(bin->length);
|
||||
memcpy((void*)b->binary, (void*)((size_t)bin + bin->binary), bin->length);
|
||||
}
|
||||
|
||||
if (!ignore_cache && bin)
|
||||
bin++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ignore_cache) {
|
||||
if (!shader_cache_file)
|
||||
shader_cache_file = shader_cache_farc.add_file(shader_cache_file_name);
|
||||
else
|
||||
free_def(shader_cache_file->data);
|
||||
|
||||
size_t bin_count = program_data_binary.size();
|
||||
size_t bin_size = sizeof(uint64_t) * 2 + bin_count * sizeof(program_binary);
|
||||
for (program_binary& k : program_data_binary)
|
||||
bin_size += align_val(k.length, 0x04);
|
||||
shader_cache_file->data = force_malloc(bin_size);
|
||||
shader_cache_file->size = bin_size;
|
||||
shader_cache_file->data_changed = true;
|
||||
|
||||
((uint64_t*)shader_cache_file->data)[0] = vert_data_hash;
|
||||
((uint64_t*)shader_cache_file->data)[1] = frag_data_hash;
|
||||
bin = (program_binary*)&((uint64_t*)shader_cache_file->data)[2];
|
||||
size_t bin_data_base = (size_t)shader_cache_file->data + sizeof(uint64_t) * 2;
|
||||
size_t bin_data = bin_data_base + bin_count * sizeof(program_binary);
|
||||
for (program_binary& k : program_data_binary) {
|
||||
bin->length = k.length;
|
||||
bin->binary_format = k.binary_format;
|
||||
bin->binary = bin_data - bin_data_base;
|
||||
memcpy((void*)bin_data, (void*)k.binary, k.length);
|
||||
bin_data_base += sizeof(program_binary);
|
||||
bin_data += align_val(k.length, 0x04);
|
||||
void* binary = (void*)k.binary;
|
||||
free_def(binary);
|
||||
k.binary = 0;
|
||||
bin++;
|
||||
}
|
||||
}
|
||||
|
||||
free_def(vert_data);
|
||||
free_def(frag_data);
|
||||
program_data_binary.clear();
|
||||
}
|
||||
vec_vert.clear();
|
||||
vec_frag.clear();
|
||||
|
||||
for (size_t j = 0; j < bind_func_table_size; j++)
|
||||
if (shader->name_index == bind_func_table[j].name_index) {
|
||||
shader->bind_func = bind_func_table[j].bind_func;
|
||||
break;
|
||||
}
|
||||
}
|
||||
free_def(binary);
|
||||
free_def(temp_vert);
|
||||
free_def(temp_frag);
|
||||
|
||||
if (shader_cache_changed)
|
||||
shader_cache_farc.write(temp_buf, FARC_FArC, FARC_NONE, false);
|
||||
|
||||
this->get_index_by_name_func = get_index_by_name;
|
||||
}
|
||||
|
||||
void shader_glsl_set_data::set(uint32_t index) {
|
||||
if (this && index && index != -1) {
|
||||
shader_glsl* shader = &shaders[index];
|
||||
if (shader->bind_func)
|
||||
shader->bind_func(this, shader);
|
||||
else
|
||||
shader->bind(this, shader->sub[0].sub_index);
|
||||
}
|
||||
else
|
||||
shader_glsl::unbind();
|
||||
}
|
||||
|
||||
void shader_glsl_set_data::unload() {
|
||||
size_t size = this->size;
|
||||
shader_glsl* shaders = this->shaders;
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
shader_glsl* shader = &shaders[i];
|
||||
if (!shader->sub)
|
||||
continue;
|
||||
|
||||
int32_t num_sub = shader->num_sub;
|
||||
shader_glsl_sub* sub = shader->sub;
|
||||
for (size_t j = 0; j < num_sub; j++, sub++) {
|
||||
int32_t unival_shad_count = 1;
|
||||
if (shader->num_uniform > 0) {
|
||||
int32_t num_uniform = shader->num_uniform;
|
||||
int32_t unival_shad_curr = 1;
|
||||
const int32_t* vp_unival_max = sub->vp_unival_max;
|
||||
const int32_t* fp_unival_max = sub->fp_unival_max;
|
||||
for (size_t k = 0; k < num_uniform; k++) {
|
||||
const int32_t unival_max = shader->use_permut[k]
|
||||
? max_def(vp_unival_max[k], fp_unival_max[k]) : 0;
|
||||
unival_shad_count += unival_shad_curr * unival_max;
|
||||
unival_shad_curr *= unival_max + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (sub->shaders) {
|
||||
shader_glsl_sub_shader* shaders = sub->shaders;
|
||||
for (size_t k = 0; k < unival_shad_count; k++)
|
||||
glDeleteProgram(shaders[k].program);
|
||||
free(shaders);
|
||||
sub->shaders = 0;
|
||||
}
|
||||
}
|
||||
free(shader->sub);
|
||||
shader->sub = 0;
|
||||
}
|
||||
free_def(shaders);
|
||||
this->shaders = 0;
|
||||
|
||||
get_index_by_name_func = 0;
|
||||
}
|
||||
|
||||
static GLuint shader_compile_shader(GLenum type, const char* data, const char* file) {
|
||||
if (!data)
|
||||
return 0;
|
||||
|
||||
GLuint shader = glCreateShader(type);
|
||||
glShaderSource(shader, 1, &data, 0);
|
||||
glCompileShader(shader);
|
||||
|
||||
GLint success = 0;
|
||||
glGetShaderiv(shader, GL_COMPILE_STATUS, &success);
|
||||
if (!success) {
|
||||
GLchar* info_log = force_malloc<GLchar>(0x10000);
|
||||
glGetShaderInfoLog(shader, 0x10000, 0, info_log);
|
||||
const char* type_str = "Unknown";
|
||||
switch (type) {
|
||||
case GL_FRAGMENT_SHADER:
|
||||
type_str = "Fragment";
|
||||
break;
|
||||
case GL_VERTEX_SHADER:
|
||||
type_str = "Vertex";
|
||||
break;
|
||||
}
|
||||
printf_debug("%s shader compile error:\nfile: %s\n%s\n", type_str, file, info_log);
|
||||
free_def(info_log);
|
||||
glDeleteShader(shader);
|
||||
|
||||
#if defined(CRE_DEV)
|
||||
wchar_t temp_buf[MAX_PATH];
|
||||
if (SUCCEEDED(SHGetFolderPathW(0, CSIDL_LOCAL_APPDATA, 0, 0, temp_buf))) {
|
||||
wcscat_s(temp_buf, sizeof(temp_buf) / sizeof(wchar_t), L"\\ReDIVA");
|
||||
temp_buf[sizeof(temp_buf) / sizeof(wchar_t) - 1] = 0;
|
||||
CreateDirectoryW(temp_buf, 0);
|
||||
|
||||
wchar_t buf[MAX_PATH];
|
||||
swprintf_s(buf, sizeof(buf) / sizeof(wchar_t),
|
||||
L"%ls\\shader_error", temp_buf);
|
||||
buf[sizeof(buf) / sizeof(wchar_t) - 1] = 0;
|
||||
CreateDirectoryW(buf, 0);
|
||||
|
||||
swprintf_s(buf, sizeof(buf) / sizeof(wchar_t),
|
||||
L"%ls\\shader_error\\%hs", temp_buf, file);
|
||||
buf[sizeof(buf) / sizeof(wchar_t) - 1] = 0;
|
||||
|
||||
file_stream s;
|
||||
s.open(buf, L"wb");
|
||||
s.write(data, utf8_length(data));
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
return shader;
|
||||
}
|
||||
|
||||
static GLuint shader_compile(const char* vert, const char* frag, const char* vp, const char* fp) {
|
||||
GLuint vert_shad = shader_compile_shader(GL_VERTEX_SHADER, vert, vp);
|
||||
GLuint frag_shad = shader_compile_shader(GL_FRAGMENT_SHADER, frag, fp);
|
||||
|
||||
GLuint program = glCreateProgram();
|
||||
if (vert_shad)
|
||||
glAttachShader(program, vert_shad);
|
||||
if (frag_shad)
|
||||
glAttachShader(program, frag_shad);
|
||||
glLinkProgram(program);
|
||||
|
||||
if (vert_shad)
|
||||
glDeleteShader(vert_shad);
|
||||
if (frag_shad)
|
||||
glDeleteShader(frag_shad);
|
||||
|
||||
GLint success = 0;
|
||||
glGetProgramiv(program, GL_LINK_STATUS, &success);
|
||||
if (!success) {
|
||||
GLchar* info_log = force_malloc<GLchar>(0x10000);
|
||||
glGetProgramInfoLog(program, 0x10000, 0, info_log);
|
||||
printf_debug("Program Shader Permut linking error:\nvp: %s; fp: %s\n%s\n", vp, fp, info_log);
|
||||
free_def(info_log);
|
||||
glDeleteProgram(program);
|
||||
|
||||
#if defined(CRE_DEV)
|
||||
wchar_t temp_buf[MAX_PATH];
|
||||
if (SUCCEEDED(SHGetFolderPathW(0, CSIDL_LOCAL_APPDATA, 0, 0, temp_buf))) {
|
||||
wcscat_s(temp_buf, sizeof(temp_buf) / sizeof(wchar_t), L"\\ReDIVA");
|
||||
temp_buf[sizeof(temp_buf) / sizeof(wchar_t) - 1] = 0;
|
||||
CreateDirectoryW(temp_buf, 0);
|
||||
|
||||
wchar_t buf[MAX_PATH];
|
||||
swprintf_s(buf, sizeof(buf) / sizeof(wchar_t),
|
||||
L"%ls\\shader_error", temp_buf);
|
||||
buf[sizeof(buf) / sizeof(wchar_t) - 1] = 0;
|
||||
CreateDirectoryW(buf, 0);
|
||||
|
||||
swprintf_s(buf, sizeof(buf) / sizeof(wchar_t),
|
||||
L"%ls\\shader_error\\%hs", temp_buf, vp);
|
||||
buf[sizeof(buf) / sizeof(wchar_t) - 1] = 0;
|
||||
|
||||
file_stream s;
|
||||
s.open(buf, L"wb");
|
||||
s.write(vert, utf8_length(vert));
|
||||
s.close();
|
||||
|
||||
swprintf_s(buf, sizeof(buf) / sizeof(wchar_t),
|
||||
L"%ls\\shader_error\\%hs", temp_buf, fp);
|
||||
buf[sizeof(buf) / sizeof(wchar_t) - 1] = 0;
|
||||
|
||||
s.open(buf, L"wb");
|
||||
s.write(frag, utf8_length(frag));
|
||||
s.close();
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
gl_state_get_all_gl_errors();
|
||||
return program;
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
memset(bin, 0, sizeof(*bin));
|
||||
|
||||
GLuint vert_shad = shader_compile_shader(GL_VERTEX_SHADER, vert, vp);
|
||||
GLuint frag_shad = shader_compile_shader(GL_FRAGMENT_SHADER, frag, fp);
|
||||
|
||||
GLuint program = glCreateProgram();
|
||||
if (vert_shad)
|
||||
glAttachShader(program, vert_shad);
|
||||
if (frag_shad)
|
||||
glAttachShader(program, frag_shad);
|
||||
glLinkProgram(program);
|
||||
|
||||
if (vert_shad)
|
||||
glDeleteShader(vert_shad);
|
||||
if (frag_shad)
|
||||
glDeleteShader(frag_shad);
|
||||
|
||||
GLint success = 0;
|
||||
glGetProgramiv(program, GL_LINK_STATUS, &success);
|
||||
if (!success) {
|
||||
GLchar* info_log = force_malloc<GLchar>(0x10000);
|
||||
glGetProgramInfoLog(program, 0x10000, 0, info_log);
|
||||
printf_debug("Program Shader Permut linking error:\nvp: %s; fp: %s\n%s\n", vp, fp, info_log);
|
||||
free_def(info_log);
|
||||
glDeleteProgram(program);
|
||||
|
||||
#if defined(CRE_DEV)
|
||||
wchar_t temp_buf[MAX_PATH];
|
||||
if (SUCCEEDED(SHGetFolderPathW(0, CSIDL_LOCAL_APPDATA, 0, 0, temp_buf))) {
|
||||
wcscat_s(temp_buf, sizeof(temp_buf) / sizeof(wchar_t), L"\\ReDIVA");
|
||||
temp_buf[sizeof(temp_buf) / sizeof(wchar_t) - 1] = 0;
|
||||
CreateDirectoryW(temp_buf, 0);
|
||||
|
||||
wchar_t buf[MAX_PATH];
|
||||
swprintf_s(buf, sizeof(buf) / sizeof(wchar_t),
|
||||
L"%ls\\shader_error", temp_buf);
|
||||
buf[sizeof(buf) / sizeof(wchar_t) - 1] = 0;
|
||||
CreateDirectoryW(buf, 0);
|
||||
|
||||
swprintf_s(buf, sizeof(buf) / sizeof(wchar_t),
|
||||
L"%ls\\shader_error\\%hs", temp_buf, vp);
|
||||
buf[sizeof(buf) / sizeof(wchar_t) - 1] = 0;
|
||||
|
||||
file_stream s;
|
||||
s.open(buf, L"wb");
|
||||
s.write(vert, utf8_length(vert));
|
||||
s.close();
|
||||
|
||||
swprintf_s(buf, sizeof(buf) / sizeof(wchar_t),
|
||||
L"%ls\\shader_error\\%hs", temp_buf, fp);
|
||||
buf[sizeof(buf) / sizeof(wchar_t) - 1] = 0;
|
||||
|
||||
s.open(buf, L"wb");
|
||||
s.write(frag, utf8_length(frag));
|
||||
s.close();
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
gl_state_get_all_gl_errors();
|
||||
|
||||
GLenum binary_format = 0x0;
|
||||
GLsizei length = 0;
|
||||
while (*buffer_size < 0x7FFFFFF) {
|
||||
glGetProgramBinary(program, *buffer_size, &length, &binary_format, *binary);
|
||||
if (!gl_state_get_error())
|
||||
break;
|
||||
|
||||
free_def(*binary);
|
||||
*buffer_size <<= 1;
|
||||
*binary = force_malloc(*buffer_size);
|
||||
}
|
||||
|
||||
bin->length = length;
|
||||
bin->binary_format = binary_format;
|
||||
bin->binary = (size_t)force_malloc(length);
|
||||
if (*binary)
|
||||
memcpy((void*)bin->binary, *binary, length);
|
||||
return program;
|
||||
}
|
||||
}
|
||||
|
||||
static bool shader_load_binary_shader(program_binary* bin, GLuint* program) {
|
||||
*program = glCreateProgram();
|
||||
glProgramBinary(*program, bin->binary_format, (void*)((size_t)bin + bin->binary), bin->length);
|
||||
GLint success = 0;
|
||||
glGetProgramiv(*program, GL_LINK_STATUS, &success);
|
||||
if (!success) {
|
||||
glDeleteProgram(*program);
|
||||
*program = 0;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void shader_glsl_update_data(shader_glsl_set_data* set) {
|
||||
if (!set)
|
||||
return;
|
||||
|
||||
if (set->curr_shader) {
|
||||
shader_glsl_sub_shader* shader = set->curr_shader;
|
||||
if (shader->uniform_val_update) {
|
||||
glUniform1iv(0, SHADER_MAX_UNIFORM_VALUES, (GLint*)shader->uniform_val);
|
||||
shader->uniform_val_update = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (set->primitive_restart) {
|
||||
gl_state_enable_primitive_restart();
|
||||
gl_state_set_primitive_restart_index(set->primitive_restart_index);
|
||||
}
|
||||
else
|
||||
gl_state_disable_primitive_restart();
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "../KKdLib/farc.hpp"
|
||||
#include "../KKdLib/mat.hpp"
|
||||
#include "../KKdLib/vec.hpp"
|
||||
#include "gl.hpp"
|
||||
#include "uniform.hpp"
|
||||
|
||||
#define SHADER_MAX_LIGHTS 8
|
||||
#define SHADER_MAX_PALETTE_MATRICES 32
|
||||
#define SHADER_MAX_PROGRAM_ENV_PARAMETERS 256
|
||||
#define SHADER_MAX_PROGRAM_LOCAL_PARAMETERS 64
|
||||
#define SHADER_MAX_PROGRAM_BUFFER_PARAMETERS 1024
|
||||
#define SHADER_MAX_PROGRAM_MATRICES 8
|
||||
#define SHADER_MAX_TEXTURE_COORDS 8
|
||||
#define SHADER_MAX_UNIFORM_BLOCK_SIZE 65536
|
||||
#define SHADER_MAX_UNIFORM_VALUES 16
|
||||
|
||||
struct shader_glsl_sub_table {
|
||||
uint32_t sub_index;
|
||||
const int32_t* vp_unival_max;
|
||||
const int32_t* fp_unival_max;
|
||||
const char* vp;
|
||||
const char* fp;
|
||||
};
|
||||
|
||||
struct shader_glsl_table {
|
||||
const char* name;
|
||||
uint32_t name_index;
|
||||
int32_t num_sub;
|
||||
const shader_glsl_sub_table* sub;
|
||||
int32_t num_uniform;
|
||||
const uniform_name* use_uniform;
|
||||
const bool* use_permut;
|
||||
};
|
||||
|
||||
struct shader_glsl;
|
||||
struct shader_glsl_set_data;
|
||||
|
||||
typedef int32_t (*PFNSHADERGLSLGETINDEXFUNCPROC)(const char* name);
|
||||
|
||||
typedef void (*PFNSHADERGLSLBINDFUNCPROC)(shader_glsl_set_data* set, shader_glsl* shad);
|
||||
|
||||
struct shader_glsl_bind_func {
|
||||
uint32_t name_index;
|
||||
PFNSHADERGLSLBINDFUNCPROC bind_func;
|
||||
};
|
||||
|
||||
struct shader_glsl_sub_shader {
|
||||
GLuint program;
|
||||
int32_t uniform_val[SHADER_MAX_UNIFORM_VALUES];
|
||||
bool uniform_val_update;
|
||||
};
|
||||
|
||||
struct shader_glsl_sub {
|
||||
uint32_t sub_index;
|
||||
const int32_t* vp_unival_max;
|
||||
const int32_t* fp_unival_max;
|
||||
shader_glsl_sub_shader* shaders;
|
||||
};
|
||||
|
||||
struct shader_glsl {
|
||||
const char* name;
|
||||
uint32_t name_index;
|
||||
int32_t num_sub;
|
||||
shader_glsl_sub* sub;
|
||||
int32_t num_uniform;
|
||||
const uniform_name* use_uniform;
|
||||
const bool* use_permut;
|
||||
PFNSHADERGLSLBINDFUNCPROC bind_func;
|
||||
|
||||
int32_t bind(shader_glsl_set_data* set, uint32_t sub_index);
|
||||
|
||||
static bool parse_define(const char* data, char** temp, size_t* temp_size);
|
||||
static bool parse_define(const char* data, int32_t num_uniform,
|
||||
int32_t* uniform_value, char** temp, size_t* temp_size);
|
||||
static char* parse_include(char* data, farc* f);
|
||||
static void unbind();
|
||||
};
|
||||
|
||||
struct shader_glsl_set_data {
|
||||
size_t size;
|
||||
shader_glsl* shaders;
|
||||
shader_glsl_sub_shader* curr_shader;
|
||||
GLboolean primitive_restart;
|
||||
GLuint primitive_restart_index;
|
||||
|
||||
PFNSHADERGLSLGETINDEXFUNCPROC get_index_by_name_func;
|
||||
|
||||
shader_glsl_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_glsl_table* shaders_table, const size_t size,
|
||||
const shader_glsl_bind_func* bind_func_table, const size_t bind_func_table_size,
|
||||
PFNSHADERGLSLGETINDEXFUNCPROC get_index_by_name);
|
||||
void set(uint32_t index);
|
||||
void unload();
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "shader_glsl.hpp"
|
||||
|
||||
enum shader_ft_enum {
|
||||
SHADER_FT_FFP = 0,
|
||||
SHADER_FT_BLINN,
|
||||
SHADER_FT_ITEM,
|
||||
SHADER_FT_STAGE,
|
||||
SHADER_FT_SKIN,
|
||||
SHADER_FT_SSS_SKIN,
|
||||
SHADER_FT_SSS_FILT,
|
||||
SHADER_FT_HAIR,
|
||||
SHADER_FT_CLOTH,
|
||||
SHADER_FT_TIGHTS,
|
||||
SHADER_FT_SKY,
|
||||
//SHADER_FT_EYEBALL,
|
||||
//SHADER_FT_EYELENS,
|
||||
SHADER_FT_GLASEYE,
|
||||
//SHADER_FT_MEMBRAN,
|
||||
//SHADER_FT_SHDMAP,
|
||||
//SHADER_FT_ESM,
|
||||
SHADER_FT_ESMGAUSS,
|
||||
SHADER_FT_ESMFILT,
|
||||
SHADER_FT_LITPROJ,
|
||||
SHADER_FT_SIMPLE,
|
||||
SHADER_FT_SIL,
|
||||
SHADER_FT_LAMBERT,
|
||||
SHADER_FT_CONSTANT,
|
||||
//SHADER_FT_PEEL,
|
||||
SHADER_FT_TONEMAP,
|
||||
SHADER_FT_REDUCE,
|
||||
SHADER_FT_MAGNIFY,
|
||||
SHADER_FT_MLAA,
|
||||
SHADER_FT_CONTOUR,
|
||||
SHADER_FT_CONTOUR_NPR,
|
||||
SHADER_FT_EXPOSURE,
|
||||
SHADER_FT_GAUSS,
|
||||
SHADER_FT_SUN,
|
||||
SHADER_FT_SUN_NO_TEXTURED,
|
||||
//SHADER_FT_FADE,
|
||||
SHADER_FT_WATER01,
|
||||
//SHADER_FT_WATER02,
|
||||
//SHADER_FT_WATRING,
|
||||
SHADER_FT_W_PTCL,
|
||||
SHADER_FT_SNOW_PT,
|
||||
SHADER_FT_LEAF_PT,
|
||||
SHADER_FT_STAR,
|
||||
//SHADER_FT_SNORING,
|
||||
//SHADER_FT_SN_FOOT,
|
||||
//SHADER_FT_SN_TSL,
|
||||
//SHADER_FT_SN_NRM,
|
||||
SHADER_FT_FLOOR,
|
||||
SHADER_FT_PUDDLE,
|
||||
SHADER_FT_S_REFL,
|
||||
SHADER_FT_S_REFR,
|
||||
SHADER_FT_RIPEMIT,
|
||||
SHADER_FT_RAIN,
|
||||
//SHADER_FT_VOLLIT,
|
||||
//SHADER_FT_FENCE,
|
||||
SHADER_FT_RIPPLE,
|
||||
SHADER_FT_FOGPTCL,
|
||||
SHADER_FT_PARTICL,
|
||||
SHADER_FT_GLITTER_PT,
|
||||
//SHADER_FT_SHOW_VEC,
|
||||
SHADER_FT_FONT,
|
||||
SHADER_FT_MOVIE,
|
||||
SHADER_FT_IMGFILT,
|
||||
SHADER_FT_SPRITE,
|
||||
SHADER_FT_END,
|
||||
SHADER_FT_MAX,
|
||||
};
|
||||
|
||||
extern const shader_glsl_table shader_ft_table[];
|
||||
extern const size_t shader_ft_table_size;
|
||||
extern const shader_glsl_bind_func shader_ft_bind_func_table[];
|
||||
extern const size_t shader_ft_bind_func_table_size;
|
||||
|
||||
extern shader_glsl_set_data shaders_ft;
|
||||
|
||||
extern int32_t shader_ft_get_index_by_name(const char* name);
|
||||
@@ -0,0 +1,237 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "shader_table.hpp"
|
||||
#include "../KKdLib/mat.hpp"
|
||||
#include "render_context.hpp"
|
||||
#include "render_texture.hpp"
|
||||
#include "shader_glsl_ft.hpp"
|
||||
#include "types.hpp"
|
||||
#include "wrap.hpp"
|
||||
|
||||
Shader* shaders = (Shader*)0x000000014CC57C10;
|
||||
ShaderTable* shader_table = (ShaderTable*)0x0000000140A41D20;
|
||||
ShaderBindFunc* shader_name_bind_func_table = (ShaderBindFunc*)0x0000000140A40F50;
|
||||
int32_t* current_vp = (int32_t*)0x000000014CC587B0;
|
||||
int32_t* current_fp = (int32_t*)0x000000014CC587B4;
|
||||
|
||||
void FASTCALL shader_set(ShaderName name) {
|
||||
if (!name) {
|
||||
shader_unbind();
|
||||
return;
|
||||
}
|
||||
|
||||
glProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 24,
|
||||
(float)uniform->arr[U_TEXTURE_BLEND], 0.0, 0.0, 0.0);
|
||||
|
||||
Shader* shad = &shaders[name];
|
||||
if (shad->bind_func)
|
||||
shad->bind_func(shad);
|
||||
else
|
||||
shader_bind(shad, shad->sub->sub_name);
|
||||
}
|
||||
|
||||
void FASTCALL shader_bind_blinn(Shader* shad) {
|
||||
shader_bind(shad, uniform->arr[U_NORMAL] ? BLINN_FRAG : BLINN_VERT);
|
||||
}
|
||||
|
||||
void FASTCALL shader_bind_cloth(Shader* shad) {
|
||||
shader_bind(shad, uniform->arr[U_NPR] ? CLOTH_NPR1
|
||||
: (uniform->arr[U_ANISO] ? CLOTH_ANISO : CLOTH_DEFAULT));
|
||||
}
|
||||
|
||||
void FASTCALL shader_bind_hair(Shader* shad) {
|
||||
shader_bind(shad, uniform->arr[U_NPR] ? HAIR_NPR1
|
||||
: (uniform->arr[U_ANISO] ? HAIR_ANISO : HAIR_DEFAULT));
|
||||
}
|
||||
|
||||
void FASTCALL shader_bind_membrane(Shader* shad) {
|
||||
uniform->arr[U_MEMBRANE] = 3;
|
||||
if (shader_bind(shad, MEMBRANE) < 0)
|
||||
return;
|
||||
|
||||
uint32_t(FASTCALL * sub_140192E00)() = (uint32_t(FASTCALL*)())0x0000000140192E00;
|
||||
uint32_t v1 = sub_140192E00();
|
||||
mat4 mat = mat4_identity;
|
||||
mat4_mul_rotate_x(&mat, (float_t)((v1 & 0x1FF) * (M_PI / 256.0)), &mat);
|
||||
mat4_mul_rotate_z(&mat, (float_t)((v1 % 0x168) * (M_PI / 180.0)), &mat);
|
||||
|
||||
vec4 vec = { 1.0f, 0.0f, 0.0f, 0.0f };
|
||||
mat4_transform_vector(&mat, &vec, &vec);
|
||||
|
||||
glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 10, vec.x, vec.y, vec.z, 0.0);
|
||||
}
|
||||
|
||||
void FASTCALL shader_bind_eye_ball(Shader* shad) {
|
||||
uniform->arr[U18] = 0;
|
||||
if (shader_bind(&shaders[_GLASEYE], GLASS_EYE) >= 0) {
|
||||
float* glass_eye = (float*)0x0000000140CA2D70;
|
||||
void (FASTCALL * glass_eye_calc)(float* glass_eye) = (void (FASTCALL*)(float* glass_eye))0x00000001405E53D0;
|
||||
void (FASTCALL * glass_eye_set)(float* glass_eye) = (void (FASTCALL*)(float* glass_eye))0x00000001405E4750;
|
||||
glass_eye_calc(glass_eye);
|
||||
glass_eye_set(glass_eye);
|
||||
}
|
||||
}
|
||||
|
||||
void FASTCALL shader_bind_tone_map(Shader* shad) {
|
||||
shader_bind(shad, uniform->arr[U_NPR] == 1 ? TONEMAP_NPR1 : TONEMAP);
|
||||
}
|
||||
|
||||
int32_t FASTCALL shader_bind(Shader* shad, SubShaderName name) {
|
||||
int32_t num_sub = shad->num_sub;
|
||||
int32_t subshader_index = 0;
|
||||
if (num_sub <= 0)
|
||||
return -1;
|
||||
|
||||
for (SubShader* i = shad->sub; i->sub_name != name; i++) {
|
||||
subshader_index++;
|
||||
if (subshader_index >= num_sub)
|
||||
return -1;
|
||||
}
|
||||
|
||||
SubShader* subshader = &shad->sub[subshader_index];
|
||||
if (!subshader)
|
||||
return -1;
|
||||
|
||||
int32_t num_uniform = shad->num_uniform;
|
||||
int32_t unival_vp_curr = 1;
|
||||
int32_t unival_fp_curr = 1;
|
||||
int32_t unival_vp = 0;
|
||||
int32_t unival_fp = 0;
|
||||
if (num_uniform > 0) {
|
||||
int32_t* vp_unival_max = subshader->vp_unival_max;
|
||||
int32_t* fp_unival_max = subshader->fp_unival_max;
|
||||
for (size_t i = 0; i < num_uniform; i++) {
|
||||
int32_t unival = uniform->arr[shad->use_uniform[i]];
|
||||
unival_vp += unival_vp_curr * min_def(unival, vp_unival_max[i]);
|
||||
unival_fp += unival_fp_curr * min_def(unival, fp_unival_max[i]);
|
||||
unival_vp_curr *= vp_unival_max[i] + 1;
|
||||
unival_fp_curr *= fp_unival_max[i] + 1;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t vp = subshader->vp[unival_vp];
|
||||
int32_t fp = subshader->fp[unival_fp];
|
||||
if (*current_vp != vp) {
|
||||
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, vp);
|
||||
*current_vp = vp;
|
||||
}
|
||||
|
||||
if (*current_fp != fp) {
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, fp);
|
||||
*current_fp = fp;
|
||||
}
|
||||
|
||||
glEnableDLL(GL_VERTEX_PROGRAM_ARB);
|
||||
glEnableDLL(GL_FRAGMENT_PROGRAM_ARB);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FASTCALL shader_unbind() {
|
||||
if (current_vp) {
|
||||
if (*current_vp)
|
||||
glDisableDLL(GL_VERTEX_PROGRAM_ARB);
|
||||
*current_vp = 0;
|
||||
}
|
||||
|
||||
if (current_fp) {
|
||||
if (*current_fp)
|
||||
glDisableDLL(GL_FRAGMENT_PROGRAM_ARB);
|
||||
*current_fp = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void FASTCALL shader_load_all_shaders() {
|
||||
{
|
||||
farc f;
|
||||
f.read("F:\\msys64\\ReDIVA\\bin\\rom\\ft_shaders.farc", true, false);
|
||||
shaders_ft.load(&f, true, "ft", shader_ft_table, shader_ft_table_size,
|
||||
shader_ft_bind_func_table, shader_ft_bind_func_table_size,
|
||||
shader_ft_get_index_by_name);
|
||||
}
|
||||
return;
|
||||
|
||||
void (FASTCALL * shader_load_program_file)(GLuint program, const char* file_name, bool vertex_program)
|
||||
= (void (FASTCALL*)(GLuint program, const char* file_name, bool vertex_program))0x00000001405E52D0;
|
||||
|
||||
ShaderTable* shaders_table = &shader_table[_BLINN];
|
||||
Shader* shader = &shaders[_BLINN];
|
||||
int32_t curr_shader = SHADER_END - 1;
|
||||
do {
|
||||
shader->name = shaders_table->name;
|
||||
shader->name_index = shaders_table->name_index;
|
||||
shader->num_sub = shaders_table->num_sub;
|
||||
int32_t num_sub = shaders_table->num_sub;
|
||||
|
||||
const SubShaderTable* sub_table = shaders_table->sub;
|
||||
SubShader* sub = (SubShader*)_operator_new(sizeof(SubShader) * num_sub);
|
||||
memset(sub, 0, sizeof(SubShader) * num_sub);
|
||||
shader->sub = sub;
|
||||
shader->num_uniform = shaders_table->num_uniform;
|
||||
shader->use_uniform = shaders_table->use_uniform;
|
||||
|
||||
for (int32_t i = 0; i < num_sub; i++, sub_table++, sub++) {
|
||||
sub->sub_name = sub_table->sub_name;
|
||||
sub->vp_unival_max = (int32_t*)sub_table->vp_unival_max;
|
||||
sub->fp_unival_max = (int32_t*)sub_table->fp_unival_max;
|
||||
sub->num_vp = sub_table->num_vp;
|
||||
sub->num_fp = sub_table->num_fp;
|
||||
sub->vp = (GLuint*)_operator_new(sizeof(GLuint) * sub_table->num_vp);
|
||||
sub->fp = (GLuint*)_operator_new(sizeof(GLuint) * sub_table->num_fp);
|
||||
|
||||
glGenProgramsARB((GLsizei)sub_table->num_vp, (GLuint*)sub->vp);
|
||||
glGenProgramsARB((GLsizei)sub_table->num_fp, (GLuint*)sub->fp);
|
||||
|
||||
for (int32_t j = 0; j < sub_table->num_vp; j++)
|
||||
shader_load_program_file(sub->vp[j], sub_table->vp[j], true);
|
||||
|
||||
for (int32_t j = 0; j < sub_table->num_fp; j++)
|
||||
shader_load_program_file(sub->fp[j], sub_table->fp[j], false);
|
||||
}
|
||||
shader->bind_func = 0;
|
||||
|
||||
ShaderBindFunc* bind_func_table = shader_name_bind_func_table;
|
||||
ShaderName bind_func_name = _BLINN;
|
||||
while (shader->name_index != bind_func_name) {
|
||||
bind_func_name = (++bind_func_table)->name_index;
|
||||
if (bind_func_table->name_index == SHADER_END)
|
||||
break;
|
||||
}
|
||||
shader->bind_func = bind_func_table->bind_func;
|
||||
shader++;
|
||||
shaders_table++;
|
||||
curr_shader--;
|
||||
} while (curr_shader);
|
||||
}
|
||||
|
||||
void FASTCALL shader_free() {
|
||||
shaders_ft.unload();
|
||||
return;
|
||||
Shader* shader = &shaders[SHADER_FFP];
|
||||
for (int32_t i = 0; i < SHADER_END; i++, shader++) {
|
||||
if (!shader->sub)
|
||||
continue;
|
||||
|
||||
for (int32_t j = 0; j < shader->num_sub; j++) {
|
||||
SubShader* sub = shader->sub;
|
||||
if (sub[j].vp) {
|
||||
glDeleteProgramsARB(sub[j].num_vp, sub[j].vp);
|
||||
_operator_delete(sub[j].vp);
|
||||
sub[j].vp = 0;
|
||||
}
|
||||
|
||||
if (sub[j].fp) {
|
||||
glDeleteProgramsARB(sub[j].num_fp, sub[j].fp);
|
||||
_operator_delete(sub[j].fp);
|
||||
sub[j].fp = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (shader->sub) {
|
||||
_operator_delete(shader->sub);
|
||||
shader->sub = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "gl.hpp"
|
||||
#include "uniform.hpp"
|
||||
|
||||
enum SubShaderName {
|
||||
SHADER_SUB_FFP = 0,
|
||||
BLINN_VERT = 1,
|
||||
BLINN_FRAG = 2,
|
||||
ITEM_BLINN = 3,
|
||||
STAGE_BLINN = 4,
|
||||
SKIN_DEFAULT = 5,
|
||||
SSS_SKIN = 6,
|
||||
SSS_FILTER = 7,
|
||||
HAIR_DEFAULT = 8,
|
||||
HAIR_ANISO = 9,
|
||||
HAIR_NPR1 = 10,
|
||||
CLOTH_DEFAULT = 11,
|
||||
CLOTH_ANISO = 12,
|
||||
CLOTH_NPR1 = 13,
|
||||
TIGHTS = 14,
|
||||
SKY_DEFAULT = 15,
|
||||
EYE_BALL = 16,
|
||||
EYE_LENS = 17,
|
||||
GLASS_EYE = 18,
|
||||
MEMBRANE = 19,
|
||||
SHADOWMAP = 20,
|
||||
ESM = 21,
|
||||
ESM_GAUSS = 22,
|
||||
ESM_FILTER = 23,
|
||||
LIT_PROJ = 24,
|
||||
SIMPLE = 25,
|
||||
SILHOUETTE = 26,
|
||||
LAMBERT = 27,
|
||||
CONSTANT = 28,
|
||||
PEEL = 29,
|
||||
TONEMAP = 30,
|
||||
TONEMAP_NPR1 = 31,
|
||||
REDUCE_TEX = 32,
|
||||
MAGNIFY = 33,
|
||||
MLAA = 34,
|
||||
CONTOUR = 35,
|
||||
EXPOSURE = 36,
|
||||
PP_GAUSS = 37,
|
||||
SUN = 38,
|
||||
FADE = 39,
|
||||
WATER01 = 40,
|
||||
WATER02 = 41,
|
||||
WATER_RING = 42,
|
||||
WATER_PARTICLE = 43,
|
||||
SNOW_PARTICLE = 44,
|
||||
LEAF_PARTICLE = 45,
|
||||
STAR = 46,
|
||||
SNOW_RING = 47,
|
||||
SNOW_FOOTPRINT = 48,
|
||||
SNOW_TEX_SPACE_LIGHT = 49,
|
||||
SNOW_CALC_NORMAL = 50,
|
||||
FLOOR = 51,
|
||||
PUDDLE = 52,
|
||||
SIMPLE_REFLECT = 53,
|
||||
SIMPLE_REFRACT = 54,
|
||||
RIPPLE_EMIT = 55,
|
||||
RAIN = 56,
|
||||
VOLUME_LIGHT = 57,
|
||||
FENCE_ALPHA = 58,
|
||||
RIPPLE = 59,
|
||||
FOG_PTCL = 60,
|
||||
PARTICLE = 61,
|
||||
GLITTER_PARTICLE = 62,
|
||||
SHOW_VECTOR = 63,
|
||||
FONT = 64,
|
||||
MOVIE = 65,
|
||||
IMGFILTER = 66,
|
||||
SPRITE = 67,
|
||||
};
|
||||
|
||||
enum ShaderName {
|
||||
SHADER_FFP = 0,
|
||||
_BLINN = 1,
|
||||
_ITEM = 2,
|
||||
_STAGE = 3,
|
||||
_SKIN = 4,
|
||||
_SSS_SKIN = 5,
|
||||
_SSS_FILT = 6,
|
||||
_HAIR = 7,
|
||||
_CLOTH = 8,
|
||||
_TIGHTS = 9,
|
||||
_SKY = 10,
|
||||
_EYEBALL = 11,
|
||||
_EYELENS = 12,
|
||||
_GLASEYE = 13,
|
||||
_MEMBRAN = 14,
|
||||
_SHDMAP = 15,
|
||||
_ESM = 16,
|
||||
_ESMGAUSS = 17,
|
||||
_ESMFILT = 18,
|
||||
_LITPROJ = 19,
|
||||
_SIMPLE = 20,
|
||||
_SIL = 21,
|
||||
_LAMBERT = 22,
|
||||
_CONSTANT = 23,
|
||||
_PEEL = 24,
|
||||
_TONEMAP = 25,
|
||||
_REDUCE = 26,
|
||||
_MAGNIFY = 27,
|
||||
_MLAA = 28,
|
||||
_CONTOUR = 29,
|
||||
_EXPOSURE = 30,
|
||||
_GAUSS = 31,
|
||||
_SUN = 32,
|
||||
_FADE = 33,
|
||||
_WATER01 = 34,
|
||||
_WATER02 = 35,
|
||||
_WATRING = 36,
|
||||
_W_PTCL = 37,
|
||||
_SNOW_PT = 38,
|
||||
_LEAF_PT = 39,
|
||||
_STAR = 40,
|
||||
_SNORING = 41,
|
||||
_SN_FOOT = 42,
|
||||
_SN_TSL = 43,
|
||||
_SN_NRM = 44,
|
||||
_FLOOR = 45,
|
||||
_PUDDLE = 46,
|
||||
_S_REFL = 47,
|
||||
_S_REFR = 48,
|
||||
_RIPEMIT = 49,
|
||||
_RAIN = 50,
|
||||
_VOLLIT = 51,
|
||||
_FENCE = 52,
|
||||
_RIPPLE = 53,
|
||||
_FOGPTCL = 54,
|
||||
_PARTICL = 55,
|
||||
_GLITTER_PT = 56,
|
||||
_SHOWVEC = 57,
|
||||
_FONT = 58,
|
||||
_MOVIE = 59,
|
||||
_IMGFILT = 60,
|
||||
_SPRITE = 61,
|
||||
SHADER_END = 62,
|
||||
};
|
||||
|
||||
struct SubShaderTable {
|
||||
SubShaderName sub_name;
|
||||
int32_t padding;
|
||||
const int32_t* vp_unival_max;
|
||||
const int32_t* fp_unival_max;
|
||||
int32_t num_vp;
|
||||
int32_t num_fp;
|
||||
const char** vp;
|
||||
const char** fp;
|
||||
};
|
||||
|
||||
struct ShaderTable {
|
||||
const char* name;
|
||||
ShaderName name_index;
|
||||
int32_t num_sub;
|
||||
const SubShaderTable* sub;
|
||||
int32_t num_uniform;
|
||||
int32_t padding;
|
||||
uniform_name* use_uniform;
|
||||
};
|
||||
|
||||
struct SubShader {
|
||||
SubShaderName sub_name;
|
||||
int32_t padding;
|
||||
int32_t* vp_unival_max;
|
||||
int32_t* fp_unival_max;
|
||||
int32_t num_vp;
|
||||
int32_t num_fp;
|
||||
GLuint* vp;
|
||||
GLuint* fp;
|
||||
};
|
||||
|
||||
struct Shader;
|
||||
|
||||
typedef void (FASTCALL* PFNSHADERBINDFUNCPROC)(Shader* shad);
|
||||
|
||||
struct Shader {
|
||||
const char* name;
|
||||
ShaderName name_index;
|
||||
int32_t num_sub;
|
||||
SubShader* sub;
|
||||
int32_t num_uniform;
|
||||
int32_t padding;
|
||||
uniform_name* use_uniform;
|
||||
PFNSHADERBINDFUNCPROC bind_func;
|
||||
};
|
||||
|
||||
struct ShaderBindFunc {
|
||||
ShaderName name_index;
|
||||
int32_t padding;
|
||||
PFNSHADERBINDFUNCPROC bind_func;
|
||||
};
|
||||
|
||||
extern Shader* shaders;
|
||||
extern ShaderTable* shader_table;
|
||||
extern ShaderBindFunc* shader_name_bind_func_table;
|
||||
extern int32_t* current_vp;
|
||||
extern int32_t* current_fp;
|
||||
|
||||
extern void FASTCALL shader_set(ShaderName name); // 0x00000001405E4CE0
|
||||
extern void FASTCALL shader_bind_blinn(Shader* shad); // 0x00000001405E4320
|
||||
extern void FASTCALL shader_bind_cloth(Shader* shad); // 0x00000001405E4340
|
||||
extern void FASTCALL shader_bind_hair(Shader* shad); // 0x00000001405E4370
|
||||
extern void FASTCALL shader_bind_membrane(Shader* shas); // 0x00000001405E43A0
|
||||
extern void FASTCALL shader_bind_eye_ball(Shader* shad); // 0x00000001405E4530
|
||||
extern void FASTCALL shader_bind_tone_map(Shader* shad); // 0x00000001405E4580
|
||||
extern int32_t FASTCALL shader_bind(Shader* shad, SubShaderName name); // 0x00000001405E4B50
|
||||
extern void FASTCALL shader_unbind(); // 0x00000001405E5660
|
||||
extern void FASTCALL shader_load_all_shaders(); // 0x00000001405E4FC0
|
||||
extern void FASTCALL shader_free(); // 0x00000001405E4DB0
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "shadow.hpp"
|
||||
|
||||
Shadow** shadow_ptr = (Shadow**)0x000000014CC587B8;
|
||||
|
||||
Shadow* shadow_ptr_get() {
|
||||
return *shadow_ptr;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "../KKdLib/time.hpp"
|
||||
#include "../KKdLib/vec.hpp"
|
||||
#include "render_texture.hpp"
|
||||
#include "shared.hpp"
|
||||
#include "types.hpp"
|
||||
|
||||
enum shadow_type_enum {
|
||||
SHADOW_CHARA = 0,
|
||||
SHADOW_STAGE,
|
||||
SHADOW_MAX,
|
||||
};
|
||||
|
||||
struct Shadow {
|
||||
void* __vftable;
|
||||
RenderTexture render_textures[7];
|
||||
RenderTexture* curr_render_textures[3];
|
||||
float_t view_region;
|
||||
float_t range;
|
||||
vec3 view_point[2];
|
||||
vec3 interest[2];
|
||||
vec3 field_1A8[2];
|
||||
float_t field_1C0[2];
|
||||
float_t field_1C8[2];
|
||||
prj::vector<vec3> field_1D0[2];
|
||||
int32_t field_200[2];
|
||||
float_t field_208;
|
||||
vec3 direction;
|
||||
vec3 view_point_shared;
|
||||
vec3 interest_shared;
|
||||
mat4 view_mat[2];
|
||||
int32_t near_blur;
|
||||
blur_filter_mode blur_filter;
|
||||
int32_t far_blur;
|
||||
int32_t field_2BC;
|
||||
float_t distance;
|
||||
float_t field_2C4;
|
||||
float_t z_near;
|
||||
float_t z_far;
|
||||
float_t field_2D0;
|
||||
float_t field_2D4;
|
||||
float_t field_2D8;
|
||||
float_t field_2DC;
|
||||
float_t field_2E0;
|
||||
float_t ambient;
|
||||
bool field_2E8;
|
||||
int32_t field_2EC;
|
||||
bool field_2F0[2];
|
||||
bool self_shadow;
|
||||
bool blur_filter_enable[2];
|
||||
bool field_2F5;
|
||||
};
|
||||
|
||||
static_assert(sizeof(Shadow) == 0x2F8, "\"Shadow\" struct should have a size of 0x2F8");
|
||||
|
||||
extern Shadow* shadow_ptr_get();
|
||||
@@ -0,0 +1,6 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "shared.hpp"
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "../KKdLib/mat.hpp"
|
||||
#include "../KKdLib/vec.hpp"
|
||||
#include "wrap.hpp"
|
||||
|
||||
enum blur_filter_mode {
|
||||
BLUR_FILTER_4 = 0,
|
||||
BLUR_FILTER_9,
|
||||
BLUR_FILTER_16,
|
||||
BLUR_FILTER_32,
|
||||
BLUR_FILTER_MAX,
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "../KKdLib/mat.hpp"
|
||||
#include "../KKdLib/vec.hpp"
|
||||
#include "gl_state.hpp"
|
||||
#include "render_context.hpp"
|
||||
#include "resolution_mode.hpp"
|
||||
#include "texture.hpp"
|
||||
#include "types.hpp"
|
||||
|
||||
struct rectangle {
|
||||
vec2 pos;
|
||||
vec2 size;
|
||||
};
|
||||
|
||||
struct spr_info {
|
||||
uint16_t index;
|
||||
uint16_t set_index;
|
||||
};
|
||||
|
||||
struct SpriteHeaderFile {
|
||||
uint32_t flag;
|
||||
uint32_t texofs;
|
||||
int32_t num_of_texture;
|
||||
int32_t num_of_sprite;
|
||||
uint32_t sprinfo_offset;
|
||||
uint32_t texname_offset;
|
||||
uint32_t sprname_offset;
|
||||
uint32_t sprdata_offset;
|
||||
};
|
||||
|
||||
struct SpriteHeader {
|
||||
uint32_t flag;
|
||||
uint32_t texofs;
|
||||
int32_t num_of_texture;
|
||||
int32_t num_of_sprite;
|
||||
spr::SprInfo* sprinfo;
|
||||
const char** texname;
|
||||
const char** sprname;
|
||||
SpriteData* sprdata;
|
||||
};
|
||||
|
||||
struct shared_ptr_prj__stack_allocator {
|
||||
void* ptr;
|
||||
void* ref;
|
||||
};
|
||||
|
||||
struct SprSet {
|
||||
void* vftable;
|
||||
int32_t flag;
|
||||
int32_t index;
|
||||
SpriteHeaderFile* header_file;
|
||||
SpriteHeader* header;
|
||||
texture** textures;
|
||||
int32_t load_count;
|
||||
void* file_handler;
|
||||
bool ready;
|
||||
shared_ptr_prj__stack_allocator alloc_handler;
|
||||
prj::string file;
|
||||
};
|
||||
|
||||
namespace spr {
|
||||
enum SprAttr : uint32_t {
|
||||
SPR_ATTR_FLIP_H = 0x00010000,
|
||||
SPR_ATTR_FLIP_V = 0x00020000,
|
||||
SPR_ATTR_CTR_LT = 0x00040000,
|
||||
SPR_ATTR_CTR_CT = 0x00080000,
|
||||
SPR_ATTR_CTR_RT = 0x00100000,
|
||||
SPR_ATTR_CTR_LC = 0x00200000,
|
||||
SPR_ATTR_CTR_CC = 0x00400000,
|
||||
SPR_ATTR_CTR_RC = 0x00800000,
|
||||
SPR_ATTR_CTR_LB = 0x01000000,
|
||||
SPR_ATTR_CTR_CB = 0x02000000,
|
||||
SPR_ATTR_CTR_RB = 0x04000000,
|
||||
SPR_ATTR_MATRIX = 0x08000000,
|
||||
SPR_ATTR_10000000 = 0x10000000,
|
||||
SPR_ATTR_NOBLEND = 0x20000000,
|
||||
|
||||
SPR_ATTR_CTR = 0x07FC0000,
|
||||
};
|
||||
|
||||
enum SprKind {
|
||||
SPR_KIND_NORMAL = 0,
|
||||
SPR_KIND_LINE,
|
||||
SPR_KIND_LINES,
|
||||
SPR_KIND_RECT,
|
||||
SPR_KIND_MULTI,
|
||||
SPR_KIND_ARROW_A,
|
||||
SPR_KIND_ARROW_B,
|
||||
SPR_KIND_ARROW_AB,
|
||||
SPR_KIND_TRIANGLE,
|
||||
SPR_KIND_CIRCLE,
|
||||
};
|
||||
|
||||
enum SprPrio {
|
||||
SPR_PRIO_00 = 0,
|
||||
SPR_PRIO_01,
|
||||
SPR_PRIO_02,
|
||||
SPR_PRIO_03,
|
||||
SPR_PRIO_04,
|
||||
SPR_PRIO_05,
|
||||
SPR_PRIO_06,
|
||||
SPR_PRIO_07,
|
||||
SPR_PRIO_08,
|
||||
SPR_PRIO_09,
|
||||
SPR_PRIO_10,
|
||||
SPR_PRIO_11,
|
||||
SPR_PRIO_12,
|
||||
SPR_PRIO_13,
|
||||
SPR_PRIO_14,
|
||||
SPR_PRIO_15,
|
||||
SPR_PRIO_16,
|
||||
SPR_PRIO_17,
|
||||
SPR_PRIO_18,
|
||||
SPR_PRIO_19,
|
||||
SPR_PRIO_20,
|
||||
SPR_PRIO_21,
|
||||
SPR_PRIO_22,
|
||||
SPR_PRIO_23,
|
||||
SPR_PRIO_24,
|
||||
SPR_PRIO_25,
|
||||
SPR_PRIO_26,
|
||||
SPR_PRIO_27,
|
||||
SPR_PRIO_28,
|
||||
SPR_PRIO_29,
|
||||
SPR_PRIO_30,
|
||||
SPR_PRIO_31,
|
||||
SPR_PRIO_MAX,
|
||||
};
|
||||
|
||||
struct SpriteVertex {
|
||||
vec3 pos;
|
||||
vec2 uv;
|
||||
vec4u8 color;
|
||||
};
|
||||
|
||||
struct SprArgs {
|
||||
enum Flags : uint32_t {
|
||||
SPRITE_SIZE = 0x01,
|
||||
TEXTURE_POS_SIZE = 0x02,
|
||||
};
|
||||
|
||||
union IDUnion {
|
||||
int32_t index;
|
||||
uint32_t id;
|
||||
spr_info info;
|
||||
|
||||
IDUnion() {
|
||||
index = -1;
|
||||
id = -1;
|
||||
info = {};
|
||||
}
|
||||
};
|
||||
|
||||
SprKind kind;
|
||||
IDUnion id;
|
||||
vec4u8 color;
|
||||
SprAttr attr;
|
||||
int32_t blend;
|
||||
int32_t index;
|
||||
int32_t layer;
|
||||
SprPrio prio;
|
||||
resolution_mode resolution_mode_screen;
|
||||
resolution_mode resolution_mode_sprite;
|
||||
vec3 center;
|
||||
vec3 trans;
|
||||
vec3 scale;
|
||||
vec3 rot;
|
||||
vec2 skew_angle;
|
||||
mat4 mat;
|
||||
texture* texture;
|
||||
int32_t shader;
|
||||
SpriteVertex* vertex_array;
|
||||
size_t num_vertex;
|
||||
Flags flags;
|
||||
vec2 sprite_size;
|
||||
int32_t field_CC;
|
||||
vec2 texture_pos;
|
||||
vec2 texture_size;
|
||||
spr::SprArgs* next;
|
||||
};
|
||||
|
||||
|
||||
extern void(FASTCALL* put_rgb_cross)(mat4* mat);
|
||||
}
|
||||
|
||||
extern size_t(FASTCALL* sprite_manager_get_reqlist_count)(int32_t index);
|
||||
|
||||
extern void sprite_manager_init();
|
||||
extern void sprite_manager_draw(int32_t index, bool font, texture* tex);
|
||||
extern void sprite_manager_set_res(double_t aspect, int32_t width, int32_t height);
|
||||
extern void sprite_manager_set_view_projection(bool aet_3d);
|
||||
extern void sprite_manager_free();
|
||||
|
||||
extern void sprite_patch();
|
||||
@@ -0,0 +1,206 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "stage.hpp"
|
||||
#include "../KKdLib/mat.hpp"
|
||||
#include "../KKdLib/vec.hpp"
|
||||
#include "object.hpp"
|
||||
#include "render_context.hpp"
|
||||
#include <Helpers.h>
|
||||
|
||||
enum stage_data_flags {
|
||||
STAGE_DATA_FLAG_1 = 0x01,
|
||||
STAGE_DATA_LIGHT_CHARA_AMBIENT = 0x02,
|
||||
STAGE_DATA_FLAG_4 = 0x04,
|
||||
STAGE_DATA_FLAG_8 = 0x08,
|
||||
};
|
||||
|
||||
struct stage_data_reflect {
|
||||
reflect_refract_resolution_mode mode;
|
||||
int32_t blur_num;
|
||||
blur_filter_mode blur_filter;
|
||||
};
|
||||
|
||||
static_assert(sizeof(stage_data_reflect) == 0x0C, "\"stage_data_reflect\" struct should have a size of 0x0C");
|
||||
|
||||
struct stage_data_refract {
|
||||
reflect_refract_resolution_mode mode;
|
||||
};
|
||||
|
||||
static_assert(sizeof(stage_data_refract) == 0x04, "\"stage_data_refract\" struct should have a size of 0x04");
|
||||
|
||||
struct stage_data {
|
||||
const char* name;
|
||||
const char* auth_3d_name;
|
||||
int32_t object_set_id;
|
||||
object_info object_ground;
|
||||
object_info object_ring;
|
||||
object_info object_sky;
|
||||
object_info object_shadow;
|
||||
object_info object_reflect;
|
||||
object_info object_refract;
|
||||
uint32_t lens_flare_texture;
|
||||
uint32_t lens_shaft_texture;
|
||||
uint32_t lens_ghost_texture;
|
||||
float_t lens_shaft_inv_scale;
|
||||
uint32_t field_3C;
|
||||
uint32_t render_texture;
|
||||
uint32_t movie_texture;
|
||||
const char* collision_file_path;
|
||||
stage_data_reflect_type reflect_type;
|
||||
bool refract;
|
||||
stage_data_reflect* reflect_data;
|
||||
stage_data_refract* refract_data;
|
||||
stage_data_flags flags;
|
||||
float_t ring_rectangle_x;
|
||||
float_t ring_rectangle_y;
|
||||
float_t ring_rectangle_width;
|
||||
float_t ring_rectangle_height;
|
||||
float_t ring_height;
|
||||
float_t ring_out_height;
|
||||
int32_t field_84;
|
||||
};
|
||||
|
||||
static_assert(sizeof(stage_data) == 0x88, "\"stage_data\" struct should have a size of 0x88");
|
||||
|
||||
struct stage {
|
||||
int32_t index;
|
||||
uint16_t counter;
|
||||
int32_t state;
|
||||
stage_data* stage_data;
|
||||
bool stage_display;
|
||||
bool lens_flare;
|
||||
bool ground;
|
||||
bool ring;
|
||||
bool sky;
|
||||
bool auth_3d_loaded;
|
||||
mat4 mat;
|
||||
float_t rot_y;
|
||||
uint32_t obj_set;
|
||||
};
|
||||
|
||||
static_assert(sizeof(stage) == 0x68, "\"stage\" struct should have a size of 0x68");
|
||||
|
||||
|
||||
static bool object_bounding_sphere_check_visibility_shadow(obj_bounding_sphere* sphere, mat4* mat);
|
||||
static bool object_bounding_sphere_check_visibility_shadow_chara(obj_bounding_sphere* sphere);
|
||||
static bool object_bounding_sphere_check_visibility_shadow_stage(obj_bounding_sphere* sphere);
|
||||
|
||||
HOOK(void, FASTCALL, stage__disp, 0x0000000140649560, stage* s) {
|
||||
if (s->state != 6 || !s->stage_display)
|
||||
return;
|
||||
|
||||
mdl::DispManager& disp_manager = *::disp_manager;
|
||||
|
||||
mat4 mat;
|
||||
mat4_rotate_y(s->rot_y, &mat);
|
||||
|
||||
if (s->stage_data->object_ground.not_null() && s->ground)
|
||||
disp_manager.entry_obj_by_object_info(&mat, s->stage_data->object_ground);
|
||||
|
||||
if (s->stage_data->object_ring.not_null() && s->ring)
|
||||
disp_manager.entry_obj_by_object_info(&mat, s->stage_data->object_ring);
|
||||
|
||||
if (s->stage_data->object_reflect.not_null()) {
|
||||
disp_manager.set_obj_flags((mdl::ObjFlags)(mdl::OBJ_NO_TRANSLUCENCY | mdl::OBJ_REFLECT));
|
||||
disp_manager.entry_obj_by_object_info(&mat, s->stage_data->object_reflect);
|
||||
disp_manager.set_obj_flags();
|
||||
}
|
||||
|
||||
if (s->stage_data->object_refract.not_null()) {
|
||||
disp_manager.set_obj_flags((mdl::ObjFlags)(mdl::OBJ_NO_TRANSLUCENCY | mdl::OBJ_REFRACT));
|
||||
disp_manager.entry_obj_by_object_info(&mat, s->stage_data->object_refract);
|
||||
disp_manager.set_obj_flags();
|
||||
}
|
||||
|
||||
if (s->stage_data->object_sky.not_null() && s->sky) {
|
||||
mat4 t = s->mat;
|
||||
mat4_mul(&t, &mat, &t);
|
||||
disp_manager.entry_obj_by_object_info(&t, s->stage_data->object_sky);
|
||||
}
|
||||
|
||||
if (s->stage_data->lens_flare_texture != -1 && s->lens_flare) {
|
||||
int32_t object_set_id = s->stage_data->object_set_id;
|
||||
rndr::Render* rend = render;
|
||||
rend->lens_flare_texture = obj_database_get_obj_set_texture(
|
||||
object_set_id, s->stage_data->lens_flare_texture);
|
||||
if (rend->lens_flare_texture) {
|
||||
rend->lens_shaft_texture = obj_database_get_obj_set_texture(
|
||||
object_set_id, s->stage_data->lens_shaft_texture);
|
||||
rend->lens_ghost_texture = obj_database_get_obj_set_texture(
|
||||
object_set_id, s->stage_data->lens_ghost_texture);
|
||||
rend->lens_ghost_count = 16;
|
||||
rend->lens_shaft_inv_scale = s->stage_data->lens_shaft_inv_scale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void stage__disp_shadow_object(object_info object, mat4* mat) {
|
||||
mdl::DispManager& disp_manager = *::disp_manager;
|
||||
|
||||
for (int32_t i = SHADOW_CHARA; i < SHADOW_MAX; i++) {
|
||||
disp_manager.set_shadow_type((shadow_type_enum)i);
|
||||
disp_manager.set_culling_finc(i == SHADOW_CHARA
|
||||
? object_bounding_sphere_check_visibility_shadow_chara
|
||||
: object_bounding_sphere_check_visibility_shadow_stage);
|
||||
disp_manager.set_obj_flags((mdl::ObjFlags)(mdl::OBJ_NO_TRANSLUCENCY | mdl::OBJ_SHADOW_OBJECT));
|
||||
disp_manager.entry_obj_by_object_info(mat, object);
|
||||
}
|
||||
|
||||
disp_manager.set_obj_flags();
|
||||
disp_manager.set_culling_finc();
|
||||
disp_manager.set_shadow_type();
|
||||
}
|
||||
|
||||
|
||||
HOOK(void, FASTCALL, stage__disp_shadow, 0x00000001406497C0, stage* s) {
|
||||
if (s->state != 6 || !s->stage_display)
|
||||
return;
|
||||
|
||||
mat4 mat;
|
||||
mat4_rotate_y(s->rot_y, &mat);
|
||||
if (s->stage_data->object_shadow.not_null())
|
||||
stage__disp_shadow_object(s->stage_data->object_shadow, &mat);
|
||||
}
|
||||
|
||||
void stage_patch() {
|
||||
INSTALL_HOOK(stage__disp);
|
||||
INSTALL_HOOK(stage__disp_shadow);
|
||||
}
|
||||
|
||||
static bool object_bounding_sphere_check_visibility_shadow(obj_bounding_sphere* sphere, mat4* mat) {
|
||||
mat4 view_matrix;
|
||||
mat4_transpose(&camera_data->view_matrix, &view_matrix);
|
||||
|
||||
vec3 center;
|
||||
mat4_transform_point(mat, &sphere->center, ¢er);
|
||||
mat4_transform_point(&view_matrix, ¢er, ¢er);
|
||||
float_t radius = sphere->radius;
|
||||
|
||||
Shadow* shad = shadow_ptr_get();
|
||||
float_t v9 = shad->view_region * shad->range;
|
||||
if ((center.x + radius) < -v9
|
||||
|| (center.x - radius) > v9
|
||||
|| (center.y + radius) < -v9
|
||||
|| (center.y - radius) > v9
|
||||
|| (center.z - radius) > -shad->z_near
|
||||
|| (center.z + radius) < -shad->z_far)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool object_bounding_sphere_check_visibility_shadow_chara(obj_bounding_sphere* sphere) {
|
||||
mat4 mat;
|
||||
Shadow* shad = shadow_ptr_get();
|
||||
mat4_look_at(&shad->view_point[0], &shad->interest[0], &mat);
|
||||
return object_bounding_sphere_check_visibility_shadow(sphere, &mat);
|
||||
}
|
||||
|
||||
static bool object_bounding_sphere_check_visibility_shadow_stage(obj_bounding_sphere* sphere) {
|
||||
mat4 mat;
|
||||
Shadow* shad = shadow_ptr_get();
|
||||
mat4_look_at(&shad->view_point[1], &shad->interest[1], &mat);
|
||||
return object_bounding_sphere_check_visibility_shadow(sphere, &mat);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
|
||||
extern void stage_patch();
|
||||
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "stage_param.hpp"
|
||||
|
||||
stage_param_data_litproj** stage_param_data_litproj_current = (stage_param_data_litproj**)0x0000000141194D80;
|
||||
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "../KKdLib/vec.hpp"
|
||||
#include "object.hpp"
|
||||
#include "types.hpp"
|
||||
|
||||
/*struct stage_param_data_coli {
|
||||
int32_t pv_id;
|
||||
prj::map<int32_t, osage_ring_data> stage_ring_data;
|
||||
prj::map<int32_t, osage_ring_data> mhd_id_ring_data;
|
||||
prj::map<int32_t, prj::string> stage_wind_file;
|
||||
};
|
||||
|
||||
static_assert(sizeof(stage_param_data_coli) == 0x38, "\"stage_param_data_coli\" struct should have a size of 0x38");*/
|
||||
|
||||
struct stage_param_data_fog_ring {
|
||||
int32_t num_ptcls;
|
||||
float_t ring_size;
|
||||
vec3 wind_dir;
|
||||
int32_t tex_id;
|
||||
vec4 color;
|
||||
float_t ptcl_size;
|
||||
float_t density;
|
||||
float_t density_offset;
|
||||
};
|
||||
|
||||
static_assert(sizeof(stage_param_data_fog_ring) == 0x34, "\"stage_param_data_fog_ring\" struct should have a size of 0x34");
|
||||
|
||||
struct stage_param_data_leaf_lie_plane_xz {
|
||||
float_t min_x;
|
||||
float_t max_x;
|
||||
float_t min_z;
|
||||
float_t max_z;
|
||||
};
|
||||
|
||||
static_assert(sizeof(stage_param_data_leaf_lie_plane_xz) == 0x10, "\"stage_param_data_fog_ring\" struct should have a size of 0x10");
|
||||
|
||||
struct stage_param_data_leaf {
|
||||
int32_t tex_id;
|
||||
vec4 color;
|
||||
float_t psize;
|
||||
int32_t num_initial_ptcls;
|
||||
float_t frame_speed_coef;
|
||||
float_t emit_interval;
|
||||
vec3 wind;
|
||||
vec3 range;
|
||||
vec3 offset;
|
||||
stage_param_data_leaf_lie_plane_xz lie_plane_xz;
|
||||
bool split_tex;
|
||||
};
|
||||
|
||||
static_assert(sizeof(stage_param_data_leaf) == 0x5C, "\"stage_param_data_leaf\" struct should have a size of 0x5C");
|
||||
|
||||
struct stage_param_data_litproj {
|
||||
int32_t tex_id;
|
||||
};
|
||||
|
||||
static_assert(sizeof(stage_param_data_litproj) == 0x04, "\"stage_param_data_litproj\" struct should have a size of 0x04");
|
||||
|
||||
struct stage_param_data_rain {
|
||||
int32_t tex_id;
|
||||
int32_t num_rain;
|
||||
vec4 color;
|
||||
vec3 velocity;
|
||||
vec3 vel_range;
|
||||
vec2 psize;
|
||||
vec3 range;
|
||||
vec3 offset;
|
||||
};
|
||||
|
||||
static_assert(sizeof(stage_param_data_rain) == 0x50, "\"stage_param_data_rain\" struct should have a size of 0x50");
|
||||
|
||||
struct stage_param_data_ripple {
|
||||
size_t rain_ripple_num;
|
||||
float_t rain_ripple_min_value;
|
||||
float_t rain_ripple_max_value;
|
||||
float_t ground_y;
|
||||
float_t emit_pos_scale;
|
||||
float_t emit_pos_ofs_x;
|
||||
float_t emit_pos_ofs_z;
|
||||
float_t wake_attn;
|
||||
float_t speed;
|
||||
int32_t ripple_tex_id;
|
||||
bool use_float_ripplemap;
|
||||
float_t rob_emitter_size;
|
||||
vec3* emitter_list;
|
||||
size_t emitter_num;
|
||||
float_t emitter_size;
|
||||
};
|
||||
|
||||
static_assert(sizeof(stage_param_data_ripple) == 0x50, "\"stage_param_data_ripple\" struct should have a size of 0x50");
|
||||
|
||||
struct stage_param_data_snow_colli_ground {
|
||||
float_t min_x;
|
||||
float_t max_x;
|
||||
float_t min_z;
|
||||
float_t max_z;
|
||||
float_t y;
|
||||
};
|
||||
|
||||
static_assert(sizeof(stage_param_data_snow_colli_ground) == 0x14, "\"stage_param_data_snow_colli_ground\" struct should have a size of 0x14");
|
||||
|
||||
struct stage_param_data_snow {
|
||||
int32_t tex_id;
|
||||
int32_t num_snow;
|
||||
int32_t num_snow_gpu;
|
||||
vec4 color;
|
||||
vec3 velocity;
|
||||
vec3 vel_range;
|
||||
vec3 range;
|
||||
vec3 range_gpu;
|
||||
vec3 offset;
|
||||
vec3 offset_gpu;
|
||||
stage_param_data_snow_colli_ground colli_ground;
|
||||
};
|
||||
|
||||
static_assert(sizeof(stage_param_data_snow) == 0x78, "\"stage_param_data_snow\" struct should have a size of 0x78");
|
||||
|
||||
struct stage_param_data_splash {
|
||||
int32_t splash_tex_id;
|
||||
object_info splash_obj_id;
|
||||
float_t particle_size;
|
||||
int32_t emit_num;
|
||||
float_t emission_ratio_attn;
|
||||
float_t emission_velocity_scale;
|
||||
float_t ripple_emission;
|
||||
vec4 color;
|
||||
bool in_water;
|
||||
bool blink;
|
||||
};
|
||||
|
||||
static_assert(sizeof(stage_param_data_splash) == 0x30, "\"stage_param_data_splash\" struct should have a size of 0x30");
|
||||
|
||||
struct stage_param_data_star_utc {
|
||||
int32_t year;
|
||||
int32_t month;
|
||||
int32_t day;
|
||||
int32_t hour;
|
||||
int32_t minute;
|
||||
float_t second;
|
||||
};
|
||||
|
||||
static_assert(sizeof(stage_param_data_star_utc) == 0x18, "\"stage_param_data_star_utc\" struct should have a size of 0x18");
|
||||
|
||||
struct stage_param_data_star_modifiers {
|
||||
float_t color_scale;
|
||||
float_t pos_scale;
|
||||
float_t offset_scale;
|
||||
float_t threshold;
|
||||
float_t size_max;
|
||||
};
|
||||
|
||||
static_assert(sizeof(stage_param_data_star_modifiers) == 0x14, "\"stage_param_data_star_modifiers\" struct should have a size of 0x14");
|
||||
|
||||
struct stage_param_data_star {
|
||||
int32_t tex_id;
|
||||
stage_param_data_star_utc utc;
|
||||
float_t rotation_y_deg;
|
||||
float_t observer_north_latitude_deg;
|
||||
float_t observer_east_longitude_deg;
|
||||
stage_param_data_star_modifiers modifiers[2];
|
||||
};
|
||||
|
||||
static_assert(sizeof(stage_param_data_star) == 0x50, "\"stage_param_data_star\" struct should have a size of 0x50");
|
||||
|
||||
extern stage_param_data_litproj** stage_param_data_litproj_current;
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "texture.hpp"
|
||||
#include "../KKdLib/mat.hpp"
|
||||
#include "../KKdLib/txp.hpp"
|
||||
#include "gl_state.hpp"
|
||||
#include <Helpers.h>
|
||||
|
||||
static void texture_bind(GLenum target, GLuint texture);
|
||||
|
||||
texture* (FASTCALL* _texture_init)(texture_id id)
|
||||
= (texture * (FASTCALL*)(texture_id id))0x000000014069A390;
|
||||
texture* (FASTCALL* _texture_copy)(texture_id id, texture* org_tex)
|
||||
= (texture * (FASTCALL*)(texture_id id, texture * org_tex))0x000000014069B550;
|
||||
texture* (FASTCALL* texture_load_tex_cubemap)(uint32_t id, GLenum internal_format,
|
||||
int32_t width, int32_t height, int32_t max_mipmap_level, void** data_ptr)
|
||||
= (texture * (FASTCALL*)(uint32_t id, GLenum internal_format, int32_t width,
|
||||
int32_t height, int32_t max_mipmap_level, void** data_ptr))0x000000014069B860;
|
||||
texture* (FASTCALL* texture_load_tex_2d)(texture_id id, GLenum internal_format,
|
||||
int32_t width, int32_t height, int32_t max_mipmap_level, void** data_ptr, bool use_high_anisotropy)
|
||||
= (texture * (FASTCALL*)(texture_id id, GLenum internal_format, int32_t width, int32_t height,
|
||||
int32_t max_mipmap_level, void** data_ptr, bool use_high_anisotropy))0x000000014069B8E0;
|
||||
void(FASTCALL* texture_free)(texture* tex)
|
||||
= (void(FASTCALL*)(texture * tex))0x000000014069DA70;
|
||||
int32_t(FASTCALL* texture_info_get_id)(const char* name)
|
||||
= (int32_t(FASTCALL*)(const char* name))0x000000014069CBD0;
|
||||
texture* (FASTCALL* texture_handler_get_texture)(uint32_t id)
|
||||
= (texture * (FASTCALL*)(uint32_t id))0x000000014069CD70;
|
||||
|
||||
void texture_set_params(GLenum target, int32_t max_mipmap_level, bool use_high_anisotropy) {
|
||||
glTexParameteriDLL(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteriDLL(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteriDLL(target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
||||
static const vec4 border_color = 0.0f;
|
||||
glTexParameterfvDLL(target, GL_TEXTURE_BORDER_COLOR, (GLfloat*)&border_color);
|
||||
glTexParameteriDLL(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteriDLL(target, GL_TEXTURE_MIN_FILTER,
|
||||
max_mipmap_level > 0 ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR);
|
||||
glTexParameteriDLL(target, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteriDLL(target, GL_TEXTURE_MAX_LEVEL, max_mipmap_level);
|
||||
|
||||
float_t max_anisotropy;
|
||||
if (use_high_anisotropy)
|
||||
max_anisotropy = 16.0f;
|
||||
else
|
||||
max_anisotropy = 1.0f;
|
||||
glTexParameterfDLL(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, max_anisotropy);
|
||||
}
|
||||
|
||||
void texture_params_get(GLuint tex_0, texture_param* tex_0_param,
|
||||
GLuint tex_1, texture_param* tex_1_param, GLuint tex_2, texture_param* tex_2_param) {
|
||||
gl_state_disable_depth_test();
|
||||
if (tex_0_param) {
|
||||
tex_0_param->width = 0;
|
||||
tex_0_param->height = 0;
|
||||
if (tex_0) {
|
||||
gl_state_bind_texture_2d(tex_0);
|
||||
glGetTexLevelParameterivDLL(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &tex_0_param->width);
|
||||
glGetTexLevelParameterivDLL(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &tex_0_param->height);
|
||||
}
|
||||
}
|
||||
|
||||
if (tex_1_param) {
|
||||
tex_1_param->width = 0;
|
||||
tex_1_param->height = 0;
|
||||
if (tex_1) {
|
||||
gl_state_bind_texture_2d(tex_1);
|
||||
glGetTexLevelParameterivDLL(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &tex_1_param->width);
|
||||
glGetTexLevelParameterivDLL(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &tex_1_param->height);
|
||||
}
|
||||
}
|
||||
|
||||
if (tex_2_param) {
|
||||
tex_2_param->width = 0;
|
||||
tex_2_param->height = 0;
|
||||
if (tex_2) {
|
||||
gl_state_bind_texture_2d(tex_2);
|
||||
glGetTexLevelParameterivDLL(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &tex_2_param->width);
|
||||
glGetTexLevelParameterivDLL(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &tex_2_param->height);
|
||||
}
|
||||
}
|
||||
gl_state_bind_texture_2d(0);
|
||||
|
||||
if (tex_0_param)
|
||||
glViewportDLL(0, 0, tex_0_param->width, tex_0_param->height);
|
||||
}
|
||||
|
||||
void texture_params_restore(texture_param* tex_0_param,
|
||||
texture_param* tex_1_param, texture_param* tex_2_param) {
|
||||
for (int32_t i = 0; i < 4; i++)
|
||||
gl_state_active_bind_texture_2d(i, 0);
|
||||
}
|
||||
|
||||
inline static void texture_bind(GLenum target, GLuint texture) {
|
||||
switch (target) {
|
||||
case GL_TEXTURE_2D:
|
||||
gl_state_bind_texture_2d(texture, true);
|
||||
break;
|
||||
case GL_TEXTURE_CUBE_MAP:
|
||||
gl_state_bind_texture_cube_map(texture, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "../KKdLib/image.hpp"
|
||||
#include "../KKdLib/txp.hpp"
|
||||
#include "wrap.hpp"
|
||||
|
||||
enum texture_flags {
|
||||
TEXTURE_BLOCK_COMPRESSION = 0x01,
|
||||
};
|
||||
|
||||
struct texture_id {
|
||||
uint32_t index : 24;
|
||||
uint32_t id : 8;
|
||||
|
||||
inline texture_id() {
|
||||
id = 0;
|
||||
index = 0;
|
||||
}
|
||||
|
||||
inline texture_id(uint8_t id, uint32_t index) {
|
||||
this->id = id;
|
||||
this->index = index;
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator >(const texture_id& left, const texture_id& right) {
|
||||
return left.id > right.id && left.index > right.index;
|
||||
}
|
||||
|
||||
inline bool operator <(const texture_id& left, const texture_id& right) {
|
||||
return left.id < right.id && left.index < right.index;
|
||||
}
|
||||
|
||||
inline bool operator >=(const texture_id& left, const texture_id& right) {
|
||||
return left.id >= right.id && left.index >= right.index;
|
||||
}
|
||||
|
||||
inline bool operator <=(const texture_id& left, const texture_id& right) {
|
||||
return left.id <= right.id && left.index <= right.index;
|
||||
}
|
||||
|
||||
inline bool operator ==(const texture_id& left, const texture_id& right) {
|
||||
return left.id == right.id && left.index == right.index;
|
||||
}
|
||||
|
||||
inline bool operator !=(const texture_id& left, const texture_id& right) {
|
||||
return left.id != right.id || left.index != right.index;
|
||||
}
|
||||
|
||||
static_assert(sizeof(texture_id) == 0x04, "\"texture_id\" struct should have a size of 0x04");
|
||||
|
||||
struct texture {
|
||||
int32_t init_count;
|
||||
texture_id id;
|
||||
texture_flags flags;
|
||||
int16_t width;
|
||||
int16_t height;
|
||||
GLuint tex;
|
||||
GLenum target;
|
||||
GLenum internal_format;
|
||||
int32_t max_mipmap_level;
|
||||
int32_t size;
|
||||
};
|
||||
|
||||
static_assert(sizeof(texture) == 0x24, "\"texture\" struct should have a size of 0x24");
|
||||
|
||||
struct texture_param {
|
||||
GLint width;
|
||||
GLint height;
|
||||
};
|
||||
|
||||
static_assert(sizeof(texture_param) == 0x08, "\"texture_param\" struct should have a size of 0x08");
|
||||
|
||||
extern texture* (FASTCALL* texture_init)(texture_id id);
|
||||
extern texture* (FASTCALL* texture_copy)(texture_id id, texture* org_tex);
|
||||
extern texture* (FASTCALL* texture_load_tex_cubemap)(uint32_t id, GLenum internal_format,
|
||||
int32_t width, int32_t height, int32_t max_mipmap_level, void** data_ptr);
|
||||
extern texture* (FASTCALL* texture_load_tex_2d)(texture_id id, GLenum internal_format,
|
||||
int32_t width, int32_t height, int32_t max_mipmap_level, void** data_ptr, bool use_high_anisotropy);
|
||||
extern void(FASTCALL* texture_free)(texture* tex);
|
||||
extern int32_t(FASTCALL* texture_info_get_id)(const char* name);
|
||||
extern texture* (FASTCALL* texture_handler_get_texture)(uint32_t id);
|
||||
|
||||
extern void texture_set_params(GLenum target, int32_t max_mipmap_level, bool use_high_anisotropy);
|
||||
|
||||
extern void texture_params_get(GLuint tex_0 = 0, texture_param* tex_0_param = 0,
|
||||
GLuint tex_1 = 0, texture_param* tex_1_param = 0, GLuint tex_2 = 0, texture_param* tex_2_param = 0);
|
||||
extern void texture_params_restore(texture_param* tex_0_param = 0,
|
||||
texture_param* tex_1_param = 0, texture_param* tex_2_param = 0);
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
|
||||
Original: Allocator.h, Types.h by blueskythlikesclouds from DivaModLoader
|
||||
*/
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef enum HeapCMallocType {
|
||||
HeapCMallocSystem = 0x00,
|
||||
HeapCMallocTemp = 0x01,
|
||||
HeapCMallocMode = 0x02,
|
||||
HeapCMallocEvent = 0x03,
|
||||
HeapCMallocDebug = 0x04,
|
||||
HeapCMallocMax = 0x05,
|
||||
} HeapCMallocType;
|
||||
|
||||
static void* (*HeapCMallocAllocate)(HeapCMallocType type, size_t size, const char* name)
|
||||
= (void* (*)(HeapCMallocType, size_t, const char*))0x00000001403F2A00;
|
||||
static void(*HeapCMallocFree)(HeapCMallocType type, void* data)
|
||||
= (void(*)(HeapCMallocType, void*))0x00000001403F2960;
|
||||
static void* (*_operator_new)(size_t) = (void* (*)(size_t))0x000000014084530C;
|
||||
static void(*_operator_delete)(void*) = (void(*)(void*))0x0000000140845378;
|
||||
|
||||
template <class T>
|
||||
class Allocator {
|
||||
public:
|
||||
using value_type = T;
|
||||
|
||||
Allocator() noexcept {}
|
||||
template <class U> Allocator(Allocator<U> const&) noexcept {}
|
||||
|
||||
value_type* allocate(std::size_t n) {
|
||||
return reinterpret_cast<value_type*>(_operator_new(n * sizeof(value_type)));
|
||||
}
|
||||
|
||||
void deallocate(value_type* p, std::size_t) noexcept {
|
||||
_operator_delete(reinterpret_cast<void*>(p));
|
||||
}
|
||||
};
|
||||
|
||||
template <class T, class U>
|
||||
bool operator==(Allocator<T> const&, Allocator<U> const&) noexcept {
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class T, class U>
|
||||
bool operator!=(Allocator<T> const& x, Allocator<U> const& y) noexcept {
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
namespace prj {
|
||||
using string = std::basic_string<char, std::char_traits<char>, Allocator<char>>;
|
||||
|
||||
template<typename T>
|
||||
using vector = std::vector<T, Allocator<T>>;
|
||||
|
||||
template<typename T>
|
||||
using list = std::list<T, Allocator<T>>;
|
||||
|
||||
template<typename T, typename U>
|
||||
using map = std::map<T, U, Allocator<std::pair<T, U>>>;
|
||||
|
||||
template<typename T, typename U>
|
||||
using pair = std::pair<T, U>;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "uniform.hpp"
|
||||
|
||||
uniform_value* uniform = (uniform_value*)0x000000014CC57AF0;
|
||||
|
||||
void(FASTCALL* uniform_value_reset)() = (void(FASTCALL*)())0x0000000140443400;
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
|
||||
enum uniform_name {
|
||||
U_NONE = 0x00,
|
||||
U_ALPHA_MASK = 0x01,
|
||||
U_ALPHA_TEST = 0x02,
|
||||
U_ANISO = 0x03,
|
||||
U_AET_BACK = 0x04,
|
||||
U_TEXTURE_BLEND = 0x05,
|
||||
U_CHARA_COLOR = 0x06,
|
||||
U_CLIP_PLANE = 0x07,
|
||||
U08 = 0x08,
|
||||
U_DEPTH_PEEL = 0x09,
|
||||
U0A = 0x0A,
|
||||
U0B = 0x0B,
|
||||
U_ALPHA_BLEND = 0x0C,
|
||||
U_RIPPLE_EMIT = 0x0D,
|
||||
U_ESM_FILTER = 0x0E,
|
||||
U_EXPOSURE = 0x0F,
|
||||
U_SCENE_FADE = 0x10,
|
||||
U_FADE = 0x11,
|
||||
U12 = 0x12,
|
||||
U_FLARE = 0x13,
|
||||
U_FOG_HEIGHT = 0x14,
|
||||
U_FOG = 0x15,
|
||||
U16 = 0x16,
|
||||
U_GAUSS = 0x17,
|
||||
U18 = 0x18,
|
||||
U_IMAGE_FILTER = 0x19,
|
||||
U_INSTANCE = 0x1A,
|
||||
U_TONE_CURVE = 0x1B,
|
||||
U_LIGHT_PROJ = 0x1C,
|
||||
U_MAGNIFY = 0x1D,
|
||||
U_MEMBRANE = 0x1E,
|
||||
U_MLAA = 0x1F,
|
||||
U_MLAA_SEARCH = 0x20,
|
||||
U_MORPH_COLOR = 0x21,
|
||||
U_MORPH = 0x22,
|
||||
U_MOVIE = 0x23,
|
||||
U24 = 0x24,
|
||||
U25 = 0x25,
|
||||
U26 = 0x26,
|
||||
U_NPR = 0x27,
|
||||
U_LIGHT_1 = 0x28,
|
||||
U_REFLECT = 0x29,
|
||||
U_REDUCE = 0x2A,
|
||||
U_SELF_SHADOW = 0x2B,
|
||||
U_SHADOW = 0x2C,
|
||||
U2D = 0x2D,
|
||||
U2E = 0x2E,
|
||||
U_SHOW_VECTOR = 0x2F,
|
||||
U_BONE_MAT = 0x30,
|
||||
U_SNOW_PARTICLE = 0x31,
|
||||
U_SPECULAR_IBL = 0x32,
|
||||
U_COMBINER = 0x33,
|
||||
U_TEX_0_TYPE = 0x34,
|
||||
U_TEX_1_TYPE = 0x35,
|
||||
U_SSS_FILTER = 0x36,
|
||||
U37 = 0x37,
|
||||
U_STAR = 0x38,
|
||||
U_TEXTURE_COUNT = 0x39,
|
||||
U_ENV_MAP = 0x3A,
|
||||
U_RIPPLE = 0x3B,
|
||||
U_TRANSLUCENCY = 0x3C,
|
||||
U_NORMAL = 0x3D,
|
||||
U_TRANSPARENCY = 0x3E,
|
||||
U_WATER_REFLECT = 0x3F,
|
||||
U40 = 0x40,
|
||||
U41 = 0x41,
|
||||
U_LIGHT_0 = 0x42,
|
||||
U_SPECULAR = 0x43,
|
||||
U_TONE_MAP = 0x44,
|
||||
U45 = 0x45,
|
||||
U_MAX = 0x46,
|
||||
U_INVALID = 0xFFFFFFFF,
|
||||
};
|
||||
|
||||
struct uniform_value {
|
||||
int32_t arr[U_MAX];
|
||||
};
|
||||
|
||||
extern uniform_value* uniform;
|
||||
|
||||
extern void(FASTCALL* uniform_value_reset)();
|
||||
+2580
File diff suppressed because it is too large
Load Diff
+3432
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,52 @@
|
||||
SigScan.hpp combined from DivaModLoader's Source/DivaModLoader/SigScan.h and Source/DivaModLoader/SigScan.cpp
|
||||
Dependencies/Helpers.h from DivaModLoader
|
||||
|
||||
# MIT License
|
||||
|
||||
Copyright (c) 2022 Skyth
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
- The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Detours
|
||||
|
||||
# Copyright (c) Microsoft Corporation
|
||||
|
||||
All rights reserved.
|
||||
|
||||
# MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
Reference in New Issue
Block a user