diff --git a/client/src/main/java/client/Client.java b/client/src/main/java/client/Client.java index 3f5a9e80..25d722aa 100755 --- a/client/src/main/java/client/Client.java +++ b/client/src/main/java/client/Client.java @@ -737,6 +737,8 @@ public class Client implements IThreadListener { public boolean specularColors = true; @Variable(name = "gl_flat_shading", category = CVarCategory.RENDER, display = "Flaches Shading") public boolean flatShading = false; + @Variable(name = "gl_use_shader", category = CVarCategory.RENDER, display = "Shader verwenden") + public boolean useShader = false; public static final Client CLIENT = new Client(); diff --git a/client/src/main/java/client/gui/options/GuiGraphics.java b/client/src/main/java/client/gui/options/GuiGraphics.java index addfcd65..b56a9316 100644 --- a/client/src/main/java/client/gui/options/GuiGraphics.java +++ b/client/src/main/java/client/gui/options/GuiGraphics.java @@ -26,11 +26,12 @@ public class GuiGraphics extends GuiOptions { this.addSelector("gl_dynlight_viewdist", 0, 200, 240, 0); this.addSelector("gl_dynlight_maxdist", 242, 200, 240, 0); - - this.addSelector("gl_light_blend", 0, 220, 240, 0); - this.addSelector("gl_specular", 242, 220, 240, 0); - this.addSelector("gl_flat_shading", 0, 240, 240, 0); + this.addSelector("gl_use_shader", 0, 220, 240, 0); + this.addSelector("gl_light_blend", 242, 220, 240, 0); + + this.addSelector("gl_specular", 0, 240, 240, 0); + this.addSelector("gl_flat_shading", 242, 240, 240, 0); this.addSelector("gl_tex_filter", 0, 260, 240, 0); this.addSelector("gl_tex_mipmaps", 242, 260, 240, 0); diff --git a/client/src/main/java/client/renderer/DefaultVertexFormats.java b/client/src/main/java/client/renderer/DefaultVertexFormats.java index 60ade6a6..b1358903 100755 --- a/client/src/main/java/client/renderer/DefaultVertexFormats.java +++ b/client/src/main/java/client/renderer/DefaultVertexFormats.java @@ -3,6 +3,7 @@ package client.renderer; public class DefaultVertexFormats { public static final VertexFormat BLOCK = new VertexFormat(); + public static final VertexFormat BLOCK_SHADED = new VertexFormat(); public static final VertexFormat ITEM = new VertexFormat(); public static final VertexFormat OLDMODEL_POSITION_TEX_NORMAL = new VertexFormat(); public static final VertexFormat PARTICLE_POSITION_TEX_COLOR_LMAP = new VertexFormat(); @@ -18,14 +19,15 @@ public class DefaultVertexFormats public static final VertexFormatElement TEX_2F = new VertexFormatElement(0, VertexFormatElement.EnumType.FLOAT, VertexFormatElement.EnumUsage.UV, 2); public static final VertexFormatElement TEX_2S = new VertexFormatElement(1, VertexFormatElement.EnumType.SHORT, VertexFormatElement.EnumUsage.UV, 2); public static final VertexFormatElement NORMAL_3B = new VertexFormatElement(0, VertexFormatElement.EnumType.BYTE, VertexFormatElement.EnumUsage.NORMAL, 3); + public static final VertexFormatElement NORMAL_4B = new VertexFormatElement(0, VertexFormatElement.EnumType.BYTE, VertexFormatElement.EnumUsage.NORMAL, 4); public static final VertexFormatElement PADDING_1B = new VertexFormatElement(0, VertexFormatElement.EnumType.BYTE, VertexFormatElement.EnumUsage.PADDING, 1); static { - BLOCK.addElement(POSITION_3F); - BLOCK.addElement(COLOR_4UB); - BLOCK.addElement(TEX_2F); - BLOCK.addElement(TEX_2S); + BLOCK_SHADED.addElement(POSITION_3F); + BLOCK_SHADED.addElement(NORMAL_4B); + BLOCK_SHADED.addElement(TEX_2F); + BLOCK_SHADED.addElement(COLOR_4UB); ITEM.addElement(POSITION_3F); ITEM.addElement(COLOR_4UB); ITEM.addElement(TEX_2F); diff --git a/client/src/main/java/client/renderer/RenderBuffer.java b/client/src/main/java/client/renderer/RenderBuffer.java index 8def53f3..cc4c095d 100755 --- a/client/src/main/java/client/renderer/RenderBuffer.java +++ b/client/src/main/java/client/renderer/RenderBuffer.java @@ -406,6 +406,19 @@ public class RenderBuffer return this; } + public RenderBuffer normal(float x, float y, float z, float shine) + { + int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex); + + this.byteBuffer.put(i, (byte)((int)x * 127 & 255)); + this.byteBuffer.put(i + 1, (byte)((int)y * 127 & 255)); + this.byteBuffer.put(i + 2, (byte)((int)z * 127 & 255)); + this.byteBuffer.put(i + 3, (byte)((int)(shine / 32.0f) * 127 & 255)); + + this.nextVertexFormatIndex(); + return this; + } + public void setTranslation(double x, double y, double z) { this.xOffset = x; diff --git a/client/src/main/java/client/renderer/Renderer.java b/client/src/main/java/client/renderer/Renderer.java index 4387878d..6c798dee 100755 --- a/client/src/main/java/client/renderer/Renderer.java +++ b/client/src/main/java/client/renderer/Renderer.java @@ -107,7 +107,8 @@ public class Renderer { private static final float FOG_DISTANCE = 0.4f; private static final float SQRT_2 = ExtMath.sqrtf(2.0F); private static final float[] SUN_COLOR = new float[4]; - private static final float[] BRIGHTNESS = new float[] {0.0f, 0.02f, 0.04f, 0.06f, 0.08f, 0.11f, 0.14f, 0.18f, 0.22f, 0.27f, 0.33f, 0.41f, 0.5f, 0.62f, 0.78f, 1.0f}; + private static final float[] BRIGHTNESS = {0.0f, 0.02f, 0.04f, 0.06f, 0.08f, 0.11f, 0.14f, 0.18f, 0.22f, 0.27f, 0.33f, 0.41f, 0.5f, 0.62f, 0.78f, 1.0f}; + private static final Facing[] LIQUID_FACINGS = {Facing.NORTH, Facing.SOUTH, Facing.WEST, Facing.EAST}; private final Client gm; private final Random rng = new Random(); @@ -2547,73 +2548,145 @@ public class Renderer { this.renderChunks.add(renderchunk); } } - GlState.setActiveTexture(GL46.GL_TEXTURE1); - GL46.glMatrixMode(GL46.GL_TEXTURE); - GL46.glLoadIdentity(); - GL46.glMatrixMode(GL46.GL_MODELVIEW); - this.gm.getTextureManager().bindTexture(TEX_LIGHTMAP); - GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_MIN_FILTER, GL46.GL_LINEAR); - GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_MAG_FILTER, GL46.GL_LINEAR); - GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_WRAP_S, GL46.GL_CLAMP); - GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_WRAP_T, GL46.GL_CLAMP); - GlState.color(1.0F, 1.0F, 1.0F, 1.0F); - GlState.enableTexture2D(); - GlState.setActiveTexture(GL46.GL_TEXTURE0); - if (this.initialized) - { - ShaderContext context = Shader.WORLD.use(); - boolean moon = false; - for(int color : this.theWorld.dimension.getMoonColors()) { - if((color & 0xff000000) == 0) { - moon = true; - break; - } - } - context.bool("sky_light", this.theWorld.dimension.hasSkyLight() && !this.gm.setGamma && !this.gm.xrayActive); - context.bool("moon_light", moon); - for (RenderChunk renderchunk : this.renderChunks) + if(this.gm.useShader) { + GlState.setActiveTexture(GL46.GL_TEXTURE1); + GL46.glMatrixMode(GL46.GL_TEXTURE); + GL46.glLoadIdentity(); + GL46.glMatrixMode(GL46.GL_MODELVIEW); + this.gm.getTextureManager().bindTexture(TEX_LIGHTMAP); + GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_MIN_FILTER, GL46.GL_LINEAR); + GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_MAG_FILTER, GL46.GL_LINEAR); + GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_WRAP_S, GL46.GL_CLAMP); + GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_WRAP_T, GL46.GL_CLAMP); + GlState.color(1.0F, 1.0F, 1.0F, 1.0F); + GlState.enableTexture2D(); + GlState.setActiveTexture(GL46.GL_TEXTURE0); + + if (this.initialized) + { + ShaderContext context = Shader.WORLD.use(); + boolean moon = false; + for(int color : this.theWorld.dimension.getMoonColors()) { + if((color & 0xff000000) == 0) { + moon = true; + break; + } + } + context.bool("sky_light", this.theWorld.dimension.hasSkyLight() && !this.gm.setGamma && !this.gm.xrayActive); + context.bool("moon_light", moon); + for (RenderChunk renderchunk : this.renderChunks) + { + VertexBuffer vertexbuffer = renderchunk.getVertexBuffer(); + + BlockPos blockpos = renderchunk.getPosition(); + context.vec("offset", (float)((double)blockpos.getX() - this.viewEntityX), (float)((double)blockpos.getY() - this.viewEntityY), (float)((double)blockpos.getZ() - this.viewEntityZ)); + // Vec3 cam = MatrixState.project(Client.CLIENT.getRenderViewEntity(), Client.CLIENT.getTickFraction()); + context.vec("cam_pos", (float)this.viewEntityX, (float)this.viewEntityY + this.gm.player.getEyeHeight(), (float)this.viewEntityZ); + context.matrix("model", renderchunk.getModelviewMatrix()); + context.integer("chunk_x", blockpos.getX()); + context.integer("chunk_y", blockpos.getY()); + context.integer("chunk_z", blockpos.getZ()); + + vertexbuffer.bindBuffer(); + + GL46.glVertexAttribPointer(0, 3, GL46.GL_FLOAT, false, 28, 0L); + GL46.glEnableVertexAttribArray(0); + GL46.glVertexAttribPointer(1, 4, GL46.GL_BYTE, true, 28, 12L); + GL46.glEnableVertexAttribArray(1); + GL46.glVertexAttribPointer(2, 2, GL46.GL_FLOAT, false, 28, 16L); + GL46.glEnableVertexAttribArray(2); + GL46.glVertexAttribPointer(3, 4, GL46.GL_UNSIGNED_BYTE, true, 28, 24L); + GL46.glEnableVertexAttribArray(3); + + vertexbuffer.drawArrays(GL46.GL_QUADS); + + GL46.glDisableVertexAttribArray(0); + GL46.glDisableVertexAttribArray(1); + GL46.glDisableVertexAttribArray(2); + GL46.glDisableVertexAttribArray(3); + } + context.finish(); + + GL46.glBindBuffer(GL46.GL_ARRAY_BUFFER, 0); + GlState.resetColor(); + this.renderChunks.clear(); + } + } + else { + this.gm.renderer.enableLightmap(); + + GL46.glEnableClientState(GL46.GL_VERTEX_ARRAY); + GL46.glClientActiveTexture(GL46.GL_TEXTURE0); + GL46.glEnableClientState(GL46.GL_TEXTURE_COORD_ARRAY); + GL46.glClientActiveTexture(GL46.GL_TEXTURE1); + GL46.glEnableClientState(GL46.GL_TEXTURE_COORD_ARRAY); + GL46.glClientActiveTexture(GL46.GL_TEXTURE0); + GL46.glEnableClientState(GL46.GL_COLOR_ARRAY); + + if (this.initialized) { - VertexBuffer vertexbuffer = renderchunk.getVertexBuffer(); - - BlockPos blockpos = renderchunk.getPosition(); - context.vec("offset", (float)((double)blockpos.getX() - this.viewEntityX), (float)((double)blockpos.getY() - this.viewEntityY), (float)((double)blockpos.getZ() - this.viewEntityZ)); - // Vec3 cam = MatrixState.project(Client.CLIENT.getRenderViewEntity(), Client.CLIENT.getTickFraction()); - context.vec("cam_pos", (float)this.viewEntityX, (float)this.viewEntityY + this.gm.player.getEyeHeight(), (float)this.viewEntityZ); - context.matrix("model", renderchunk.getModelviewMatrix()); - context.integer("chunk_x", blockpos.getX()); - context.integer("chunk_y", blockpos.getY()); - context.integer("chunk_z", blockpos.getZ()); - - vertexbuffer.bindBuffer(); + for (RenderChunk renderchunk : this.renderChunks) + { + VertexBuffer vertexbuffer = renderchunk.getVertexBuffer(); + GL46.glPushMatrix(); + this.preRenderChunk(renderchunk); + GL46.glMultMatrixf(renderchunk.getModelviewMatrix()); + vertexbuffer.bindBuffer(); + this.setupArrayPointers(); + vertexbuffer.drawArrays(GL46.GL_QUADS); + GL46.glPopMatrix(); + } - GL46.glVertexAttribPointer(0, 3, GL46.GL_FLOAT, false, 28, 0L); - GL46.glEnableVertexAttribArray(0); - GL46.glVertexAttribPointer(1, 4, GL46.GL_BYTE, true, 28, 12L); - GL46.glEnableVertexAttribArray(1); - GL46.glVertexAttribPointer(2, 2, GL46.GL_FLOAT, false, 28, 16L); - GL46.glEnableVertexAttribArray(2); - GL46.glVertexAttribPointer(3, 4, GL46.GL_UNSIGNED_BYTE, true, 28, 24L); - GL46.glEnableVertexAttribArray(3); - - vertexbuffer.drawArrays(GL46.GL_QUADS); - - GL46.glDisableVertexAttribArray(0); - GL46.glDisableVertexAttribArray(1); - GL46.glDisableVertexAttribArray(2); - GL46.glDisableVertexAttribArray(3); + GL46.glBindBuffer(GL46.GL_ARRAY_BUFFER, 0); + GlState.resetColor(); + this.renderChunks.clear(); } - context.finish(); - GL46.glBindBuffer(GL46.GL_ARRAY_BUFFER, 0); - GlState.resetColor(); - this.renderChunks.clear(); + for (VertexFormatElement vertexformatelement : DefaultVertexFormats.BLOCK.getElements()) + { + VertexFormatElement.EnumUsage vertexformatelement$enumusage = vertexformatelement.usage(); + int s = vertexformatelement.index(); + + switch (vertexformatelement$enumusage) + { + case POSITION: + GL46.glDisableClientState(GL46.GL_VERTEX_ARRAY); + break; + + case UV: + GL46.glClientActiveTexture(GL46.GL_TEXTURE0 + s); + GL46.glDisableClientState(GL46.GL_TEXTURE_COORD_ARRAY); + GL46.glClientActiveTexture(GL46.GL_TEXTURE0); + break; + + case COLOR: + GL46.glDisableClientState(GL46.GL_COLOR_ARRAY); + GlState.resetColor(); + } + } } this.gm.renderer.disableLightmap(); return l; } + private void setupArrayPointers() + { + GL46.nglVertexPointer(3, GL46.GL_FLOAT, 28, 0L); + GL46.nglColorPointer(4, GL46.GL_UNSIGNED_BYTE, 28, 12L); + GL46.glTexCoordPointer(2, GL46.GL_FLOAT, 28, 16L); + GL46.glClientActiveTexture(GL46.GL_TEXTURE1); + GL46.glTexCoordPointer(2, GL46.GL_SHORT, 28, 24L); + GL46.glClientActiveTexture(GL46.GL_TEXTURE0); + } + + private void preRenderChunk(RenderChunk renderChunkIn) + { + BlockPos blockpos = renderChunkIn.getPosition(); + GL46.glTranslatef((float)((double)blockpos.getX() - this.viewEntityX), (float)((double)blockpos.getY() - this.viewEntityY), (float)((double)blockpos.getZ() - this.viewEntityZ)); + } + private void renderSkyBox(String texture) { GlState.disableFog(); @@ -3305,16 +3378,45 @@ public class Renderer { } return rendered; } + + private float getFaceBrightness(Facing side) { + switch(side) { + case DOWN: + return 0.5F; + case UP: + default: + return 1.0F; + case NORTH: + case SOUTH: + return 0.8F; + case WEST: + case EAST: + return 0.6F; + } + } - public static int getLightColor(int light) { - return Math.max(Math.max((light >> 16) & 0xff, (light >> 8) & 0xff), light & 0xff) << 24 | (light & 0x00ff00) | ((light >> 16) & 0xff) | ((light & 0xff) << 16); + public int getLightColor(int light, BlockPos pos, Facing side) { + if(this.gm.useShader) + return Math.max(Math.max((light >> 16) & 0xff, (light >> 8) & 0xff), light & 0xff) << 24 | (light & 0x00ff00) | ((light >> 16) & 0xff) | ((light & 0xff) << 16); + + float sky = this.theWorld.dimension.hasSkyLight() && !this.gm.setGamma && !this.gm.xrayActive ? pos.getY() < 0 ? 0.0f : (pos.getY() < 64 ? (float)pos.getY() / 64.0f : 1.0f) : 1.0f; + Vec3 light_color = new Vec3(light); + float shading = getFaceBrightness(side); + float max = (float)Math.max(Math.max((light >> 16) & 0xff, (light >> 8) & 0xff), light & 0xff) / 255.0f; + max = sky * (1.0f - max * this.gm.lightBlend); + float directR = Math.min((float)(light >> 16 & 0xff) / 255.0f + this.sunColorRed * max, 1.0f); + float directG = Math.min((float)(light >> 8 & 0xff) / 255.0f + this.sunColorGreen * max, 1.0f); + float directB = Math.min((float)(light & 0xff) / 255.0f + this.sunColorBlue * max, 1.0f); +// if(moon_light) +// result += calc_dir_light(norm, dir, direct, moon_direction, moon_ambient); + return 0xff000000 | (int)(directR * 255.0f) << 16 | (int)(directG * 255.0f) << 8 | (int)(directB * 255.0f); } public static int componentMax(int lightA, int lightB) { return Math.max((lightA >> 16) & 0xff, (lightB >> 16) & 0xff) << 16 | Math.max((lightA >> 8) & 0xff, (lightB >> 8) & 0xff) << 8 | Math.max(lightA & 0xff, lightB & 0xff); } - private int getLightmapValue(IWorldAccess world, BlockPos pos) { + private int getLightmapValue(IWorldAccess world, BlockPos pos, Facing side) { Block block = world.getState(pos).getBlock(); int light = componentMax(world.getCombinedLight(pos), block.getLight()); if(light == 0 && block instanceof BlockSlab) { @@ -3322,13 +3424,13 @@ public class Renderer { block = world.getState(pos).getBlock(); light = componentMax(world.getCombinedLight(pos), block.getLight()); } - return getLightColor(light); + return getLightColor(light, pos, side); } - private int getLightmapValueLiquid(IWorldAccess world, BlockPos pos) { + private int getLightmapValueLiquid(IWorldAccess world, BlockPos pos, Facing side) { int light = world.getCombinedLight(pos); int up = world.getCombinedLight(pos.up()); - return getLightColor(componentMax(light, up)); + return getLightColor(componentMax(light, up), pos, side); } private void renderModelStandardQuads(IWorldAccess blockAccessIn, Block blockIn, BlockPos blockPosIn, Facing faceIn, int light, boolean ownLight, RenderBuffer worldRendererIn, List listQuadsIn, BitSet boundsFlags) @@ -3342,7 +3444,7 @@ public class Renderer { if (ownLight) { this.fillQuadBounds(blockIn, bakedquad.getVertexData(), bakedquad.getFace(), (float[])null, boundsFlags); - light = boundsFlags.get(0) ? getLightmapValue(blockAccessIn, blockPosIn.offset(bakedquad.getFace())) : getLightmapValue(blockAccessIn, blockPosIn); + light = boundsFlags.get(0) ? getLightmapValue(blockAccessIn, blockPosIn.offset(bakedquad.getFace()), bakedquad.getFace()) : getLightmapValue(blockAccessIn, blockPosIn, bakedquad.getFace()); } worldRendererIn.addVertexData(bakedquad.getVertexData()); @@ -3501,20 +3603,18 @@ public class Renderer { f20 = textureatlassprite.getInterpolatedV((double)(8.0F + (-f22 - f21) * 16.0F)); } - int k2 = getLightmapValueLiquid(blockAccess, blockPosIn); - int l2 = k2 >> 16 & 65535; - int i3 = k2 & 65535; - worldRendererIn.pos(d0 + 0.0D, d1 + (double)f7, d2 + 0.0D).color(0.0f, 1.0f, 0.0f, shine).tex((double)f13, (double)f17).lightmap(l2, i3).endVertex(); - worldRendererIn.pos(d0 + 0.0D, d1 + (double)f8, d2 + 1.0D).color(0.0f, 1.0f, 0.0f, shine).tex((double)f14, (double)f18).lightmap(l2, i3).endVertex(); - worldRendererIn.pos(d0 + 1.0D, d1 + (double)f9, d2 + 1.0D).color(0.0f, 1.0f, 0.0f, shine).tex((double)f15, (double)f19).lightmap(l2, i3).endVertex(); - worldRendererIn.pos(d0 + 1.0D, d1 + (double)f10, d2 + 0.0D).color(0.0f, 1.0f, 0.0f, shine).tex((double)f16, (double)f20).lightmap(l2, i3).endVertex(); + int light = getLightmapValueLiquid(blockAccess, blockPosIn, Facing.UP); + worldRendererIn.pos(d0 + 0.0D, d1 + (double)f7, d2 + 0.0D).normal(0.0f, 1.0f, 0.0f, shine).tex((double)f13, (double)f17).color(light).endVertex(); + worldRendererIn.pos(d0 + 0.0D, d1 + (double)f8, d2 + 1.0D).normal(0.0f, 1.0f, 0.0f, shine).tex((double)f14, (double)f18).color(light).endVertex(); + worldRendererIn.pos(d0 + 1.0D, d1 + (double)f9, d2 + 1.0D).normal(0.0f, 1.0f, 0.0f, shine).tex((double)f15, (double)f19).color(light).endVertex(); + worldRendererIn.pos(d0 + 1.0D, d1 + (double)f10, d2 + 0.0D).normal(0.0f, 1.0f, 0.0f, shine).tex((double)f16, (double)f20).color(light).endVertex(); if (blockliquid.shouldRenderSides(blockAccess, blockPosIn.up())) { - worldRendererIn.pos(d0 + 0.0D, d1 + (double)f7, d2 + 0.0D).color(0.0f, 1.0f, 0.0f, shine).tex((double)f13, (double)f17).lightmap(l2, i3).endVertex(); - worldRendererIn.pos(d0 + 1.0D, d1 + (double)f10, d2 + 0.0D).color(0.0f, 1.0f, 0.0f, shine).tex((double)f16, (double)f20).lightmap(l2, i3).endVertex(); - worldRendererIn.pos(d0 + 1.0D, d1 + (double)f9, d2 + 1.0D).color(0.0f, 1.0f, 0.0f, shine).tex((double)f15, (double)f19).lightmap(l2, i3).endVertex(); - worldRendererIn.pos(d0 + 0.0D, d1 + (double)f8, d2 + 1.0D).color(0.0f, 1.0f, 0.0f, shine).tex((double)f14, (double)f18).lightmap(l2, i3).endVertex(); + worldRendererIn.pos(d0 + 0.0D, d1 + (double)f7, d2 + 0.0D).normal(0.0f, 1.0f, 0.0f, shine).tex((double)f13, (double)f17).color(light).endVertex(); + worldRendererIn.pos(d0 + 1.0D, d1 + (double)f10, d2 + 0.0D).normal(0.0f, 1.0f, 0.0f, shine).tex((double)f16, (double)f20).color(light).endVertex(); + worldRendererIn.pos(d0 + 1.0D, d1 + (double)f9, d2 + 1.0D).normal(0.0f, 1.0f, 0.0f, shine).tex((double)f15, (double)f19).color(light).endVertex(); + worldRendererIn.pos(d0 + 0.0D, d1 + (double)f8, d2 + 1.0D).normal(0.0f, 1.0f, 0.0f, shine).tex((double)f14, (double)f18).color(light).endVertex(); } } @@ -3524,13 +3624,11 @@ public class Renderer { float f36 = atextureatlassprite[0].getMaxU(); float f37 = atextureatlassprite[0].getMinV(); float f38 = atextureatlassprite[0].getMaxV(); - int l1 = getLightmapValueLiquid(blockAccess, blockPosIn.down()); - int i2 = l1 >> 16 & 65535; - int j2 = l1 & 65535; - worldRendererIn.pos(d0, d1, d2 + 1.0D).color(0.0f, -1.0f, 0.0f, shine).tex((double)f35, (double)f38).lightmap(i2, j2).endVertex(); - worldRendererIn.pos(d0, d1, d2).color(0.0f, -1.0f, 0.0f, shine).tex((double)f35, (double)f37).lightmap(i2, j2).endVertex(); - worldRendererIn.pos(d0 + 1.0D, d1, d2).color(0.0f, -1.0f, 0.0f, shine).tex((double)f36, (double)f37).lightmap(i2, j2).endVertex(); - worldRendererIn.pos(d0 + 1.0D, d1, d2 + 1.0D).color(0.0f, -1.0f, 0.0f, shine).tex((double)f36, (double)f38).lightmap(i2, j2).endVertex(); + int light = getLightmapValueLiquid(blockAccess, blockPosIn.down(), Facing.DOWN); + worldRendererIn.pos(d0, d1, d2 + 1.0D).normal(0.0f, -1.0f, 0.0f, shine).tex((double)f35, (double)f38).color(light).endVertex(); + worldRendererIn.pos(d0, d1, d2).normal(0.0f, -1.0f, 0.0f, shine).tex((double)f35, (double)f37).color(light).endVertex(); + worldRendererIn.pos(d0 + 1.0D, d1, d2).normal(0.0f, -1.0f, 0.0f, shine).tex((double)f36, (double)f37).color(light).endVertex(); + worldRendererIn.pos(d0 + 1.0D, d1, d2 + 1.0D).normal(0.0f, -1.0f, 0.0f, shine).tex((double)f36, (double)f38).color(light).endVertex(); rendered = true; } @@ -3614,19 +3712,17 @@ public class Renderer { float f28 = textureatlassprite1.getInterpolatedV((double)((1.0F - f39) * 16.0F * 0.5F)); float f29 = textureatlassprite1.getInterpolatedV((double)((1.0F - f40) * 16.0F * 0.5F)); float f30 = textureatlassprite1.getInterpolatedV(8.0D); - int j = getLightmapValueLiquid(blockAccess, blockpos); - int k = j >> 16 & 65535; - int l = j & 65535; + int light = getLightmapValueLiquid(blockAccess, blockpos, LIQUID_FACINGS[np]); float xn = np == 2 ? -1.0f : (np == 3 ? 1.0f : 0.0f); float zn = np == 0 ? -1.0f : (np == 1 ? 1.0f : 0.0f); - worldRendererIn.pos(d3, d1 + (double)f39, d4).color(xn, 0.0f, zn, shine).tex((double)f41, (double)f28).lightmap(k, l).endVertex(); - worldRendererIn.pos(d5, d1 + (double)f40, d6).color(xn, 0.0f, zn, shine).tex((double)f27, (double)f29).lightmap(k, l).endVertex(); - worldRendererIn.pos(d5, d1 + 0.0D, d6).color(xn, 0.0f, zn, shine).tex((double)f27, (double)f30).lightmap(k, l).endVertex(); - worldRendererIn.pos(d3, d1 + 0.0D, d4).color(xn, 0.0f, zn, shine).tex((double)f41, (double)f30).lightmap(k, l).endVertex(); - worldRendererIn.pos(d3, d1 + 0.0D, d4).color(xn, 0.0f, zn, shine).tex((double)f41, (double)f30).lightmap(k, l).endVertex(); - worldRendererIn.pos(d5, d1 + 0.0D, d6).color(xn, 0.0f, zn, shine).tex((double)f27, (double)f30).lightmap(k, l).endVertex(); - worldRendererIn.pos(d5, d1 + (double)f40, d6).color(xn, 0.0f, zn, shine).tex((double)f27, (double)f29).lightmap(k, l).endVertex(); - worldRendererIn.pos(d3, d1 + (double)f39, d4).color(xn, 0.0f, zn, shine).tex((double)f41, (double)f28).lightmap(k, l).endVertex(); + worldRendererIn.pos(d3, d1 + (double)f39, d4).normal(xn, 0.0f, zn, shine).tex((double)f41, (double)f28).color(light).endVertex(); + worldRendererIn.pos(d5, d1 + (double)f40, d6).normal(xn, 0.0f, zn, shine).tex((double)f27, (double)f29).color(light).endVertex(); + worldRendererIn.pos(d5, d1 + 0.0D, d6).normal(xn, 0.0f, zn, shine).tex((double)f27, (double)f30).color(light).endVertex(); + worldRendererIn.pos(d3, d1 + 0.0D, d4).normal(xn, 0.0f, zn, shine).tex((double)f41, (double)f30).color(light).endVertex(); + worldRendererIn.pos(d3, d1 + 0.0D, d4).normal(xn, 0.0f, zn, shine).tex((double)f41, (double)f30).color(light).endVertex(); + worldRendererIn.pos(d5, d1 + 0.0D, d6).normal(xn, 0.0f, zn, shine).tex((double)f27, (double)f30).color(light).endVertex(); + worldRendererIn.pos(d5, d1 + (double)f40, d6).normal(xn, 0.0f, zn, shine).tex((double)f27, (double)f29).color(light).endVertex(); + worldRendererIn.pos(d3, d1 + (double)f39, d4).normal(xn, 0.0f, zn, shine).tex((double)f41, (double)f28).color(light).endVertex(); } } @@ -3729,20 +3825,18 @@ public class Renderer { f16 = f15; f20 = f17; - int k2 = getLightmapValueLiquid(blockAccess, blockPosIn); - int l2 = k2 >> 16 & 65535; - int i3 = k2 & 65535; - worldRendererIn.pos(d0 + 0.0D, d1 + (double)f7, d2 + 0.0D).color(0.0f, 1.0f, 0.0f, shine).tex((double)f13, (double)f17).lightmap(l2, i3).endVertex(); - worldRendererIn.pos(d0 + 0.0D, d1 + (double)f8, d2 + 1.0D).color(0.0f, 1.0f, 0.0f, shine).tex((double)f14, (double)f18).lightmap(l2, i3).endVertex(); - worldRendererIn.pos(d0 + 1.0D, d1 + (double)f9, d2 + 1.0D).color(0.0f, 1.0f, 0.0f, shine).tex((double)f15, (double)f19).lightmap(l2, i3).endVertex(); - worldRendererIn.pos(d0 + 1.0D, d1 + (double)f10, d2 + 0.0D).color(0.0f, 1.0f, 0.0f, shine).tex((double)f16, (double)f20).lightmap(l2, i3).endVertex(); + int light = getLightmapValueLiquid(blockAccess, blockPosIn, Facing.UP); + worldRendererIn.pos(d0 + 0.0D, d1 + (double)f7, d2 + 0.0D).normal(0.0f, 1.0f, 0.0f, shine).tex((double)f13, (double)f17).color(light).endVertex(); + worldRendererIn.pos(d0 + 0.0D, d1 + (double)f8, d2 + 1.0D).normal(0.0f, 1.0f, 0.0f, shine).tex((double)f14, (double)f18).color(light).endVertex(); + worldRendererIn.pos(d0 + 1.0D, d1 + (double)f9, d2 + 1.0D).normal(0.0f, 1.0f, 0.0f, shine).tex((double)f15, (double)f19).color(light).endVertex(); + worldRendererIn.pos(d0 + 1.0D, d1 + (double)f10, d2 + 0.0D).normal(0.0f, 1.0f, 0.0f, shine).tex((double)f16, (double)f20).color(light).endVertex(); // // if (block.shouldRenderSides(blockAccess, blockPosIn.up())) // { -// worldRendererIn.pos(d0 + 0.0D, d1 + (double)f7, d2 + 0.0D).color(0.0f, 1.0f, 0.0f, shine).tex((double)f13, (double)f17).lightmap(l2, i3).endVertex(); -// worldRendererIn.pos(d0 + 1.0D, d1 + (double)f10, d2 + 0.0D).color(0.0f, 1.0f, 0.0f, shine).tex((double)f16, (double)f20).lightmap(l2, i3).endVertex(); -// worldRendererIn.pos(d0 + 1.0D, d1 + (double)f9, d2 + 1.0D).color(0.0f, 1.0f, 0.0f, shine).tex((double)f15, (double)f19).lightmap(l2, i3).endVertex(); -// worldRendererIn.pos(d0 + 0.0D, d1 + (double)f8, d2 + 1.0D).color(0.0f, 1.0f, 0.0f, shine).tex((double)f14, (double)f18).lightmap(l2, i3).endVertex(); +// worldRendererIn.pos(d0 + 0.0D, d1 + (double)f7, d2 + 0.0D).normal(0.0f, 1.0f, 0.0f, shine).tex((double)f13, (double)f17).color(light).endVertex(); +// worldRendererIn.pos(d0 + 1.0D, d1 + (double)f10, d2 + 0.0D).normal(0.0f, 1.0f, 0.0f, shine).tex((double)f16, (double)f20).color(light).endVertex(); +// worldRendererIn.pos(d0 + 1.0D, d1 + (double)f9, d2 + 1.0D).normal(0.0f, 1.0f, 0.0f, shine).tex((double)f15, (double)f19).color(light).endVertex(); +// worldRendererIn.pos(d0 + 0.0D, d1 + (double)f8, d2 + 1.0D).normal(0.0f, 1.0f, 0.0f, shine).tex((double)f14, (double)f18).color(light).endVertex(); // } } @@ -3752,13 +3846,11 @@ public class Renderer { float f36 = textureatlassprite.getMaxU(); float f37 = textureatlassprite.getMinV(); float f38 = textureatlassprite.getMaxV(); - int l1 = getLightmapValueLiquid(blockAccess, blockPosIn.down()); - int i2 = l1 >> 16 & 65535; - int j2 = l1 & 65535; - worldRendererIn.pos(d0, d1, d2 + 1.0D).color(0.0f, -1.0f, 0.0f, shine).tex((double)f35, (double)f38).lightmap(i2, j2).endVertex(); - worldRendererIn.pos(d0, d1, d2).color(0.0f, -1.0f, 0.0f, shine).tex((double)f35, (double)f37).lightmap(i2, j2).endVertex(); - worldRendererIn.pos(d0 + 1.0D, d1, d2).color(0.0f, -1.0f, 0.0f, shine).tex((double)f36, (double)f37).lightmap(i2, j2).endVertex(); - worldRendererIn.pos(d0 + 1.0D, d1, d2 + 1.0D).color(0.0f, -1.0f, 0.0f, shine).tex((double)f36, (double)f38).lightmap(i2, j2).endVertex(); + int light = getLightmapValueLiquid(blockAccess, blockPosIn.down(), Facing.DOWN); + worldRendererIn.pos(d0, d1, d2 + 1.0D).normal(0.0f, -1.0f, 0.0f, shine).tex((double)f35, (double)f38).color(light).endVertex(); + worldRendererIn.pos(d0, d1, d2).normal(0.0f, -1.0f, 0.0f, shine).tex((double)f35, (double)f37).color(light).endVertex(); + worldRendererIn.pos(d0 + 1.0D, d1, d2).normal(0.0f, -1.0f, 0.0f, shine).tex((double)f36, (double)f37).color(light).endVertex(); + worldRendererIn.pos(d0 + 1.0D, d1, d2 + 1.0D).normal(0.0f, -1.0f, 0.0f, shine).tex((double)f36, (double)f38).color(light).endVertex(); rendered = true; } @@ -3842,19 +3934,17 @@ public class Renderer { float f28 = textureatlassprite1.getInterpolatedV((double)((1.0F - f39) * 16.0F)); float f29 = textureatlassprite1.getInterpolatedV((double)((1.0F - f40) * 16.0F)); float f30 = textureatlassprite1.getInterpolatedV(16.0D); - int j = getLightmapValueLiquid(blockAccess, blockpos); - int k = j >> 16 & 65535; - int l = j & 65535; + int light = getLightmapValueLiquid(blockAccess, blockpos, LIQUID_FACINGS[np]); float xn = np == 2 ? -1.0f : (np == 3 ? 1.0f : 0.0f); float zn = np == 0 ? -1.0f : (np == 1 ? 1.0f : 0.0f); - worldRendererIn.pos(d3, d1 + (double)f39, d4).color(xn, 0.0f, zn, shine).tex((double)f41, (double)f28).lightmap(k, l).endVertex(); - worldRendererIn.pos(d5, d1 + (double)f40, d6).color(xn, 0.0f, zn, shine).tex((double)f27, (double)f29).lightmap(k, l).endVertex(); - worldRendererIn.pos(d5, d1 + 0.0D, d6).color(xn, 0.0f, zn, shine).tex((double)f27, (double)f30).lightmap(k, l).endVertex(); - worldRendererIn.pos(d3, d1 + 0.0D, d4).color(xn, 0.0f, zn, shine).tex((double)f41, (double)f30).lightmap(k, l).endVertex(); - worldRendererIn.pos(d3, d1 + 0.0D, d4).color(xn, 0.0f, zn, shine).tex((double)f41, (double)f30).lightmap(k, l).endVertex(); - worldRendererIn.pos(d5, d1 + 0.0D, d6).color(xn, 0.0f, zn, shine).tex((double)f27, (double)f30).lightmap(k, l).endVertex(); - worldRendererIn.pos(d5, d1 + (double)f40, d6).color(xn, 0.0f, zn, shine).tex((double)f27, (double)f29).lightmap(k, l).endVertex(); - worldRendererIn.pos(d3, d1 + (double)f39, d4).color(xn, 0.0f, zn, shine).tex((double)f41, (double)f28).lightmap(k, l).endVertex(); + worldRendererIn.pos(d3, d1 + (double)f39, d4).normal(xn, 0.0f, zn, shine).tex((double)f41, (double)f28).color(light).endVertex(); + worldRendererIn.pos(d5, d1 + (double)f40, d6).normal(xn, 0.0f, zn, shine).tex((double)f27, (double)f29).color(light).endVertex(); + worldRendererIn.pos(d5, d1 + 0.0D, d6).normal(xn, 0.0f, zn, shine).tex((double)f27, (double)f30).color(light).endVertex(); + worldRendererIn.pos(d3, d1 + 0.0D, d4).normal(xn, 0.0f, zn, shine).tex((double)f41, (double)f30).color(light).endVertex(); + worldRendererIn.pos(d3, d1 + 0.0D, d4).normal(xn, 0.0f, zn, shine).tex((double)f41, (double)f30).color(light).endVertex(); + worldRendererIn.pos(d5, d1 + 0.0D, d6).normal(xn, 0.0f, zn, shine).tex((double)f27, (double)f30).color(light).endVertex(); + worldRendererIn.pos(d5, d1 + (double)f40, d6).normal(xn, 0.0f, zn, shine).tex((double)f27, (double)f29).color(light).endVertex(); + worldRendererIn.pos(d3, d1 + (double)f39, d4).normal(xn, 0.0f, zn, shine).tex((double)f41, (double)f28).color(light).endVertex(); } }