Fluid and item visuals

This commit is contained in:
2026-10-25 18:46:48 -03:00
parent 08df7f1b6b
commit 233c518def
15 changed files with 549 additions and 122 deletions
+15 -9
View File
@@ -4,10 +4,10 @@ A plan for porting all of Create to bworld as a mod, `mods/create`: its kinetics
redstone, contraptions, trains, equipment, decoration and schematics. It aims to do this with as little hand work as
possible, and to stay fast on both the server and the client when a world has thousands of moving parts.
Built so far: the importer and Create's imported blocks and items, R1, R2, R3 (`transformed` and `rotating`), R4, R5,
R8, S0, S4, S7, S12, stonecutting from S9, the start of P1's kinetics (shafts and cogwheels turned by a hand crank),
Create's pressing recipes, and the mechanical press pressing items on the ground. Facts about Create come from reading
`ports/create1.21.1` and `ports/create1.19.3`, and facts about bworld from its source.
Built so far: the importer and Create's imported blocks and items, R1, R2, R3 (`transformed`, `rotating`, `fluid` and
items), R4, R5, R8, S0, S4, S7, S12, stonecutting from S9, the start of P1's kinetics (shafts and cogwheels turned by a
hand crank), Create's pressing recipes, and the mechanical press pressing items on the ground. Facts about Create come
from reading `ports/create1.21.1` and `ports/create1.19.3`, and facts about bworld from its source.
## Sources
@@ -248,9 +248,9 @@ draws `rotating` and `transformed` instances of its block's model or of any mode
variant. A visual that has to move on the CPU (a crank easing in, a press head) gets `on_frame`, like `DynamicVisual`.
Visuals are kept per chunk, and only the ones in chunks in view get `on_frame`.
**R3. Instanced drawing** (P1, `transformed` and `rotating` built). A WebGPU pipeline that draws one model many times
from an instance buffer (`vs_instance` in `client/renderer/core.ts`, cut out like cutout terrain). The instance types,
matching Create's:
**R3. Instanced drawing** (P1, `transformed`, `rotating`, `fluid` and items built). A WebGPU pipeline that draws one
model many times from an instance buffer (`vs_instance` in `client/renderer/core.ts`, cut out like cutout terrain). The
instance types, matching Create's:
| Type | Per instance | Shader |
| ------------- | ------------------------------------------ | ----------------------------------------------------------------------- |
@@ -269,8 +269,14 @@ instances are grouped by model alone. Each group keeps its instances on the CPU
range from the first changed instance to the last once a frame. A deleted instance's place is taken by the last one, so
a group's instances are always its first ones. Light comes with each chunk mesh. Every instance is drawn each frame,
with no culling by chunk, since a draw call per model is cheaper than one per model per chunk until there are far more
instances than P1 has. Faces are shaded on the GPU by the way they face after turning. `scrolling` comes with belts (P4)
and `fluid` with tanks (P5).
instances than P1 has. Faces are shaded on the GPU by the way they face after turning. `scrolling` comes with belts
(P4).
`fluid` is built apart from the table: each box is a model of its own, built on the CPU when its box is set, cut into a
piece per block it crosses so the texture is never stretched, like Create's `renderTiledFace`, and tinted in its fluid's
color. It's one draw call per box, drawn blended after the other instances and back to front. Items are transformed
instances too, of a model built once from what an item draws, one per way an item looks (its id, texture and layer
colors), so a belt of one item is one draw call.
**R4. Models without blocks** (P1). Any model in `models/` can be loaded by id for visuals, baked once into a GPU
buffer, and turned for whatever axis it's used on. Built: each model is baked the first time a visual uses it and