Skip to content

Commit 6c31073

Browse files
committed
Define and explain standard materials
1 parent c3f1bf1 commit 6c31073

File tree

2 files changed

+50
-3
lines changed

2 files changed

+50
-3
lines changed

src/main/java/net/fabricmc/fabric/api/client/model/fabric/ModelMaterial.java

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616

1717
package net.fabricmc.fabric.api.client.model.fabric;
1818

19+
import net.minecraft.block.Block;
20+
import net.minecraft.client.render.model.BakedModel;
21+
import net.minecraft.util.Identifier;
22+
1923
/**
2024
* A reference to a model material that specifies texture blending,
2125
* lighting, coloring and other aspects of quad rendering. Every
@@ -38,9 +42,42 @@
3842
* Materials are not required to know their registration identity, and two materials
3943
* with the same attributes may or may not satisfy equality and identity tests. Model
4044
* implementations should never attempt to analyze materials or implement control logic based on them.
41-
* They are only tokens for communicating quad attributes to the ModelRenderer.
45+
* They are only tokens for communicating quad attributes to the ModelRenderer.<p>
46+
*
47+
* <b>STANDARD MATERIALS</b><p>
48+
*
49+
* All {@link ModelRenderer} implementations must pre-register the water and lava materials
50+
* using the identifiers defined below. This gives models access to any fancy renders that may
51+
* be implemented for those materials.<p>
4252
*/
4353
public interface ModelMaterial {
54+
55+
/**
56+
* This will be identical to the material that would be obtained by calling {@link ModelMaterialBuilder#build()}
57+
* on a new, unaltered, {@link ModelMaterialBuilder} instance. It is defined here for clarity and convenience.
58+
*
59+
* Quads using this material have a single texture layer, use {@link Block#getRenderLayer()} of the associated
60+
* block to determine texture blending (or translucent for item models), honor block color index,
61+
* are non-emissive, and have {@link ShadingMode} inferred from {@link BakedModel#useAmbientOcclusion()}
62+
* and block light level. All standard, non-fluid baked models are rendered using this material.<p>
63+
*
64+
* {@link ModelRenderer} implementations may or may not define and use more explicit materials for the
65+
* various context-dependent combinations of shading and render layer and those are not defined or exposed.
66+
*/
67+
Identifier MATERIAL_STANDARD = new Identifier("minecraft", "standard");
68+
69+
/**
70+
* Material that is used for water rendering. Useful if the model renderer implements
71+
* some kind of fancy render for water and you want a model to use the same effect.
72+
*/
73+
Identifier MATERIAL_WATER = new Identifier("minecraft", "water");
74+
75+
/**
76+
* Material that is used for lava rendering. Useful if the model renderer implements
77+
* some kind of fancy render for lava and you want a model to use the same effect.
78+
*/
79+
Identifier MATERIAL_LAVA = new Identifier("minecraft", "lava");
80+
4481
/**
4582
* The number of integers needed to represent a single quad with this materials.
4683
* For use by models to allocate vertex storage and transfer vertex data.

src/main/java/net/fabricmc/fabric/api/client/model/fabric/ModelMaterialBuilder.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
package net.fabricmc.fabric.api.client.model.fabric;
1818

19+
import net.minecraft.block.Block;
1920
import net.minecraft.block.BlockRenderLayer;
21+
import net.minecraft.client.render.model.BakedModel;
2022

2123
/**
2224
* Creates a {@link ModelMaterial} instance used to communicate
@@ -59,11 +61,15 @@ public interface ModelMaterialBuilder {
5961
* will emulate the way that Minecraft renders each pass. But this does
6062
* NOT mean the texture will be rendered in a specific render pass - some
6163
* implementations may not use the standard Minecraft render passes.<p>
64+
*
65+
* CAN be null and is null by default. A null value means the renderer
66+
* will use {@link Block#getRenderLayer()} for the associate block, or
67+
* {@link BlockRenderLayer#TRANSLUCENT} for item renders. (Normal Minecraft rendering)
6268
*/
6369
default void setBlendMode(BlockRenderLayer blendMode) {
6470
setBlendMode(0, blendMode);
6571
}
66-
72+
6773
/**
6874
* Sets blend mode for a specific texture layer. Useful when texture depth is > 1.
6975
*/
@@ -82,7 +88,11 @@ default void setBlendMode(BlockRenderLayer blendMode) {
8288

8389
/**
8490
* Specifies if and how pixel color should be modified by diffuse
85-
* shading and ambient occlusion. See {@link ShadingMode}
91+
* shading and ambient occlusion. See {@link ShadingMode}.<p>
92+
*
93+
* ShadingMode CAN be null and is null by default. A null value
94+
* means the shading mode should be inferred from {@link BakedModel#useAmbientOcclusion()}
95+
* and block light level. (Normal Minecraft rendering)
8696
*/
8797
default void setShading(ShadingMode shading) {
8898
setShading(0, shading);

0 commit comments

Comments
 (0)