Posted March 27, 20214 yr I'm porting my mod that creates armor dynamically from blocks from 1.12 to 1.16.5 and having some difficulties with rendering translucent armor and the item layers. So the way my item models are made is by combining quads from a base texture, a template (with the block's texture), and a partially-transparent overlay to give it some texture/lighting: The issue I'm having is that the partially-transparent parts of the overlay are rendering invisible in the 3d model: Does anyone know any solution to this? My code for creating the item model quads is below: ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder(); int color = new Color(1f, 1f, 1f, 1f).getRGB(); //Base texture and model builder.addAll(model.getQuads(null, null, new Random())); //Template texture for left half ResourceLocation templateLocation = new ResourceLocation(BlockArmor.MODID+":items/icons/block_armor_"+armorType+"1_template"); TextureAtlasSprite templateTexture = Minecraft.getInstance().getModelManager().getAtlasTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE).getSprite(templateLocation); builder.addAll(ItemTextureQuadConverter.convertTexture(transform, templateTexture, sprite, NORTH_Z_FLUID, Direction.NORTH, color, 1)); builder.addAll(ItemTextureQuadConverter.convertTexture(transform, templateTexture, sprite, SOUTH_Z_FLUID, Direction.SOUTH, color, 1)); //Template texture for right half templateLocation = new ResourceLocation(BlockArmor.MODID+":items/icons/block_armor_"+armorType+"2_template"); templateTexture = Minecraft.getInstance().getModelManager().getAtlasTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE).getSprite(templateLocation); builder.addAll(ItemTextureQuadConverter.convertTexture(transform, templateTexture, sprite, NORTH_Z_FLUID, Direction.NORTH, color, 1)); builder.addAll(ItemTextureQuadConverter.convertTexture(transform, templateTexture, sprite, SOUTH_Z_FLUID, Direction.SOUTH, color, 1)); //Overlay texture ResourceLocation coverLocation = new ResourceLocation(BlockArmor.MODID+":items/icons/block_armor_"+armorType+"_cover"); TextureAtlasSprite coverTexture = templateTexture = Minecraft.getInstance().getModelManager().getAtlasTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE).getSprite(coverLocation); builder.add(ItemTextureQuadConverter.genQuad(transform, 0, 0, 16, 16, NORTH_Z_BASE, coverTexture, Direction.NORTH, color, 1)); builder.add(ItemTextureQuadConverter.genQuad(transform, 0, 0, 16, 16, SOUTH_Z_BASE, coverTexture, Direction.SOUTH, color, 1)); ImmutableList<BakedQuad> quads = builder.build(); Another issue I'm having is rendering translucent armor. This is magenta glass armor, but it is not rendering transparent at all: Here is the rendering code for it: matrix.push(); RenderSystem.enableBlend(); RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); float alpha = 0.5f; // I've tried different alpha values with no difference this.bipedHead.render(matrix, vertex, lightMapUV, overlayUV, red, green, blue, alpha); this.bipedBody.render(matrix, vertex, lightMapUV, overlayUV, red, green, blue, alpha); this.bipedRightArm.render(matrix, vertex, lightMapUV, overlayUV, red, green, blue, alpha); this.bipedLeftArm.render(matrix, vertex, lightMapUV, overlayUV, red, green, blue, alpha); this.bipedWaist.render(matrix, vertex, lightMapUV, overlayUV, red, green, blue, alpha); this.bipedRightLeg.render(matrix, vertex, lightMapUV, overlayUV, red, green, blue, alpha); this.bipedLeftLeg.render(matrix, vertex, lightMapUV, overlayUV, red, green, blue, alpha); this.bipedRightFoot.render(matrix, vertex, lightMapUV, overlayUV, red, green, blue, alpha); this.bipedLeftFoot.render(matrix, vertex, lightMapUV, overlayUV, red, green, blue, alpha); RenderSystem.disableBlend(); matrix.pop(); In 1.12, I used to have this code and it would render transparent properly: GlStateManager.color(red, green, blue, alpha); GlStateManager.pushMatrix(); GlStateManager.enableBlend(); //enables transparency GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); this.bipedHead.render(scale); this.bipedBody.render(scale); this.bipedRightArm.render(scale); this.bipedLeftArm.render(scale); this.bipedWaist.render(scale); this.bipedRightLeg.render(scale); this.bipedLeftLeg.render(scale); this.bipedRightFoot.render(scale); this.bipedLeftFoot.render(scale); GlStateManager.disableBlend(); //disables transparency GlStateManager.popMatrix(); I'm not very familiar with OpenGL/rendering, so any help here would be appreciated! Edited April 5, 20214 yr by Furgl https://i.gyazo.com/9d22a3d74363977ac76d662e7c22effb.png[/img]
March 30, 20214 yr Author Bump - I still haven't had any luck with fixing either of this issues. Any help is appreciated! https://i.gyazo.com/9d22a3d74363977ac76d662e7c22effb.png[/img]
April 5, 20214 yr Author I fixed the item rendering issue by overriding my IBakedModel#getLayerModels to use RenderType.getTranslucent() when rendering the Overlay layer, so that it is not culled. And similarly I fixed the armor rendering issue by using RenderType.getEntityTranslucent(loc). https://i.gyazo.com/9d22a3d74363977ac76d662e7c22effb.png[/img]
June 28, 20214 yr On 4/6/2021 at 12:05 AM, Furgl said: I fixed the item rendering issue by overriding my IBakedModel#getLayerModels to use RenderType.getTranslucent() when rendering the Overlay layer, so that it is not culled. And similarly I fixed the armor rendering issue by using RenderType.getEntityTranslucent(loc). Hey i have the same problem,and i have hear you have fixed this already can you maybe show me the code of it?
June 28, 20214 yr Author Sure, you can look at my code on GitHub: https://github.com/2piradians/Block-Armor https://i.gyazo.com/9d22a3d74363977ac76d662e7c22effb.png[/img]
June 29, 20214 yr On 4/6/2021 at 12:05 AM, Furgl said: I fixed the item rendering issue by overriding my IBakedModel#getLayerModels to use RenderType.getTranslucent() when rendering the Overlay layer, so that it is not culled. And similarly I fixed the armor rendering issue by using RenderType.getEntityTranslucent(loc).
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.