Before moving boneSelector from unsigned complete

- boneSelector being unsigned might be the reason why gles is having a hard time. Just stashing this commit here as a bookmark in case I need it
This commit is contained in:
Shiny Metagross 2022-09-13 11:46:05 -07:00 committed by Christoph Oelckers
commit ee7c467a17
5 changed files with 96 additions and 10 deletions

View file

@ -32,6 +32,7 @@
#include "gles_shader.h"
#include "gles_renderer.h"
#include "hw_lightbuffer.h"
#include "hw_bonebuffer.h"
#include "gles_renderbuffers.h"
#include "gles_hwtexture.h"
#include "gles_buffers.h"
@ -251,6 +252,7 @@ bool FGLRenderState::ApplyShader()
activeShader->cur->muTimer.Set((double)(screen->FrameTime - firstFrame) * (double)mShaderTimer / 1000.);
activeShader->cur->muAlphaThreshold.Set(mAlphaThreshold);
activeShader->cur->muClipSplit.Set(mClipSplit);
activeShader->cur->muBoneIndexBase.Set(-1);
activeShader->cur->muSpecularMaterial.Set(mGlossiness, mSpecularLevel);
activeShader->cur->muAddColor.Set(mStreamData.uAddColor);
activeShader->cur->muTextureAddColor.Set(mStreamData.uTextureAddColor);
@ -349,6 +351,9 @@ bool FGLRenderState::ApplyShader()
activeShader->cur->muLightRange.Set(range);
}
int index = mBoneIndexBase;
activeShader->cur->muBoneIndexBase.Set(index);
return true;
}

View file

@ -66,6 +66,7 @@ class FGLRenderState final : public FRenderState
int lastTranslation = 0;
int maxBoundMaterial = -1;
size_t mLastMappedLightIndex = SIZE_MAX;
size_t mLastMappedBoneIndexBase = SIZE_MAX;
IVertexBuffer *mCurrentVertexBuffer;
int mCurrentVertexOffsets[2]; // one per binding point

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"
@ -321,6 +322,12 @@ bool FShader::Load(const char * name, const char * vert_prog_lump_, const char *
// dynamic lights
uniform ivec4 uLightRange;
// bone animation
uniform int uBoneIndexBase;
// bone matrix buffers
uniform mat4 bones[NUM_UBO_BONES];
// Blinn glossiness and specular level
uniform vec2 uSpecularMaterial;
@ -391,10 +398,11 @@ bool FShader::Load(const char * name, const char * vert_prog_lump_, const char *
FString vp_comb;
assert(screen->mLights != NULL);
assert(screen->mBones != NULL);
unsigned int lightbuffersize = screen->mLights->GetBlockSize();
vp_comb.Format("#version 100\n#define NUM_UBO_LIGHTS %d\n#define NO_CLIPDISTANCE_SUPPORT\n", lightbuffersize);
vp_comb.Format("#version 100\n#define NUM_UBO_LIGHTS %d\n#define NO_CLIPDISTANCE_SUPPORT\n#define NUM_UBO_BONES %d\n", lightbuffersize, screen->mBones->GetBlockSize());
FString fp_comb = vp_comb;
vp_comb << defines << i_data.GetChars();
@ -529,6 +537,8 @@ bool FShader::Load(const char * name, const char * vert_prog_lump_, const char *
glBindAttribLocation(shaderData->hShader, VATTR_VERTEX2, "aVertex2");
glBindAttribLocation(shaderData->hShader, VATTR_NORMAL, "aNormal");
glBindAttribLocation(shaderData->hShader, VATTR_NORMAL2, "aNormal2");
glBindAttribLocation(shaderData->hShader, VATTR_BONEWEIGHT, "aBoneWeight");
glBindAttribLocation(shaderData->hShader, VATTR_BONESELECTOR, "aBoneSelector");
glLinkProgram(shaderData->hShader);
@ -591,6 +601,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump_, const char *
shaderData->muLightParms.Init(shaderData->hShader, "uLightAttr");
shaderData->muClipSplit.Init(shaderData->hShader, "uClipSplit");
shaderData->muLightRange.Init(shaderData->hShader, "uLightRange");
shaderData->muBoneIndexBase.Init(shaderData->hShader, "uBoneIndexBase");
shaderData->muFogColor.Init(shaderData->hShader, "uFogColor");
shaderData->muDynLightColor.Init(shaderData->hShader, "uDynLightColor");
shaderData->muObjectColor.Init(shaderData->hShader, "uObjectColor");

View file

@ -327,6 +327,7 @@ public: class ShaderVariantData
FBufferedUniform4f muLightParms;
FBufferedUniform2f muClipSplit;
FBufferedUniform4i muLightRange;
FBufferedUniform1i muBoneIndexBase;
FBufferedUniformPE muFogColor;
FBufferedUniform4f muDynLightColor;
FBufferedUniformPE muObjectColor;