diff --git a/client/src/main/java/client/renderer/Renderer.java b/client/src/main/java/client/renderer/Renderer.java index c8052e6a..07df4773 100755 --- a/client/src/main/java/client/renderer/Renderer.java +++ b/client/src/main/java/client/renderer/Renderer.java @@ -3468,6 +3468,7 @@ public class Renderer { boolean up = blockliquid.canRender(blockAccess, blockPosIn.up(), Facing.UP); boolean down = blockliquid.canRender(blockAccess, blockPosIn.down(), Facing.DOWN); boolean[] aboolean = new boolean[] {blockliquid.canRender(blockAccess, blockPosIn.north(), Facing.NORTH), blockliquid.canRender(blockAccess, blockPosIn.south(), Facing.SOUTH), blockliquid.canRender(blockAccess, blockPosIn.west(), Facing.WEST), blockliquid.canRender(blockAccess, blockPosIn.east(), Facing.EAST)}; + float shine = (blockliquid.getShinyness() / 32.0f) * 0.5f; if (!up && !down && !aboolean[0] && !aboolean[1] && !aboolean[2] && !aboolean[3]) { @@ -3538,17 +3539,17 @@ public class Renderer { 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, 0.5F).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, 0.5F).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, 0.5F).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, 0.5F).tex((double)f16, (double)f20).lightmap(l2, i3).endVertex(); + 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(); if (blockliquid.shouldRenderSides(blockAccess, blockPosIn.up())) { - worldRendererIn.pos(d0 + 0.0D, d1 + (double)f7, d2 + 0.0D).color(0.0f, 1.0f, 0.0f, 0.5F).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, 0.5F).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, 0.5F).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, 0.5F).tex((double)f14, (double)f18).lightmap(l2, i3).endVertex(); + 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(); } } @@ -3561,10 +3562,10 @@ public class Renderer { 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, 0.25F).tex((double)f35, (double)f38).lightmap(i2, j2).endVertex(); - worldRendererIn.pos(d0, d1, d2).color(0.0f, -1.0f, 0.0f, 0.25F).tex((double)f35, (double)f37).lightmap(i2, j2).endVertex(); - worldRendererIn.pos(d0 + 1.0D, d1, d2).color(0.0f, -1.0f, 0.0f, 0.25F).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, 0.25F).tex((double)f36, (double)f38).lightmap(i2, j2).endVertex(); + 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(); rendered = true; } @@ -3653,15 +3654,14 @@ public class Renderer { int l = j & 65535; float xn = np == 2 ? -1.0f : (np == 3 ? 1.0f : 0.0f); float zn = np == 0 ? -1.0f : (np == 1 ? 1.0f : 0.0f); - float br = np < 2 ? 0.4f : 0.3f; - worldRendererIn.pos(d3, d1 + (double)f39, d4).color(xn, 0.0f, zn, br).tex((double)f41, (double)f28).lightmap(k, l).endVertex(); - worldRendererIn.pos(d5, d1 + (double)f40, d6).color(xn, 0.0f, zn, br).tex((double)f27, (double)f29).lightmap(k, l).endVertex(); - worldRendererIn.pos(d5, d1 + 0.0D, d6).color(xn, 0.0f, zn, br).tex((double)f27, (double)f30).lightmap(k, l).endVertex(); - worldRendererIn.pos(d3, d1 + 0.0D, d4).color(xn, 0.0f, zn, br).tex((double)f41, (double)f30).lightmap(k, l).endVertex(); - worldRendererIn.pos(d3, d1 + 0.0D, d4).color(xn, 0.0f, zn, br).tex((double)f41, (double)f30).lightmap(k, l).endVertex(); - worldRendererIn.pos(d5, d1 + 0.0D, d6).color(xn, 0.0f, zn, br).tex((double)f27, (double)f30).lightmap(k, l).endVertex(); - worldRendererIn.pos(d5, d1 + (double)f40, d6).color(xn, 0.0f, zn, br).tex((double)f27, (double)f29).lightmap(k, l).endVertex(); - worldRendererIn.pos(d3, d1 + (double)f39, d4).color(xn, 0.0f, zn, br).tex((double)f41, (double)f28).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(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(); } } diff --git a/client/src/main/java/client/renderer/Shader.java b/client/src/main/java/client/renderer/Shader.java index d9c77703..c9368669 100644 --- a/client/src/main/java/client/renderer/Shader.java +++ b/client/src/main/java/client/renderer/Shader.java @@ -23,7 +23,7 @@ import common.util.Vector3f; import common.util.Vector4f; public enum Shader { - WORLD("world", "world", context -> {context.integer("tex", 0); context.integer("lightmap", 1); /* GL46.glUniformBlockBinding(context.getProgram(), GL46.glGetUniformBlockIndex(context.getProgram(), "light_block"), 0); */}, context -> { + WORLD("world", "world", context -> {context.integer("tex", 0); /* GL46.glUniformBlockBinding(context.getProgram(), GL46.glGetUniformBlockIndex(context.getProgram(), "light_block"), 0); */}, context -> { context.vec("clip_near", Client.CLIENT.renderer.getNearPlane()); context.vec("clip_far", Client.CLIENT.renderer.getFarPlane()); context.vec("screen", (float)Client.CLIENT.fbRawX, (float)Client.CLIENT.fbRawY); @@ -51,8 +51,6 @@ public enum Shader { context.integer("n_lights", 0); context.color3("specular", 0xffffff); - context.vec("shine", 1.0f); - // context.vec("density", density); GlState.setActiveTexture(GL46.GL_TEXTURE0); // glBindBufferBase(GL_UNIFORM_BUFFER, 0, world->light_buf); diff --git a/client/src/main/java/client/renderer/blockmodel/FaceBakery.java b/client/src/main/java/client/renderer/blockmodel/FaceBakery.java index 23c04ebe..1d72ca77 100755 --- a/client/src/main/java/client/renderer/blockmodel/FaceBakery.java +++ b/client/src/main/java/client/renderer/blockmodel/FaceBakery.java @@ -73,9 +73,9 @@ public class FaceBakery FACINGS[Constants.EAST_INDEX] = EnumFaceDirection.EAST; } - public BakedQuad makeBakedQuad(Vector3f posFrom, Vector3f posTo, BlockPartFace face, Sprite sprite, Facing facing, ModelRotation modelRotationIn, BlockPartRotation partRotation, boolean uvLocked, boolean shade) + public BakedQuad makeBakedQuad(Vector3f posFrom, Vector3f posTo, BlockPartFace face, Sprite sprite, Facing facing, ModelRotation modelRotationIn, BlockPartRotation partRotation, boolean uvLocked, boolean shade, float shine) { - int[] aint = this.makeQuadVertexData(face, sprite, facing, this.getPositionsDiv16(posFrom, posTo), modelRotationIn, partRotation, uvLocked, shade); + int[] aint = this.makeQuadVertexData(face, sprite, facing, this.getPositionsDiv16(posFrom, posTo), modelRotationIn, partRotation, uvLocked, shade, shine); Facing enumfacing = getFacingFromVertexData(aint); if (uvLocked) @@ -91,13 +91,13 @@ public class FaceBakery return new BakedQuad(aint, face.tint, enumfacing); } - private int[] makeQuadVertexData(BlockPartFace partFace, Sprite sprite, Facing facing, float[] p_178405_4_, ModelRotation modelRotationIn, BlockPartRotation partRotation, boolean uvLocked, boolean shade) + private int[] makeQuadVertexData(BlockPartFace partFace, Sprite sprite, Facing facing, float[] p_178405_4_, ModelRotation modelRotationIn, BlockPartRotation partRotation, boolean uvLocked, boolean shade, float shine) { int[] aint = new int[28]; for (int i = 0; i < 4; ++i) { - this.fillVertexData(aint, i, facing, partFace, p_178405_4_, sprite, modelRotationIn, partRotation, uvLocked, shade); + this.fillVertexData(aint, i, facing, partFace, p_178405_4_, sprite, modelRotationIn, partRotation, uvLocked, shade, shine); } return aint; @@ -105,7 +105,7 @@ public class FaceBakery private int getFaceShadeColor(Facing facing) { - return this.getFaceBrightness(facing) << 24 | this.getFaceNormal(facing); + return this.getFaceNormal(facing); } private int getFaceNormal(Facing facing) @@ -128,29 +128,6 @@ public class FaceBakery } } - private int getFaceBrightness(Facing facing) - { - switch (facing) - { - case DOWN: - return 0x3f; - - case UP: - return 0x7f; - - case NORTH: - case SOUTH: - return 0x65; - - case WEST: - case EAST: - return 0x4c; - - default: - return 0x7f; - } - } - private float[] getPositionsDiv16(Vector3f pos1, Vector3f pos2) { float[] afloat = new float[Facing.values().length]; @@ -163,10 +140,10 @@ public class FaceBakery return afloat; } - private void fillVertexData(int[] faceData, int vertexIndex, Facing facing, BlockPartFace partFace, float[] p_178402_5_, Sprite sprite, ModelRotation modelRotationIn, BlockPartRotation partRotation, boolean uvLocked, boolean shade) + private void fillVertexData(int[] faceData, int vertexIndex, Facing facing, BlockPartFace partFace, float[] p_178402_5_, Sprite sprite, ModelRotation modelRotationIn, BlockPartRotation partRotation, boolean uvLocked, boolean shade, float shine) { Facing enumfacing = modelRotationIn.rotateFace(facing); - int i = shade ? this.getFaceShadeColor(enumfacing) : 0x7f000000; + int i = (int)((shine / 32.0f) * 127.0f) << 24 | (shade ? this.getFaceShadeColor(enumfacing) : 0x000000); VertexInformation enumfacedirection$vertexinformation = EnumFaceDirection.getFacing(facing).getVertexInformation(vertexIndex); Vector3f vector3f = new Vector3f(p_178402_5_[enumfacedirection$vertexinformation.xIndex], p_178402_5_[enumfacedirection$vertexinformation.yIndex], p_178402_5_[enumfacedirection$vertexinformation.zIndex]); this.rotatePart(vector3f, partRotation); diff --git a/client/src/main/java/client/renderer/blockmodel/ModelBakery.java b/client/src/main/java/client/renderer/blockmodel/ModelBakery.java index e6f7bcf4..ca3e7ba5 100755 --- a/client/src/main/java/client/renderer/blockmodel/ModelBakery.java +++ b/client/src/main/java/client/renderer/blockmodel/ModelBakery.java @@ -61,6 +61,7 @@ public abstract class ModelBakery for(Entry entry : map.entrySet()) { ModelBlock model = (ModelBlock)entry.getKey().getBlock().getModel(provider, BlockRegistry.getName(entry.getKey().getBlock()) .toString(), entry.getKey()); + model.setShinyness(entry.getKey().getBlock().getShinyness()); models.put(entry.getValue(), model); variants.add(entry.getValue()); } @@ -231,9 +232,9 @@ public abstract class ModelBakery sprite = sprite == null ? fallback : sprite; if (face.cull == null) - builder.addGeneralQuad(faceBakery.makeBakedQuad(blockpart.positionFrom, blockpart.positionTo, face, sprite, enumfacing, modelRotationIn, blockpart.partRotation, uvLocked, blockpart.shade)); + builder.addGeneralQuad(faceBakery.makeBakedQuad(blockpart.positionFrom, blockpart.positionTo, face, sprite, enumfacing, modelRotationIn, blockpart.partRotation, uvLocked, blockpart.shade, modelBlockIn.getShinyness())); else - builder.addFaceQuad(modelRotationIn.rotateFace(face.cull), faceBakery.makeBakedQuad(blockpart.positionFrom, blockpart.positionTo, face, sprite, enumfacing, modelRotationIn, blockpart.partRotation, uvLocked, blockpart.shade)); + builder.addFaceQuad(modelRotationIn.rotateFace(face.cull), faceBakery.makeBakedQuad(blockpart.positionFrom, blockpart.positionTo, face, sprite, enumfacing, modelRotationIn, blockpart.partRotation, uvLocked, blockpart.shade, modelBlockIn.getShinyness())); } } return builder.makeBakedModel(); diff --git a/client/src/main/java/client/renderer/blockmodel/ModelBlock.java b/client/src/main/java/client/renderer/blockmodel/ModelBlock.java index e4bc904c..3476e9eb 100755 --- a/client/src/main/java/client/renderer/blockmodel/ModelBlock.java +++ b/client/src/main/java/client/renderer/blockmodel/ModelBlock.java @@ -21,6 +21,7 @@ public class ModelBlock extends Model { private ModelRotation rotation; private boolean uvLock; private GuiPosition transform; + private float shinyness; private BlockPart lastPart; private BlockPartFace[] last; @@ -159,4 +160,12 @@ public class ModelBlock extends Model { public boolean isUvLocked() { return this.uvLock; } + + public void setShinyness(float shinyness) { + this.shinyness = shinyness; + } + + public float getShinyness() { + return this.shinyness; + } } diff --git a/client/src/main/resources/shaders/world.fsh b/client/src/main/resources/shaders/world.fsh index 9a1dc848..02eb7dd1 100644 --- a/client/src/main/resources/shaders/world.fsh +++ b/client/src/main/resources/shaders/world.fsh @@ -12,12 +12,11 @@ in vec3 vertex; in vec3 normal; in vec2 tex_coord; in vec4 light_color; -in float brightness; +in float shine; uniform vec3 cam_pos; uniform sampler2D tex; uniform vec3 specular; -uniform float shine; uniform float max_vert_dist; uniform float max_cam_dist; uniform float light_factor; diff --git a/client/src/main/resources/shaders/world.vsh b/client/src/main/resources/shaders/world.vsh index 59640021..47a4a8d8 100644 --- a/client/src/main/resources/shaders/world.vsh +++ b/client/src/main/resources/shaders/world.vsh @@ -7,7 +7,7 @@ out vec3 vertex; out vec3 normal; out vec2 tex_coord; out vec4 light_color; -out float brightness; +out float shine; uniform mat4 model; uniform mat4 view; @@ -21,7 +21,7 @@ void main() { vec3 nvertex = vec3(model * vec4(pos, 1.0)); vertex = vec3(float(chunk_x) + pos.x, float(chunk_y) + pos.y, float(chunk_z) + pos.z); normal = mat3(transpose(inverse(model))) * norm.rgb; - brightness = norm.a; + shine = norm.a * 32.0; tex_coord = coord; light_color = light; gl_Position = projection * view * vec4(offset + nvertex, 1.0); diff --git a/common/src/main/java/common/block/Block.java b/common/src/main/java/common/block/Block.java index a2c681ef..5d6a2c0e 100755 --- a/common/src/main/java/common/block/Block.java +++ b/common/src/main/java/common/block/Block.java @@ -1075,6 +1075,11 @@ public class Block { return provider.getModel(name).add().all(); } + @Clientside + public float getShinyness() { + return 1.0f; + } + @Clientside public GuiPosition getItemPosition() { return GuiPosition.NORMAL; diff --git a/common/src/main/java/common/block/artificial/BlockGlass.java b/common/src/main/java/common/block/artificial/BlockGlass.java index 6555c913..3cbd7a20 100755 --- a/common/src/main/java/common/block/artificial/BlockGlass.java +++ b/common/src/main/java/common/block/artificial/BlockGlass.java @@ -6,6 +6,7 @@ import common.entity.Entity; import common.item.CheatTab; import common.rng.Random; import common.util.BlockPos; +import common.util.Clientside; import common.util.Facing; import common.util.Serverside; import common.world.AWorldServer; @@ -45,4 +46,9 @@ public class BlockGlass extends Block { world.destroyBlock(pos, true); return false; } + + @Clientside + public float getShinyness() { + return 16.0f; + } } diff --git a/common/src/main/java/common/block/artificial/BlockMetalBlock.java b/common/src/main/java/common/block/artificial/BlockMetalBlock.java index 8d3ec9f0..40d1fe13 100644 --- a/common/src/main/java/common/block/artificial/BlockMetalBlock.java +++ b/common/src/main/java/common/block/artificial/BlockMetalBlock.java @@ -11,6 +11,7 @@ import common.entity.npc.EntityNPC; import common.init.MetalType; import common.item.CheatTab; import common.item.ItemStack; +import common.util.Clientside; public class BlockMetalBlock extends Block { private final MetalType metal; @@ -50,4 +51,9 @@ public class BlockMetalBlock extends Block { if(this.metal.radioactivity > 0.0f) map.put(Attribute.RADIATION, this.metal.radioactivity * 4.0f * 9.0f); } + + @Clientside + public float getShinyness() { + return 32.0f; + } } diff --git a/common/src/main/java/common/block/artificial/BlockPane.java b/common/src/main/java/common/block/artificial/BlockPane.java index 61fefba2..d7e1a5a9 100755 --- a/common/src/main/java/common/block/artificial/BlockPane.java +++ b/common/src/main/java/common/block/artificial/BlockPane.java @@ -17,6 +17,7 @@ import common.properties.PropertyBool; import common.rng.Random; import common.util.BlockPos; import common.util.BoundingBox; +import common.util.Clientside; import common.util.Facing; import common.util.Serverside; import common.world.AWorldServer; @@ -204,6 +205,11 @@ public class BlockPane extends Block return this.material == Material.SOLID ? "iron_bars" : "glass_pane"; } + @Clientside + public float getShinyness() { + return this.material == Material.SOLID ? 4.0f : 16.0f; + } + public Model getModel(ModelProvider provider, String name, State state) { boolean n = state.getValue(NORTH); boolean s = state.getValue(SOUTH); diff --git a/common/src/main/java/common/block/artificial/BlockStainedGlassPane.java b/common/src/main/java/common/block/artificial/BlockStainedGlassPane.java index 79af4e33..fcca3377 100755 --- a/common/src/main/java/common/block/artificial/BlockStainedGlassPane.java +++ b/common/src/main/java/common/block/artificial/BlockStainedGlassPane.java @@ -3,6 +3,7 @@ package common.block.artificial; import common.block.Material; import common.item.CheatTab; import common.properties.Property; +import common.util.Clientside; import common.util.Color; public class BlockStainedGlassPane extends BlockPane @@ -40,4 +41,9 @@ public class BlockStainedGlassPane extends BlockPane protected String getPaneEdge() { return this.color.getName() + "_glass_pane"; } + + @Clientside + public float getShinyness() { + return 16.0f; + } }