Skip to content

Commit

Permalink
diagonal lines on slice level
Browse files Browse the repository at this point in the history
  • Loading branch information
tomba committed Mar 14, 2016
1 parent 9839fb0 commit ad8202d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
12 changes: 12 additions & 0 deletions Client/MapControl3D/Content/TerrainEffect.fx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

static const float PI = 3.14159265f;

struct VS_IN
{
uint4 pos0 : POSITION0;
Expand Down Expand Up @@ -276,6 +278,16 @@ float4 PSMain(PS_IN input) : SV_Target
c2 = blockTextures.Sample(blockSampler, float3(input.tex, input.texPack[2]));
c2 = float4(c2.rgb * g_colorBuffer[input.colorPack[2]], c2.a);
color = c2.rgb + (1.0f - c2.a) * color.rgb;

// XXX slice hack. Show diagonal line pattern on slice level
// this could be a normal texture
if (input.texPack[3])
{
float f = sin((input.tex.x - input.tex.y) * 2 * PI);
f = saturate(f);
f *= fadeMult;
color *= 1 - f * 0.5;
}
}

float4 edgecolor = float4(0, 0, 0, 0);
Expand Down
10 changes: 6 additions & 4 deletions Client/MapControl3D/VoxelTerrain/Chunk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public Chunk(EnvironmentObject map, IntVector3 chunkPosition)
}

bool m_scanned;
public bool IsAllEmpty { get; private set; } // XXX public for OutlineRenderer
public bool IsAllUndefined { get; private set; } // XXX public for OutlineRenderer
public bool IsAllEmpty { get; private set; } // XXX public for OutlineRenderer
public bool IsAllUndefined { get; private set; } // XXX public for OutlineRenderer

public string GetVoxelDebug(IntVector3 mp)
{
Expand Down Expand Up @@ -705,9 +705,11 @@ void CreateCube(IntVector3 p, Direction visibleFaces,
SByte4 edges;
GetEdgeHighlightsForFace(p, (DirectionOrdinal)side, out edges);

var tex = side == (int)DirectionOrdinal.PositiveZ ? topTexture : baseTexture;
byte sliceHack = isSliceFace ? (byte)1 : (byte)0;

var vd = new TerrainVertex(v0, v1, v2, v3, occ0, occ1, occ2, occ3,
side == (int)DirectionOrdinal.PositiveZ ? topTexture : baseTexture,
edges);
tex, edges, sliceHack);
vertexList.Add(vd);
}
}
Expand Down
5 changes: 3 additions & 2 deletions Client/MapControl3D/VoxelTerrain/TerrainEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,16 @@ struct TerrainVertex

// vertices in order: top right, bottom right, bottom left, top left
public TerrainVertex(IntVector3 p0, IntVector3 p1, IntVector3 p2, IntVector3 p3,
int occ0, int occ1, int occ2, int occ3, FaceTexture tex, SByte4 edges)
int occ0, int occ1, int occ2, int occ3, FaceTexture tex, SByte4 edges,
byte sliceHack = 0)
{
// last bytes of positions are unused
this.Position0 = new Byte4(p3.X, p3.Y, p3.Z, 0);
this.Position1 = new Byte4(p0.X, p0.Y, p0.Z, 0);
this.Position2 = new Byte4(p2.X, p2.Y, p2.Z, 0);
this.Position3 = new Byte4(p1.X, p1.Y, p1.Z, 0);
this.Occlusion = new Byte4(occ3, occ0, occ2, occ1);
this.TexPack = new Byte4((byte)0, (byte)tex.Symbol1, (byte)tex.Symbol2, (byte)0);
this.TexPack = new Byte4((byte)0, (byte)tex.Symbol1, (byte)tex.Symbol2, sliceHack);
this.ColorPack = new Byte4((byte)tex.Color0, (byte)tex.Color1, (byte)tex.Color2, (byte)0);
this.Edges = edges;
}
Expand Down

0 comments on commit ad8202d

Please sign in to comment.