Change the matrix interface on RenderState so the backend doesn't have to try detect changes on each Apply
Include the texture matrix in the mesh builder
This commit is contained in:
parent
96ac7ba3f0
commit
eba0bee9f6
17 changed files with 126 additions and 136 deletions
|
|
@ -73,14 +73,15 @@ void FHWModelRenderer::BeginDrawModel(FRenderStyle style, FSpriteModelFrame *smf
|
|||
state.SetCulling((mirrored ^ portalState.isMirrored()) ? Cull_CCW : Cull_CW);
|
||||
}
|
||||
|
||||
state.mModelMatrix = objectToWorldMatrix;
|
||||
state.EnableModelMatrix(true);
|
||||
VSMatrix normalModelMatrix;
|
||||
normalModelMatrix.computeNormalMatrix(objectToWorldMatrix);
|
||||
state.SetModelMatrix(objectToWorldMatrix, normalModelMatrix);
|
||||
}
|
||||
|
||||
void FHWModelRenderer::EndDrawModel(FRenderStyle style, FSpriteModelFrame *smf)
|
||||
{
|
||||
state.SetBoneIndexBase(-1);
|
||||
state.EnableModelMatrix(false);
|
||||
state.SetModelMatrix(VSMatrix::identity(), VSMatrix::identity());
|
||||
state.SetDepthFunc(DF_Less);
|
||||
if (!(style == DefaultRenderStyle()) && !(smf->flags & MDL_DONTCULLBACKFACES))
|
||||
state.SetCulling(Cull_None);
|
||||
|
|
@ -106,14 +107,15 @@ void FHWModelRenderer::BeginDrawHUDModel(FRenderStyle style, const VSMatrix &obj
|
|||
state.SetCulling((mirrored ^ portalState.isMirrored()) ? Cull_CW : Cull_CCW);
|
||||
}
|
||||
|
||||
state.mModelMatrix = objectToWorldMatrix;
|
||||
state.EnableModelMatrix(true);
|
||||
VSMatrix normalModelMatrix;
|
||||
normalModelMatrix.computeNormalMatrix(objectToWorldMatrix);
|
||||
state.SetModelMatrix(objectToWorldMatrix, normalModelMatrix);
|
||||
}
|
||||
|
||||
void FHWModelRenderer::EndDrawHUDModel(FRenderStyle style)
|
||||
{
|
||||
state.SetBoneIndexBase(-1);
|
||||
state.EnableModelMatrix(false);
|
||||
state.SetModelMatrix(VSMatrix::identity(), VSMatrix::identity());
|
||||
|
||||
state.SetDepthFunc(DF_Less);
|
||||
if (!(style == DefaultRenderStyle()))
|
||||
|
|
|
|||
|
|
@ -432,7 +432,6 @@ inline float Dist2(float x1,float y1,float x2,float y2)
|
|||
return sqrtf((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
|
||||
}
|
||||
|
||||
bool hw_SetPlaneTextureRotation(const HWSectorPlane * secplane, FGameTexture * gltexture, VSMatrix &mat);
|
||||
void hw_GetDynModelLight(AActor *self, FDynLightData &modellightdata);
|
||||
|
||||
extern const float LARGE_VALUE;
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ CVAR(Int, gl_breaksec, -1, 0)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
bool hw_SetPlaneTextureRotation(const HWSectorPlane * secplane, FGameTexture * gltexture, VSMatrix &dest)
|
||||
bool SetPlaneTextureRotation(FRenderState& state, HWSectorPlane* secplane, FGameTexture* gltexture)
|
||||
{
|
||||
// only manipulate the texture matrix if needed.
|
||||
if (!secplane->Offs.isZero() ||
|
||||
|
|
@ -80,24 +80,18 @@ bool hw_SetPlaneTextureRotation(const HWSectorPlane * secplane, FGameTexture * g
|
|||
float xscale2 = 64.f / gltexture->GetDisplayWidth();
|
||||
float yscale2 = 64.f / gltexture->GetDisplayHeight();
|
||||
|
||||
dest.loadIdentity();
|
||||
dest.scale(xscale1, yscale1, 1.0f);
|
||||
dest.translate(uoffs, voffs, 0.0f);
|
||||
dest.scale(xscale2, yscale2, 1.0f);
|
||||
dest.rotate(angle, 0.0f, 0.0f, 1.0f);
|
||||
VSMatrix mat;
|
||||
mat.loadIdentity();
|
||||
mat.scale(xscale1, yscale1, 1.0f);
|
||||
mat.translate(uoffs, voffs, 0.0f);
|
||||
mat.scale(xscale2, yscale2, 1.0f);
|
||||
mat.rotate(angle, 0.0f, 0.0f, 1.0f);
|
||||
state.SetTextureMatrix(mat);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SetPlaneTextureRotation(FRenderState &state, HWSectorPlane* plane, FGameTexture* texture)
|
||||
{
|
||||
if (hw_SetPlaneTextureRotation(plane, texture, state.mTextureMatrix))
|
||||
{
|
||||
state.EnableTextureMatrix(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==========================================================================
|
||||
|
|
@ -334,9 +328,10 @@ void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent)
|
|||
if (sector->special != GLSector_Skybox)
|
||||
{
|
||||
state.SetMaterial(texture, UF_Texture, 0, CLAMP_NONE, 0, -1);
|
||||
SetPlaneTextureRotation(state, &plane, texture);
|
||||
bool texmatrix = SetPlaneTextureRotation(state, &plane, texture);
|
||||
DrawSubsectors(di, state);
|
||||
state.EnableTextureMatrix(false);
|
||||
if (texmatrix)
|
||||
state.SetTextureMatrix(VSMatrix::identity());
|
||||
}
|
||||
else if (!hacktype)
|
||||
{
|
||||
|
|
@ -362,9 +357,10 @@ void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent)
|
|||
if (!texture->GetTranslucency()) state.AlphaFunc(Alpha_GEqual, gl_mask_threshold);
|
||||
else state.AlphaFunc(Alpha_GEqual, 0.f);
|
||||
state.SetMaterial(texture, UF_Texture, 0, CLAMP_NONE, 0, -1);
|
||||
SetPlaneTextureRotation(state, &plane, texture);
|
||||
bool texmatrix = SetPlaneTextureRotation(state, &plane, texture);
|
||||
DrawSubsectors(di, state);
|
||||
state.EnableTextureMatrix(false);
|
||||
if (texmatrix)
|
||||
state.SetTextureMatrix(VSMatrix::identity());
|
||||
}
|
||||
state.SetRenderStyle(DefaultRenderStyle());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
EXTERN_CVAR(Int, r_mirror_recursions)
|
||||
EXTERN_CVAR(Bool, gl_portals)
|
||||
|
||||
void SetPlaneTextureRotation(FRenderState& state, HWSectorPlane* plane, FGameTexture* texture);
|
||||
bool SetPlaneTextureRotation(FRenderState& state, HWSectorPlane* plane, FGameTexture* texture);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
|
|
@ -986,18 +986,19 @@ void HWHorizonPortal::DrawContents(HWDrawInfo *di, FRenderState &state)
|
|||
state.EnableBrightmap(true);
|
||||
state.SetMaterial(texture, UF_Texture, 0, CLAMP_NONE, 0, -1);
|
||||
state.SetObjectColor(origin->specialcolor);
|
||||
|
||||
SetPlaneTextureRotation(state, sp, texture);
|
||||
state.AlphaFunc(Alpha_GEqual, 0.f);
|
||||
state.SetRenderStyle(STYLE_Source);
|
||||
|
||||
bool texmatrix = SetPlaneTextureRotation(state, sp, texture);
|
||||
|
||||
for (unsigned i = 0; i < vcount; i += 4)
|
||||
{
|
||||
state.Draw(DT_TriangleStrip, voffset + i, 4, true);// i == 0);
|
||||
}
|
||||
state.Draw(DT_TriangleStrip, voffset + vcount, 10, false);
|
||||
|
||||
state.EnableTextureMatrix(false);
|
||||
if (texmatrix)
|
||||
state.SetTextureMatrix(VSMatrix::identity());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -122,9 +122,6 @@ void HWWall::RenderMirrorSurface(HWDrawInfo *di, FRenderState &state)
|
|||
|
||||
state.SetDepthFunc(DF_LEqual);
|
||||
|
||||
// we use texture coordinates and texture matrix to pass the normal stuff to the shader so that the default vertex buffer format can be used as is.
|
||||
state.EnableTextureMatrix(true);
|
||||
|
||||
// Use sphere mapping for this
|
||||
state.SetEffect(EFF_SPHEREMAP);
|
||||
di->SetColor(state, lightlevel, 0, di->isFullbrightScene(), Colormap, 0.1f);
|
||||
|
|
@ -138,7 +135,7 @@ void HWWall::RenderMirrorSurface(HWDrawInfo *di, FRenderState &state)
|
|||
flags &= ~HWWall::HWF_GLOW;
|
||||
RenderWall(di, state, HWWall::RWF_BLANK);
|
||||
|
||||
state.EnableTextureMatrix(false);
|
||||
state.SetTextureMatrix(VSMatrix::identity());
|
||||
state.SetEffect(EFF_NONE);
|
||||
state.AlphaFunc(Alpha_GEqual, gl_mask_sprite_threshold);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue