Fix shadows on map water sides (Thanks Lemon), fix liquids being offset incorrectly.

This commit is contained in:
UnknownShadow200 2016-02-20 00:00:39 +11:00
parent 19d9c182c3
commit 6f595f81ec
5 changed files with 13 additions and 12 deletions

View File

@ -143,14 +143,14 @@ namespace ClassicalSharp {
public void DrawShadows() { public void DrawShadows() {
if( ShadowMode == EntityShadow.None ) return; if( ShadowMode == EntityShadow.None ) return;
Player.boundShadowTex = false; Player.boundShadowTex = false;
game.Graphics.AlphaTest = false;
game.Graphics.AlphaArgBlend = true; game.Graphics.AlphaArgBlend = true;
game.Graphics.AlphaTestFunc( CompareFunc.Greater, 0.05f );
Players[255].DrawShadow( ShadowMode ); Players[255].DrawShadow( ShadowMode );
if( ShadowMode == EntityShadow.CircleAll ) if( ShadowMode == EntityShadow.CircleAll )
DrawOtherShadows(); DrawOtherShadows();
game.Graphics.AlphaTest = true;
game.Graphics.AlphaArgBlend = false; game.Graphics.AlphaArgBlend = false;
game.Graphics.AlphaTestFunc( CompareFunc.Greater, 0.5f );
} }
void DrawOtherShadows() { void DrawOtherShadows() {

View File

@ -98,8 +98,11 @@ namespace ClassicalSharp {
} }
byte GetShadowBlock( int x, int y, int z ) { byte GetShadowBlock( int x, int y, int z ) {
if( x < 0 || z < 0 || x >= game.Map.Width || z >= game.Map.Length ) if( x < 0 || z < 0 || x >= game.Map.Width || z >= game.Map.Length ) {
return y == (game.Map.SidesHeight - 1) ? (byte)game.Map.SidesBlock : (byte)0; if (y == game.Map.EdgeHeight - 1) return (byte)game.Map.EdgeBlock;
if (y == game.Map.SidesHeight - 1) return (byte)game.Map.SidesBlock;
return (byte)Block.Air;
}
return game.Map.GetBlock( x, y, z ); return game.Map.GetBlock( x, y, z );
} }

View File

@ -357,7 +357,7 @@ namespace ClassicalSharp {
public void SetNewScreen( Screen screen ) { SetNewScreen( screen, true ); } public void SetNewScreen( Screen screen ) { SetNewScreen( screen, true ); }
public void SetNewScreen( Screen screen, bool disposeOld ) { public void SetNewScreen( Screen screen, bool disposeOld ) {
// don't switch to the new screen immediately if the user // Don't switch to the new screen immediately if the user
// is currently looking at a warning dialog. // is currently looking at a warning dialog.
if( activeScreen is WarningScreen ) { if( activeScreen is WarningScreen ) {
WarningScreen warning = (WarningScreen)activeScreen; WarningScreen warning = (WarningScreen)activeScreen;

View File

@ -144,7 +144,7 @@ namespace ClassicalSharp {
x2 = x + max.X; y2 = y + max.Y; z2 = z + max.Z; x2 = x + max.X; y2 = y + max.Y; z2 = z + max.Z;
if( isTranslucent && info.CollideType[tile] != BlockCollideType.Solid ) { if( isTranslucent && info.CollideType[tile] != BlockCollideType.Solid ) {
x1 -= 0.1f/16; x2 -= 0.1f/16f; z1 -= 0.1f/16f; z2 -= 0.1f/16f; x1 -= 0.1f/16; x2 -= 0.1f/16f; z1 -= 0.1f/16f; z2 -= 0.1f/16f;
y1 += 0.1f/16; y2 += 0.1f/16f; y1 -= 0.1f/16; y2 -= 0.1f/16f;
} }
this.minBB = min; this.maxBB = max; this.minBB = min; this.maxBB = max;
minBB.Y = 1 - minBB.Y; maxBB.Y = 1 - maxBB.Y; minBB.Y = 1 - minBB.Y; maxBB.Y = 1 - maxBB.Y;

View File

@ -55,8 +55,7 @@ namespace ClassicalSharp {
bool underWater = camPos.Y < game.Map.EdgeHeight; bool underWater = camPos.Y < game.Map.EdgeHeight;
graphics.AlphaBlending = true; graphics.AlphaBlending = true;
game.Players.DrawShadows(); game.Players.DrawShadows();
if( underWater ) if( underWater ) game.WeatherRenderer.Render( deltaTime );
game.WeatherRenderer.Render( deltaTime );
graphics.BindTexture( edgeTexId ); graphics.BindTexture( edgeTexId );
graphics.BindVb( edgesVb ); graphics.BindVb( edgesVb );
@ -66,8 +65,7 @@ namespace ClassicalSharp {
if( game.Map.EdgeBlock != Block.Air && camPos.Y >= yVisible ) if( game.Map.EdgeBlock != Block.Air && camPos.Y >= yVisible )
graphics.DrawIndexedVb_TrisT2fC4b( edgesVertices * 6 / 4, 0 ); graphics.DrawIndexedVb_TrisT2fC4b( edgesVertices * 6 / 4, 0 );
if( !underWater ) if( !underWater ) game.WeatherRenderer.Render( deltaTime );
game.WeatherRenderer.Render( deltaTime );
graphics.AlphaBlending = false; graphics.AlphaBlending = false;
graphics.Texturing = false; graphics.Texturing = false;
graphics.AlphaTest = false; graphics.AlphaTest = false;
@ -175,7 +173,7 @@ namespace ClassicalSharp {
fullColEdge = game.BlockInfo.FullBright[(byte)game.Map.EdgeBlock]; fullColEdge = game.BlockInfo.FullBright[(byte)game.Map.EdgeBlock];
FastColour col = fullColEdge ? FastColour.White : map.Sunlight; FastColour col = fullColEdge ? FastColour.White : map.Sunlight;
foreach( Rectangle rec in rects ) { foreach( Rectangle rec in rects ) {
DrawY( rec.X, rec.Y, rec.X + rec.Width, rec.Y + rec.Height, waterLevel, axisSize, col, ref vertices ); DrawY( rec.X, rec.Y, rec.X + rec.Width, rec.Y + rec.Height, waterLevel - 0.1f/16f, axisSize, col, ref vertices );
} }
edgesVb = graphics.CreateVb( ptr, VertexFormat.Pos3fTex2fCol4b, edgesVertices ); edgesVb = graphics.CreateVb( ptr, VertexFormat.Pos3fTex2fCol4b, edgesVertices );
} }
@ -218,7 +216,7 @@ namespace ClassicalSharp {
} }
} }
void DrawY( int x1, int z1, int x2, int z2, int y, int axisSize, FastColour col, ref VertexPos3fTex2fCol4b* vertices ) { void DrawY( int x1, int z1, int x2, int z2, float y, int axisSize, FastColour col, ref VertexPos3fTex2fCol4b* vertices ) {
int endX = x2, endZ = z2, startZ = z1; int endX = x2, endZ = z2, startZ = z1;
for( ; x1 < endX; x1 += axisSize ) { for( ; x1 < endX; x1 += axisSize ) {
x2 = x1 + axisSize; x2 = x1 + axisSize;