mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-20 19:02:12 +00:00
Added support for ZDRay static light things
This commit is contained in:
parent
ab6d46a690
commit
21e89cf975
9 changed files with 262 additions and 101 deletions
|
@ -1,5 +1,104 @@
|
|||
gzdoom_lights
|
||||
{
|
||||
staticlights
|
||||
{
|
||||
color = 7;
|
||||
arrow = 0;
|
||||
title = "Static Lights";
|
||||
sort = 1;
|
||||
width = 0;
|
||||
height = 0;
|
||||
hangs = 0;
|
||||
blocking = 0;
|
||||
fixedsize = true;
|
||||
sprite = "internal:light";
|
||||
|
||||
9875
|
||||
{
|
||||
title = "Light Probe";
|
||||
}
|
||||
|
||||
9876
|
||||
{
|
||||
title = "Static Point Light";
|
||||
class = "StaticPointLight"; // Fake class name
|
||||
arg0
|
||||
{
|
||||
title = "Red";
|
||||
default = 255;
|
||||
}
|
||||
arg1
|
||||
{
|
||||
title = "Green";
|
||||
default = 255;
|
||||
}
|
||||
arg2
|
||||
{
|
||||
title = "Blue";
|
||||
default = 255;
|
||||
}
|
||||
arg3
|
||||
{
|
||||
title = "Radius";
|
||||
default = 64;
|
||||
}
|
||||
}
|
||||
|
||||
9881
|
||||
{
|
||||
title = "Static Spotlight";
|
||||
class = "StaticSpotLight"; // Fake class name
|
||||
arg0
|
||||
{
|
||||
title = "Color";
|
||||
default = 16777215;
|
||||
str = true;
|
||||
}
|
||||
arg1
|
||||
{
|
||||
title = "Inner angle";
|
||||
default = 8;
|
||||
}
|
||||
arg2
|
||||
{
|
||||
title = "Outer angle";
|
||||
default = 32;
|
||||
}
|
||||
arg3
|
||||
{
|
||||
title = "Radius";
|
||||
default = 64;
|
||||
}
|
||||
}
|
||||
|
||||
9890
|
||||
{
|
||||
title = "ZDRayInfo";
|
||||
class = "ZDRaySun"; // Fake class name
|
||||
arg0
|
||||
{
|
||||
title = "Sun color";
|
||||
default = 16777215;
|
||||
str = true;
|
||||
}
|
||||
arg1
|
||||
{
|
||||
title = "Sample distance";
|
||||
default = 8;
|
||||
}
|
||||
arg2
|
||||
{
|
||||
title = "Bounces";
|
||||
default = 1;
|
||||
}
|
||||
arg3
|
||||
{
|
||||
title = "Probe grid size";
|
||||
default = 32;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dynlights
|
||||
{
|
||||
color = 7;
|
||||
|
|
|
@ -374,7 +374,25 @@ universalfields
|
|||
{
|
||||
type = 2;
|
||||
default = "";
|
||||
}
|
||||
}
|
||||
|
||||
lightcolorline
|
||||
{
|
||||
type = 10;
|
||||
default = 16777215;
|
||||
}
|
||||
|
||||
lightintensityline
|
||||
{
|
||||
type = 1;
|
||||
default = 1.0;
|
||||
}
|
||||
|
||||
lightdistanceline
|
||||
{
|
||||
type = 1;
|
||||
default = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
sidedef
|
||||
|
@ -711,85 +729,6 @@ universalfields
|
|||
type = 1;
|
||||
default = 1.0;
|
||||
}
|
||||
|
||||
lightcolor
|
||||
{
|
||||
type = 10;
|
||||
thingtypespecific = true;
|
||||
}
|
||||
|
||||
lightintensity
|
||||
{
|
||||
type = 1;
|
||||
default = 1.0;
|
||||
thingtypespecific = true;
|
||||
}
|
||||
|
||||
lightdistance
|
||||
{
|
||||
type = 1;
|
||||
default = 0.0;
|
||||
thingtypespecific = true;
|
||||
}
|
||||
|
||||
lightinnerangle
|
||||
{
|
||||
type = 1;
|
||||
default = 180.0;
|
||||
thingtypespecific = true;
|
||||
}
|
||||
|
||||
lightouterangle
|
||||
{
|
||||
type = 1;
|
||||
default = 180.0;
|
||||
thingtypespecific = true;
|
||||
}
|
||||
|
||||
suncolor
|
||||
{
|
||||
type = 10;
|
||||
thingtypespecific = true;
|
||||
}
|
||||
|
||||
sundirx
|
||||
{
|
||||
type = 1;
|
||||
thingtypespecific = true;
|
||||
}
|
||||
|
||||
sundiry
|
||||
{
|
||||
type = 1;
|
||||
thingtypespecific = true;
|
||||
}
|
||||
|
||||
sundirz
|
||||
{
|
||||
type = 1;
|
||||
thingtypespecific = true;
|
||||
}
|
||||
|
||||
sampledistance
|
||||
{
|
||||
type = 0;
|
||||
default = 8;
|
||||
thingtypespecific = true;
|
||||
}
|
||||
|
||||
bounces
|
||||
{
|
||||
type = 0;
|
||||
default = 1;
|
||||
thingtypespecific = true;
|
||||
}
|
||||
|
||||
gridsize
|
||||
{
|
||||
type = 1;
|
||||
default = 32.0;
|
||||
thingtypespecific = true;
|
||||
}
|
||||
}
|
||||
|
||||
sector
|
||||
|
@ -1092,7 +1031,43 @@ universalfields
|
|||
{
|
||||
type = 3;
|
||||
default = false;
|
||||
}
|
||||
}
|
||||
|
||||
lightcolorfloor
|
||||
{
|
||||
type = 10;
|
||||
default = 16777215;
|
||||
}
|
||||
|
||||
lightintensityfloor
|
||||
{
|
||||
type = 1;
|
||||
default = 1.0;
|
||||
}
|
||||
|
||||
lightdistancefloor
|
||||
{
|
||||
type = 1;
|
||||
default = 0.0;
|
||||
}
|
||||
|
||||
lightcolorceiling
|
||||
{
|
||||
type = 10;
|
||||
default = 16777215;
|
||||
}
|
||||
|
||||
lightintensityceiling
|
||||
{
|
||||
type = 1;
|
||||
default = 1.0;
|
||||
}
|
||||
|
||||
lightdistanceceiling
|
||||
{
|
||||
type = 1;
|
||||
default = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -579,6 +579,14 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
|
|||
color = new PixelColor((byte)linealpha, (byte)t.Args[1], (byte)t.Args[2], (byte)t.Args[3]);
|
||||
break;
|
||||
|
||||
case GZGeneral.LightDef.POINT_STATIC:
|
||||
// ZDRay static lights have an intensity that's set through the thing's alpha value
|
||||
double intensity = t.Fields.GetValue("alpha", 1.0);
|
||||
byte r = (byte)General.Clamp(t.Args[0] * intensity, 0.0, 255.0);
|
||||
byte g = (byte)General.Clamp(t.Args[1] * intensity, 0.0, 255.0);
|
||||
byte b = (byte)General.Clamp(t.Args[2] * intensity, 0.0, 255.0);
|
||||
color = new PixelColor((byte)linealpha, r, g, b);
|
||||
break;
|
||||
default:
|
||||
color = new PixelColor((byte)linealpha, (byte)t.Args[0], (byte)t.Args[1], (byte)t.Args[2]);
|
||||
break;
|
||||
|
@ -613,6 +621,20 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
|
|||
}
|
||||
else color = new PixelColor((byte)linealpha, (byte)((t.Args[0] & 0xFF0000) >> 16), (byte)((t.Args[0] & 0x00FF00) >> 8), (byte)((t.Args[0] & 0x0000FF)));
|
||||
|
||||
// ZDRay static lights have an intensity that's set through the thing's alpha value
|
||||
if (t.DynamicLightType.LightDef == GZGeneral.LightDef.SPOT_STATIC)
|
||||
{
|
||||
double intensity = t.Fields.GetValue("alpha", 1.0);
|
||||
if (intensity != 1.0)
|
||||
{
|
||||
byte r = (byte)General.Clamp(color.r * intensity, 0.0, 255.0);
|
||||
byte g = (byte)General.Clamp(color.g * intensity, 0.0, 255.0);
|
||||
byte b = (byte)General.Clamp(color.b * intensity, 0.0, 255.0);
|
||||
color = new PixelColor((byte)linealpha, r, g, b);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (highlight)
|
||||
{
|
||||
color = General.Colors.Highlight.WithAlpha((byte)linealpha);
|
||||
|
@ -729,7 +751,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
|
|||
foreach (Thing t in things)
|
||||
{
|
||||
GZGeneral.LightData ld = t.DynamicLightType;
|
||||
if (ld == null) continue;
|
||||
if (ld == null || ld.LightType == GZGeneral.LightType.SUN) continue;
|
||||
|
||||
if (ld.LightType != GZGeneral.LightType.SPOT)
|
||||
{
|
||||
|
|
|
@ -120,6 +120,24 @@ namespace CodeImp.DoomBuilder.GZBuilder
|
|||
[LightDefClass("vavoomlightcolor")]
|
||||
VAVOOM_COLORED,
|
||||
|
||||
[LightDefRenderStyle(LightRenderStyle.STATIC)]
|
||||
[LightDefNum(9876)]
|
||||
[LightDefClass("staticpointlight")]
|
||||
[LightDefModifier(LightModifier.NORMAL)]
|
||||
POINT_STATIC,
|
||||
|
||||
[LightDefRenderStyle(LightRenderStyle.STATIC)]
|
||||
[LightDefNum(9881)]
|
||||
[LightDefClass("staticspotlight")]
|
||||
[LightDefModifier(LightModifier.NORMAL)]
|
||||
SPOT_STATIC,
|
||||
|
||||
[LightDefRenderStyle(LightRenderStyle.NONE)]
|
||||
[LightDefNum(9890)]
|
||||
[LightDefClass("zdraysun")]
|
||||
[LightDefModifier(LightModifier.NORMAL)]
|
||||
SUN,
|
||||
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
|
@ -132,6 +150,7 @@ namespace CodeImp.DoomBuilder.GZBuilder
|
|||
ATTENUATED = 98,
|
||||
VAVOOM = 50,
|
||||
ADDITIVE = 25,
|
||||
STATIC = 98, // Same as attenuated
|
||||
NONE = 0,
|
||||
}
|
||||
|
||||
|
@ -148,7 +167,8 @@ namespace CodeImp.DoomBuilder.GZBuilder
|
|||
{
|
||||
POINT,
|
||||
SPOT,
|
||||
VAVOOM
|
||||
VAVOOM,
|
||||
SUN
|
||||
}
|
||||
|
||||
public static LightDefNum GetLightDefNum(LightDef d)
|
||||
|
@ -212,18 +232,23 @@ namespace CodeImp.DoomBuilder.GZBuilder
|
|||
case LightDef.POINT_ADDITIVE:
|
||||
case LightDef.POINT_SUBTRACTIVE:
|
||||
case LightDef.POINT_ATTENUATED:
|
||||
case LightDef.POINT_STATIC:
|
||||
LightType = LightType.POINT;
|
||||
break;
|
||||
case LightDef.SPOT_NORMAL:
|
||||
case LightDef.SPOT_ADDITIVE:
|
||||
case LightDef.SPOT_SUBTRACTIVE:
|
||||
case LightDef.SPOT_ATTENUATED:
|
||||
case LightDef.SPOT_STATIC:
|
||||
LightType = LightType.SPOT;
|
||||
break;
|
||||
case LightDef.VAVOOM_GENERIC:
|
||||
case LightDef.VAVOOM_COLORED:
|
||||
LightType = LightType.VAVOOM;
|
||||
break;
|
||||
case LightDef.SUN:
|
||||
LightType = LightType.SUN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -556,16 +556,46 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
return new PixelColor(255, (byte)t.Args[1], (byte)t.Args[2], (byte)t.Args[3]);
|
||||
if (t.DynamicLightType.LightType == GZGeneral.LightType.SPOT)
|
||||
{
|
||||
PixelColor color;
|
||||
|
||||
if (t.Fields.ContainsKey("arg0str"))
|
||||
{
|
||||
PixelColor pc;
|
||||
ZDoom.ZDTextParser.GetColorFromString(t.Fields["arg0str"].Value.ToString(), out pc);
|
||||
pc.a = 255;
|
||||
return pc;
|
||||
|
||||
ZDoom.ZDTextParser.GetColorFromString(t.Fields["arg0str"].Value.ToString(), out color);
|
||||
color.a = 255;
|
||||
|
||||
}
|
||||
return new PixelColor(255, (byte)((t.Args[0] & 0xFF0000) >> 16), (byte)((t.Args[0] & 0x00FF00) >> 8), (byte)((t.Args[0] & 0x0000FF)));
|
||||
else
|
||||
color = new PixelColor(255, (byte)((t.Args[0] & 0xFF0000) >> 16), (byte)((t.Args[0] & 0x00FF00) >> 8), (byte)((t.Args[0] & 0x0000FF)));
|
||||
|
||||
// ZDRay static lights have an intensity that's set through the thing's alpha value
|
||||
if (t.DynamicLightType.LightDef == GZGeneral.LightDef.SPOT_STATIC)
|
||||
{
|
||||
double intensity = t.Fields.GetValue("alpha", 1.0);
|
||||
if (intensity != 1.0)
|
||||
{
|
||||
byte r = (byte)General.Clamp(color.r * intensity, 0.0, 255.0);
|
||||
byte g = (byte)General.Clamp(color.g * intensity, 0.0, 255.0);
|
||||
byte b = (byte)General.Clamp(color.b * intensity, 0.0, 255.0);
|
||||
color = new PixelColor(255, r, g, b);
|
||||
}
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
return new PixelColor(255, (byte)t.Args[0], (byte)t.Args[1], (byte)t.Args[2]);
|
||||
|
||||
// Point light
|
||||
if (t.DynamicLightType.LightDef == GZGeneral.LightDef.POINT_STATIC)
|
||||
{
|
||||
// ZDRay static lights have an intensity that's set through the thing's alpha value
|
||||
double intensity = t.Fields.GetValue("alpha", 1.0);
|
||||
byte r = (byte)General.Clamp(t.Args[0] * intensity, 0.0, 255.0);
|
||||
byte g = (byte)General.Clamp(t.Args[1] * intensity, 0.0, 255.0);
|
||||
byte b = (byte)General.Clamp(t.Args[2] * intensity, 0.0, 255.0);
|
||||
return new PixelColor(255, r, g, b);
|
||||
}
|
||||
else
|
||||
return new PixelColor(255, (byte)t.Args[0], (byte)t.Args[1], (byte)t.Args[2]);
|
||||
}
|
||||
|
||||
return t.Color;
|
||||
|
|
|
@ -601,6 +601,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
case GZGeneral.LightRenderStyle.VAVOOM: lightOffsets[0]++; break;
|
||||
case GZGeneral.LightRenderStyle.ADDITIVE: lightOffsets[2]++; break;
|
||||
case GZGeneral.LightRenderStyle.SUBTRACTIVE: lightOffsets[3]++; break;
|
||||
case GZGeneral.LightRenderStyle.STATIC: // Static lights look the same as attenuated lights
|
||||
default: lightOffsets[1]++; break; // attenuated
|
||||
}
|
||||
}
|
||||
|
@ -1024,7 +1025,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
world = CreateThingPositionMatrix(t);
|
||||
|
||||
//mxd. If current thing is light - set it's color to light color
|
||||
if(t.LightType != null && t.LightType.LightInternal && !fullbrightness && !General.Settings.ClassicRendering)
|
||||
if(t.LightType != null && t.LightType.LightInternal && t.LightType.LightType != GZGeneral.LightType.SUN && !fullbrightness && !General.Settings.ClassicRendering)
|
||||
{
|
||||
wantedshaderpass += 4; // Render using one of passes, which uses World3D.VertexColor
|
||||
vertexcolor = t.LightColor;
|
||||
|
|
|
@ -668,7 +668,7 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
public void UpdateLight()
|
||||
{
|
||||
lightType = thing.DynamicLightType;
|
||||
if (lightType == null)
|
||||
if (lightType == null || lightType.LightType == GZGeneral.LightType.SUN)
|
||||
return;
|
||||
GZGeneral.LightData ld = lightType;
|
||||
if (ld.LightDef != GZGeneral.LightDef.VAVOOM_GENERIC &&
|
||||
|
@ -678,11 +678,14 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
{
|
||||
if (ld.LightDef != GZGeneral.LightDef.POINT_SUBTRACTIVE) // normal, additive, attenuated
|
||||
{
|
||||
// ZDRay static lights have an intensity that's set through the thing's alpha value
|
||||
float intensity = ld.LightRenderStyle == GZGeneral.LightRenderStyle.STATIC ? (float)thing.Fields.GetValue("alpha", 1.0) : 1.0f;
|
||||
|
||||
//lightColor.Alpha used in shader to perform some calculations based on light type
|
||||
lightColor = new Color4(
|
||||
thing.Args[0] / DYNLIGHT_INTENSITY_SCALER,
|
||||
thing.Args[1] / DYNLIGHT_INTENSITY_SCALER,
|
||||
thing.Args[2] / DYNLIGHT_INTENSITY_SCALER,
|
||||
thing.Args[0] / DYNLIGHT_INTENSITY_SCALER * intensity,
|
||||
thing.Args[1] / DYNLIGHT_INTENSITY_SCALER * intensity,
|
||||
thing.Args[2] / DYNLIGHT_INTENSITY_SCALER * intensity,
|
||||
(float)ld.LightRenderStyle / 100.0f);
|
||||
}
|
||||
else // negative
|
||||
|
@ -714,10 +717,13 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
|
||||
if (ld.LightDef != GZGeneral.LightDef.SPOT_SUBTRACTIVE)
|
||||
{
|
||||
lightColor = new Color4(
|
||||
c1 / DYNLIGHT_INTENSITY_SCALER,
|
||||
c2 / DYNLIGHT_INTENSITY_SCALER,
|
||||
c3 / DYNLIGHT_INTENSITY_SCALER,
|
||||
// ZDRay static lights have an intensity that's set through the thing's alpha value
|
||||
float intensity = ld.LightRenderStyle == GZGeneral.LightRenderStyle.STATIC ? (float)thing.Fields.GetValue("alpha", 1.0) : 1.0f;
|
||||
|
||||
lightColor = new Color4(
|
||||
c1 / DYNLIGHT_INTENSITY_SCALER * intensity,
|
||||
c2 / DYNLIGHT_INTENSITY_SCALER * intensity,
|
||||
c3 / DYNLIGHT_INTENSITY_SCALER * intensity,
|
||||
(float)ld.LightRenderStyle / 100.0f);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -996,7 +996,10 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
{
|
||||
foreach(Thing t in things)
|
||||
{
|
||||
double value = General.Clamp(alpha.GetResultFloat(t.Fields.GetValue("alpha", 1.0)), 0.0, 1.0);
|
||||
// ZDRay static lights uses the alpha value for intensity, which can go higher than 1.0, so don't clamp the upper value.
|
||||
// It doesn't look like UDB or GZDoom have problems with "normal" things having an alpha > 1.0
|
||||
// TODO: clamp based on thing type info?
|
||||
double value = General.Clamp(alpha.GetResultFloat(t.Fields.GetValue("alpha", 1.0)), 0.0, double.MaxValue);
|
||||
UniFields.SetFloat(t.Fields, "alpha", value, 1.0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ namespace CodeImp.DoomBuilder.ColorPicker.Windows
|
|||
//update color
|
||||
if(colorChanged) //need this check to allow relative mode to work properly
|
||||
{
|
||||
if (t.DynamicLightType.LightType == GZGeneral.LightType.SPOT)
|
||||
if (t.DynamicLightType.LightType == GZGeneral.LightType.SPOT || t.DynamicLightType.LightType == GZGeneral.LightType.SUN)
|
||||
{
|
||||
int c = ((int)lightProps.Red << 16) | ((int)lightProps.Green << 8) | lightProps.Blue;
|
||||
t.Args[0] = 0;
|
||||
|
@ -332,7 +332,7 @@ namespace CodeImp.DoomBuilder.ColorPicker.Windows
|
|||
{
|
||||
if (thing.DynamicLightType.LightDef == GZGeneral.LightDef.VAVOOM_GENERIC) return Color.White; //vavoom light
|
||||
if (thing.DynamicLightType.LightDef == GZGeneral.LightDef.VAVOOM_COLORED) return Color.FromArgb((byte)thing.Args[1], (byte)thing.Args[2], (byte)thing.Args[3]); //vavoom colored light
|
||||
if (thing.DynamicLightType.LightType == GZGeneral.LightType.SPOT)
|
||||
if (thing.DynamicLightType.LightType == GZGeneral.LightType.SPOT || thing.DynamicLightType.LightType == GZGeneral.LightType.SUN)
|
||||
{
|
||||
if (thing.Fields.ContainsKey("arg0str"))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue