2017-11-12 12 views
3

내가 남쪽이나 동쪽에서 보았을 때 예상대로 렌더링되었지만 북쪽이나 서쪽에서 보았을 때 그 뒤에있는 물체를 숨기는 이유는 무엇입니까?Minecraft 투명 렌더링 블록 숨기기

나는 내부에 여러 항목을 렌더링하고 반투명 한 질감을 가진 블록에 문제가있는 보이지 않는 블록이 있습니다. 기본 및 텍스처 블록 모두에 대해 모든 블록 속성 (예 : 렌더링 유형, 레이어, 불투명)을 전환하려고 시도했으며 렌더링시 다른 혼합 옵션을 시도했습니다.

포지 버전 1.12

기본보기 Normal view from south 깨진보기 Broken view from north 렌더러

public class BlueRenderer extends TileEntitySpecialRenderer<TileEntityBlue> { 

    @Override 
    public void render(TileEntityBlue tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { 
     itemRenderer = mc.getRenderItem(); 
     textureManager = mc.getTextureManager(); 
     blockModelShapes = mc.getBlockRendererDispatcher().getBlockModelShapes(); 

     GlStateManager.pushAttrib(); 
     GlStateManager.pushMatrix(); 

     GlStateManager.translate(x, y, z); 
     GlStateManager.disableRescaleNormal(); 

     renderItem(new GetBlock("minecraft:jukebox"), 0.5F); 
     renderItem(new GetBlock("mymod:blue"), 1F); 

     GlStateManager.popMatrix(); 
     GlStateManager.popAttrib(); 
    } 

    private void renderItem(GetBlock block, float scale) { 

     RenderHelper.enableStandardItemLighting(); 
     GlStateManager.enableLighting(); 
     GlStateManager.pushMatrix(); 
     GlStateManager.translate(0.5, 0.5, 0.5); 
     GlStateManager.scale(scale, scale, scale); 

     IBakedModel model = blockModelShapes.getModelForState(block.state); 
     model = ForgeHooksClient.handleCameraTransforms(model, ItemCameraTransforms.TransformType.NONE, false); 

     GlStateManager.enableBlend(); 
     GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); 

     textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); 
     itemRenderer.renderItem(block.stack, model); 

     GlStateManager.disableBlend(); 

     GlStateManager.popMatrix(); 
    } 

답변

0

transparency에 독서 후 - 나는에 깊이 마스크 누락 알파 기능을 가지고 있었다. 명심해야 할

GlStateManager.enableBlend(); 
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); 
    if (transparent) { 
     GlStateManager.depthMask(false); 
     GlStateManager.alphaFunc(GL11.GL_LESS, 1.0F); 
     itemRenderer.renderItem(block.stack, model); 
     GlStateManager.depthMask(true); 
    } else { 
     GlStateManager.alphaFunc(GL11.GL_EQUAL, 1.0F); 
     itemRenderer.renderItem(block.stack, model); 
    } 
    GlStateManager.disableBlend(); 

것 :

하는 투명 용지는 달리 그들은 "내부로"제대로 표시되지 않습니다 마지막으로 렌더링합니다.

renderItem(new GetBlock("minecraft:jukebox"), 0.5F, false); 
    renderItem(new GetBlock("mymod:blue"), 1F, true /*transparent*/); 

고체 항목도 필요 블렌드 함수 스택 최초 고체 제품의 특정 각도 글리치 것처럼 GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); :

enter image description here