Skip to content

Commit

Permalink
Renderer: Clamp lightlevels applied uniformly to a chunk of map geometry
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Dec 17, 2013
1 parent 24698bf commit d7de80d
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions doomsday/client/src/render/rend_main.cpp
Expand Up @@ -604,22 +604,6 @@ static inline double viewFacingDot(Vector2d const &v1, Vector2d const &v2)
return (v1.y - v2.y) * (v1.x - vOrigin.x) + (v2.x - v1.x) * (v1.y - vOrigin.z);
}

static void Rend_VertexColorsGlow(Vector4f *colors, uint num, float glow)
{
for(uint i = 0; i < num; ++i)
{
colors[i].x = colors[i].y = colors[i].z = glow;
}
}

static void Rend_VertexColorsAlpha(Vector4f *colors, uint num, float alpha)
{
for(uint i = 0; i < num; ++i)
{
colors[i].w = alpha;
}
}

float Rend_ExtraLightDelta()
{
return extraLightDelta;
Expand Down Expand Up @@ -1221,8 +1205,12 @@ static bool renderWorldPoly(Vector3f *posCoords, uint numVertices,
if(levelFullBright || !(p.glowing < 1))
{
// Uniform color. Apply to all vertices.
float glowStrength = currentSectorLightLevel + (levelFullBright? 1 : p.glowing);
Rend_VertexColorsGlow(colorCoords, numVertices, glowStrength);
float ll = de::clamp(0.f, currentSectorLightLevel + (levelFullBright? 1 : p.glowing), 1.f);
Vector4f *colorIt = colorCoords;
for(uint i = 0; i < numVertices; ++i, colorIt++)
{
colorIt->x = colorIt->y = colorIt->z = ll;
}
}
else
{
Expand Down Expand Up @@ -1330,7 +1318,11 @@ static bool renderWorldPoly(Vector3f *posCoords, uint numVertices,
}

// Apply uniform alpha.
Rend_VertexColorsAlpha(colorCoords, numVertices, p.alpha);
Vector4f *colorIt = colorCoords;
for(uint i = 0; i < numVertices; ++i, colorIt++)
{
colorIt->w = p.alpha;
}
}

if(useLights || useShadows)
Expand Down

0 comments on commit d7de80d

Please sign in to comment.