IQM Support Implemented

More info to come
This commit is contained in:
Shiny Metagross 2022-08-12 13:17:08 -07:00 committed by Christoph Oelckers
commit 08f520f1c6
49 changed files with 1356 additions and 62 deletions

View file

@ -38,6 +38,7 @@
#include "shaderuniforms.h"
#include "hw_viewpointuniforms.h"
#include "hw_lightbuffer.h"
#include "hw_bonebuffer.h"
#include "i_specialpaths.h"
#include "printf.h"
#include "version.h"
@ -276,6 +277,9 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
// dynamic lights
uniform int uLightIndex;
// bone animation
uniform int uBoneIndexBase;
// Blinn glossiness and specular level
uniform vec2 uSpecularMaterial;
@ -297,6 +301,19 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
};
#endif
// bone matrix buffers
#ifdef SHADER_STORAGE_BONES
layout(std430, binding = 7) buffer BoneBufferSSO
{
mat4 bones[];
};
#elif defined NUM_UBO_BONES
uniform BoneBufferUBO
{
mat4 bones[NUM_UBO_BONES];
};
#endif
// textures
uniform sampler2D tex;
uniform sampler2D ShadowMap;
@ -369,20 +386,21 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
FString vp_comb;
assert(screen->mLights != NULL);
assert(screen->mBones != NULL);
bool lightbuffertype = screen->mLights->GetBufferType();
unsigned int lightbuffersize = screen->mLights->GetBlockSize();
if (!lightbuffertype)
{
vp_comb.Format("#version 330 core\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize);
vp_comb.Format("#version 330 core\n#define NUM_UBO_LIGHTS %d\n#define NUM_UBO_BONES %d\n", lightbuffersize, screen->mBones->GetBlockSize());
}
else
{
// This differentiation is for Intel which do not seem to expose the full extension, even if marked as required.
if (gl.glslversion < 4.3f)
vp_comb = "#version 400 core\n#extension GL_ARB_shader_storage_buffer_object : require\n#define SHADER_STORAGE_LIGHTS\n";
vp_comb = "#version 400 core\n#extension GL_ARB_shader_storage_buffer_object : require\n#define SHADER_STORAGE_LIGHTS\n#define SHADER_STORAGE_BONES\n";
else
vp_comb = "#version 430 core\n#define SHADER_STORAGE_LIGHTS\n";
vp_comb = "#version 430 core\n#define SHADER_STORAGE_LIGHTS\n#define SHADER_STORAGE_BONES\n";
}
if ((gl.flags & RFL_SHADER_STORAGE_BUFFER) && screen->allowSSBO())
@ -576,6 +594,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
muLightParms.Init(hShader, "uLightAttr");
muClipSplit.Init(hShader, "uClipSplit");
muLightIndex.Init(hShader, "uLightIndex");
muBoneIndexBase.Init(hShader, "uBoneIndexBase");
muFogColor.Init(hShader, "uFogColor");
muDynLightColor.Init(hShader, "uDynLightColor");
muObjectColor.Init(hShader, "uObjectColor");
@ -610,6 +629,9 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
{
int tempindex = glGetUniformBlockIndex(hShader, "LightBufferUBO");
if (tempindex != -1) glUniformBlockBinding(hShader, tempindex, LIGHTBUF_BINDINGPOINT);
tempindex = glGetUniformBlockIndex(hShader, "BoneBufferUBO");
if (tempindex != -1) glUniformBlockBinding(hShader, tempindex, BONEBUF_BINDINGPOINT);
}
int tempindex = glGetUniformBlockIndex(hShader, "ViewpointUBO");
if (tempindex != -1) glUniformBlockBinding(hShader, tempindex, VIEWPOINT_BINDINGPOINT);