Interface QuadEmitter
- All Superinterfaces:
MutableQuadView
,QuadView
MutableQuadView
that supports transformers and
sends quads to some destination, such as a mesh builder or rendering.
Instances of QuadEmitter
will practically always be
thread local and/or reused - do not retain references.
Only the renderer should implement or extend this interface.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final float
Tolerance for determining if the depth parameter tosquare(Direction, float, float, float, float, float)
is effectively zero - meaning the face is a cull face.Fields inherited from interface net.fabricmc.fabric.api.renderer.v1.mesh.MutableQuadView
BAKE_FLIP_U, BAKE_FLIP_V, BAKE_LOCK_UV, BAKE_NORMALIZED, BAKE_ROTATE_180, BAKE_ROTATE_270, BAKE_ROTATE_90, BAKE_ROTATE_NONE
Fields inherited from interface net.fabricmc.fabric.api.renderer.v1.mesh.QuadView
VANILLA_QUAD_STRIDE, VANILLA_VERTEX_STRIDE
-
Method Summary
Modifier and TypeMethodDescriptionControls whether vertex colors should be modified for ambient occlusion.color
(int vertexIndex, int color) Sets the color in ARGB format (0xAARRGGBB) for the given vertex.default QuadEmitter
color
(int c0, int c1, int c2, int c3) Sets the color in ARGB format (0xAARRGGBB) for all vertices at once.Copies all quad data and properties from the givenQuadView
to this quad.Sets the cull face.diffuseShade
(boolean shade) Controls whether vertex colors should be modified for diffuse shading.emissive
(boolean emissive) When true, this quad will be rendered at full brightness.emit()
In static mesh building, causes quad to be appended to the mesh being built.fromBakedQuad
(BakedQuad quad) Sets all applicable data and properties of this quad as specified by the givenBakedQuad
.fromVanilla
(int[] vertexData, int startIndex) Sets this quad's vertex data for all vertices using data in given array, starting at the given index.glint
(ItemRenderState.Glint glint) Controls how glint should be applied.lightmap
(int vertexIndex, int lightmap) Sets the minimum lightmap value for the given vertex.default QuadEmitter
lightmap
(int l0, int l1, int l2, int l3) Sets the lightmap value for all vertices at once.nominalFace
(@Nullable Direction face) Sets the nominal face, which provides a hint to the renderer about the facing of this quad.normal
(int vertexIndex, float x, float y, float z) Sets the normal vector for the given vertex.default QuadEmitter
normal
(int vertexIndex, org.joml.Vector3f normal) Sets the normal vector for the given vertex.default QuadEmitter
normal
(int vertexIndex, org.joml.Vector3fc normal) Sets the normal vector for the given vertex.void
Removes the transformer added by the last call topushTransform(QuadTransform)
.pos
(int vertexIndex, float x, float y, float z) Sets the geometric vertex position for the given vertex, relative to block origin, (0,0,0).default QuadEmitter
pos
(int vertexIndex, org.joml.Vector3f pos) Sets the geometric position for the given vertex.default QuadEmitter
pos
(int vertexIndex, org.joml.Vector3fc pos) Sets the geometric position for the given vertex.void
pushTransform
(QuadTransform transform) Pushed transforms will be applied immediately after every call toemit()
and before the quad data is delivered to its destination.renderLayer
(@Nullable BlockRenderLayer renderLayer) Controls how this quad's pixels should be blended with the scene.A hint to the renderer about how this quad is intended to be shaded, for example through ambient occlusion and diffuse shading.default QuadEmitter
spriteBake
(Sprite sprite, int bakeFlags) Sets the texture coordinates for all vertices using the given sprite.default QuadEmitter
Helper method to assign vertex coordinates for a square aligned with the given face.tag
(int tag) Sets the tag, which is an arbitrary integer that is meant to be encoded intoMesh
es to later allow performing conditional transformation or filtering on their quads.tintIndex
(int tintIndex) Sets the tint index, which is used to retrieve the tint color.uv
(int vertexIndex, float u, float v) Sets the texture coordinates for the given vertex.default QuadEmitter
uv
(int vertexIndex, org.joml.Vector2f uv) Sets the texture coordinates for the given vertex.default QuadEmitter
uv
(int vertexIndex, org.joml.Vector2fc uv) Sets the texture coordinates for the given vertex.default QuadEmitter
Methods inherited from interface net.fabricmc.fabric.api.renderer.v1.mesh.QuadView
ambientOcclusion, color, copyNormal, copyPos, copyUv, cullFace, diffuseShade, emissive, faceNormal, glint, hasNormal, lightFace, lightmap, nominalFace, normalX, normalY, normalZ, posByIndex, renderLayer, shadeMode, tag, tintIndex, toBakedQuad, toVanilla, u, v, x, y, z
-
Field Details
-
CULL_FACE_EPSILON
static final float CULL_FACE_EPSILONTolerance for determining if the depth parameter tosquare(Direction, float, float, float, float, float)
is effectively zero - meaning the face is a cull face.- See Also:
-
-
Method Details
-
pos
Description copied from interface:MutableQuadView
Sets the geometric vertex position for the given vertex, relative to block origin, (0,0,0). Minecraft rendering is designed for models that fit within a single block space and is recommended that coordinates remain in the 0-1 range, with multi-block meshes split into multiple per-block models.The default value for all vertices is
0.0f
.- Specified by:
pos
in interfaceMutableQuadView
-
pos
Description copied from interface:MutableQuadView
Sets the geometric position for the given vertex. Only use this method if you already have aVector3f
. Otherwise, useMutableQuadView.pos(int, float, float, float)
.- Specified by:
pos
in interfaceMutableQuadView
-
pos
Description copied from interface:MutableQuadView
Sets the geometric position for the given vertex. Only use this method if you already have aVector3fc
. Otherwise, useMutableQuadView.pos(int, float, float, float)
.- Specified by:
pos
in interfaceMutableQuadView
-
color
Description copied from interface:MutableQuadView
Sets the color in ARGB format (0xAARRGGBB) for the given vertex.The default value for all vertices is
0xFFFFFFFF
.- Specified by:
color
in interfaceMutableQuadView
-
color
Description copied from interface:MutableQuadView
Sets the color in ARGB format (0xAARRGGBB) for all vertices at once.- Specified by:
color
in interfaceMutableQuadView
- See Also:
-
uv
Description copied from interface:MutableQuadView
Sets the texture coordinates for the given vertex.The default value for all vertices is
0.0f
.- Specified by:
uv
in interfaceMutableQuadView
-
uv
Description copied from interface:MutableQuadView
Sets the texture coordinates for the given vertex. Only use this method if you already have aVector2f
. Otherwise, useMutableQuadView.uv(int, float, float)
.- Specified by:
uv
in interfaceMutableQuadView
-
uv
Description copied from interface:MutableQuadView
Sets the texture coordinates for the given vertex. Only use this method if you already have aVector2fc
. Otherwise, useMutableQuadView.uv(int, float, float)
.- Specified by:
uv
in interfaceMutableQuadView
-
spriteBake
Description copied from interface:MutableQuadView
Sets the texture coordinates for all vertices using the given sprite. Can handle UV locking, rotation, interpolation, etc. Control this behavior by passing additive combinations of the BAKE_ flags defined in this interface.- Specified by:
spriteBake
in interfaceMutableQuadView
-
uvUnitSquare
-
lightmap
Description copied from interface:MutableQuadView
Sets the minimum lightmap value for the given vertex. Input values will override lightmap values computed from world state if input values are higher. Exposed for completeness but some rendering implementations with non-standard lighting model may not honor it.For emissive rendering, prefer using
MutableQuadView.emissive(boolean)
.The default value for all vertices is
0
.- Specified by:
lightmap
in interfaceMutableQuadView
-
lightmap
Description copied from interface:MutableQuadView
Sets the lightmap value for all vertices at once.For emissive rendering, prefer using
MutableQuadView.emissive(boolean)
.- Specified by:
lightmap
in interfaceMutableQuadView
- See Also:
-
normal
Description copied from interface:MutableQuadView
Sets the normal vector for the given vertex. The face normal is used when no vertex normal is provided. Models that have per-vertex normals should include them to get correct lighting when it matters.- Specified by:
normal
in interfaceMutableQuadView
-
normal
Description copied from interface:MutableQuadView
Sets the normal vector for the given vertex. Only use this method if you already have aVector3f
. Otherwise, useMutableQuadView.normal(int, float, float, float)
.- Specified by:
normal
in interfaceMutableQuadView
-
normal
Description copied from interface:MutableQuadView
Sets the normal vector for the given vertex. Only use this method if you already have aVector3fc
. Otherwise, useMutableQuadView.normal(int, float, float, float)
.- Specified by:
normal
in interfaceMutableQuadView
-
nominalFace
Description copied from interface:MutableQuadView
Sets the nominal face, which provides a hint to the renderer about the facing of this quad. It is not required, but if set, should be the expected value ofQuadView.lightFace()
. It may be used to shortcut geometric analysis, if the provided value was correct; otherwise, it is ignored.The nominal face is also used for
MutableQuadView.spriteBake(Sprite, int)
withMutableQuadView.BAKE_LOCK_UV
.When
MutableQuadView.cullFace(Direction)
is called, it also sets the nominal face.The default value is
null
.This property is transient. It is set to the same value as
QuadView.lightFace()
when a quad is decoded.- Specified by:
nominalFace
in interfaceMutableQuadView
-
cullFace
Description copied from interface:MutableQuadView
Sets the cull face. This quad will not be rendered if its cull face is non-null and the block is occluded by another block in the direction of the cull face.The cull face is different from
BakedQuad.face()
, which is equivalent toQuadView.lightFace()
. The light face is computed based on geometry and must be non-null.When called, sets
MutableQuadView.nominalFace(Direction)
to the same value.The default value is
null
.This property is respected only in block contexts. It will not have an effect in other contexts.
- Specified by:
cullFace
in interfaceMutableQuadView
-
renderLayer
Description copied from interface:MutableQuadView
Controls how this quad's pixels should be blended with the scene.If set to
null
,RenderLayers.getBlockLayer(BlockState)
will be used to retrieve the render layer in block contexts and the render layer of the state layer will be used in item contexts. Set to another value to override this behavior.In block contexts, a non-null value will be used directly. In item contexts, a non-null value will be converted to a
RenderLayer
usingRenderLayerHelper.getEntityBlockLayer(BlockRenderLayer)
.The default value is
null
.- Specified by:
renderLayer
in interfaceMutableQuadView
-
emissive
Description copied from interface:MutableQuadView
When true, this quad will be rendered at full brightness. Lightmap values provided viaQuadView.lightmap(int)
will be ignored.This is the preferred method for emissive lighting effects as some renderers with advanced lighting pipelines may not use lightmaps.
Note that vertex colors will still be modified by diffuse shading and ambient occlusion, unless disabled via
MutableQuadView.diffuseShade(boolean)
andMutableQuadView.ambientOcclusion(TriState)
.The default value is
false
.- Specified by:
emissive
in interfaceMutableQuadView
-
diffuseShade
Description copied from interface:MutableQuadView
Controls whether vertex colors should be modified for diffuse shading.The default value is
true
.This property is guaranteed to be respected in block contexts. Some renderers may also respect it in item contexts, but this is not guaranteed.
- Specified by:
diffuseShade
in interfaceMutableQuadView
-
ambientOcclusion
Description copied from interface:MutableQuadView
Controls whether vertex colors should be modified for ambient occlusion.If set to
TriState.DEFAULT
, ambient occlusion will be used if the block state has a luminance of 0. Set toTriState.TRUE
orTriState.FALSE
to override this behavior.TriState.TRUE
will not have an effect if ambient occlusion is disabled globally.The default value is
TriState.DEFAULT
.This property is respected only in block contexts. It will not have an effect in other contexts.
- Specified by:
ambientOcclusion
in interfaceMutableQuadView
-
glint
Description copied from interface:MutableQuadView
Controls how glint should be applied.If set to
null
, glint will be applied in item contexts based on the glint type of the layer. Set to another value to override this behavior.The default value is
null
.This property is guaranteed to be respected in item contexts. Some renderers may also respect it in block contexts, but this is not guaranteed.
- Specified by:
glint
in interfaceMutableQuadView
-
shadeMode
Description copied from interface:MutableQuadView
A hint to the renderer about how this quad is intended to be shaded, for example through ambient occlusion and diffuse shading. The renderer is free to ignore this hint.The default value is
ShadeMode.ENHANCED
.This property is respected only in block contexts. It will not have an effect in other contexts.
- Specified by:
shadeMode
in interfaceMutableQuadView
- See Also:
-
tintIndex
Description copied from interface:MutableQuadView
Sets the tint index, which is used to retrieve the tint color.The default value is
-1
.- Specified by:
tintIndex
in interfaceMutableQuadView
-
tag
Description copied from interface:MutableQuadView
Sets the tag, which is an arbitrary integer that is meant to be encoded intoMesh
es to later allow performing conditional transformation or filtering on their quads.The default value is
0
.- Specified by:
tag
in interfaceMutableQuadView
-
copyFrom
Description copied from interface:MutableQuadView
Copies all quad data and properties from the givenQuadView
to this quad.Calling this method does not emit this quad.
- Specified by:
copyFrom
in interfaceMutableQuadView
-
fromVanilla
Description copied from interface:MutableQuadView
Sets this quad's vertex data for all vertices using data in given array, starting at the given index. The array must have at leastQuadView.VANILLA_QUAD_STRIDE
elements starting at the given index. The format of the data must be the same asBakedQuad.vertexData()
. This quad's lightmap values and normals will be set even though vanilla does not decode them from packed vertex data.Prefer using
MutableQuadView.fromBakedQuad(BakedQuad)
instead if you have aBakedQuad
.Calling this method does not emit this quad.
- Specified by:
fromVanilla
in interfaceMutableQuadView
-
fromBakedQuad
Description copied from interface:MutableQuadView
Sets all applicable data and properties of this quad as specified by the givenBakedQuad
. This quad's lightmap values and normals will be set even though vanilla does not decode them from packed vertex data. The baked quad's light emission will be applied to the lightmap values from the vertex data after copying.Calling this method does not emit this quad.
- Specified by:
fromBakedQuad
in interfaceMutableQuadView
-
square
default QuadEmitter square(Direction nominalFace, float left, float bottom, float right, float top, float depth) Helper method to assign vertex coordinates for a square aligned with the given face. Ensures that vertex order is consistent with vanilla convention. (Incorrect order can lead to bad AO lighting unless enhanced lighting logic is available/enabled.)Square will be parallel to the given face and coplanar with the face (and culled if the face is occluded) if the depth parameter is approximately zero. See
CULL_FACE_EPSILON
.All coordinates should be normalized (0-1).
-
pushTransform
Pushed transforms will be applied immediately after every call toemit()
and before the quad data is delivered to its destination. If any transform returnsfalse
, the emitted quad will be discarded and will not be delivered to its destination.You MUST call
popTransform()
once you are done using this emitter in the current scope.More than one transformer can be pushed. Transformers are applied in reverse order. (Last pushed is applied first.)
Using
this
emitter from inside the pushed quad transform is not supported. -
popTransform
void popTransform()Removes the transformer added by the last call topushTransform(QuadTransform)
. MUST be called once you are done using this emitter in the current scope. -
emit
QuadEmitter emit()In static mesh building, causes quad to be appended to the mesh being built. In a dynamic render context, create a new quad to be output to rendering. In both cases, current instance is reset to default values.
-