mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-07 12:56:31 +01:00
Move RenderStage from Material to InstancerManager#instancer
This commit is contained in:
parent
bbcf019bc2
commit
9a88bb96ab
19 changed files with 89 additions and 115 deletions
|
@ -1,5 +1,6 @@
|
||||||
package com.jozufozu.flywheel.api.instancer;
|
package com.jozufozu.flywheel.api.instancer;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.api.RenderStage;
|
||||||
import com.jozufozu.flywheel.api.struct.StructType;
|
import com.jozufozu.flywheel.api.struct.StructType;
|
||||||
import com.jozufozu.flywheel.core.model.Model;
|
import com.jozufozu.flywheel.core.model.Model;
|
||||||
|
|
||||||
|
@ -12,7 +13,7 @@ public interface InstancerManager {
|
||||||
*
|
*
|
||||||
* @return An instancer for the given struct type and model.
|
* @return An instancer for the given struct type and model.
|
||||||
*/
|
*/
|
||||||
<D extends InstancedPart> Instancer<D> instancer(StructType<D> type, Model model);
|
<D extends InstancedPart> Instancer<D> instancer(StructType<D> type, Model model, RenderStage stage);
|
||||||
|
|
||||||
Vec3i getOriginCoordinate();
|
Vec3i getOriginCoordinate();
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.jozufozu.flywheel.api.material;
|
package com.jozufozu.flywheel.api.material;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.api.RenderStage;
|
|
||||||
import com.jozufozu.flywheel.api.vertex.MutableVertexList;
|
import com.jozufozu.flywheel.api.vertex.MutableVertexList;
|
||||||
import com.jozufozu.flywheel.core.source.FileResolution;
|
import com.jozufozu.flywheel.core.source.FileResolution;
|
||||||
|
|
||||||
|
@ -8,8 +7,6 @@ import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
|
|
||||||
public interface Material {
|
public interface Material {
|
||||||
RenderStage getRenderStage();
|
|
||||||
|
|
||||||
FileResolution getVertexShader();
|
FileResolution getVertexShader();
|
||||||
|
|
||||||
FileResolution getFragmentShader();
|
FileResolution getFragmentShader();
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package com.jozufozu.flywheel.backend.instancing;
|
package com.jozufozu.flywheel.backend.instancing;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.api.RenderStage;
|
||||||
import com.jozufozu.flywheel.api.instancer.InstancedPart;
|
import com.jozufozu.flywheel.api.instancer.InstancedPart;
|
||||||
import com.jozufozu.flywheel.api.struct.StructType;
|
import com.jozufozu.flywheel.api.struct.StructType;
|
||||||
import com.jozufozu.flywheel.core.model.Model;
|
import com.jozufozu.flywheel.core.model.Model;
|
||||||
|
|
||||||
public record InstancerKey<D extends InstancedPart>(StructType<D> type, Model model) {
|
public record InstancerKey<D extends InstancedPart>(StructType<D> type, Model model, RenderStage stage) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,8 @@ public class BatchingEngine implements Engine {
|
||||||
protected final BatchingDrawTracker drawTracker = new BatchingDrawTracker();
|
protected final BatchingDrawTracker drawTracker = new BatchingDrawTracker();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <D extends InstancedPart> Instancer<D> instancer(StructType<D> type, Model model) {
|
public <D extends InstancedPart> Instancer<D> instancer(StructType<D> type, Model model, RenderStage stage) {
|
||||||
return transformManager.getInstancer(type, model);
|
return transformManager.getInstancer(type, model, stage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -27,8 +27,8 @@ import net.minecraft.client.renderer.RenderType;
|
||||||
|
|
||||||
public class BatchingTransformManager {
|
public class BatchingTransformManager {
|
||||||
private final Map<InstancerKey<?>, CPUInstancer<?>> instancers = new HashMap<>();
|
private final Map<InstancerKey<?>, CPUInstancer<?>> instancers = new HashMap<>();
|
||||||
private final List<UninitializedModel> uninitializedModels = new ArrayList<>();
|
private final List<UninitializedInstancer> uninitializedInstancers = new ArrayList<>();
|
||||||
private final List<CPUInstancer<?>> allInstancers = new ArrayList<>();
|
private final List<CPUInstancer<?>> initializedInstancers = new ArrayList<>();
|
||||||
private final Map<RenderStage, TransformSet> transformSets = new EnumMap<>(RenderStage.class);
|
private final Map<RenderStage, TransformSet> transformSets = new EnumMap<>(RenderStage.class);
|
||||||
private final Map<RenderStage, TransformSet> transformSetsView = Collections.unmodifiableMap(transformSets);
|
private final Map<RenderStage, TransformSet> transformSetsView = Collections.unmodifiableMap(transformSets);
|
||||||
private final Map<VertexFormat, BatchedMeshPool> meshPools = new HashMap<>();
|
private final Map<VertexFormat, BatchedMeshPool> meshPools = new HashMap<>();
|
||||||
|
@ -42,22 +42,22 @@ public class BatchingTransformManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <D extends InstancedPart> Instancer<D> getInstancer(StructType<D> type, Model model) {
|
public <D extends InstancedPart> Instancer<D> getInstancer(StructType<D> type, Model model, RenderStage stage) {
|
||||||
InstancerKey<D> key = new InstancerKey<>(type, model);
|
InstancerKey<D> key = new InstancerKey<>(type, model, stage);
|
||||||
CPUInstancer<D> instancer = (CPUInstancer<D>) instancers.get(key);
|
CPUInstancer<D> instancer = (CPUInstancer<D>) instancers.get(key);
|
||||||
if (instancer == null) {
|
if (instancer == null) {
|
||||||
instancer = new CPUInstancer<>(type);
|
instancer = new CPUInstancer<>(type);
|
||||||
instancers.put(key, instancer);
|
instancers.put(key, instancer);
|
||||||
uninitializedModels.add(new UninitializedModel(instancer, model));
|
uninitializedInstancers.add(new UninitializedInstancer(instancer, model, stage));
|
||||||
}
|
}
|
||||||
return instancer;
|
return instancer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flush() {
|
public void flush() {
|
||||||
for (var model : uninitializedModels) {
|
for (var instancer : uninitializedInstancers) {
|
||||||
add(model.instancer(), model.model());
|
add(instancer.instancer(), instancer.model(), instancer.stage());
|
||||||
}
|
}
|
||||||
uninitializedModels.clear();
|
uninitializedInstancers.clear();
|
||||||
|
|
||||||
for (var pool : meshPools.values()) {
|
for (var pool : meshPools.values()) {
|
||||||
pool.flush();
|
pool.flush();
|
||||||
|
@ -71,25 +71,24 @@ public class BatchingTransformManager {
|
||||||
.forEach(BatchedMeshPool::delete);
|
.forEach(BatchedMeshPool::delete);
|
||||||
meshPools.clear();
|
meshPools.clear();
|
||||||
|
|
||||||
allInstancers.forEach(CPUInstancer::delete);
|
initializedInstancers.forEach(CPUInstancer::delete);
|
||||||
allInstancers.clear();
|
initializedInstancers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearInstancers() {
|
public void clearInstancers() {
|
||||||
allInstancers.forEach(CPUInstancer::clear);
|
initializedInstancers.forEach(CPUInstancer::clear);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void add(CPUInstancer<?> instancer, Model model) {
|
private void add(CPUInstancer<?> instancer, Model model, RenderStage stage) {
|
||||||
|
TransformSet transformSet = transformSets.computeIfAbsent(stage, TransformSet::new);
|
||||||
var meshes = model.getMeshes();
|
var meshes = model.getMeshes();
|
||||||
for (var entry : meshes.entrySet()) {
|
for (var entry : meshes.entrySet()) {
|
||||||
var material = entry.getKey();
|
var material = entry.getKey();
|
||||||
var renderType = material.getBatchingRenderType();
|
var renderType = material.getBatchingRenderType();
|
||||||
TransformCall<?> transformCall = new TransformCall<>(instancer, material, alloc(entry.getValue(), renderType.format()));
|
TransformCall<?> transformCall = new TransformCall<>(instancer, material, alloc(entry.getValue(), renderType.format()));
|
||||||
|
transformSet.put(renderType, transformCall);
|
||||||
transformSets.computeIfAbsent(material.getRenderStage(), TransformSet::new)
|
|
||||||
.put(renderType, transformCall);
|
|
||||||
}
|
}
|
||||||
allInstancers.add(instancer);
|
initializedInstancers.add(instancer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BatchedMeshPool.BufferedMesh alloc(Mesh mesh, VertexFormat format) {
|
private BatchedMeshPool.BufferedMesh alloc(Mesh mesh, VertexFormat format) {
|
||||||
|
@ -127,6 +126,6 @@ public class BatchingTransformManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private record UninitializedModel(CPUInstancer<?> instancer, Model model) {
|
private record UninitializedInstancer(CPUInstancer<?> instancer, Model model, RenderStage stage) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package com.jozufozu.flywheel.backend.instancing.batching;
|
package com.jozufozu.flywheel.backend.instancing.batching;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.jozufozu.flywheel.api.instancer.InstancedPart;
|
import com.jozufozu.flywheel.api.instancer.InstancedPart;
|
||||||
import com.jozufozu.flywheel.api.struct.StructType;
|
import com.jozufozu.flywheel.api.struct.StructType;
|
||||||
import com.jozufozu.flywheel.backend.instancing.AbstractInstancer;
|
import com.jozufozu.flywheel.backend.instancing.AbstractInstancer;
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.jozufozu.flywheel.backend.instancing.indirect;
|
||||||
|
|
||||||
import org.lwjgl.system.MemoryUtil;
|
import org.lwjgl.system.MemoryUtil;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.api.RenderStage;
|
||||||
import com.jozufozu.flywheel.api.instancer.InstancedPart;
|
import com.jozufozu.flywheel.api.instancer.InstancedPart;
|
||||||
import com.jozufozu.flywheel.api.material.Material;
|
import com.jozufozu.flywheel.api.material.Material;
|
||||||
|
|
||||||
|
@ -9,13 +10,15 @@ public final class IndirectDraw<T extends InstancedPart> {
|
||||||
final IndirectInstancer<T> instancer;
|
final IndirectInstancer<T> instancer;
|
||||||
final IndirectMeshPool.BufferedMesh mesh;
|
final IndirectMeshPool.BufferedMesh mesh;
|
||||||
final Material material;
|
final Material material;
|
||||||
|
final RenderStage stage;
|
||||||
int baseInstance = -1;
|
int baseInstance = -1;
|
||||||
|
|
||||||
boolean needsFullWrite = true;
|
boolean needsFullWrite = true;
|
||||||
|
|
||||||
IndirectDraw(IndirectInstancer<T> instancer, Material material, IndirectMeshPool.BufferedMesh mesh) {
|
IndirectDraw(IndirectInstancer<T> instancer, Material material, RenderStage stage, IndirectMeshPool.BufferedMesh mesh) {
|
||||||
this.instancer = instancer;
|
this.instancer = instancer;
|
||||||
this.material = material;
|
this.material = material;
|
||||||
|
this.stage = stage;
|
||||||
this.mesh = mesh;
|
this.mesh = mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.api.RenderStage;
|
||||||
import com.jozufozu.flywheel.api.instancer.InstancedPart;
|
import com.jozufozu.flywheel.api.instancer.InstancedPart;
|
||||||
import com.jozufozu.flywheel.api.instancer.Instancer;
|
import com.jozufozu.flywheel.api.instancer.Instancer;
|
||||||
import com.jozufozu.flywheel.api.struct.StructType;
|
import com.jozufozu.flywheel.api.struct.StructType;
|
||||||
|
@ -16,27 +17,27 @@ import com.jozufozu.flywheel.util.Pair;
|
||||||
public class IndirectDrawManager {
|
public class IndirectDrawManager {
|
||||||
|
|
||||||
private final Map<InstancerKey<?>, IndirectInstancer<?>> instancers = new HashMap<>();
|
private final Map<InstancerKey<?>, IndirectInstancer<?>> instancers = new HashMap<>();
|
||||||
private final List<UninitializedModel> uninitializedModels = new ArrayList<>();
|
private final List<UninitializedInstancer> uninitializedInstancers = new ArrayList<>();
|
||||||
private final List<IndirectInstancer<?>> allInstancers = new ArrayList<>();
|
private final List<IndirectInstancer<?>> initializedInstancers = new ArrayList<>();
|
||||||
public final Map<Pair<StructType<?>, VertexType>, IndirectCullingGroup<?>> renderLists = new HashMap<>();
|
public final Map<Pair<StructType<?>, VertexType>, IndirectCullingGroup<?>> renderLists = new HashMap<>();
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <D extends InstancedPart> Instancer<D> getInstancer(StructType<D> type, Model model) {
|
public <D extends InstancedPart> Instancer<D> getInstancer(StructType<D> type, Model model, RenderStage stage) {
|
||||||
InstancerKey<D> key = new InstancerKey<>(type, model);
|
InstancerKey<D> key = new InstancerKey<>(type, model, stage);
|
||||||
IndirectInstancer<D> instancer = (IndirectInstancer<D>) instancers.get(key);
|
IndirectInstancer<D> instancer = (IndirectInstancer<D>) instancers.get(key);
|
||||||
if (instancer == null) {
|
if (instancer == null) {
|
||||||
instancer = new IndirectInstancer<>(type);
|
instancer = new IndirectInstancer<>(type);
|
||||||
instancers.put(key, instancer);
|
instancers.put(key, instancer);
|
||||||
uninitializedModels.add(new UninitializedModel(instancer, model));
|
uninitializedInstancers.add(new UninitializedInstancer(instancer, model, stage));
|
||||||
}
|
}
|
||||||
return instancer;
|
return instancer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flush() {
|
public void flush() {
|
||||||
for (var model : uninitializedModels) {
|
for (var instancer : uninitializedInstancers) {
|
||||||
add(model.instancer(), model.model());
|
add(instancer.instancer(), instancer.model(), instancer.stage());
|
||||||
}
|
}
|
||||||
uninitializedModels.clear();
|
uninitializedInstancers.clear();
|
||||||
|
|
||||||
for (IndirectCullingGroup<?> value : renderLists.values()) {
|
for (IndirectCullingGroup<?> value : renderLists.values()) {
|
||||||
value.beginFrame();
|
value.beginFrame();
|
||||||
|
@ -50,16 +51,16 @@ public class IndirectDrawManager {
|
||||||
.forEach(IndirectCullingGroup::delete);
|
.forEach(IndirectCullingGroup::delete);
|
||||||
renderLists.clear();
|
renderLists.clear();
|
||||||
|
|
||||||
allInstancers.forEach(IndirectInstancer::delete);
|
initializedInstancers.forEach(IndirectInstancer::delete);
|
||||||
allInstancers.clear();
|
initializedInstancers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearInstancers() {
|
public void clearInstancers() {
|
||||||
allInstancers.forEach(IndirectInstancer::clear);
|
initializedInstancers.forEach(IndirectInstancer::clear);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private <D extends InstancedPart> void add(IndirectInstancer<D> instancer, Model model) {
|
private <D extends InstancedPart> void add(IndirectInstancer<D> instancer, Model model, RenderStage stage) {
|
||||||
var meshes = model.getMeshes();
|
var meshes = model.getMeshes();
|
||||||
for (var entry : meshes.entrySet()) {
|
for (var entry : meshes.entrySet()) {
|
||||||
var material = entry.getKey();
|
var material = entry.getKey();
|
||||||
|
@ -67,13 +68,13 @@ public class IndirectDrawManager {
|
||||||
|
|
||||||
var indirectList = (IndirectCullingGroup<D>) renderLists.computeIfAbsent(Pair.of(instancer.type, mesh.getVertexType()), p -> new IndirectCullingGroup<>(p.first(), p.second()));
|
var indirectList = (IndirectCullingGroup<D>) renderLists.computeIfAbsent(Pair.of(instancer.type, mesh.getVertexType()), p -> new IndirectCullingGroup<>(p.first(), p.second()));
|
||||||
|
|
||||||
indirectList.drawSet.add(instancer, material, indirectList.meshPool.alloc(mesh));
|
indirectList.drawSet.add(instancer, material, stage, indirectList.meshPool.alloc(mesh));
|
||||||
|
|
||||||
break; // TODO: support multiple meshes per model
|
break; // TODO: support multiple meshes per model
|
||||||
}
|
}
|
||||||
allInstancers.add(instancer);
|
initializedInstancers.add(instancer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private record UninitializedModel(IndirectInstancer<?> instancer, Model model) {
|
private record UninitializedInstancer(IndirectInstancer<?> instancer, Model model, RenderStage stage) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,19 +23,19 @@ public class IndirectDrawSet<T extends InstancedPart> {
|
||||||
return indirectDraws.size();
|
return indirectDraws.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(IndirectInstancer<T> instancer, Material material, IndirectMeshPool.BufferedMesh bufferedMesh) {
|
public void add(IndirectInstancer<T> instancer, Material material, RenderStage stage, IndirectMeshPool.BufferedMesh bufferedMesh) {
|
||||||
indirectDraws.add(new IndirectDraw<>(instancer, material, bufferedMesh));
|
indirectDraws.add(new IndirectDraw<>(instancer, material, stage, bufferedMesh));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void submit(RenderStage stage) {
|
public void submit(RenderStage stage) {
|
||||||
final int stride = (int) IndirectBuffers.DRAW_COMMAND_STRIDE;
|
final int stride = (int) IndirectBuffers.DRAW_COMMAND_STRIDE;
|
||||||
for (int i = 0, indirectDrawsSize = indirectDraws.size(); i < indirectDrawsSize; i++) {
|
for (int i = 0, indirectDrawsSize = indirectDraws.size(); i < indirectDrawsSize; i++) {
|
||||||
var batch = indirectDraws.get(i);
|
var batch = indirectDraws.get(i);
|
||||||
var material = batch.material;
|
if (batch.stage != stage) {
|
||||||
|
|
||||||
if (material.getRenderStage() != stage) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var material = batch.material;
|
||||||
material.setup();
|
material.setup();
|
||||||
glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_INT, i * stride, 1, stride);
|
glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_INT, i * stride, 1, stride);
|
||||||
material.clear();
|
material.clear();
|
||||||
|
@ -44,7 +44,7 @@ public class IndirectDrawSet<T extends InstancedPart> {
|
||||||
|
|
||||||
public boolean contains(RenderStage stage) {
|
public boolean contains(RenderStage stage) {
|
||||||
for (var draw : indirectDraws) {
|
for (var draw : indirectDraws) {
|
||||||
if (draw.material.getRenderStage() == stage) {
|
if (draw.stage == stage) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,8 @@ public class IndirectEngine implements Engine {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <D extends InstancedPart> Instancer<D> instancer(StructType<D> type, Model model) {
|
public <D extends InstancedPart> Instancer<D> instancer(StructType<D> type, Model model, RenderStage stage) {
|
||||||
return drawManager.getInstancer(type, model);
|
return drawManager.getInstancer(type, model, stage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -25,35 +25,35 @@ import com.jozufozu.flywheel.core.model.Model;
|
||||||
public class InstancingDrawManager {
|
public class InstancingDrawManager {
|
||||||
|
|
||||||
private final Map<InstancerKey<?>, GPUInstancer<?>> instancers = new HashMap<>();
|
private final Map<InstancerKey<?>, GPUInstancer<?>> instancers = new HashMap<>();
|
||||||
private final List<UninitializedModel> uninitializedModels = new ArrayList<>();
|
private final List<UninitializedInstancer> uninitializedInstancers = new ArrayList<>();
|
||||||
private final List<GPUInstancer<?>> allInstancers = new ArrayList<>();
|
private final List<GPUInstancer<?>> initializedInstancers = new ArrayList<>();
|
||||||
private final Map<RenderStage, DrawSet> renderLists = new EnumMap<>(RenderStage.class);
|
private final Map<RenderStage, DrawSet> drawDets = new EnumMap<>(RenderStage.class);
|
||||||
private final Map<VertexType, InstancedMeshPool> meshPools = new HashMap<>();
|
private final Map<VertexType, InstancedMeshPool> meshPools = new HashMap<>();
|
||||||
|
|
||||||
public DrawSet get(RenderStage stage) {
|
public DrawSet get(RenderStage stage) {
|
||||||
return renderLists.getOrDefault(stage, DrawSet.EMPTY);
|
return drawDets.getOrDefault(stage, DrawSet.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <D extends InstancedPart> Instancer<D> getInstancer(StructType<D> type, Model model) {
|
public <D extends InstancedPart> Instancer<D> getInstancer(StructType<D> type, Model model, RenderStage stage) {
|
||||||
InstancerKey<D> key = new InstancerKey<>(type, model);
|
InstancerKey<D> key = new InstancerKey<>(type, model, stage);
|
||||||
GPUInstancer<D> instancer = (GPUInstancer<D>) instancers.get(key);
|
GPUInstancer<D> instancer = (GPUInstancer<D>) instancers.get(key);
|
||||||
if (instancer == null) {
|
if (instancer == null) {
|
||||||
instancer = new GPUInstancer<>(type);
|
instancer = new GPUInstancer<>(type);
|
||||||
instancers.put(key, instancer);
|
instancers.put(key, instancer);
|
||||||
uninitializedModels.add(new UninitializedModel(instancer, model));
|
uninitializedInstancers.add(new UninitializedInstancer(instancer, model, stage));
|
||||||
}
|
}
|
||||||
return instancer;
|
return instancer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flush() {
|
public void flush() {
|
||||||
for (var model : uninitializedModels) {
|
for (var instancer : uninitializedInstancers) {
|
||||||
model.instancer()
|
instancer.instancer()
|
||||||
.init();
|
.init();
|
||||||
|
|
||||||
add(model.instancer(), model.model());
|
add(instancer.instancer(), instancer.model(), instancer.stage());
|
||||||
}
|
}
|
||||||
uninitializedModels.clear();
|
uninitializedInstancers.clear();
|
||||||
|
|
||||||
for (var pool : meshPools.values()) {
|
for (var pool : meshPools.values()) {
|
||||||
pool.flush();
|
pool.flush();
|
||||||
|
@ -67,29 +67,27 @@ public class InstancingDrawManager {
|
||||||
.forEach(InstancedMeshPool::delete);
|
.forEach(InstancedMeshPool::delete);
|
||||||
meshPools.clear();
|
meshPools.clear();
|
||||||
|
|
||||||
renderLists.values()
|
drawDets.values()
|
||||||
.forEach(DrawSet::delete);
|
.forEach(DrawSet::delete);
|
||||||
renderLists.clear();
|
drawDets.clear();
|
||||||
|
|
||||||
allInstancers.forEach(GPUInstancer::delete);
|
initializedInstancers.forEach(GPUInstancer::delete);
|
||||||
allInstancers.clear();
|
initializedInstancers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearInstancers() {
|
public void clearInstancers() {
|
||||||
allInstancers.forEach(GPUInstancer::clear);
|
initializedInstancers.forEach(GPUInstancer::clear);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void add(GPUInstancer<?> instancer, Model model) {
|
private void add(GPUInstancer<?> instancer, Model model, RenderStage stage) {
|
||||||
|
DrawSet drawSet = drawDets.computeIfAbsent(stage, DrawSet::new);
|
||||||
var meshes = model.getMeshes();
|
var meshes = model.getMeshes();
|
||||||
for (var entry : meshes.entrySet()) {
|
for (var entry : meshes.entrySet()) {
|
||||||
DrawCall drawCall = new DrawCall(instancer, entry.getKey(), alloc(entry.getValue()));
|
DrawCall drawCall = new DrawCall(instancer, entry.getKey(), alloc(entry.getValue()));
|
||||||
var material = drawCall.getMaterial();
|
var shaderState = new ShaderState(drawCall.getMaterial(), drawCall.getVertexType(), drawCall.instancer.type);
|
||||||
var shaderState = new ShaderState(material, drawCall.getVertexType(), drawCall.instancer.type);
|
drawSet.put(shaderState, drawCall);
|
||||||
|
|
||||||
renderLists.computeIfAbsent(material.getRenderStage(), DrawSet::new)
|
|
||||||
.put(shaderState, drawCall);
|
|
||||||
}
|
}
|
||||||
allInstancers.add(instancer);
|
initializedInstancers.add(instancer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private InstancedMeshPool.BufferedMesh alloc(Mesh mesh) {
|
private InstancedMeshPool.BufferedMesh alloc(Mesh mesh) {
|
||||||
|
@ -134,6 +132,6 @@ public class InstancingDrawManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private record UninitializedModel(GPUInstancer<?> instancer, Model model) {
|
private record UninitializedInstancer(GPUInstancer<?> instancer, Model model, RenderStage stage) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,8 +50,8 @@ public class InstancingEngine implements Engine {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <D extends InstancedPart> Instancer<D> instancer(StructType<D> type, Model model) {
|
public <D extends InstancedPart> Instancer<D> instancer(StructType<D> type, Model model, RenderStage stage) {
|
||||||
return drawManager.getInstancer(type, model);
|
return drawManager.getInstancer(type, model, stage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.jozufozu.flywheel.core;
|
package com.jozufozu.flywheel.core;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.api.RenderStage;
|
|
||||||
import com.jozufozu.flywheel.api.material.Material;
|
import com.jozufozu.flywheel.api.material.Material;
|
||||||
import com.jozufozu.flywheel.backend.ShadersModHandler;
|
import com.jozufozu.flywheel.backend.ShadersModHandler;
|
||||||
import com.jozufozu.flywheel.backend.gl.GlTextureUnit;
|
import com.jozufozu.flywheel.backend.gl.GlTextureUnit;
|
||||||
|
@ -36,7 +35,6 @@ public final class Materials {
|
||||||
private static final ResourceLocation MINECART_LOCATION = new ResourceLocation("textures/entity/minecart.png");
|
private static final ResourceLocation MINECART_LOCATION = new ResourceLocation("textures/entity/minecart.png");
|
||||||
|
|
||||||
public static final Material CHUNK_SOLID_SHADED = SimpleMaterial.builder()
|
public static final Material CHUNK_SOLID_SHADED = SimpleMaterial.builder()
|
||||||
.stage(RenderStage.AFTER_SOLID_TERRAIN)
|
|
||||||
.vertexShader(Components.Files.SHADED_VERTEX)
|
.vertexShader(Components.Files.SHADED_VERTEX)
|
||||||
.fragmentShader(Components.Files.DEFAULT_FRAGMENT)
|
.fragmentShader(Components.Files.DEFAULT_FRAGMENT)
|
||||||
.addShard(Shards.diffuseTex(InventoryMenu.BLOCK_ATLAS, false, true))
|
.addShard(Shards.diffuseTex(InventoryMenu.BLOCK_ATLAS, false, true))
|
||||||
|
@ -44,7 +42,6 @@ public final class Materials {
|
||||||
.vertexTransformer(SHADING_TRANSFORMER)
|
.vertexTransformer(SHADING_TRANSFORMER)
|
||||||
.register();
|
.register();
|
||||||
public static final Material CHUNK_SOLID_UNSHADED = SimpleMaterial.builder()
|
public static final Material CHUNK_SOLID_UNSHADED = SimpleMaterial.builder()
|
||||||
.stage(RenderStage.AFTER_SOLID_TERRAIN)
|
|
||||||
.vertexShader(Components.Files.DEFAULT_VERTEX)
|
.vertexShader(Components.Files.DEFAULT_VERTEX)
|
||||||
.fragmentShader(Components.Files.DEFAULT_FRAGMENT)
|
.fragmentShader(Components.Files.DEFAULT_FRAGMENT)
|
||||||
.addShard(Shards.diffuseTex(InventoryMenu.BLOCK_ATLAS, false, true))
|
.addShard(Shards.diffuseTex(InventoryMenu.BLOCK_ATLAS, false, true))
|
||||||
|
@ -52,7 +49,6 @@ public final class Materials {
|
||||||
.register();
|
.register();
|
||||||
|
|
||||||
public static final Material CHUNK_CUTOUT_MIPPED_SHADED = SimpleMaterial.builder()
|
public static final Material CHUNK_CUTOUT_MIPPED_SHADED = SimpleMaterial.builder()
|
||||||
.stage(RenderStage.AFTER_SOLID_TERRAIN)
|
|
||||||
.vertexShader(Components.Files.SHADED_VERTEX)
|
.vertexShader(Components.Files.SHADED_VERTEX)
|
||||||
.fragmentShader(Components.Files.CUTOUT_FRAGMENT)
|
.fragmentShader(Components.Files.CUTOUT_FRAGMENT)
|
||||||
.addShard(Shards.diffuseTex(InventoryMenu.BLOCK_ATLAS, false, true))
|
.addShard(Shards.diffuseTex(InventoryMenu.BLOCK_ATLAS, false, true))
|
||||||
|
@ -60,7 +56,6 @@ public final class Materials {
|
||||||
.vertexTransformer(SHADING_TRANSFORMER)
|
.vertexTransformer(SHADING_TRANSFORMER)
|
||||||
.register();
|
.register();
|
||||||
public static final Material CHUNK_CUTOUT_MIPPED_UNSHADED = SimpleMaterial.builder()
|
public static final Material CHUNK_CUTOUT_MIPPED_UNSHADED = SimpleMaterial.builder()
|
||||||
.stage(RenderStage.AFTER_SOLID_TERRAIN)
|
|
||||||
.vertexShader(Components.Files.DEFAULT_VERTEX)
|
.vertexShader(Components.Files.DEFAULT_VERTEX)
|
||||||
.fragmentShader(Components.Files.CUTOUT_FRAGMENT)
|
.fragmentShader(Components.Files.CUTOUT_FRAGMENT)
|
||||||
.addShard(Shards.diffuseTex(InventoryMenu.BLOCK_ATLAS, false, true))
|
.addShard(Shards.diffuseTex(InventoryMenu.BLOCK_ATLAS, false, true))
|
||||||
|
@ -68,7 +63,6 @@ public final class Materials {
|
||||||
.register();
|
.register();
|
||||||
|
|
||||||
public static final Material CHUNK_CUTOUT_SHADED = SimpleMaterial.builder()
|
public static final Material CHUNK_CUTOUT_SHADED = SimpleMaterial.builder()
|
||||||
.stage(RenderStage.AFTER_SOLID_TERRAIN)
|
|
||||||
.vertexShader(Components.Files.SHADED_VERTEX)
|
.vertexShader(Components.Files.SHADED_VERTEX)
|
||||||
.fragmentShader(Components.Files.CUTOUT_FRAGMENT)
|
.fragmentShader(Components.Files.CUTOUT_FRAGMENT)
|
||||||
.addShard(Shards.diffuseTex(InventoryMenu.BLOCK_ATLAS, false, false))
|
.addShard(Shards.diffuseTex(InventoryMenu.BLOCK_ATLAS, false, false))
|
||||||
|
@ -76,7 +70,6 @@ public final class Materials {
|
||||||
.vertexTransformer(SHADING_TRANSFORMER)
|
.vertexTransformer(SHADING_TRANSFORMER)
|
||||||
.register();
|
.register();
|
||||||
public static final Material CHUNK_CUTOUT_UNSHADED = SimpleMaterial.builder()
|
public static final Material CHUNK_CUTOUT_UNSHADED = SimpleMaterial.builder()
|
||||||
.stage(RenderStage.AFTER_SOLID_TERRAIN)
|
|
||||||
.vertexShader(Components.Files.DEFAULT_VERTEX)
|
.vertexShader(Components.Files.DEFAULT_VERTEX)
|
||||||
.fragmentShader(Components.Files.CUTOUT_FRAGMENT)
|
.fragmentShader(Components.Files.CUTOUT_FRAGMENT)
|
||||||
.addShard(Shards.diffuseTex(InventoryMenu.BLOCK_ATLAS, false, false))
|
.addShard(Shards.diffuseTex(InventoryMenu.BLOCK_ATLAS, false, false))
|
||||||
|
@ -84,7 +77,6 @@ public final class Materials {
|
||||||
.register();
|
.register();
|
||||||
|
|
||||||
public static final Material CHUNK_TRANSLUCENT_SHADED = SimpleMaterial.builder()
|
public static final Material CHUNK_TRANSLUCENT_SHADED = SimpleMaterial.builder()
|
||||||
.stage(RenderStage.AFTER_TRANSLUCENT_TERRAIN)
|
|
||||||
.vertexShader(Components.Files.SHADED_VERTEX)
|
.vertexShader(Components.Files.SHADED_VERTEX)
|
||||||
.fragmentShader(Components.Files.DEFAULT_FRAGMENT)
|
.fragmentShader(Components.Files.DEFAULT_FRAGMENT)
|
||||||
.addShard(Shards.diffuseTex(InventoryMenu.BLOCK_ATLAS, false, true))
|
.addShard(Shards.diffuseTex(InventoryMenu.BLOCK_ATLAS, false, true))
|
||||||
|
@ -93,7 +85,6 @@ public final class Materials {
|
||||||
.vertexTransformer(SHADING_TRANSFORMER)
|
.vertexTransformer(SHADING_TRANSFORMER)
|
||||||
.register();
|
.register();
|
||||||
public static final Material CHUNK_TRANSLUCENT_UNSHADED = SimpleMaterial.builder()
|
public static final Material CHUNK_TRANSLUCENT_UNSHADED = SimpleMaterial.builder()
|
||||||
.stage(RenderStage.AFTER_TRANSLUCENT_TERRAIN)
|
|
||||||
.vertexShader(Components.Files.DEFAULT_VERTEX)
|
.vertexShader(Components.Files.DEFAULT_VERTEX)
|
||||||
.fragmentShader(Components.Files.DEFAULT_FRAGMENT)
|
.fragmentShader(Components.Files.DEFAULT_FRAGMENT)
|
||||||
.addShard(Shards.diffuseTex(InventoryMenu.BLOCK_ATLAS, false, true))
|
.addShard(Shards.diffuseTex(InventoryMenu.BLOCK_ATLAS, false, true))
|
||||||
|
@ -102,7 +93,6 @@ public final class Materials {
|
||||||
.register();
|
.register();
|
||||||
|
|
||||||
public static final Material CHUNK_TRIPWIRE_SHADED = SimpleMaterial.builder()
|
public static final Material CHUNK_TRIPWIRE_SHADED = SimpleMaterial.builder()
|
||||||
.stage(RenderStage.AFTER_TRANSLUCENT_TERRAIN)
|
|
||||||
.vertexShader(Components.Files.SHADED_VERTEX)
|
.vertexShader(Components.Files.SHADED_VERTEX)
|
||||||
.fragmentShader(Components.Files.CUTOUT_FRAGMENT)
|
.fragmentShader(Components.Files.CUTOUT_FRAGMENT)
|
||||||
.addShard(Shards.diffuseTex(InventoryMenu.BLOCK_ATLAS, false, true))
|
.addShard(Shards.diffuseTex(InventoryMenu.BLOCK_ATLAS, false, true))
|
||||||
|
@ -111,7 +101,6 @@ public final class Materials {
|
||||||
.vertexTransformer(SHADING_TRANSFORMER)
|
.vertexTransformer(SHADING_TRANSFORMER)
|
||||||
.register();
|
.register();
|
||||||
public static final Material CHUNK_TRIPWIRE_UNSHADED = SimpleMaterial.builder()
|
public static final Material CHUNK_TRIPWIRE_UNSHADED = SimpleMaterial.builder()
|
||||||
.stage(RenderStage.AFTER_TRANSLUCENT_TERRAIN)
|
|
||||||
.vertexShader(Components.Files.DEFAULT_VERTEX)
|
.vertexShader(Components.Files.DEFAULT_VERTEX)
|
||||||
.fragmentShader(Components.Files.CUTOUT_FRAGMENT)
|
.fragmentShader(Components.Files.CUTOUT_FRAGMENT)
|
||||||
.addShard(Shards.diffuseTex(InventoryMenu.BLOCK_ATLAS, false, true))
|
.addShard(Shards.diffuseTex(InventoryMenu.BLOCK_ATLAS, false, true))
|
||||||
|
@ -120,13 +109,11 @@ public final class Materials {
|
||||||
.register();
|
.register();
|
||||||
|
|
||||||
public static final Material CHEST = SimpleMaterial.builder()
|
public static final Material CHEST = SimpleMaterial.builder()
|
||||||
.stage(RenderStage.AFTER_BLOCK_ENTITIES)
|
|
||||||
.vertexShader(Components.Files.SHADED_VERTEX)
|
.vertexShader(Components.Files.SHADED_VERTEX)
|
||||||
.addShard(Shards.diffuseTex(Sheets.CHEST_SHEET, false, false))
|
.addShard(Shards.diffuseTex(Sheets.CHEST_SHEET, false, false))
|
||||||
.batchingRenderType(Sheets.chestSheet())
|
.batchingRenderType(Sheets.chestSheet())
|
||||||
.register();
|
.register();
|
||||||
public static final Material SHULKER = SimpleMaterial.builder()
|
public static final Material SHULKER = SimpleMaterial.builder()
|
||||||
.stage(RenderStage.AFTER_BLOCK_ENTITIES)
|
|
||||||
.vertexShader(Components.Files.SHADED_VERTEX)
|
.vertexShader(Components.Files.SHADED_VERTEX)
|
||||||
.fragmentShader(Components.Files.CUTOUT_FRAGMENT)
|
.fragmentShader(Components.Files.CUTOUT_FRAGMENT)
|
||||||
.addShard(Shards.diffuseTex(Sheets.SHULKER_SHEET, false, false))
|
.addShard(Shards.diffuseTex(Sheets.SHULKER_SHEET, false, false))
|
||||||
|
@ -134,13 +121,11 @@ public final class Materials {
|
||||||
.batchingRenderType(Sheets.shulkerBoxSheet())
|
.batchingRenderType(Sheets.shulkerBoxSheet())
|
||||||
.register();
|
.register();
|
||||||
public static final Material BELL = SimpleMaterial.builder()
|
public static final Material BELL = SimpleMaterial.builder()
|
||||||
.stage(RenderStage.AFTER_BLOCK_ENTITIES)
|
|
||||||
.vertexShader(Components.Files.SHADED_VERTEX)
|
.vertexShader(Components.Files.SHADED_VERTEX)
|
||||||
.addShard(Shards.diffuseTex(InventoryMenu.BLOCK_ATLAS, false, false))
|
.addShard(Shards.diffuseTex(InventoryMenu.BLOCK_ATLAS, false, false))
|
||||||
.batchingRenderType(Sheets.solidBlockSheet())
|
.batchingRenderType(Sheets.solidBlockSheet())
|
||||||
.register();
|
.register();
|
||||||
public static final Material MINECART = SimpleMaterial.builder()
|
public static final Material MINECART = SimpleMaterial.builder()
|
||||||
.stage(RenderStage.AFTER_ENTITIES)
|
|
||||||
.vertexShader(Components.Files.SHADED_VERTEX)
|
.vertexShader(Components.Files.SHADED_VERTEX)
|
||||||
.addShard(Shards.diffuseTex(MINECART_LOCATION, false, false))
|
.addShard(Shards.diffuseTex(MINECART_LOCATION, false, false))
|
||||||
.batchingRenderType(RenderType.entitySolid(MINECART_LOCATION))
|
.batchingRenderType(RenderType.entitySolid(MINECART_LOCATION))
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.jozufozu.flywheel.core.material;
|
package com.jozufozu.flywheel.core.material;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.api.RenderStage;
|
|
||||||
import com.jozufozu.flywheel.api.material.Material;
|
import com.jozufozu.flywheel.api.material.Material;
|
||||||
import com.jozufozu.flywheel.core.ComponentRegistry;
|
import com.jozufozu.flywheel.core.ComponentRegistry;
|
||||||
import com.jozufozu.flywheel.core.Components;
|
import com.jozufozu.flywheel.core.Components;
|
||||||
|
@ -10,7 +9,6 @@ import net.minecraft.client.renderer.RenderStateShard;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
|
|
||||||
public class SimpleMaterial implements Material {
|
public class SimpleMaterial implements Material {
|
||||||
protected final RenderStage stage;
|
|
||||||
protected final FileResolution vertexShader;
|
protected final FileResolution vertexShader;
|
||||||
protected final FileResolution fragmentShader;
|
protected final FileResolution fragmentShader;
|
||||||
protected final Runnable setup;
|
protected final Runnable setup;
|
||||||
|
@ -18,8 +16,7 @@ public class SimpleMaterial implements Material {
|
||||||
protected final RenderType batchingRenderType;
|
protected final RenderType batchingRenderType;
|
||||||
protected final VertexTransformer vertexTransformer;
|
protected final VertexTransformer vertexTransformer;
|
||||||
|
|
||||||
public SimpleMaterial(RenderStage stage, FileResolution vertexShader, FileResolution fragmentShader, Runnable setup, Runnable clear, RenderType batchingRenderType, VertexTransformer vertexTransformer) {
|
public SimpleMaterial(FileResolution vertexShader, FileResolution fragmentShader, Runnable setup, Runnable clear, RenderType batchingRenderType, VertexTransformer vertexTransformer) {
|
||||||
this.stage = stage;
|
|
||||||
this.vertexShader = vertexShader;
|
this.vertexShader = vertexShader;
|
||||||
this.fragmentShader = fragmentShader;
|
this.fragmentShader = fragmentShader;
|
||||||
this.setup = setup;
|
this.setup = setup;
|
||||||
|
@ -32,11 +29,6 @@ public class SimpleMaterial implements Material {
|
||||||
return new Builder();
|
return new Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public RenderStage getRenderStage() {
|
|
||||||
return stage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FileResolution getVertexShader() {
|
public FileResolution getVertexShader() {
|
||||||
return vertexShader;
|
return vertexShader;
|
||||||
|
@ -68,7 +60,6 @@ public class SimpleMaterial implements Material {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
protected RenderStage stage = RenderStage.AFTER_SOLID_TERRAIN;
|
|
||||||
protected FileResolution vertexShader = Components.Files.DEFAULT_VERTEX;
|
protected FileResolution vertexShader = Components.Files.DEFAULT_VERTEX;
|
||||||
protected FileResolution fragmentShader = Components.Files.DEFAULT_FRAGMENT;
|
protected FileResolution fragmentShader = Components.Files.DEFAULT_FRAGMENT;
|
||||||
protected Runnable setup = () -> {};
|
protected Runnable setup = () -> {};
|
||||||
|
@ -79,11 +70,6 @@ public class SimpleMaterial implements Material {
|
||||||
public Builder() {
|
public Builder() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder stage(RenderStage stage) {
|
|
||||||
this.stage = stage;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder vertexShader(FileResolution vertexShader) {
|
public Builder vertexShader(FileResolution vertexShader) {
|
||||||
this.vertexShader = vertexShader;
|
this.vertexShader = vertexShader;
|
||||||
return this;
|
return this;
|
||||||
|
@ -121,7 +107,7 @@ public class SimpleMaterial implements Material {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleMaterial register() {
|
public SimpleMaterial register() {
|
||||||
return ComponentRegistry.register(new SimpleMaterial(stage, vertexShader, fragmentShader, setup, clear, batchingRenderType, vertexTransformer));
|
return ComponentRegistry.register(new SimpleMaterial(vertexShader, fragmentShader, setup, clear, batchingRenderType, vertexTransformer));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Runnable chain(Runnable runnable1, Runnable runnable2) {
|
private static Runnable chain(Runnable runnable1, Runnable runnable2) {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.api.RenderStage;
|
||||||
import com.jozufozu.flywheel.api.instance.DynamicInstance;
|
import com.jozufozu.flywheel.api.instance.DynamicInstance;
|
||||||
import com.jozufozu.flywheel.api.instancer.InstancedPart;
|
import com.jozufozu.flywheel.api.instancer.InstancedPart;
|
||||||
import com.jozufozu.flywheel.api.instancer.InstancerManager;
|
import com.jozufozu.flywheel.api.instancer.InstancerManager;
|
||||||
|
@ -72,7 +73,7 @@ public class BellInstance extends BlockEntityInstance<BellBlockEntity> implement
|
||||||
}
|
}
|
||||||
|
|
||||||
private OrientedPart createBellInstance() {
|
private OrientedPart createBellInstance() {
|
||||||
return instancerManager.instancer(StructTypes.ORIENTED, MODEL)
|
return instancerManager.instancer(StructTypes.ORIENTED, MODEL, RenderStage.AFTER_BLOCK_ENTITIES)
|
||||||
.createInstance();
|
.createInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.util.function.BiFunction;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.api.RenderStage;
|
||||||
import com.jozufozu.flywheel.api.instance.DynamicInstance;
|
import com.jozufozu.flywheel.api.instance.DynamicInstance;
|
||||||
import com.jozufozu.flywheel.api.instancer.InstancedPart;
|
import com.jozufozu.flywheel.api.instancer.InstancedPart;
|
||||||
import com.jozufozu.flywheel.api.instancer.InstancerManager;
|
import com.jozufozu.flywheel.api.instancer.InstancerManager;
|
||||||
|
@ -123,13 +124,13 @@ public class ChestInstance<T extends BlockEntity & LidBlockEntity> extends Block
|
||||||
|
|
||||||
private OrientedPart baseInstance() {
|
private OrientedPart baseInstance() {
|
||||||
|
|
||||||
return instancerManager.instancer(StructTypes.ORIENTED, BASE.apply(chestType, sprite))
|
return instancerManager.instancer(StructTypes.ORIENTED, BASE.apply(chestType, sprite), RenderStage.AFTER_BLOCK_ENTITIES)
|
||||||
.createInstance();
|
.createInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
private TransformedPart lidInstance() {
|
private TransformedPart lidInstance() {
|
||||||
|
|
||||||
return instancerManager.instancer(StructTypes.TRANSFORMED, LID.apply(chestType, sprite))
|
return instancerManager.instancer(StructTypes.TRANSFORMED, LID.apply(chestType, sprite), RenderStage.AFTER_BLOCK_ENTITIES)
|
||||||
.createInstance();
|
.createInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.jozufozu.flywheel.vanilla;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.api.RenderStage;
|
||||||
import com.jozufozu.flywheel.api.instance.DynamicInstance;
|
import com.jozufozu.flywheel.api.instance.DynamicInstance;
|
||||||
import com.jozufozu.flywheel.api.instance.TickableInstance;
|
import com.jozufozu.flywheel.api.instance.TickableInstance;
|
||||||
import com.jozufozu.flywheel.api.instancer.InstancerManager;
|
import com.jozufozu.flywheel.api.instancer.InstancerManager;
|
||||||
|
@ -167,12 +168,12 @@ public class MinecartInstance<T extends AbstractMinecart> extends EntityInstance
|
||||||
if (shape == RenderShape.INVISIBLE)
|
if (shape == RenderShape.INVISIBLE)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return instancerManager.instancer(StructTypes.TRANSFORMED, Models.block(blockState))
|
return instancerManager.instancer(StructTypes.TRANSFORMED, Models.block(blockState), RenderStage.AFTER_ENTITIES)
|
||||||
.createInstance();
|
.createInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
private TransformedPart getBody() {
|
private TransformedPart getBody() {
|
||||||
return instancerManager.instancer(StructTypes.TRANSFORMED, MODEL)
|
return instancerManager.instancer(StructTypes.TRANSFORMED, MODEL, RenderStage.AFTER_ENTITIES)
|
||||||
.createInstance();
|
.createInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.api.RenderStage;
|
||||||
import com.jozufozu.flywheel.api.instance.DynamicInstance;
|
import com.jozufozu.flywheel.api.instance.DynamicInstance;
|
||||||
import com.jozufozu.flywheel.api.instancer.InstancedPart;
|
import com.jozufozu.flywheel.api.instancer.InstancedPart;
|
||||||
import com.jozufozu.flywheel.api.instancer.InstancerManager;
|
import com.jozufozu.flywheel.api.instancer.InstancerManager;
|
||||||
|
@ -105,12 +106,12 @@ public class ShulkerBoxInstance extends BlockEntityInstance<ShulkerBoxBlockEntit
|
||||||
}
|
}
|
||||||
|
|
||||||
private TransformedPart makeBaseInstance() {
|
private TransformedPart makeBaseInstance() {
|
||||||
return instancerManager.instancer(StructTypes.TRANSFORMED, BASE.apply(texture))
|
return instancerManager.instancer(StructTypes.TRANSFORMED, BASE.apply(texture), RenderStage.AFTER_BLOCK_ENTITIES)
|
||||||
.createInstance();
|
.createInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
private TransformedPart makeLidInstance() {
|
private TransformedPart makeLidInstance() {
|
||||||
return instancerManager.instancer(StructTypes.TRANSFORMED, LID.apply(texture))
|
return instancerManager.instancer(StructTypes.TRANSFORMED, LID.apply(texture), RenderStage.AFTER_BLOCK_ENTITIES)
|
||||||
.createInstance();
|
.createInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.api.RenderStage;
|
||||||
import com.jozufozu.flywheel.api.instance.DynamicInstance;
|
import com.jozufozu.flywheel.api.instance.DynamicInstance;
|
||||||
import com.jozufozu.flywheel.api.instance.TickableInstance;
|
import com.jozufozu.flywheel.api.instance.TickableInstance;
|
||||||
import com.jozufozu.flywheel.api.instancer.InstancerManager;
|
import com.jozufozu.flywheel.api.instancer.InstancerManager;
|
||||||
|
@ -247,7 +248,7 @@ public class ExampleEffect implements Effect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
instance = instancerManager.instancer(StructTypes.TRANSFORMED, Models.block(Blocks.SHROOMLIGHT.defaultBlockState()))
|
instance = instancerManager.instancer(StructTypes.TRANSFORMED, Models.block(Blocks.SHROOMLIGHT.defaultBlockState()), RenderStage.AFTER_PARTICLES)
|
||||||
.createInstance();
|
.createInstance();
|
||||||
|
|
||||||
instance.setBlockLight(15)
|
instance.setBlockLight(15)
|
||||||
|
|
Loading…
Reference in a new issue