mirror of
https://github.com/ZDoom/ZDRay.git
synced 2024-11-22 12:01:09 +00:00
Merge pull request #47 from MrRaveYard/pr_negative_lights
Allow use of negative color values for lights
This commit is contained in:
commit
207352f0c5
2 changed files with 21 additions and 23 deletions
|
@ -229,9 +229,9 @@ void FLevel::CreateLights()
|
||||||
if (thing->type != THING_POINTLIGHT_STATIC && thing->type != THING_SPOTLIGHT_STATIC)
|
if (thing->type != THING_POINTLIGHT_STATIC && thing->type != THING_SPOTLIGHT_STATIC)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
uint32_t lightcolor = 0xffffff;
|
vec3 lightColor(0, 0, 0);
|
||||||
float lightintensity = 1.0f;
|
float lightIntensity = 1.0f;
|
||||||
float lightdistance = 0.0f;
|
float lightDistance = 0.0f;
|
||||||
float innerAngleCos = -1.0f;
|
float innerAngleCos = -1.0f;
|
||||||
float outerAngleCos = -1.0f;
|
float outerAngleCos = -1.0f;
|
||||||
|
|
||||||
|
@ -242,50 +242,48 @@ void FLevel::CreateLights()
|
||||||
int r = thing->args[0];
|
int r = thing->args[0];
|
||||||
int g = thing->args[1];
|
int g = thing->args[1];
|
||||||
int b = thing->args[2];
|
int b = thing->args[2];
|
||||||
int rgb = r;
|
lightColor = vec3(r / 255.0, g / 255.0, b / 255.0);
|
||||||
rgb = rgb << 8;
|
|
||||||
rgb |= g;
|
|
||||||
rgb = rgb << 8;
|
|
||||||
rgb |= b;
|
|
||||||
lightcolor = (uint32_t)rgb;
|
|
||||||
}
|
}
|
||||||
else if (thing->type == THING_SPOTLIGHT_STATIC)
|
else if (thing->type == THING_SPOTLIGHT_STATIC)
|
||||||
{
|
{
|
||||||
lightcolor = (uint32_t)thing->args[0];
|
auto rgb = (uint32_t)thing->args[0];
|
||||||
|
|
||||||
// UDB's color picker will assign the color as a hex string, stored
|
// UDB's color picker will assign the color as a hex string, stored
|
||||||
// in the arg0str field. detect this, so that it can be converted into an int
|
// in the arg0str field. detect this, so that it can be converted into an int
|
||||||
if (thing->arg0str.Len() > 0)
|
if (thing->arg0str.Len() > 0)
|
||||||
{
|
{
|
||||||
FString hex = "0x" + thing->arg0str;
|
FString hex = "0x" + thing->arg0str;
|
||||||
int rgb = hex.ToULong();
|
rgb = (uint32_t)hex.ToULong();
|
||||||
lightcolor = (uint32_t)rgb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lightColor = vec3(
|
||||||
|
((rgb >> 16) & 0xFF) / 255.0,
|
||||||
|
((rgb >> 8) & 0xFF) / 255.0,
|
||||||
|
((rgb) & 0xFF) / 255.0
|
||||||
|
);
|
||||||
|
|
||||||
innerAngleCos = std::cos((float)thing->args[1] * 3.14159265359f / 180.0f);
|
innerAngleCos = std::cos((float)thing->args[1] * 3.14159265359f / 180.0f);
|
||||||
outerAngleCos = std::cos((float)thing->args[2] * 3.14159265359f / 180.0f);
|
outerAngleCos = std::cos((float)thing->args[2] * 3.14159265359f / 180.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is known as "intensity" on dynamic lights (and in UDB)
|
// this is known as "intensity" on dynamic lights (and in UDB)
|
||||||
lightdistance = thing->args[3];
|
lightDistance = thing->args[3];
|
||||||
|
|
||||||
// static light intensity (not to be confused with dynamic lights' intensity, which is actually static light distance
|
// static light intensity (not to be confused with dynamic lights' intensity, which is actually static light distance
|
||||||
lightintensity = thing->alpha;
|
lightIntensity = thing->alpha;
|
||||||
|
|
||||||
if (lightdistance > 0.0f && lightintensity > 0.0f && lightcolor != 0)
|
if (lightDistance > 0.0f && lightIntensity > 0.0f && lightColor != vec3(0, 0, 0))
|
||||||
{
|
{
|
||||||
int x = thing->x >> FRACBITS;
|
int x = thing->x >> FRACBITS;
|
||||||
int y = thing->y >> FRACBITS;
|
int y = thing->y >> FRACBITS;
|
||||||
|
|
||||||
ThingLight thingLight;
|
ThingLight thingLight;
|
||||||
thingLight.mapThing = thing;
|
thingLight.mapThing = thing;
|
||||||
thingLight.rgb.x = ((lightcolor >> 16) & 0xff) / 255.0f;
|
thingLight.rgb = lightColor;
|
||||||
thingLight.rgb.y = ((lightcolor >> 8) & 0xff) / 255.0f;
|
thingLight.intensity = lightIntensity;
|
||||||
thingLight.rgb.z = (lightcolor & 0xff) / 255.0f;
|
|
||||||
thingLight.intensity = lightintensity;
|
|
||||||
thingLight.innerAngleCos = std::max(innerAngleCos, outerAngleCos);
|
thingLight.innerAngleCos = std::max(innerAngleCos, outerAngleCos);
|
||||||
thingLight.outerAngleCos = outerAngleCos;
|
thingLight.outerAngleCos = outerAngleCos;
|
||||||
thingLight.radius = lightdistance;
|
thingLight.radius = lightDistance;
|
||||||
thingLight.height = thing->height;
|
thingLight.height = thing->height;
|
||||||
thingLight.bCeiling = false;
|
thingLight.bCeiling = false;
|
||||||
thingLight.ssect = PointInSubSector(x, y);
|
thingLight.ssect = PointInSubSector(x, y);
|
||||||
|
|
|
@ -444,9 +444,9 @@ void LevelMesh::FinishSurface(RectPacker& packer, Surface* surface)
|
||||||
int offs = ((textureWidth * (i + surface->atlasY)) + surface->atlasX) * 3;
|
int offs = ((textureWidth * (i + surface->atlasY)) + surface->atlasX) * 3;
|
||||||
|
|
||||||
// convert RGB to bytes
|
// convert RGB to bytes
|
||||||
currentTexture[offs + j * 3 + 0] = floatToHalf(clamp(colorSamples[i * sampleWidth + j].x, -65000.0f, 65000.0f));
|
currentTexture[offs + j * 3 + 0] = floatToHalf(clamp(colorSamples[i * sampleWidth + j].x, 0.0f, 65000.0f));
|
||||||
currentTexture[offs + j * 3 + 1] = floatToHalf(clamp(colorSamples[i * sampleWidth + j].y, -65000.0f, 65000.0f));
|
currentTexture[offs + j * 3 + 1] = floatToHalf(clamp(colorSamples[i * sampleWidth + j].y, 0.0f, 65000.0f));
|
||||||
currentTexture[offs + j * 3 + 2] = floatToHalf(clamp(colorSamples[i * sampleWidth + j].z, -65000.0f, 65000.0f));
|
currentTexture[offs + j * 3 + 2] = floatToHalf(clamp(colorSamples[i * sampleWidth + j].z, 0.0f, 65000.0f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue