QcBlockVertex Struct
Vertex layout shared by the mesher and the GPU pipeline: position (relative to the section's corner, QcChunkMesh::origin) and atlas coordinates as floats, shading, light and the surface as unsigned bytes (read as one UNormByte4 attribute), 24 bytes per vertex. More...
| Header: | #include <clientcore/meshing/QcBlockVertex.h> |
Public Functions
| float | blockLight() const |
| QcSurfaceMaterial | material() const |
| std::optional<QcBlockFace> | normal() const |
| void | setBlockLight(float value) |
| void | setShade(float value) |
| void | setSkyLight(float value) |
| void | setSurface(std::optional<QcBlockFace> normal, QcSurfaceMaterial material) |
| float | shade() const |
| float | skyLight() const |
Public Variables
Static Public Members
| const std::size_t | blockLightIndex |
| quint8 | pack(float value) |
| const std::size_t | shadeIndex |
| const std::size_t | skyLightIndex |
| const std::size_t | surfaceIndex |
| float | unpack(quint8 value) |
Related Non-Members
| enum class | QcSurfaceMaterial { Solid, Cutout, Plant, Translucent, Water, …, Emissive } |
Detailed Description
Light levels k / 15 are stored exactly (17 k); other values to within 1 / 510.
Member Function Documentation
float QcBlockVertex::blockLight() const
Returns the block light in [0, 1].
See also setBlockLight().
QcSurfaceMaterial QcBlockVertex::material() const
Returns the surface class of the vertex.
std::optional<QcBlockFace> QcBlockVertex::normal() const
Returns the face the surface looks towards; nullopt for crossed planes.
[static] quint8 QcBlockVertex::pack(float value)
Returns value clamped to [0, 1] as a byte (0..255).
void QcBlockVertex::setBlockLight(float value)
Sets the block light to value (clamped to [0, 1]).
See also blockLight().
void QcBlockVertex::setShade(float value)
Sets the shading to value (clamped to [0, 1]).
See also shade().
void QcBlockVertex::setSkyLight(float value)
Sets the sky light to value (clamped to [0, 1]).
See also skyLight().
void QcBlockVertex::setSurface(std::optional<QcBlockFace> normal, QcSurfaceMaterial material)
Sets the surface: the face normal looks towards (nullopt for crossed planes) and its material.
float QcBlockVertex::shade() const
Returns the shading in [0, 1].
See also setShade().
float QcBlockVertex::skyLight() const
Returns the sky light in [0, 1].
See also setSkyLight().
[static] float QcBlockVertex::unpack(quint8 value)
Returns byte value as a float in [0, 1].
Member Variable Documentation
const std::size_t QcBlockVertex::blockLightIndex
Byte of the block light in light.
std::array<quint8, 4> QcBlockVertex::light
Face shading and ambient occlusion, sky light (scaled by the time of day in the shader), block light (torches, independent of the time of day) and the surface: the normal in the low three bits (0: none, crossed planes; 1 + QcBlockFace: the face direction) and the QcSurfaceMaterial in the high five (decision E-390; today's shaders ignore it).
const std::size_t QcBlockVertex::shadeIndex
Byte of the face shading and ambient occlusion in light.
const std::size_t QcBlockVertex::skyLightIndex
Byte of the sky light in light.
const std::size_t QcBlockVertex::surfaceIndex
Byte of the surface (normal and material) in light.
float QcBlockVertex::u
Atlas coordinate u.
float QcBlockVertex::v
Atlas coordinate v.
float QcBlockVertex::x
Position along x, relative to the section's corner.
float QcBlockVertex::y
Position along y, relative to the section's corner.
float QcBlockVertex::z
Position along z, relative to the section's corner.
Related Non-Members
enum class QcSurfaceMaterial
What kind of surface a vertex belongs to, for render modes that treat surfaces differently (decision E-390: reflections on water, wind in leaves and plants, glow of light sources).
Today's shaders do not read it. Five bits in the vertex (at most 32 values).
| Constant | Value | Description |
|---|---|---|
QcBlockVertex::QcSurfaceMaterial::Solid | 0 | Opaque blocks. |
QcBlockVertex::QcSurfaceMaterial::Cutout | 1 | Alpha-tested blocks drawn in the opaque pass (leaves). |
QcBlockVertex::QcSurfaceMaterial::Plant | 2 | Crossed planes (plants, saplings). |
QcBlockVertex::QcSurfaceMaterial::Translucent | 3 | Translucent blocks other than liquids (glass, ice). |
QcBlockVertex::QcSurfaceMaterial::Water | 4 | Translucent liquids (water), drawn from their own list (QcChunkMesh). |
QcBlockVertex::QcSurfaceMaterial::Liquid | 5 | Opaque liquids (lava). |
QcBlockVertex::QcSurfaceMaterial::Emissive | 6 | Blocks that give off light (torches, lamps). |