Monday 13 April 2020

Block models [1.14.4+]

The models for blocks (SimpleBakedModel) are made up of BakedQuads.
Each quad is stored with a number of properties that can affect the way it is drawn:

  • Facing direction (up, down, east, west, north, south) which is used to calculate ambient occlusion lighting effects
  • A “diffuse lighting” flag: true if the quad changes brightness depending on which way it is facing.  Note – do not confuse this with the “diffuselighting” render mode used by items.  The concept is the same, but the implementation is different: item diffuse lighting is implemented by the renderer using vertex normals, whereas block diffuse lighting is implemented in code using the facing direction, not using vertex normals.
  • A TextureAtlasSprite, which is the texture used to draw the quad
  • A tintindex, which asks BlockColors for a colour – typically a function which calculates colour based on eg temperature and rainfall for foliage, or the POWER blockstate property for redstone.  Failing that it falls back to BlockState.getMaterialColor()

The BakedModel also has further information about how to draw quads:
  • It divides Quads into two types:
    Face quads, which occupy one of the outer edges of the 1x1x1 cube and are not drawn if the adjacent cube is fully opaque (because the face quad would be invisible).
    General quads, which are always rendered
  • Ambient occlusion flag (if false, ambient occlusion is not used for this model)


The BakedModel properties are set from the json files for BlockModels which have the following flags:

  • ambientocclusion: controls the ambient occlusion flag
  • tintindex: 
  • shade: controls the “diffuse lighting” flag

Interesting Vanilla classes to explore:

SimpleBakedModel
BakedQuad
OBJModel
BlockModelRenderer
BlockRendererDispatcher

Further Information

Wiki on Block Models
Lighting

No comments:

Post a Comment