Posted April 16, 20205 yr I've got a TER with a variety of animations and OpenGL effects, and one of its properties is to render an arbitrary block on top of it. This is quite easy to do with BlockRendererDispatcher#renderModelBrightness, but the caveat is that it doesn't render with ambient occlusion. Looks great with flat lighting, but sticks out like a sore thumb with smooth lighting. I've tried using BlockRendererDispatcher#renderModelSmooth, but it then seemingly ignores lighting altogether. I've never been great with rendering code, so here's the relevant excerpt of that in case I just forgot something: BlockPos pos = tileEntityIn.getPos(); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); buffer.setTranslation(-pos.getX(), -pos.getY(), -pos.getZ() - 1); renderer.getBlockModelRenderer().renderModelSmooth(world, model, state, pos, buffer, true, new Random(), 0, EmptyModelData.INSTANCE); buffer.setTranslation(0, 0, 0); tessellator.draw(); I'm probably going about this all wrong. I'd appreciate some pointers! I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.
April 17, 20205 yr Howdy I think you're heading in the right direction, the renderModelSmooth is the one that you want; some suggestions 1) pick an existing vanilla RenderBuffer instead of making your own, eg IVertexBuilder vertexBuilderBlockQuads = renderBuffer.getBuffer(RenderType.getSolid()); Ah wait - you're using 1.14.4. The principle is the same but you may have used the right buffer modes already. There are a couple of settings that will stop vanilla applying lighting properly- depends on the source of your model - if the Quads in your model have diffuse lighting false, then the direction-depending lighting won't be applied. if the block is opaque, the light value might be set to zero for quads which aren't at the outermost edges of the block if the block is glowing, ambient occlusion is turned off You might just need to trace into the render method to see exactly what is going on - the ambient occlusion & brightness methods are complicated but it's not too difficult to see what they are doing / why there's no lighting being applied at all. This link might be useful for background information http://greyminecraftcoder.blogspot.com/2020/04/lighting-1144.html Cheers TGG
April 17, 20205 yr Author @TheGreyGhost Thank you for the tips! I spent a while digging into the lighting code but didn't manage to find anything wrong. Instead, the problem was quite simple and I feel pretty silly for not noticing. The TileEntityRendererDispatcher calls RenderHelper.enableStandardItemLighting before rendering tile entities, so I simply had to call the reverse before rendering the block model and it worked flawlessly. Also, I changed my code to use BlockRendererDispatcher#renderBlock instead of renderModelSmooth for the sake of accuracy to vanilla, in case anyone cares. Edited April 17, 20205 yr by imacatlolol I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.
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.