Visual Mode: improved support for GZDoom UDMF rendering styles. Partially addresses #485

This commit is contained in:
biwa 2020-10-19 21:42:34 +02:00
parent 2217e6f633
commit 9c10069d58
2 changed files with 19 additions and 6 deletions

View file

@ -65,7 +65,7 @@ namespace CodeImp.DoomBuilder.Config
private string classname; //mxd private string classname; //mxd
private string lightname; //mxd. Dynamic light name defined using Light() state expression private string lightname; //mxd. Dynamic light name defined using Light() state expression
private int color; private int color;
private float alpha; //mxd private double alpha; //mxd
private byte alphabyte; //mxd private byte alphabyte; //mxd
private string renderstyle; //mxd private string renderstyle; //mxd
private bool bright; //mxd private bool bright; //mxd
@ -115,7 +115,7 @@ namespace CodeImp.DoomBuilder.Config
public SpriteFrameInfo[] SpriteFrame { get { return spriteframe; } } public SpriteFrameInfo[] SpriteFrame { get { return spriteframe; } }
public ActorStructure Actor { get { return actor; } } public ActorStructure Actor { get { return actor; } }
public int Color { get { return color; } } public int Color { get { return color; } }
public float Alpha { get { return alpha; } } //mxd public double Alpha { get { return alpha; } } //mxd
public byte AlphaByte { get { return alphabyte; } } //mxd public byte AlphaByte { get { return alphabyte; } } //mxd
public string RenderStyle { get { return renderstyle; } } //mxd public string RenderStyle { get { return renderstyle; } } //mxd
public bool Bright { get { return bright; } } //mxd public bool Bright { get { return bright; } } //mxd

View file

@ -124,18 +124,29 @@ namespace CodeImp.DoomBuilder.BuilderModes
renderstyle = Thing.Fields.GetValue("renderstyle", renderstyle).ToLowerInvariant(); renderstyle = Thing.Fields.GetValue("renderstyle", renderstyle).ToLowerInvariant();
} }
if((renderstyle == "add" || renderstyle == "translucent" || renderstyle == "subtract" || renderstyle.EndsWith("stencil")) if((renderstyle == "add" || renderstyle == "translucent" || renderstyle == "subtract" || renderstyle == "translucentstencil")
&& Thing.Fields.ContainsKey("alpha")) && Thing.Fields.ContainsKey("alpha"))
{ {
alpha = (byte)(General.Clamp(Thing.Fields.GetValue("alpha", info.Alpha), 0.0, 1.0) * 255.0); alpha = (byte)(General.Clamp(Thing.Fields.GetValue("alpha", info.Alpha), 0.0, 1.0) * 255.0);
} }
else if(renderstyle == "soultrans")
{
// Lost Soul trasparency is controlled by a CVAR (see https://zdoom.org/wiki/CVARs:Display#transsouls), let's use the default 0.75 here
alpha = 192;
}
else if(renderstyle == "shadow")
{
alpha = 76; // about 0.3
stencilColor = PixelColor.FromInt(PixelColor.INT_BLACK);
}
if (renderstyle.EndsWith("stencil")) if (renderstyle.EndsWith("stencil"))
{ {
stencilColor = PixelColor.FromInt(UniFields.GetInteger(Thing.Fields, "fillcolor", 0)); stencilColor = PixelColor.FromInt(UniFields.GetInteger(Thing.Fields, "fillcolor", 0));
stencilColor.a = 255; // 0xFF alpha means nothing was read. 0x00 alpha means there was a valid fillcolor. stencilColor.a = 255; // 0xFF alpha means nothing was read. 0x00 alpha means there was a valid fillcolor.
} }
else stencilColor.a = 0; else if(renderstyle != "shadow")
stencilColor.a = 0;
} }
else if(General.Map.HEXEN) else if(General.Map.HEXEN)
{ {
@ -156,7 +167,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
case "translucent": case "translucent":
case "subtract": case "subtract":
case "stencil": case "soultrans":
case "translucentstencil":
case "shadow":
RenderPass = RenderPass.Alpha; RenderPass = RenderPass.Alpha;
break; break;