| 1 | package net.minecraft.client.renderer;
|
| 2 |
|
| 3 | import com.mojang.blaze3d.pipeline.RenderTarget;
|
| 4 | import com.mojang.blaze3d.resource.ResourceHandle;
|
| 5 | import java.util.ArrayList;
|
| 6 | import java.util.List;
|
| 7 | import java.util.Set;
|
| 8 | import net.fabricmc.api.EnvType;
|
| 9 | import net.fabricmc.api.Environment;
|
| 10 | import net.minecraft.resources.Identifier;
|
| 11 | import org.jspecify.annotations.Nullable;
|
| 12 |
|
| 13 | @Environment(EnvType.CLIENT)
|
| 14 | public class LevelTargetBundle implements PostChain.TargetBundle {
|
| 15 | public static final Identifier MAIN_TARGET_ID = PostChain.MAIN_TARGET_ID;
|
| 16 | public static final Identifier ENTITY_OUTLINE_TARGET_ID = Identifier.withDefaultNamespace("entity_outline");
|
| 17 | public static final Set<Identifier> MAIN_TARGETS = Set.of(MAIN_TARGET_ID);
|
| 18 | public static final Set<Identifier> OUTLINE_TARGETS = Set.of(MAIN_TARGET_ID, ENTITY_OUTLINE_TARGET_ID);
|
| 19 | public ResourceHandle<RenderTarget> main = ResourceHandle.invalid();
|
| 20 | public ResourceHandle<RenderTarget> alwaysOnTopDepth = ResourceHandle.invalid();
|
| 21 | public ResourceHandle<RenderTarget> depthBounds = ResourceHandle.invalid();
|
| 22 | public ResourceHandle<RenderTarget> depthBoundsCulled = ResourceHandle.invalid();
|
| 23 | public final List<ResourceHandle<RenderTarget>> transmittance = new ArrayList<>();
|
| 24 | public ResourceHandle<RenderTarget> accumulate = ResourceHandle.invalid();
|
| 25 | public ResourceHandle<RenderTarget> oitCloudDepth = ResourceHandle.invalid();
|
| 26 | public ResourceHandle<RenderTarget> oitTerrainWithWaterPatchDepth = ResourceHandle.invalid();
|
| 27 | public @Nullable ResourceHandle<RenderTarget> entityOutline;
|
| 28 |
|
| 29 | public LevelTargetBundle() {
|
| 30 | for (int i = 0; i < LevelRenderer.OIT_TRANSMITTANCE_TARGET_COUNT; i++) {
|
| 31 | this.transmittance.add(ResourceHandle.invalid());
|
| 32 | }
|
| 33 | }
|
| 34 |
|
| 35 | @Override
|
| 36 | public void replace(final Identifier id, final ResourceHandle<RenderTarget> handle) {
|
| 37 | if (id.equals(MAIN_TARGET_ID)) {
|
| 38 | this.main = handle;
|
| 39 | } else {
|
| 40 | if (!id.equals(ENTITY_OUTLINE_TARGET_ID)) {
|
| 41 | throw new IllegalArgumentException("No target with id " + id);
|
| 42 | }
|
| 43 |
|
| 44 | this.entityOutline = handle;
|
| 45 | }
|
| 46 | }
|
| 47 |
|
| 48 | @Override
|
| 49 | public @Nullable ResourceHandle<RenderTarget> get(final Identifier id) {
|
| 50 | if (id.equals(MAIN_TARGET_ID)) {
|
| 51 | return this.main;
|
| 52 | } else {
|
| 53 | return id.equals(ENTITY_OUTLINE_TARGET_ID) ? this.entityOutline : null;
|
| 54 | }
|
| 55 | }
|
| 56 |
|
| 57 | public void clear() {
|
| 58 | this.main = ResourceHandle.invalid();
|
| 59 | this.entityOutline = null;
|
| 60 | }
|
| 61 | }
|
| 62 |
|