mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-29 07:22:07 +00:00
- changed model lighting setup to be done in the processing pass.
This eliminates the different code paths for GL3 and GL4.5.
This commit is contained in:
parent
fbbf2f8346
commit
ecb1578a7a
3 changed files with 24 additions and 67 deletions
|
@ -261,6 +261,7 @@ void GLSceneDrawer::CreateScene()
|
|||
gl_drawinfo->mShadowMap = &GLRenderer->mShadowMap;
|
||||
|
||||
RenderBSPNode (level.HeadNode());
|
||||
// Process all the sprites on the current portal's back side which touch the portal.
|
||||
if (GLRenderer->mCurrentPortal != NULL) GLRenderer->mCurrentPortal->RenderAttached();
|
||||
Bsp.Unclock();
|
||||
|
||||
|
@ -271,6 +272,7 @@ void GLSceneDrawer::CreateScene()
|
|||
gl_drawinfo->HandleMissingTextures(in_area); // Missing upper/lower textures
|
||||
gl_drawinfo->HandleHackedSubsectors(); // open sector hacks for deep water
|
||||
gl_drawinfo->ProcessSectorStacks(in_area); // merge visplanes of sector stacks
|
||||
SetupWeaponLight();
|
||||
GLRenderer->mLights->Finish();
|
||||
GLRenderer->mVBO->Unmap();
|
||||
|
||||
|
@ -317,8 +319,6 @@ void GLSceneDrawer::RenderScene(int recursion)
|
|||
gl_drawinfo->drawlists[GLDL_MASKEDFLATS].DrawFlats(gl_drawinfo, GLPASS_LIGHTSONLY);
|
||||
gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].Draw(gl_drawinfo, GLPASS_LIGHTSONLY);
|
||||
gl_drawinfo->drawlists[GLDL_TRANSLUCENT].Draw(gl_drawinfo, GLPASS_LIGHTSONLY, true);
|
||||
gl_drawinfo->drawlists[GLDL_MODELS].Draw(gl_drawinfo, GLPASS_LIGHTSONLY);
|
||||
SetupWeaponLight();
|
||||
GLRenderer->mLights->Finish();
|
||||
}
|
||||
|
||||
|
|
|
@ -64,36 +64,6 @@ void gl_SetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblend
|
|||
gl_RenderState.SetTextureMode(tm);
|
||||
}
|
||||
|
||||
int gl_SetDynModelLight(AActor *self, int dynlightindex)
|
||||
{
|
||||
if (gl.legacyMode)
|
||||
{
|
||||
float out[3];
|
||||
gl_drawinfo->GetDynSpriteLight(self, nullptr, out);
|
||||
gl_RenderState.SetDynLight(out[0], out[1], out[2]);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// For deferred light mode this function gets called twice. First time for list upload, and second for draw.
|
||||
if (gl.lightmethod == LM_DEFERRED && dynlightindex != -1)
|
||||
{
|
||||
gl_RenderState.SetDynLight(0, 0, 0);
|
||||
return dynlightindex;
|
||||
}
|
||||
hw_GetDynModelLight(self, lightdata);
|
||||
|
||||
dynlightindex = GLRenderer->mLights->UploadLights(lightdata);
|
||||
|
||||
if (gl.lightmethod != LM_DEFERRED)
|
||||
{
|
||||
gl_RenderState.SetDynLight(0, 0, 0);
|
||||
}
|
||||
return dynlightindex;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
@ -102,26 +72,9 @@ int gl_SetDynModelLight(AActor *self, int dynlightindex)
|
|||
|
||||
void FDrawInfo::DrawSprite(GLSprite *sprite, int pass)
|
||||
{
|
||||
if (pass == GLPASS_DECALS) return;
|
||||
if (pass == GLPASS_DECALS || pass == GLPASS_LIGHTSONLY) return;
|
||||
|
||||
auto RenderStyle = sprite->RenderStyle;
|
||||
if (pass == GLPASS_LIGHTSONLY)
|
||||
{
|
||||
if (sprite->modelframe)
|
||||
{
|
||||
if (RenderStyle.BlendOp != STYLEOP_Shadow)
|
||||
{
|
||||
if (gl_lights && GLRenderer->mLightCount && mDrawer->FixedColormap == CM_DEFAULT && !sprite->fullbright)
|
||||
{
|
||||
if (!sprite->particle)
|
||||
{
|
||||
sprite->dynlightindex = gl_SetDynModelLight(gl_light_sprites ? sprite->actor : nullptr, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
bool additivefog = false;
|
||||
bool foglayer = false;
|
||||
|
@ -193,9 +146,7 @@ void FDrawInfo::DrawSprite(GLSprite *sprite, int pass)
|
|||
{
|
||||
if (gl_lights && GLRenderer->mLightCount && mDrawer->FixedColormap == CM_DEFAULT && !sprite->fullbright)
|
||||
{
|
||||
if (sprite->modelframe && !sprite->particle)
|
||||
sprite->dynlightindex = gl_SetDynModelLight(gl_light_sprites ? sprite->actor : nullptr, sprite->dynlightindex);
|
||||
else
|
||||
if ( sprite->dynlightindex == -1) // only set if we got no light buffer index. This covers all cases where sprite lighting is used.
|
||||
{
|
||||
float out[3];
|
||||
GetDynSpriteLight(gl_light_sprites ? sprite->actor : nullptr, gl_light_particles ? sprite->particle : nullptr, out);
|
||||
|
@ -375,7 +326,16 @@ void FDrawInfo::AddSprite(GLSprite *sprite, bool translucent)
|
|||
{
|
||||
list = GLDL_MODELS;
|
||||
}
|
||||
sprite->dynlightindex = -1;
|
||||
|
||||
// That's a lot of checks...
|
||||
if (sprite->modelframe && sprite->RenderStyle.BlendOp != STYLEOP_Shadow && gl_lights && gl_light_sprites && GLRenderer->mLightCount && mDrawer->FixedColormap == CM_DEFAULT && !sprite->fullbright && !gl.legacyMode)
|
||||
{
|
||||
hw_GetDynModelLight(sprite->actor, lightdata);
|
||||
sprite->dynlightindex = GLRenderer->mLights->UploadLights(lightdata);
|
||||
}
|
||||
else
|
||||
sprite->dynlightindex = -1;
|
||||
|
||||
auto newsprt = gl_drawinfo->drawlists[list].NewSprite();
|
||||
*newsprt = *sprite;
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ void GLSceneDrawer::SetupWeaponLight()
|
|||
AActor * playermo = players[consoleplayer].camera;
|
||||
player_t * player = playermo->player;
|
||||
|
||||
// this is the same as in DrawPlayerSprites below
|
||||
// this is the same as in DrawPlayerSprites below (i.e. no weapon being drawn.)
|
||||
if (!player ||
|
||||
!r_drawplayersprites ||
|
||||
!camera->player ||
|
||||
|
@ -98,18 +98,19 @@ void GLSceneDrawer::SetupWeaponLight()
|
|||
(r_deathcamera && camera->health <= 0))
|
||||
return;
|
||||
|
||||
// Check if lighting can be used on this item.
|
||||
if (camera->RenderStyle.BlendOp == STYLEOP_Shadow || !gl_lights || !gl_light_sprites || !GLRenderer->mLightCount || FixedColormap != CM_DEFAULT || gl.legacyMode)
|
||||
return;
|
||||
|
||||
for (DPSprite *psp = player->psprites; psp != nullptr && psp->GetID() < PSP_TARGETCENTER; psp = psp->GetNext())
|
||||
{
|
||||
if (psp->GetState() != nullptr)
|
||||
{
|
||||
// set the lighting parameters
|
||||
if (gl_lights && GLRenderer->mLightCount && FixedColormap == CM_DEFAULT && gl_light_sprites)
|
||||
FSpriteModelFrame *smf = playermo->player->ReadyWeapon ? gl_FindModelFrame(playermo->player->ReadyWeapon->GetClass(), psp->GetState()->sprite, psp->GetState()->GetFrame(), false) : nullptr;
|
||||
if (smf)
|
||||
{
|
||||
FSpriteModelFrame *smf = playermo->player->ReadyWeapon ? gl_FindModelFrame(playermo->player->ReadyWeapon->GetClass(), psp->GetState()->sprite, psp->GetState()->GetFrame(), false) : nullptr;
|
||||
if (smf)
|
||||
{
|
||||
weapondynlightindex[psp] = gl_SetDynModelLight(playermo, -1);
|
||||
}
|
||||
hw_GetDynModelLight(playermo, lightdata);
|
||||
weapondynlightindex[psp] = GLRenderer->mLights->UploadLights(lightdata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -181,11 +182,7 @@ void GLSceneDrawer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep)
|
|||
if (gl_lights && GLRenderer->mLightCount && FixedColormap == CM_DEFAULT && gl_light_sprites)
|
||||
{
|
||||
FSpriteModelFrame *smf = playermo->player->ReadyWeapon ? gl_FindModelFrame(playermo->player->ReadyWeapon->GetClass(), psp->GetState()->sprite, psp->GetState()->GetFrame(), false) : nullptr;
|
||||
if (smf && !gl.legacyMode)
|
||||
{
|
||||
gl_SetDynModelLight(playermo, weapondynlightindex[psp]);
|
||||
}
|
||||
else
|
||||
if (!smf || gl.legacyMode) // For models with per-pixel lighting this was done in a previous pass.
|
||||
{
|
||||
float out[3];
|
||||
gl_drawinfo->GetDynSpriteLight(playermo, nullptr, out);
|
||||
|
|
Loading…
Reference in a new issue