Jump to content

Issue with blend and depth


Laipel

Recommended Posts

Why does depth and blending works so stange together. Does exist any way to fix it?
https://imgur.com/Y4EoGoO
I render it with EntityRenderer.

My code:
 

@Override
    public void render(SoulEntity soulEntity, float p_114486_, float pTicks, PoseStack poseStack, MultiBufferSource bufferSource, int p_114490_) {

        ISoul soul = soulEntity.getSoul();

        if (soul == null)
            return;

        RenderSystem.enableDepthTest();
        RenderSystem.enableBlend();
        RenderSystem.defaultBlendFunc();

        poseStack.pushPose();
        poseStack.scale(0.6f, 0.6f, 0.6f);
        poseStack.mulPose(this.entityRenderDispatcher.cameraOrientation());
        poseStack.mulPose(Axis.YP.rotationDegrees(180.0F));

        Minecraft.getInstance().textureManager.getTexture(getTextureLocation(soulEntity)).setBlurMipmap(true, false);

        Color color = soul.getColor();
        Matrix4f matrix4f = poseStack.last().pose();

        VertexConsumer bufferBuilder = bufferSource.getBuffer(EnsRenderType.SOUL_RENDER_TYPE);

        bufferBuilder.vertex(matrix4f, -1.2f, -1.2f, 0.0F).uv(0.0F, 1.0F).color(color.getRed(), color.getBlue(), color.getGreen(), 70).uv2(p_114490_)
                .endVertex();
        bufferBuilder.vertex(matrix4f, 1.2f, -1.2f, 0.0F).uv(1.0F, 1.0F).color(color.getRed(), color.getBlue(), color.getGreen(), 70).uv2(p_114490_).endVertex();
        bufferBuilder.vertex(matrix4f, 1.2f, 1.2f, 0.0F).uv(1.0F, 0.0F).color(color.getRed(), color.getBlue(), color.getGreen(), 70).uv2(p_114490_).endVertex();
        bufferBuilder.vertex(matrix4f, -1.2f, 1.2f, 0.0F).uv(0.0F, 0.0F).color(color.getRed(), color.getBlue(), color.getGreen(), 70).uv2(p_114490_).endVertex();

        bufferBuilder.vertex(matrix4f, (float) (0f - 0.6), (float) (0.0f - 0.6), 0.0F).uv(0.0F, 1.0F).color(color.getRed(), color.getBlue(), color.getGreen(), 100).uv2(p_114490_).endVertex();
        bufferBuilder.vertex(matrix4f, 1f - 0.4f, 0.0f - 0.6f, 0.0f).uv(1.0F, 1.0F).color(color.getRed(), color.getBlue(), color.getGreen(), 100).uv2(p_114490_).endVertex();
        bufferBuilder.vertex(matrix4f, 1f - 0.4f, 1.0f - 0.4f, 0.0f).uv(1.0F, 0.0F).color(color.getRed(), color.getBlue(), color.getGreen(), 100).uv2(p_114490_).endVertex();
        bufferBuilder.vertex(matrix4f, 0f - 0.6f, 1.0f - 0.4f, 0.0f).uv(0.0F, 0.0F).color(color.getRed(), color.getBlue(), color.getGreen(), 100).uv2(p_114490_).endVertex();
        
        bufferBuilder.vertex(matrix4f, (0f - 0.5f) + 0.13f, (0.0f - 0.5f) + 0.13f, 0.0f).uv(0.0F, 1.0F).color(color.getRed(), color.getBlue(), color.getGreen(), 120).uv2(p_114490_).endVertex();
        bufferBuilder.vertex(matrix4f, 1f - 0.5f - 0.13f, (0.0f - 0.5f) + 0.13f, 0.0f).uv(1.0F, 1.0F).color(color.getRed(), color.getBlue(), color.getGreen(), 120).uv2(p_114490_).endVertex();
        bufferBuilder.vertex(matrix4f, 1f - 0.5f - 0.13f, 1.0f - 0.5f - 0.13f, 0.0f).uv(1.0F, 0.0F).color(color.getRed(), color.getBlue(), color.getGreen(), 120).uv2(p_114490_).endVertex();
        bufferBuilder.vertex(matrix4f, (0f - 0.5f) + 0.13f, 1.0f - 0.5f - 0.13f, 0.0f).uv(0.0F, 0.0F).color(color.getRed(), color.getBlue(), color.getGreen(), 120).uv2(p_114490_).endVertex();

        Color color2 = Color.WHITE;
        
        bufferBuilder.vertex(matrix4f, (0f - 0.5f) + 0.26f, (0.0f - 0.5f) + 0.26f, 0.0f).uv(0.0F, 1.0F).color(color2.getRed(), color2.getBlue(), color2.getGreen(), 130).uv2(p_114490_).endVertex();
        bufferBuilder.vertex(matrix4f, 1f - 0.5f - 0.26f, (0.0f - 0.5f) + 0.26f, 0.0f).uv(1.0F, 1.0F).color(color2.getRed(), color2.getBlue(), color2.getGreen(), 130).uv2(p_114490_).endVertex();
        bufferBuilder.vertex(matrix4f, 1f - 0.5f - 0.26f, 1.0f - 0.5f - 0.26f, 0.0f).uv(1.0F, 0.0F).color(color2.getRed(), color2.getBlue(), color2.getGreen(), 130).uv2(p_114490_).endVertex();
        bufferBuilder.vertex(matrix4f, (0f - 0.5f) + 0.26f, 1.0f - 0.5f - 0.26f, 0.0f).uv(0.0F, 0.0F).color(color2.getRed(), color2.getBlue(), color2.getGreen(), 130).uv2(p_114490_).endVertex();
        
        bufferBuilder.vertex(matrix4f, (0f - 0.5f) + 0.4f, (0.0f - 0.5f) + 0.4f, 0.0f).uv(0.0F, 1.0F).color(color2.getRed(), color2.getBlue(), color2.getGreen(), 80).uv2(p_114490_).endVertex();
        bufferBuilder.vertex(matrix4f, 1f - 0.5f - 0.4f, (0.0f - 0.5f) + 0.4f, 0.0f).uv(1.0F, 1.0F).color(color2.getRed(), color2.getBlue(), color2.getGreen(), 80).uv2(p_114490_).endVertex();
        bufferBuilder.vertex(matrix4f, 1f - 0.5f - 0.4f, 1.0f - 0.5f - 0.4f, 0.0f).uv(1.0F, 0.0F).color(color2.getRed(), color2.getBlue(), color2.getGreen(), 80).uv2(p_114490_).endVertex();
        bufferBuilder.vertex(matrix4f, (0f - 0.5f) + 0.4f, 1.0f - 0.5f - 0.4f, 0.0f).uv(0.0F, 0.0F).color(color2.getRed(), color2.getBlue(), color2.getGreen(), 80).uv2(p_114490_).endVertex();

        poseStack.popPose();

        // RenderUtils.drawStreak(soulEntity, pTicks, poseStack, bufferSource, getStreaks(soulEntity));

        super.render(soulEntity, p_114486_, pTicks, poseStack, bufferSource, p_114490_);
    }
public static final RenderType SOUL_RENDER_TYPE = RenderType.create("soul_render_type", DefaultVertexFormat.POSITION_TEX_COLOR,
            VertexFormat.Mode.QUADS, 256, false, false,
            RenderType.CompositeState.builder()
                    .setTextureState(new RenderStateShard.TextureStateShard(new ResourceLocation(MODID, "textures/particle/wisp.png"), true, true))
                    .setLightmapState(LIGHTMAP)
                    .setTransparencyState(LIGHTNING_TRANSPARENCY)
                    .setWriteMaskState(COLOR_DEPTH_WRITE)
                    .setCullState(RenderStateShard.CULL)
                    .setShaderState(new RenderStateShard.ShaderStateShard(ShaderRegistry::getSmoothPosTexColorShader))
                    .createCompositeState(true));

 

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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