Raycoms Posted April 21, 2016 Share Posted April 21, 2016 I ran into some pretty interesting rendering glitches in 1.7.10 as well as 1.8.9 in some areas, mostly in snowy biomes. I am at two different points in the same biome. At point 1 everything renders great. I click with my tool on the ground and the whole building renders perfectly. At point 2 everything renders very bad. I click with my tool on the ground and the blocks do not render at all or do render only 2 dimensional. The interesting thing. If I render the building from point 1 at point 2 it will work and also if I render it from point 2 to point 1 it won't. It seems that the position where the command is executed influences the correct or incorrect rendering and not the place where the blocks are actually rendered. Function: public void renderBlocks(int renderPass, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) { IBlockAccess mcWorld = this.minecraft.theWorld; BlockRendererDispatcher renderBlocks = this.settings.renderBlocks; int x, y, z, wx, wy, wz; int sides; Block block, mcBlock; Vector3f zero = new Vector3f(); Vector3f size = new Vector3f(); int ambientOcclusion = this.minecraft.gameSettings.ambientOcclusion; this.minecraft.gameSettings.ambientOcclusion = 0; Tessellator tessellator = Tessellator.getInstance(); WorldRenderer renderer = Tessellator.getInstance().getWorldRenderer(); renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); for (y = minY; y < maxY; y++) { for (z = minZ; z < maxZ; z++) { for (x = minX; x < maxX; x++) { try { block = this.schematic.getBlock(x, y, z); wx = (int) this.settings.offset.x + x; wy = (int) this.settings.offset.y + y; wz = (int) this.settings.offset.z + z; BlockPos pos = new BlockPos(x, y, z); BlockPos wPos = new BlockPos(wx, wy, wz); mcBlock = mcWorld.getBlockState(wPos).getBlock(); sides = 0; if (block != null) { if (y-1 > minY && block.shouldSideBeRendered(this.schematic, pos.down(), EnumFacing.DOWN)) { sides |= RenderHelper.QUAD_DOWN; } if (y+1 < maxY && block.shouldSideBeRendered(this.schematic, pos.up(), EnumFacing.UP)) { sides |= RenderHelper.QUAD_UP; } if (z-1 > minZ && block.shouldSideBeRendered(this.schematic, pos.north(), EnumFacing.NORTH)) { sides |= RenderHelper.QUAD_NORTH; } if (z+1 < maxZ && block.shouldSideBeRendered(this.schematic, pos.south(), EnumFacing.SOUTH)) { sides |= RenderHelper.QUAD_SOUTH; } if (x-1 > minX && block.shouldSideBeRendered(this.schematic, pos.west(), EnumFacing.WEST)) { sides |= RenderHelper.QUAD_WEST; } if (x+1 < maxX && block.shouldSideBeRendered(this.schematic, pos.east(), EnumFacing.EAST)) { sides |= RenderHelper.QUAD_EAST; } } boolean isAirBlock = mcWorld.isAirBlock(wPos); if (!isAirBlock && mcBlock != Blocks.snow_layer) { if (Config.highlight && renderPass == 2) { if (block == Blocks.air && Config.highlightAir) { zero.set(x, y, z); size.set(x + 1, y + 1, z + 1); if (Config.drawQuads) { RenderHelper.drawCuboidSurface(zero, size, RenderHelper.QUAD_ALL, 0.75f, 0.0f, 0.75f, 0.25f); } if (Config.drawLines) { RenderHelper.drawCuboidOutline(zero, size, RenderHelper.LINE_ALL, 0.75f, 0.0f, 0.75f, 0.25f); } } else if (block != mcBlock) { zero.set(x, y, z); size.set(x + 1, y + 1, z + 1); if (Config.drawQuads) { RenderHelper.drawCuboidSurface(zero, size, sides, 1.0f, 0.0f, 0.0f, 0.25f); } if (Config.drawLines) { RenderHelper.drawCuboidOutline(zero, size, sides, 1.0f, 0.0f, 0.0f, 0.25f); } } else if (this.schematic.getBlockState(pos) != mcWorld.getBlockState(wPos)) { zero.set(x, y, z); size.set(x + 1, y + 1, z + 1); if (Config.drawQuads) { RenderHelper.drawCuboidSurface(zero, size, sides, 0.75f, 0.35f, 0.0f, 0.25f); } if (Config.drawLines) { RenderHelper.drawCuboidOutline(zero, size, sides, 0.75f, 0.35f, 0.0f, 0.25f); } } } } else if (block != Blocks.air) { if (Config.highlight && renderPass == 2) { zero.set(x, y, z); size.set(x + 1, y + 1, z + 1); if (Config.drawQuads) { RenderHelper.drawCuboidSurface(zero, size, sides, 0.0f, 0.75f, 1.0f, 0.25f); } if (Config.drawLines) { RenderHelper.drawCuboidOutline(zero, size, sides, 0.0f, 0.75f, 1.0f, 0.25f); } } if (block != null && block.getBlockLayer().ordinal() == renderPass && block != Blocks.wooden_pressure_plate) { renderBlocks.renderBlock(this.schematic.getBlockState(new BlockPos(x,y,z)), new BlockPos(x,y,z), mcWorld, renderer); } } } catch (Exception e) { Log.logger.error("Failed to render block!", e); } } } } tessellator.draw(); this.minecraft.gameSettings.ambientOcclusion = ambientOcclusion; } Whole code: https://bitbucket.org/cltnschlosser/minecolonies/src/af6bc4ceddc5c7f6e7a60e3dde9f0c95424f9b57/src/main/java/com/schematica/client/renderer/RendererSchematicChunk.java?at=master&fileviewer=file-view-default This code is executed from a "build-tool" which has a GUI with buttons to execute the rendering. Here it is rendered correctly (When rendering from the top green block) https://www.dropbox.com/s/2jgh2yt5lashghj/2016-04-21_20.40.47.png?dl=0 Here it is rendered incorrectly (When rendering from the top red block) https://www.dropbox.com/s/ye9scw4t7rfphdd/2016-04-21_20.41.10.png?dl=0 Here is it rendered correctly(When rendering from the top green block) https://www.dropbox.com/s/wmfaqdlqbur5igo/2016-04-21_20.41.24.png?dl=0 and here again rendered incorrectly(Rendered from the top red block) https://www.dropbox.com/s/rmri3stuib9x5os/2016-04-21_20.41.40.png?dl=0 Quote Link to comment Share on other sites More sharing options...
Raycoms Posted April 22, 2016 Author Share Posted April 22, 2016 This is only reproducible in some random places but easily in any biome with ice/snow. Outside of this particular places, the rendering works perfectly well and even inside the snow biomes, in about 20-50% of the area the rendering works well. Quote Link to comment Share on other sites More sharing options...
Bektor Posted April 23, 2016 Share Posted April 23, 2016 Anyone with an idea? Quote Developer of Primeval Forest. Link to comment Share on other sites More sharing options...
Raycoms Posted April 24, 2016 Author Share Posted April 24, 2016 Through further debugging I found out that the problem seems to be that in the ForgeBlockModelRenderer class in the following method the quads always empty is and the render method, therefore, mostly returns false. It seems that for some blocks the method returns true but if(!quads.isEmpty() && (!checkSides || block.shouldSideBeRendered(world, pos.offset(side), side))) returns false and that is why these mods are rendered 2 dimensionally. It seems like block.shouldSideBeRendered returns a bad result and that's why sometimes a few sides are rendered and some other times no side at all. But, it is strange that the floor blocks are rendered 2 dimensionally but the others not. The stairs, torches and fence posts are rendered correctly because they have a EnumFacing. public static boolean render(VertexLighterFlat lighter, IBlockAccess world, IBakedModel model, Block block, BlockPos pos, WorldRenderer wr, boolean checkSides) { lighter.setWorld(world); lighter.setBlock(block); lighter.setBlockPos(pos); boolean empty = true; List quads = model.getGeneralQuads(); if(!quads.isEmpty()) { lighter.updateBlockInfo(); empty = false; Iterator var9 = quads.iterator(); while(var9.hasNext()) { BakedQuad quad = (BakedQuad)var9.next(); quad.pipe(lighter); } } EnumFacing[] var15 = EnumFacing.values(); int var16 = var15.length; for(int var11 = 0; var11 < var16; ++var11) { EnumFacing side = var15[var11]; quads = model.getFaceQuads(side); if(!quads.isEmpty() && (!checkSides || block.shouldSideBeRendered(world, pos.offset(side), side))) { if(empty) { lighter.updateBlockInfo(); } empty = false; Iterator var13 = quads.iterator(); while(var13.hasNext()) { BakedQuad quad1 = (BakedQuad)var13.next(); quad1.pipe(lighter); } } } return !empty; } It seems like these rendering issues come from a point where there is checked if the block on the side is opaque to decide if the block should be rendered and in some strange way, this is sometimes true when it should be false. But I have no Idea why this depends on the position and mostly happens in snow biomes. Quote Link to comment Share on other sites More sharing options...
Raycoms Posted May 3, 2016 Author Share Posted May 3, 2016 I am still running into this problem, today it happened in an island biome. Quote Link to comment Share on other sites More sharing options...
Raycoms Posted May 3, 2016 Author Share Posted May 3, 2016 Exactly these schematics we're rendering. (With his permission of course) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.