Remove unused tint attribute from model shader
This commit is contained in:
committed by
Matthias Mailänder
parent
26b6118f50
commit
d05e0f23ea
@@ -49,7 +49,7 @@ namespace OpenRA.Graphics
|
||||
IModel GetModel(string model);
|
||||
IModel GetModelSequence(string model, string sequence);
|
||||
bool HasModelSequence(string model, string sequence);
|
||||
IVertexBuffer<Vertex> VertexBuffer { get; }
|
||||
IVertexBuffer<ModelVertex> VertexBuffer { get; }
|
||||
}
|
||||
|
||||
public interface IModelSequenceLoader
|
||||
@@ -64,7 +64,7 @@ namespace OpenRA.Graphics
|
||||
|
||||
sealed class PlaceholderModelCache : IModelCache
|
||||
{
|
||||
public IVertexBuffer<Vertex> VertexBuffer => throw new NotImplementedException();
|
||||
public IVertexBuffer<ModelVertex> VertexBuffer => throw new NotImplementedException();
|
||||
|
||||
public void Dispose() { }
|
||||
|
||||
|
||||
53
OpenRA.Game/Graphics/ModelVertex.cs
Normal file
53
OpenRA.Game/Graphics/ModelVertex.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright (c) The OpenRA Developers and Contributors
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace OpenRA.Graphics
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public readonly struct ModelVertex
|
||||
{
|
||||
// 3d position
|
||||
public readonly float X, Y, Z;
|
||||
|
||||
// Primary and secondary texture coordinates or RGBA color
|
||||
public readonly float S, T, U, V;
|
||||
|
||||
// Palette and channel flags
|
||||
public readonly float P, C;
|
||||
|
||||
public ModelVertex(in float3 xyz, float s, float t, float u, float v, float p, float c)
|
||||
: this(xyz.X, xyz.Y, xyz.Z, s, t, u, v, p, c) { }
|
||||
|
||||
public ModelVertex(float x, float y, float z, float s, float t, float u, float v, float p, float c)
|
||||
{
|
||||
X = x; Y = y; Z = z;
|
||||
S = s; T = t;
|
||||
U = u; V = v;
|
||||
P = p; C = c;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ModelShaderBindings : ShaderBindings
|
||||
{
|
||||
public ModelShaderBindings()
|
||||
: base("model")
|
||||
{ }
|
||||
|
||||
public override ShaderVertexAttribute[] Attributes { get; } = new[]
|
||||
{
|
||||
new ShaderVertexAttribute("aVertexPosition", 3, 0),
|
||||
new ShaderVertexAttribute("aVertexTexCoord", 4, 12),
|
||||
new ShaderVertexAttribute("aVertexTexMetadata", 2, 28),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -61,19 +61,4 @@ namespace OpenRA.Graphics
|
||||
new ShaderVertexAttribute("aVertexTint", 4, 36)
|
||||
};
|
||||
}
|
||||
|
||||
public sealed class ModelShaderBindings : ShaderBindings
|
||||
{
|
||||
public ModelShaderBindings()
|
||||
: base("model")
|
||||
{ }
|
||||
|
||||
public override ShaderVertexAttribute[] Attributes { get; } = new[]
|
||||
{
|
||||
new ShaderVertexAttribute("aVertexPosition", 3, 0),
|
||||
new ShaderVertexAttribute("aVertexTexCoord", 4, 12),
|
||||
new ShaderVertexAttribute("aVertexTexMetadata", 2, 28),
|
||||
new ShaderVertexAttribute("aVertexTint", 4, 36)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ namespace OpenRA.Mods.Cnc.Graphics
|
||||
{
|
||||
static readonly float[] ChannelSelect = { 0.75f, 0.25f, -0.25f, -0.75f };
|
||||
|
||||
readonly List<Vertex[]> vertices = new();
|
||||
readonly List<ModelVertex[]> vertices = new();
|
||||
readonly Cache<(string, string), Voxel> voxels;
|
||||
readonly IReadOnlyFileSystem fileSystem;
|
||||
IVertexBuffer<Vertex> vertexBuffer;
|
||||
IVertexBuffer<ModelVertex> vertexBuffer;
|
||||
int totalVertexCount;
|
||||
int cachedVertexCount;
|
||||
|
||||
@@ -50,14 +50,14 @@ namespace OpenRA.Mods.Cnc.Graphics
|
||||
{
|
||||
this.fileSystem = fileSystem;
|
||||
voxels = new Cache<(string, string), Voxel>(LoadFile);
|
||||
vertices = new List<Vertex[]>();
|
||||
vertices = new List<ModelVertex[]>();
|
||||
totalVertexCount = 0;
|
||||
cachedVertexCount = 0;
|
||||
|
||||
sheetBuilder = CreateSheetBuilder();
|
||||
}
|
||||
|
||||
Vertex[] GenerateSlicePlane(int su, int sv, Func<int, int, VxlElement?> first, Func<int, int, VxlElement?> second, Func<int, int, float3> coord)
|
||||
ModelVertex[] GenerateSlicePlane(int su, int sv, Func<int, int, VxlElement?> first, Func<int, int, VxlElement?> second, Func<int, int, float3> coord)
|
||||
{
|
||||
var colors = new byte[su * sv];
|
||||
var normals = new byte[su * sv];
|
||||
@@ -86,18 +86,18 @@ namespace OpenRA.Mods.Cnc.Graphics
|
||||
|
||||
var channelP = ChannelSelect[(int)s.Channel];
|
||||
var channelC = ChannelSelect[(int)t.Channel];
|
||||
return new Vertex[6]
|
||||
return new ModelVertex[6]
|
||||
{
|
||||
new Vertex(coord(0, 0), s.Left, s.Top, t.Left, t.Top, channelP, channelC),
|
||||
new Vertex(coord(su, 0), s.Right, s.Top, t.Right, t.Top, channelP, channelC),
|
||||
new Vertex(coord(su, sv), s.Right, s.Bottom, t.Right, t.Bottom, channelP, channelC),
|
||||
new Vertex(coord(su, sv), s.Right, s.Bottom, t.Right, t.Bottom, channelP, channelC),
|
||||
new Vertex(coord(0, sv), s.Left, s.Bottom, t.Left, t.Bottom, channelP, channelC),
|
||||
new Vertex(coord(0, 0), s.Left, s.Top, t.Left, t.Top, channelP, channelC)
|
||||
new ModelVertex(coord(0, 0), s.Left, s.Top, t.Left, t.Top, channelP, channelC),
|
||||
new ModelVertex(coord(su, 0), s.Right, s.Top, t.Right, t.Top, channelP, channelC),
|
||||
new ModelVertex(coord(su, sv), s.Right, s.Bottom, t.Right, t.Bottom, channelP, channelC),
|
||||
new ModelVertex(coord(su, sv), s.Right, s.Bottom, t.Right, t.Bottom, channelP, channelC),
|
||||
new ModelVertex(coord(0, sv), s.Left, s.Bottom, t.Left, t.Bottom, channelP, channelC),
|
||||
new ModelVertex(coord(0, 0), s.Left, s.Top, t.Left, t.Top, channelP, channelC)
|
||||
};
|
||||
}
|
||||
|
||||
IEnumerable<Vertex[]> GenerateSlicePlanes(VxlLimb l)
|
||||
IEnumerable<ModelVertex[]> GenerateSlicePlanes(VxlLimb l)
|
||||
{
|
||||
VxlElement? Get(int x, int y, int z)
|
||||
{
|
||||
@@ -170,7 +170,7 @@ namespace OpenRA.Mods.Cnc.Graphics
|
||||
|
||||
public ModelRenderData GenerateRenderData(VxlLimb l)
|
||||
{
|
||||
Vertex[] v;
|
||||
ModelVertex[] v;
|
||||
try
|
||||
{
|
||||
v = GenerateSlicePlanes(l).SelectMany(x => x).ToArray();
|
||||
@@ -195,12 +195,12 @@ namespace OpenRA.Mods.Cnc.Graphics
|
||||
public void RefreshBuffer()
|
||||
{
|
||||
vertexBuffer?.Dispose();
|
||||
vertexBuffer = Game.Renderer.CreateVertexBuffer<Vertex>(totalVertexCount);
|
||||
vertexBuffer = Game.Renderer.CreateVertexBuffer<ModelVertex>(totalVertexCount);
|
||||
vertexBuffer.SetData(vertices.SelectMany(v => v).ToArray(), totalVertexCount);
|
||||
cachedVertexCount = totalVertexCount;
|
||||
}
|
||||
|
||||
public IVertexBuffer<Vertex> VertexBuffer
|
||||
public IVertexBuffer<ModelVertex> VertexBuffer
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
@@ -114,7 +114,7 @@ namespace OpenRA.Mods.Cnc.Graphics
|
||||
return models[model].ContainsKey(sequence);
|
||||
}
|
||||
|
||||
public IVertexBuffer<Vertex> VertexBuffer => loader.VertexBuffer;
|
||||
public IVertexBuffer<ModelVertex> VertexBuffer => loader.VertexBuffer;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
@@ -7,7 +7,6 @@ uniform mat4 TransformMatrix;
|
||||
attribute vec4 aVertexPosition;
|
||||
attribute vec4 aVertexTexCoord;
|
||||
attribute vec2 aVertexTexMetadata;
|
||||
attribute vec3 aVertexTint;
|
||||
varying vec4 vTexCoord;
|
||||
varying vec4 vChannelMask;
|
||||
varying vec4 vNormalsMask;
|
||||
@@ -15,7 +14,6 @@ varying vec4 vNormalsMask;
|
||||
in vec4 aVertexPosition;
|
||||
in vec4 aVertexTexCoord;
|
||||
in vec2 aVertexTexMetadata;
|
||||
in vec3 aVertexTint;
|
||||
out vec4 vTexCoord;
|
||||
out vec4 vChannelMask;
|
||||
out vec4 vNormalsMask;
|
||||
|
||||
Reference in New Issue
Block a user