mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-02-16 17:11:03 +00:00
GL3: Render dynamic lights on all brush-based entities
The GL1 renderer can't do this :)
This commit is contained in:
parent
35daa08c23
commit
ca5dccb881
2 changed files with 18 additions and 5 deletions
|
@ -480,7 +480,8 @@ static const char* fragmentSrc3Dlm = MULTILINE_STRING(
|
|||
float fact = max(0, intens - distLightToPos - 64); // FIXME: really -64 for DLIGHT_CUTOFF?
|
||||
|
||||
// also factor in angle between light and point on surface
|
||||
fact *= dot(passNormal, lightToPos/distLightToPos);
|
||||
fact *= max(0, dot(passNormal, lightToPos/distLightToPos));
|
||||
|
||||
|
||||
lmTex.rgb += dynLights[i].lightColor.rgb * fact * (1.0/256.0);
|
||||
}
|
||||
|
|
|
@ -191,13 +191,25 @@ SetLightFlags(msurface_t *surf)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SetAllLightFlags(msurface_t *surf)
|
||||
{
|
||||
unsigned int lightFlags = 0xffffffff;
|
||||
|
||||
gl3_3D_vtx_t* verts = surf->polys->vertices;
|
||||
|
||||
int numVerts = surf->polys->numverts;
|
||||
for(int i=0; i<numVerts; ++i)
|
||||
{
|
||||
verts[i].lightFlags = lightFlags;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GL3_DrawGLPoly(msurface_t *fa)
|
||||
{
|
||||
glpoly_t *p = fa->polys;
|
||||
|
||||
SetLightFlags(fa);
|
||||
|
||||
GL3_BindVAO(gl3state.vao3D);
|
||||
GL3_BindVBO(gl3state.vbo3D);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(gl3_3D_vtx_t)*p->numverts, p->vertices, GL_STREAM_DRAW);
|
||||
|
@ -211,8 +223,6 @@ GL3_DrawGLFlowingPoly(msurface_t *fa)
|
|||
glpoly_t *p;
|
||||
float scroll;
|
||||
|
||||
SetLightFlags(fa);
|
||||
|
||||
p = fa->polys;
|
||||
|
||||
scroll = -64.0f * ((gl3_newrefdef.time / 40.0f) - (int)(gl3_newrefdef.time / 40.0f));
|
||||
|
@ -469,6 +479,7 @@ DrawTextureChains(void)
|
|||
|
||||
for ( ; s; s = s->texturechain)
|
||||
{
|
||||
SetLightFlags(s);
|
||||
RenderBrushPoly(s);
|
||||
}
|
||||
|
||||
|
@ -581,6 +592,7 @@ DrawInlineBModel(void)
|
|||
}
|
||||
else if(!(psurf->flags & SURF_DRAWTURB))
|
||||
{
|
||||
SetAllLightFlags(psurf);
|
||||
RenderLightmappedPoly(psurf);
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue