implement actor uniforms

This commit is contained in:
Ricardo Luís Vaz Silva 2025-01-10 19:55:10 -03:00 committed by Magnus Norddahl
commit fcf4c9d07e
5 changed files with 177 additions and 0 deletions

View file

@ -137,6 +137,17 @@ void FHWModelRenderer::SetInterpolation(double inter)
void FHWModelRenderer::SetMaterial(FGameTexture *skin, bool clampNoFilter, FTranslationID translation, AActor * act)
{
state.SetMaterial(skin, UF_Skin, 0, clampNoFilter ? CLAMP_NOFILTER : CLAMP_NONE, translation, -1, act ? act->GetClass() : nullptr);
int shader = state.getShaderIndex();
if(shader >= FIRST_USER_SHADER && act && (act != lastAct || shader != lastShader))
{ // only re-bind uniforms if the actor or the shader have changed
usershaders[shader - FIRST_USER_SHADER].BindActorFields(act);
}
lastAct = act;
lastShader = shader;
state.SetLightIndex(modellightindex);
}

View file

@ -42,6 +42,9 @@ class FHWModelRenderer : public FModelRenderer
int boneIndexBase = -1;
HWDrawInfo *di;
FRenderState &state;
AActor * lastAct = nullptr;
int lastShader = 0;
public:
FHWModelRenderer(HWDrawInfo *d, FRenderState &st, int mli) : modellightindex(mli), di(d), state(st)
{}

View file

@ -241,6 +241,16 @@ void HWSprite::DrawSprite(HWDrawInfo *di, FRenderState &state, bool translucent)
if (texture) state.SetMaterial(texture, UF_Sprite, (spritetype == RF_FACESPRITE) ? CTF_Expand : 0, clampmode, translation, OverrideShader, actor ? actor->GetClass() : nullptr);
else if (!modelframe) state.EnableTexture(false);
if (actor && texture)
{
int binding = state.getShaderIndex();
if(binding >= FIRST_USER_SHADER)
{
usershaders[binding - FIRST_USER_SHADER].BindActorFields(actor);
}
}
//SetColor(lightlevel, rel, Colormap, trans);
unsigned int iter = lightlist ? lightlist->Size() : 1;