Added: rendering of Doom64 lighting

This commit is contained in:
ZZYZX 2017-02-01 09:48:13 +02:00
parent b80ead1202
commit 42c2fc2044
3 changed files with 61 additions and 28 deletions

View file

@ -278,13 +278,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
//mxd. Interpolate vertex colors?
if(sd.CeilingGlow != null || sd.FloorGlow != null)
for(int i = 0; i < verts.Count; i++)
{
for(int i = 0; i < verts.Count; i++)
{
if(verts[i].c == PixelColor.INT_WHITE) continue; // Fullbright verts are not affected by glows.
verts[i] = InterpolateVertexColor(verts[i], sd);
}
//if(verts[i].c == PixelColor.INT_WHITE) continue; // Fullbright verts are not affected by glows.
verts[i] = InterpolateVertexColor(verts[i], sd);
}
return verts;
@ -293,6 +290,22 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd
private static WorldVertex InterpolateVertexColor(WorldVertex v, SectorData data)
{
// [ZZ] process sector top and bottom colors.
// block
{
float cz = data.Ceiling.plane.GetZ(v.x, v.y);
float cgz = data.Floor.plane.GetZ(v.x, v.y);
float delta = 1.0f - (((v.z - cgz) / (cz - cgz)) * 0.9f);
PixelColor vertexcolor = PixelColor.FromInt(v.c);
PixelColor topcolor = PixelColor.Modulate(vertexcolor, data.ColorWallTop);
PixelColor bottomcolor = PixelColor.Modulate(vertexcolor, data.ColorWallBottom);
v.c = InterpolationTools.InterpolateColor(topcolor, bottomcolor, delta).WithAlpha(255).ToInt();
}
// don't process glows if fullbright.
if (v.c == PixelColor.INT_WHITE)
return v;
// Apply ceiling glow?
if(data.CeilingGlow != null)
{

View file

@ -262,7 +262,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
PixelColor areabrightness = PixelColor.FromInt(mode.CalculateBrightness(brightness));
PixelColor areacolor = PixelColor.Modulate(level.colorbelow, areabrightness);
sectorcolor = areacolor.WithAlpha(alpha).ToInt();
// [ZZ] if sector is using Doom64 lighting, apply thing color here.
sectorcolor = PixelColor.Modulate(sd.ColorSprites, areacolor).WithAlpha(alpha).ToInt();
//mxd. Calculate fogfactor
fogfactor = VisualGeometry.CalculateFogFactor(level.sector, brightness);
@ -280,10 +282,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
fogfactor = VisualGeometry.CalculateFogFactor(level.sector, level.brightnessbelow);
}
}
}
}
//mxd. Create verts for all sprite angles
WorldVertex[][] allverts = new WorldVertex[info.SpriteFrame.Length][];
//mxd. Create verts for all sprite angles
WorldVertex[][] allverts = new WorldVertex[info.SpriteFrame.Length][];
Vector2D[] alloffsets = new Vector2D[info.SpriteFrame.Length];
base.textures = new ImageData[info.SpriteFrame.Length];
isloaded = true;

View file

@ -39,6 +39,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
internal GlowingFlatData FloorGlow; //mxd
internal Plane FloorGlowPlane; //mxd
internal Plane CeilingGlowPlane; //mxd
// [ZZ] Doom64 lighting system
internal PixelColor ColorCeiling;
internal PixelColor ColorFloor;
internal PixelColor ColorWallBottom;
internal PixelColor ColorWallTop;
internal PixelColor ColorSprites;
internal bool Doom64Absolute;
// Sectors that must be updated when this sector is changed
// The boolean value is the 'includeneighbours' of the UpdateSectorGeometry function which
@ -105,7 +113,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
lightlevels.Add(floor);
lightlevels.Add(ceiling);
BasicSetup();
BasicSetup();
}
#endregion
@ -298,24 +306,34 @@ namespace CodeImp.DoomBuilder.BuilderModes
lightfloorabsolute = sector.Fields.GetValue("lightfloorabsolute", false);
lightceiling = sector.Fields.GetValue("lightceiling", 0);
lightceilingabsolute = sector.Fields.GetValue("lightceilingabsolute", false);
if (!lightfloorabsolute) lightfloor = sector.Brightness + lightfloor;
if (!lightceilingabsolute) lightceiling = sector.Brightness + lightceiling;
// Determine colors & light levels
PixelColor lightcolor = PixelColor.FromInt(color);
if(!lightfloorabsolute) lightfloor = sector.Brightness + lightfloor;
if(!lightceilingabsolute) lightceiling = sector.Brightness + lightceiling;
PixelColor floorbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightfloor));
PixelColor ceilingbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightceiling));
PixelColor floorcolor = PixelColor.Modulate(lightcolor, floorbrightness);
PixelColor ceilingcolor = PixelColor.Modulate(lightcolor, ceilingbrightness);
floor.color = floorcolor.WithAlpha(255).ToInt();
floor.brightnessbelow = sector.Brightness;
floor.colorbelow = lightcolor.WithAlpha(255);
ceiling.color = ceilingcolor.WithAlpha(255).ToInt();
ceiling.brightnessbelow = sector.Brightness;
ceiling.colorbelow = lightcolor.WithAlpha(255);
// Determine colors & light levels
// [ZZ] Doom64 lighting
//
// ceiling/floor
ColorCeiling = PixelColor.FromInt(sector.Fields.GetValue("color_ceiling", PixelColor.INT_WHITE));
ColorFloor = PixelColor.FromInt(sector.Fields.GetValue("color_floor", PixelColor.INT_WHITE));
ColorSprites = PixelColor.FromInt(sector.Fields.GetValue("color_sprites", PixelColor.INT_WHITE));
ColorWallTop = PixelColor.FromInt(sector.Fields.GetValue("color_walltop", PixelColor.INT_WHITE));
ColorWallBottom = PixelColor.FromInt(sector.Fields.GetValue("color_wallbottom", PixelColor.INT_WHITE));
Doom64Absolute = sector.Fields.GetValue("color_absolute", false);
//mxd. Store a copy of initial settings
floor.CopyProperties(floorbase);
PixelColor floorbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightfloor));
PixelColor ceilingbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightceiling));
PixelColor lightcolor = PixelColor.FromInt(color);
PixelColor floorcolor = PixelColor.Modulate(ColorFloor, PixelColor.Modulate(lightcolor, floorbrightness));
PixelColor ceilingcolor = PixelColor.Modulate(ColorCeiling, PixelColor.Modulate(lightcolor, ceilingbrightness));
floor.color = floorcolor.WithAlpha(255).ToInt();
floor.brightnessbelow = sector.Brightness;
floor.colorbelow = lightcolor.WithAlpha(255);
ceiling.color = ceilingcolor.WithAlpha(255).ToInt();
ceiling.brightnessbelow = sector.Brightness;
ceiling.colorbelow = lightcolor.WithAlpha(255);
//mxd. Store a copy of initial settings
floor.CopyProperties(floorbase);
ceiling.CopyProperties(ceilingbase);
//mxd. We need sector brightness here, unaffected by custom ceiling brightness...
@ -324,7 +342,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd
glowingflateffect.Update();
}
}
//mxd
public void UpdateForced()