Skip to content
6 changes: 3 additions & 3 deletions Core/Render/OpenGL/Renderers/Legacy/World/DynamicVertex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public struct DynamicVertex
public float V;

[VertexAttribute]
public float Options;
public float SurfaceOptions;

[VertexAttribute]
public float LightLevelAdd;
Expand All @@ -30,6 +30,6 @@ public struct DynamicVertex
public float PrevU;
public float PrevV;

[VertexAttribute(required: false)]
public float ColorMapIndex;
[VertexAttribute]
public float RenderOptions;
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ protected override string VertexShader() => @"
#version 330

layout(location = 0) in vec3 pos;
layout(location = 1) in float options;
layout(location = 1) in float surfaceOptions;
layout(location = 2) in vec3 prevPos;
layout(location = 3) in float offsetXYZ;
layout(location = 4) in float colorMapAndRenderIndex;
layout(location = 4) in float renderOptions;

flat out float lightLevelOut;
flat out float alphaOut;
Expand All @@ -168,15 +168,15 @@ protected override string VertexShader() => @"

void main()
{
int intOptions = floatBitsToInt(options);
int intOptions = floatBitsToInt(surfaceOptions);
alphaOut = (intOptions & 0xFF) / 255.0;
fuzzOut = (intOptions >> 8) & 1;
flipUOut = (intOptions >> 9) & 1;
lightLevelOut = (intOptions >> 10) & 0xFF;
colorMapTranslationOut = (intOptions >> 18);

intOptions = floatBitsToInt(colorMapAndRenderIndex);
int sectorIndexInt = intOptions >> 16;
intOptions = floatBitsToInt(renderOptions);
int lightIndexInt = intOptions >> 16;
int renderIndex = intOptions & 0xFFFF;

intOptions = floatBitsToInt(offsetXYZ);
Expand All @@ -188,8 +188,8 @@ void main()
offsetZOut = mix(offsetZOut, -offsetZOut, offsetZSign);
renderIndexOut = renderIndex;

sectorColorMapIndexOut = texelFetch(sectorColormapTexture, sectorIndexInt).rgb;
sectorFogOut = texelFetch(sectorFogTexture, sectorIndexInt).rgba;
sectorColorMapIndexOut = texelFetch(sectorColormapTexture, lightIndexInt).rgb;
sectorFogOut = texelFetch(sectorFogTexture, lightIndexInt).rgba;
gl_Position = vec4(mix(prevPos, pos, timeFrac), 1.0);
positionZOut = gl_Position.z;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ public void RenderEntity(Entity entity, in Vec2D position, int renderIndex)
vertex.PrevPos.X = (float)(entity.PrevPosition.X - nudgeAmount.X);
vertex.PrevPos.Y = (float)(entity.PrevPosition.Y - nudgeAmount.Y);
vertex.PrevPos.Z = (float)entity.PrevPosition.Z;
vertex.Options = VertexOptions.Entity(alpha, fuzz, flipU, colorMapIndex, lightLevel);
vertex.ColorMapAndRenderIndex = VertexOptions.EntityColorMapAndRenderIndex(
Renderer.GetColorMapBufferIndex(sector, WorldStatic.Sector3D && sector.Sectors3D.Length > 0 ? LightBufferType.Wall : LightBufferType.Floor), renderIndex);
vertex.SurfaceOptions = VertexOptions.EntityPackSurface(alpha, fuzz, flipU, colorMapIndex, lightLevel);
vertex.RenderOptions = VertexOptions.EntityPackRender(
Renderer.GetLightBufferIndex(sector, WorldStatic.Sector3D && sector.Sectors3D.Length > 0 ? LightBufferType.Wall : LightBufferType.Floor), renderIndex);

if (entity.Definition.Flags.SpawnCeiling() && m_vanillaRender)
{
Expand All @@ -298,7 +298,7 @@ public void RenderEntity(Entity entity, in Vec2D position, int renderIndex)
vertex.PrevPos.Z = entity.PrevPosition.Z != entity.Position.Z ? (float)entity.Sector.Ceiling.PrevZ : ceilingZ;
}

vertex.OffsetXYZ = VertexOptions.EntityXYZ(offsetX, offsetZ);
vertex.OffsetXYZ = VertexOptions.EntityPackXYZ(offsetX, offsetZ);
arrayData.Length = length + 1;

if (m_healthBars && entity.Flags.Shootable() && (m_healthBarLimit <= 0 || m_healthBarLimit <= entity.Properties.Health))
Expand Down Expand Up @@ -326,10 +326,10 @@ private void RenderHealthBar(Entity entity, GLLegacyTexture texture, float offse
float min = 1f / (entity.Properties.HealthBarWidth + MinBarWidth - 5);
// Normalized health percent (0-255)
int health = (int)(Math.Max(min, entity.Health / (float)entity.Properties.Health) * 255f);
vertex.Options = VertexOptions.Entity(1, attackFlash ? 1 : 0, 0, entity.Properties.HealthBarWidth, health);
vertex.SurfaceOptions = VertexOptions.EntityPackSurface(1, attackFlash ? 1 : 0, 0, entity.Properties.HealthBarWidth, health);
vertex.Pos = entityVertex.Pos;
vertex.PrevPos = entityVertex.PrevPos;
vertex.OffsetXYZ = VertexOptions.EntityXYZ(0, offset);
vertex.OffsetXYZ = VertexOptions.EntityPackXYZ(0, offset);

array.SetLength(array.Length + 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ public struct EntityVertex
public Vec3F Pos;

[VertexAttribute]
// X offset written to colormap option portion when in health bar mode
public float Options;
// X offset written to surface option portions when in health bar mode
public float SurfaceOptions;

[VertexAttribute]
public Vec3F PrevPos;

[VertexAttribute]
public float OffsetXYZ;

[VertexAttribute(required: false)]
public float ColorMapAndRenderIndex;
[VertexAttribute]
public float RenderOptions;
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,22 @@ public static unsafe void CopyCoverWallVertices(Side side, StaticVertex[] static
{
DynamicVertex* v = startVertex;
staticVertices[index++] = new StaticVertex(v->X, v->Y, v->Z + heights.AddTop, v->U, v->V,
v->Options, v->LightLevelAdd, 0);
v->SurfaceOptions, v->LightLevelAdd, 0);
v++;
staticVertices[index++] = new StaticVertex(v->X, v->Y, v->Z - heights.SubBottom, v->U, v->V,
v->Options, v->LightLevelAdd, 0);
v->SurfaceOptions, v->LightLevelAdd, 0);
v++;
staticVertices[index++] = new StaticVertex(v->X, v->Y, v->Z + heights.AddTop, v->U, v->V,
v->Options, v->LightLevelAdd, 0);
v->SurfaceOptions, v->LightLevelAdd, 0);
v++;
staticVertices[index++] = new StaticVertex(v->X, v->Y, v->Z - heights.SubBottom, v->U, v->V,
v->Options, v->LightLevelAdd, 0);
v->SurfaceOptions, v->LightLevelAdd, 0);
v++;
staticVertices[index++] = new StaticVertex(v->X, v->Y, v->Z + heights.AddTop, v->U, v->V,
v->Options, v->LightLevelAdd, 0);
v->SurfaceOptions, v->LightLevelAdd, 0);
v++;
staticVertices[index++] = new StaticVertex(v->X, v->Y, v->Z - heights.SubBottom, v->U, v->V,
v->Options, v->LightLevelAdd, 0);
v->SurfaceOptions, v->LightLevelAdd, 0);
}
}

Expand Down
Loading
Loading