Colored lights improvements

Color value is now uint32_t, removed superfluous conversion to unsigned value, simplification in the shader.

Open: C4DP_Last and number of drawing passes
Controls
Mark 2015-07-02 20:59:20 +02:00
parent 9042450399
commit d45cc7c95b
7 changed files with 15 additions and 19 deletions

View File

@ -71,9 +71,9 @@ slice(color+5)
lightColor.rgb = sqrt(3.0) * normalize(lightColor.rgb);
// Add light
color = vec4(light * color.rgb * lightColor.rgb, color.a);
color.rgb = light * color.rgb * lightColor.rgb;
#ifdef HAVE_2PX
color2 = vec4(light2 * color2.rgb * lightColor.rgb, color2.a);
color2.rgb = light2 * color2.rgb * lightColor.rgb;
#endif
}

View File

@ -59,7 +59,7 @@ void C4FoWDrawLightTextureStrategy::Begin(int32_t passPar)
glScissor(0, 0, width, height);
break;
default:
assert(false);
assert(!"Unexpected value for light drawing pass");
break;
}

View File

@ -80,9 +80,9 @@ void C4FoWLight::SetReach(int32_t iReach2, int32_t iFadeout2)
void C4FoWLight::SetColor(uint32_t iValue)
{
colorR = (GetRedValue(iValue) & 255) / 255.0f;
colorG = (GetGreenValue(iValue) & 255) / 255.0f;
colorB = (GetBlueValue(iValue) & 255) / 255.0f;
colorR = GetRedValue(iValue) / 255.0f;
colorG = GetGreenValue(iValue) / 255.0f;
colorB = GetBlueValue(iValue) / 255.0f;
float min = Min(colorR, Min(colorG, colorB));
colorV = Max(Max(colorR, Max(colorG, colorB)), 1e-3f); // prevent division by 0
@ -210,7 +210,7 @@ void C4FoWLight::CalculateIntermediateFadeTriangles(TriangleList &triangles) con
// an extra intermediate fade point is only necessary on cliffs
tri.descending = distFanR > distNextFanL;
if (tri.descending) {
if (tri.descending) {
if (distFanR < distNextFadeL)
{
tri.fadeIX = nextTri.fadeLX;

View File

@ -152,13 +152,14 @@ void C4FoWRegion::Render(const C4TargetFacet *pOnScreen)
gluOrtho2D(0, getSurface()->Wdt, getSurface()->Hgt, 0);
// Clear texture contents
glScissor(0, getSurface()->Hgt / 2.0, getSurface()->Wdt, getSurface()->Hgt / 2.0);
assert(getSurface()->Hgt % 2 == 0);
glScissor(0, getSurface()->Hgt / 2, getSurface()->Wdt, getSurface()->Hgt / 2);
glClearColor(0.0f, 0.5f / 1.5f, 0.5f / 1.5f, 1.0f);
glEnable(GL_SCISSOR_TEST);
glClear(GL_COLOR_BUFFER_BIT);
// clear lower half of texture
glScissor(0, 0, getSurface()->Wdt, getSurface()->Hgt / 2.0);
glScissor(0, 0, getSurface()->Wdt, getSurface()->Hgt / 2);
glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glDisable(GL_SCISSOR_TEST);

View File

@ -4129,7 +4129,7 @@ bool C4Object::SetLightRange(int32_t iToRange, int32_t iToFadeoutRange)
}
bool C4Object::SetLightColor(long iValue)
bool C4Object::SetLightColor(uint32_t iValue)
{
// set new color value
lightColor = iValue;

View File

@ -139,7 +139,7 @@ public:
int32_t Audible, AudiblePan; // NoSave //
int32_t lightRange;
int32_t lightFadeoutRange;
long lightColor;
uint32_t lightColor;
C4Real fix_x,fix_y,fix_r; // SyncClearance-Fix //
C4Real xdir,ydir,rdir;
int32_t iLastAttachMovementFrame; // last frame in which Attach-movement by a SolidMask was done
@ -322,8 +322,8 @@ public:
int32_t GetValue(C4Object *pInBase, int32_t iForPlayer);
bool SetOwner(int32_t iOwner);
bool SetLightRange(int32_t iToRange, int32_t iToFadeoutRange);
long GetLightColor() const { return lightColor; }
bool SetLightColor(long iValue);
uint32_t GetLightColor() const { return lightColor; }
bool SetLightColor(uint32_t iValue);
void SetOnFire(bool OnFire) { this->OnFire = OnFire; SetOCF(); }
bool GetOnFire() const { return OnFire; }
void SetAlive(bool Alive) { this->Alive = Alive; SetOCF(); }

View File

@ -1341,13 +1341,8 @@ static long FnGetLightColor(C4Object *Obj)
}
static C4Void FnSetLightColor(C4Object *Obj, Nillable<long> iValue)
static C4Void FnSetLightColor(C4Object *Obj, long iValue)
{
if (iValue.IsNil())
{
iValue = 0;
}
Obj->SetLightColor(iValue);
return C4Void();
}