Howdy
I don't see you put any lightmap information into your vertex, but I presume you are using the Block vertex format? In my previous digging through the rendering code, I sometime found that to be important.
DefaultVertexFormats.BLOCK
// IVertexBuilder::addQuad and FaceBakery; see also DefaultVertexFormats.BLOCK.
// Summary:
// faceData[i + 0] = Float.floatToRawIntBits(positionIn.getX());
// faceData[i + 1] = Float.floatToRawIntBits(positionIn.getY());
// faceData[i + 2] = Float.floatToRawIntBits(positionIn.getZ());
// faceData[i + 3] = shadeColor;
// faceData[i + 4] = Float.floatToRawIntBits(textureU));
// faceData[i + 5] = Float.floatToRawIntBits(textureV));
// faceData[i + 6] = baked lighting (blocklight + skylight)
// faceData[i + 7] = normal;
You could consider using the face bakery to generate your quads, like this
/**
* Returns a quad for the given digit
* @param digit the digit (0 -> 9)
* @param isBlank if true: this digit should be blank (is a leading zero)
* @param minX: the minimum [x,y,z] of the digit quad (from the viewer's point of view). units = model space i.e. 0->16 is 1 metre block
* @param maxX: the maximum [x,y,z] of the digit quad (from the viewer's point of view). units = model space i.e. 0->16 is 1 metre block
* @return
*/
private BakedQuad getQuadForDigit(int digit, boolean isBlank, Direction whichFace,
double minX, double minY, double minZ, double maxX, double maxY, double maxZ) {
// generate a BakedQuad for the given digit
// we can do this manually by providing a list of vertex data, or we can use the FaceBakery::bakeQuads method
// FaceBakery::bakeQuad is much simpler and suitable for pretty much any block-style rendering, so I've used that here
// If you want to manually provide vertex data yourself, the format is an array of ints; look in
// IVertexBuilder::addQuad and FaceBakery; see also DefaultVertexFormats.BLOCK.
// Summary:
// faceData[i + 0] = Float.floatToRawIntBits(positionIn.getX());
// faceData[i + 1] = Float.floatToRawIntBits(positionIn.getY());
// faceData[i + 2] = Float.floatToRawIntBits(positionIn.getZ());
// faceData[i + 3] = shadeColor;
// faceData[i + 4] = Float.floatToRawIntBits(textureU));
// faceData[i + 5] = Float.floatToRawIntBits(textureV));
// faceData[i + 6] = baked lighting (blocklight + skylight)
// faceData[i + 7] = normal;
// When constructing a face manually in this way, the order of vertices is very important!
// 1) must be added anti-clockwise (from the point of view of the person looking at the face). Otherwise the face
// will point in the wrong direction and it may be invisible (backs of faces are usually culled for block rendering)
// 2) ambient occlusion (a block lighting effect) assumes that the vertices are added in the order:
// top left, then bottom left, then bottom right, then top right - for the east, west, north, south faces.
// for the top face: NW, SW, SE, NE. for the bottom face: SW, NW, NE, SE
// If your face has ambient occlusion enabled, and the order is wrong, then the shading will be messed up
// FaceBakery:
// Vanilla uses it to convert from the elements in a block model, i.e.
// "elements": [
// { "from": [ 7, 0, 7 ],
// "to": [ 9, 10, 9 ],
// "shade": false,
// "faces": {
// "down": { "uv": [ 7, 13, 9, 15 ], "texture": "#torch" },
// "up": { "uv": [ 7, 6, 9, 8 ], "texture": "#torch" }
// }
// },
// see https://minecraft.gamepedia.com/Model#Block_models
// In order to use the FaceBakery::bakeQuad method, we need to provide:
// 1) A suitable cuboid 'from' and 'to', in model coordinate (eg the full 1 metre cube is from [0,0,0] to [16, 16, 16])
// 2) the corresponding [u,v] texture coordinates for the face: [minU,minV] first then [maxU,maxV], again in texels 0->16
// 3) the face we want to make the quad for (eg up, down, east, west, etc).
Vector3f from = new Vector3f((float)minX, (float)minY, (float)minZ);
Vector3f to = new Vector3f((float)maxX, (float)maxY, (float)maxZ);
// texture UV order is important! i.e. [minU,minV] first then [maxU,maxV]
float [] uvArray = getDigitUVs(digit, isBlank);
final int ROTATION_NONE = 0;
BlockFaceUV blockFaceUV = new BlockFaceUV(uvArray, ROTATION_NONE);
final Direction NO_FACE_CULLING = null;
final int TINT_INDEX_NONE = -1; // used for tintable blocks such as grass, which make a call to BlockColors to change their rendering colour. -1 for not tintable.
final String DUMMY_TEXTURE_NAME = ""; // texture name is only needed for loading from json files; not needed here
BlockPartFace blockPartFace = new BlockPartFace(NO_FACE_CULLING, TINT_INDEX_NONE, DUMMY_TEXTURE_NAME, blockFaceUV);
// we have previously registered digitsTexture in StartupClientOnly::onTextureStitchEvent
AtlasTexture blocksStitchedTextures = ModelLoader.instance().getSpriteMap().getAtlasTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
TextureAtlasSprite digitsTextures = blocksStitchedTextures.getSprite(digitsTextureRL);
final IModelTransform NO_TRANSFORMATION = IDENTITY;
final BlockPartRotation DEFAULT_ROTATION = null; // rotate based on the face direction
final boolean APPLY_SHADING = true;
final ResourceLocation DUMMY_RL = new ResourceLocation("dummy_name"); // used for error message only
BakedQuad bakedQuad = faceBakery.bakeQuad(from, to, blockPartFace, digitsTextures, whichFace, NO_TRANSFORMATION, DEFAULT_ROTATION,
APPLY_SHADING, DUMMY_RL);
return bakedQuad;
}
If that doesn't help, I'd suggest you add a breakpoint to ForgeBlockModelRenderer::renderModelSmooth (or much easier - ::renderModelFlat if you turn off ambient occlusion) and watch how your block's quads are rendered to the buffer.
I've also had this problem arise previously with blocks which used the skylight+blocklight value for rendering but which had a calculated skylight+blocklight of 0 due to the block's settings (I forget which, sorry). The breakpoint I suggested above should show that, if it's the cause.
-TGG