mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-31 04:40:55 +00:00
Visual mode, UDMF: "nofakecontrast", "smoothlighting" and "lightabsolute" flags are now taken into account when calculating fake contrast/smooth lighting brightness values for walls.
This commit is contained in:
parent
7a2aafbb6b
commit
c441c5640a
1 changed files with 32 additions and 15 deletions
|
@ -99,23 +99,40 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
|
|
||||||
//mxd. This calculates wall brightness level with doom-style shading
|
//mxd. This calculates wall brightness level with doom-style shading
|
||||||
public int CalculateBrightness(int level, Sidedef sd) {
|
public int CalculateBrightness(int level, Sidedef sd) {
|
||||||
if (level < 253 && !General.Map.Data.MapInfo.EvenLighting && sd != null) {
|
if(level < 253 && sd != null) {
|
||||||
//all walls are shaded by their angle
|
bool evenlighting = General.Map.Data.MapInfo.EvenLighting;
|
||||||
if (General.Map.Data.MapInfo.SmoothLighting) {
|
bool smoothlighting = General.Map.Data.MapInfo.SmoothLighting;
|
||||||
float ammount = Math.Abs((float)Math.Sin(sd.Angle));
|
|
||||||
int hAmmount = (int)((1.0f - ammount) * General.Map.Data.MapInfo.HorizWallShade);
|
|
||||||
int vAmmount = (int)(ammount * General.Map.Data.MapInfo.VertWallShade);
|
|
||||||
|
|
||||||
level = General.Clamp(level - hAmmount - vAmmount, 0, 255);
|
//check for possiburu UDMF overrides
|
||||||
|
if(General.Map.UDMF) {
|
||||||
|
if(sd.IsFlagSet("lightabsolute") && sd.Fields.ContainsKey("light")) {
|
||||||
|
evenlighting = true;
|
||||||
|
} else {
|
||||||
|
if(sd.IsFlagSet("nofakecontrast"))
|
||||||
|
evenlighting = true;
|
||||||
|
if(sd.IsFlagSet("smoothlighting"))
|
||||||
|
smoothlighting = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else { //only horizontal/verticel walls are shaded
|
if(!evenlighting) {
|
||||||
int angle = (int)Angle2D.RadToDeg(sd.Angle);// * 180.0f / Math.PI);
|
//all walls are shaded by their angle
|
||||||
//horizontal wall
|
if(smoothlighting) {
|
||||||
if (angle == 270 || angle == 90) {
|
float ammount = Math.Abs((float)Math.Sin(sd.Angle));
|
||||||
level = General.Clamp(level + General.Map.Data.MapInfo.HorizWallShade, 0, 255);
|
int hAmmount = (int)((1.0f - ammount) * General.Map.Data.MapInfo.HorizWallShade);
|
||||||
//vertical wall
|
int vAmmount = (int)(ammount * General.Map.Data.MapInfo.VertWallShade);
|
||||||
} else if (angle == 0 || angle == 180) {
|
|
||||||
level = General.Clamp(level + General.Map.Data.MapInfo.VertWallShade, 0, 255);
|
level = General.Clamp(level - hAmmount - vAmmount, 0, 255);
|
||||||
|
|
||||||
|
} else { //only horizontal/verticel walls are shaded
|
||||||
|
int angle = (int)Angle2D.RadToDeg(sd.Angle);
|
||||||
|
//horizontal wall
|
||||||
|
if(angle == 270 || angle == 90) {
|
||||||
|
level = General.Clamp(level + General.Map.Data.MapInfo.HorizWallShade, 0, 255);
|
||||||
|
//vertical wall
|
||||||
|
} else if(angle == 0 || angle == 180) {
|
||||||
|
level = General.Clamp(level + General.Map.Data.MapInfo.VertWallShade, 0, 255);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue