Remove SheetType.DualIndexed from voxel rendering.

This commit is contained in:
Paul Chote
2016-04-10 15:13:35 -04:00
parent 7c67b10d28
commit b68fee9521
3 changed files with 22 additions and 14 deletions

View File

@@ -54,10 +54,10 @@ namespace OpenRA.Graphics
if (allocated) if (allocated)
throw new SheetOverflowException(""); throw new SheetOverflowException("");
allocated = true; allocated = true;
return SheetBuilder.AllocateSheet(SheetType.DualIndexed, Game.Settings.Graphics.SheetSize); return SheetBuilder.AllocateSheet(SheetType.Indexed, Game.Settings.Graphics.SheetSize);
}; };
return new SheetBuilder(SheetType.DualIndexed, allocate); return new SheetBuilder(SheetType.Indexed, allocate);
} }
public VoxelLoader(IReadOnlyFileSystem fileSystem) public VoxelLoader(IReadOnlyFileSystem fileSystem)
@@ -78,6 +78,7 @@ namespace OpenRA.Graphics
var c = 0; var c = 0;
for (var v = 0; v < sv; v++) for (var v = 0; v < sv; v++)
{
for (var u = 0; u < su; u++) for (var u = 0; u < su; u++)
{ {
var voxel = first(u, v) ?? second(u, v); var voxel = first(u, v) ?? second(u, v);
@@ -85,22 +86,28 @@ namespace OpenRA.Graphics
normals[c] = voxel == null ? (byte)0 : voxel.Normal; normals[c] = voxel == null ? (byte)0 : voxel.Normal;
c++; c++;
} }
}
var s = sheetBuilder.Allocate(new Size(su, sv)); var size = new Size(su, sv);
Util.FastCopyIntoChannel(s, 0, colors); var s = sheetBuilder.Allocate(size);
Util.FastCopyIntoChannel(s, 1, normals); var t = sheetBuilder.Allocate(size);
Util.FastCopyIntoChannel(s, colors);
Util.FastCopyIntoChannel(t, normals);
// s and t are guaranteed to use the same sheet because
// of the custom voxel sheet allocation implementation
s.Sheet.CommitBufferedData(); s.Sheet.CommitBufferedData();
var channelP = ChannelSelect[(int)s.Channel]; var channelP = ChannelSelect[(int)s.Channel];
var channelC = ChannelSelect[(int)s.Channel + 1]; var channelC = ChannelSelect[(int)t.Channel];
return new Vertex[6] return new Vertex[6]
{ {
new Vertex(coord(0, 0), s.Left, s.Top, 0, 0, channelP, channelC), new Vertex(coord(0, 0), s.Left, s.Top, t.Left, t.Top, channelP, channelC),
new Vertex(coord(su, 0), s.Right, s.Top, 0, 0, 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, 0, 0, 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, 0, 0, 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, 0, 0, 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, 0, 0, channelP, channelC) new Vertex(coord(0, 0), s.Left, s.Top, t.Left, t.Top, channelP, channelC)
}; };
} }

View File

@@ -332,7 +332,7 @@ namespace OpenRA.Graphics
var size = new Size(renderer.SheetSize, renderer.SheetSize); var size = new Size(renderer.SheetSize, renderer.SheetSize);
var framebuffer = renderer.Device.CreateFrameBuffer(size); var framebuffer = renderer.Device.CreateFrameBuffer(size);
var sheet = new Sheet(SheetType.DualIndexed, framebuffer.Texture); var sheet = new Sheet(SheetType.BGRA, framebuffer.Texture);
mappedBuffers.Add(sheet, framebuffer); mappedBuffers.Add(sheet, framebuffer);
return sheet; return sheet;

View File

@@ -15,7 +15,8 @@ void main()
if (color.a < 0.01) if (color.a < 0.01)
discard; discard;
vec4 normal = (2.0 * texture2D(Palette, vec2(dot(x, vNormalsMask), PaletteRows.y)) - 1.0); vec4 y = texture2D(DiffuseTexture, vTexCoord.pq);
vec4 normal = (2.0 * texture2D(Palette, vec2(dot(y, vNormalsMask), PaletteRows.y)) - 1.0);
vec3 intensity = AmbientLight + DiffuseLight * max(dot(normal, LightDirection), 0.0); vec3 intensity = AmbientLight + DiffuseLight * max(dot(normal, LightDirection), 0.0);
gl_FragColor = vec4(intensity * color.rgb, color.a); gl_FragColor = vec4(intensity * color.rgb, color.a);
} }