Modding:Block Tessellator: Difference between revisions
From Vintage Story Wiki
(Clarify what level of detail 1 is) |
(Describe the json tessellator's level of detail handling) |
||
Line 1: | Line 1: | ||
== JSON == | == JSON == | ||
=== BlockEntity === | |||
If the block has a block entity, then [https://apidocs.vintagestory.at/api/Vintagestory.API.Common.BlockEntity.html#Vintagestory_API_Common_BlockEntity_OnTesselation_Vintagestory_API_Client_ITerrainMeshPool_Vintagestory_API_Client_ITesselatorAPI_ OnTesselation] is called on it. OnTesselation may add meshes to the meshpool (meshes to be rendered for the chunk) through the <code>mesher</code> parameter. It may return false, in which case the json mesh file is still processed. Or it may return true to skip processing the json mesh file. | |||
=== Level of detail === | |||
Most blocks only use the [[Modding:Block_Json_Properties#p_shape|Shape]] property and leave the other render settings at the default. This causes the shape to be rendered as long as it is visible within the frustum. However, there are some properties to adjust the level of detail at different render distances: | |||
; <code>Lod0Shape</code> (composite shape) | |||
: Shape rendered at close distances | |||
:; <code>FaceCullMode</code> (EnumFaceCullMode: default "default") | |||
:: When set to "collapsematerial" and the <code>Lod0Shape</code> is set, then the <code>Lod0Shape</code> is not rendered when the block is surrounded all sides (except for the bottom, which is ignored). | |||
; <code>Lod2Shape</code> (composite shape) | |||
: When set, this is rendered at far distances. The rendering of the regular shape is changed such that it is only shown at short and medium distances. | |||
; <code>DoNotRenderAtLod2</code> (boolean: default false) | |||
: Causes <code>Shape</code> to only be shown at short and medium distances. This only has an effect when <code>Lod2Shape</code> is unset. | |||
The interaction between these properties is rather complicated and the effect of every combination is shown in this table. | |||
<table class="wikitable"> | |||
<tr style="background-color: rgba(0,0,0,0.2);"> | |||
<th style="background-color: rgba(0,0,0,0.2);">Lod0Shape set</th> | |||
<th style="background-color: rgba(0,0,0,0.2);">Lod2Shape set</th> | |||
<th style="background-color: rgba(0,0,0,0.2); border-right: 2px solid green;">DoNotRenderAtLod2</th> | |||
<th style="background-color: rgba(0,0,0,0.2);">Block lighting</th> | |||
<th style="background-color: rgba(0,0,0,0.2);">Collapsible material and surrounded</th> | |||
<th style="background-color: rgba(0,0,0,0.2);">Rendered at short distance</th> | |||
<th style="background-color: rgba(0,0,0,0.2);">Rendered at medium distance</th> | |||
<th style="background-color: rgba(0,0,0,0.2);">Rendered at far distance</th> | |||
</tr> | |||
<tr> | |||
<td rowspan="6">no</td> | |||
<td rowspan="4">no</td> | |||
<td rowspan="2" style="border-right: 2px solid green;">false</td> | |||
<td>dark</td> | |||
<td rowspan="6">either</td> | |||
<td>Shape</td> | |||
<td style="background-color: rgba(0,0,0,0.2);">none</td> | |||
<td style="background-color: rgba(0,0,0,0.2);">none</td> | |||
</tr> | |||
<tr> | |||
<td>lit</td> | |||
<td>Shape</td> | |||
<td>Shape</td> | |||
<td>Shape</td> | |||
</tr> | |||
<tr> | |||
<td rowspan="2" style="border-right: 2px solid green;">true</td> | |||
<td>dark</td> | |||
<td>Shape</td> | |||
<td style="background-color: rgba(0,0,0,0.2);">none</td> | |||
<td style="background-color: rgba(0,0,0,0.2);">none</td> | |||
</tr> | |||
<tr> | |||
<td>lit</td> | |||
<td>Shape</td> | |||
<td>Shape</td> | |||
<td>Shape</td> | |||
</tr> | |||
<tr> | |||
<td rowspan="2">yes</td> | |||
<td rowspan="2" style="border-right: 2px solid green;">either</td> | |||
<td>dark</td> | |||
<td>Shape</td> | |||
<td style="background-color: rgba(0,0,0,0.2);">none</td> | |||
<td style="background-color: rgba(0,0,0,0.2);">none</td> | |||
</tr> | |||
<tr> | |||
<td>lit</td> | |||
<td>Shape</td> | |||
<td>Shape</td> | |||
<td>Lod2Shape</td> | |||
</tr> | |||
<tr> | |||
<td rowspan="12">yes</td> | |||
<td rowspan="8">no</td> | |||
<td rowspan="4" style="border-right: 2px solid green;">false</td> | |||
<td rowspan="2">dark</td> | |||
<td>no</td> | |||
<td>Lod0Shape and Shape</td> | |||
<td rowspan="2" style="background-color: rgba(0,0,0,0.2);">none</td> | |||
<td rowspan="2" style="background-color: rgba(0,0,0,0.2);">none</td> | |||
</tr> | |||
<tr> | |||
<td>yes</td> | |||
<td>Shape</td> | |||
</tr> | |||
<tr> | |||
<td rowspan="2">lit</td> | |||
<td>no</td> | |||
<td>Lod0Shape and Shape</td> | |||
<td>Shape</td> | |||
<td>Shape</td> | |||
</tr> | |||
</tr> | |||
<td>yes</td> | |||
<td>Shape</td> | |||
<td>Shape</td> | |||
<td style="background-color: rgba(0,0,0,0.2);">none</td> | |||
</tr> | |||
<tr> | |||
<td rowspan="4" style="border-right: 2px solid green;">true</td> | |||
<td rowspan="2">dark</td> | |||
<td>no</td> | |||
<td>Lod0Shape and Shape</td> | |||
<td rowspan="2" style="background-color: rgba(0,0,0,0.2);">none</td> | |||
<td rowspan="4" style="background-color: rgba(0,0,0,0.2);">none</td> | |||
</tr> | |||
<tr> | |||
<td>yes</td> | |||
<td>Shape</td> | |||
</tr> | |||
<tr> | |||
<td rowspan="2">lit</td> | |||
<td>no</td> | |||
<td>Lod0Shape and Shape</td> | |||
<td rowspan="2">Shape</td> | |||
</tr> | |||
<tr> | |||
<td>yes</td> | |||
<td>Shape</td> | |||
</tr> | |||
<tr> | |||
<td rowspan="4">yes</td> | |||
<td rowspan="4" style="border-right: 2px solid green;">either</td> | |||
<td rowspan="2">dark</td> | |||
<td>no</td> | |||
<td>Lod0Shape and Shape</td> | |||
<td rowspan="2" style="background-color: rgba(0,0,0,0.2);">none</td> | |||
<td rowspan="2" style="background-color: rgba(0,0,0,0.2);">none</td> | |||
</tr> | |||
<tr> | |||
<td>yes</td> | |||
<td>Shape</td> | |||
</tr> | |||
<tr> | |||
<td rowspan="2">lit</td> | |||
<td>no</td> | |||
<td>Lod0Shape and Shape</td> | |||
<td rowspan="2">Shape</td> | |||
<td rowspan="2">Lod2Shape</td> | |||
</tr> | |||
<tr> | |||
<td>yes</td> | |||
<td>Shape</td> | |||
</tr> | |||
</table> |
Revision as of 06:34, 30 October 2023
JSON
BlockEntity
If the block has a block entity, then OnTesselation is called on it. OnTesselation may add meshes to the meshpool (meshes to be rendered for the chunk) through the mesher
parameter. It may return false, in which case the json mesh file is still processed. Or it may return true to skip processing the json mesh file.
Level of detail
Most blocks only use the Shape property and leave the other render settings at the default. This causes the shape to be rendered as long as it is visible within the frustum. However, there are some properties to adjust the level of detail at different render distances:
Lod0Shape
(composite shape)- Shape rendered at close distances
FaceCullMode
(EnumFaceCullMode: default "default")- When set to "collapsematerial" and the
Lod0Shape
is set, then theLod0Shape
is not rendered when the block is surrounded all sides (except for the bottom, which is ignored).
Lod2Shape
(composite shape)- When set, this is rendered at far distances. The rendering of the regular shape is changed such that it is only shown at short and medium distances.
DoNotRenderAtLod2
(boolean: default false)- Causes
Shape
to only be shown at short and medium distances. This only has an effect whenLod2Shape
is unset.
The interaction between these properties is rather complicated and the effect of every combination is shown in this table.
Lod0Shape set | Lod2Shape set | DoNotRenderAtLod2 | Block lighting | Collapsible material and surrounded | Rendered at short distance | Rendered at medium distance | Rendered at far distance |
---|---|---|---|---|---|---|---|
no | no | false | dark | either | Shape | none | none |
lit | Shape | Shape | Shape | ||||
true | dark | Shape | none | none | |||
lit | Shape | Shape | Shape | ||||
yes | either | dark | Shape | none | none | ||
lit | Shape | Shape | Lod2Shape | ||||
yes | no | false | dark | no | Lod0Shape and Shape | none | none |
yes | Shape | ||||||
lit | no | Lod0Shape and Shape | Shape | Shape | |||
yes | Shape | Shape | none | ||||
true | dark | no | Lod0Shape and Shape | none | none | ||
yes | Shape | ||||||
lit | no | Lod0Shape and Shape | Shape | ||||
yes | Shape | ||||||
yes | either | dark | no | Lod0Shape and Shape | none | none | |
yes | Shape | ||||||
lit | no | Lod0Shape and Shape | Shape | Lod2Shape | |||
yes | Shape |