Jump to content

[1.8] [1.7] Rendering glitches in some areas [Unsolved]


Raycoms

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 weeks later...

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • So the default PlayerModel contains this code here to set the players arms to slim   if (pSlim) { $$3.addOrReplaceChild("left_arm", CubeListBuilder.create().texOffs(32, 48).addBox(-1.0F, -2.0F, -2.0F, 3.0F, 12.0F, 4.0F, pCubeDeformation), PartPose.offset(5.0F, 2.5F, 0.0F)); $$3.addOrReplaceChild("right_arm", CubeListBuilder.create().texOffs(40, 16).addBox(-2.0F, -2.0F, -2.0F, 3.0F, 12.0F, 4.0F, pCubeDeformation), PartPose.offset(-5.0F, 2.5F, 0.0F)); $$3.addOrReplaceChild("left_sleeve", CubeListBuilder.create().texOffs(48, 48).addBox(-1.0F, -2.0F, -2.0F, 3.0F, 12.0F, 4.0F, pCubeDeformation.extend(0.25F)), PartPose.offset(5.0F, 2.5F, 0.0F)); $$3.addOrReplaceChild("right_sleeve", CubeListBuilder.create().texOffs(40, 32).addBox(-2.0F, -2.0F, -2.0F, 3.0F, 12.0F, 4.0F, pCubeDeformation.extend(0.25F)), PartPose.offset(-5.0F, 2.5F, 0.0F)); } else { $$3.addOrReplaceChild("left_arm", CubeListBuilder.create().texOffs(32, 48).addBox(-1.0F, -2.0F, -2.0F, 4.0F, 12.0F, 4.0F, pCubeDeformation), PartPose.offset(5.0F, 2.0F, 0.0F)); $$3.addOrReplaceChild("left_sleeve", CubeListBuilder.create().texOffs(48, 48).addBox(-1.0F, -2.0F, -2.0F, 4.0F, 12.0F, 4.0F, pCubeDeformation.extend(0.25F)), PartPose.offset(5.0F, 2.0F, 0.0F)); $$3.addOrReplaceChild("right_sleeve", CubeListBuilder.create().texOffs(40, 32).addBox(-3.0F, -2.0F, -2.0F, 4.0F, 12.0F, 4.0F, pCubeDeformation.extend(0.25F)), PartPose.offset(-5.0F, 2.0F, 0.0F)); } And that's got me thinking. If I can't replace the whole model in one fell swoop, what if I replaced each individual limb with my models mesh definitions? Note: It was crazy. The createMesh method in PlayerModel could not be @Overriden and addOrReplaceChild just makes changes to a new model that uses the original as a base.     However, I did render my model using this   final toatestentity idk = entities.toatest.get().create(p.level()); Minecraft.getInstance().getEntityRenderDispatcher().getRenderer(idk).render(idk, 0f, pTicks, stack, buffer, paLights); However that just uses the render from the entity I used to test getting the model to render in the first place. I don't want to do that. I want to fully replace the player model which this doesn't actually do (I don't think?).  Maybe it'd just be best to render my model as a new layer and make the base player model invisible? Maybe I'll take a look at how armor is rendered to move with the player so I won't have to make my own animations? Idk, I'm really set on figuring this out though.
    • AT Launcher works just fine
    • Make a test with another Launcher like MultiMC or AT Launcher  
    • https://mclo.gs/EZ0jeA2
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.