Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite facade rendering #945

Open
wants to merge 3 commits into
base: dev/1.21.1
Choose a base branch
from
Open

Conversation

IMS212
Copy link

@IMS212 IMS212 commented Dec 30, 2024

Description

This rewrites facade rendering to always use the additional chunk buffering system. Additionally, bugs have been fixed with shaders and mods, and the block breaking overlay now correctly shows when breaking a facade.

Checklist

  • My code follows the style guidelines of this project (.editorconfig, most IDEs will use this for you).
  • I have made corresponding changes to the documentation.
  • My changes are ready for review from a contributor.

@IMS212 IMS212 changed the title Dev/1.21.1 Rewrite facade rendering Dec 30, 2024
@IMS212
Copy link
Author

IMS212 commented Dec 30, 2024

This could be improved quite a bit if there was a map of chunks that had facades; but adding that right now seems potentially out of scope.

@Rover656 Rover656 requested a review from ferriarnus December 30, 2024 20:16
@IMS212
Copy link
Author

IMS212 commented Dec 30, 2024

I've added a chunk map, fixing the above issue. It will check if the chunk has any facades, skipping the expensive lookup step.

Copy link
Member

@ferriarnus ferriarnus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think most of this is good, just some small nitpicks. I do however think an alternative path to not render anything (or a replacement transparent overlay) when shaders are active is needed. This should be linked to a config as wel IMO (I don't mind doing this myself if you haven't worked with the neo config system yet). Thanks for the PR!

@@ -79,7 +83,8 @@ public class ConduitBundleBlockEntity extends EnderBlockEntity {
public static final String CONDUIT_INV_KEY = "ConduitInv";

@UseOnly(LogicalSide.CLIENT)
public static final Map<BlockPos, BlockState> FACADES = new HashMap<>();
public static final Long2ObjectMap<BlockState> FACADES = new Long2ObjectOpenHashMap<>();
public static final Long2ObjectMap<Set<BlockPos>> CHUNK_FACADES = new Long2ObjectOpenHashMap<>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small thing, can this be a LongSet instead of Set<BlockPos>? We do need to convert it back to a blockpos, but it may be a bit faster?

@@ -217,7 +228,8 @@ public void onChunkUnloaded() {
ConduitSavedData savedData = ConduitSavedData.get(serverLevel);
bundle.getConduits().forEach(type -> onChunkUnloaded(savedData, type));
} else {
FACADES.remove(worldPosition);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a heads up, I added another remove in this file a bit after your PR, so there's a small conflict you'll have to solve.

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(BlockRenderDispatcher.class)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we don't have many mixins in enderio, do you mind writing a short explanation what this does/fixes? I think this is for the breaking overlay, but want to make sure.

model.getModelData(level, entry.getKey(), entry.getValue(), ModelData.EMPTY),
renderType);
.tesselateBlock(context.getRegion(), model, state, pos, context.getPoseStack(), consumer,
true, random, 42L, OverlayTexture.NO_OVERLAY, ModelData.EMPTY, renderType);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here (and above as well) ModelData.EMPTY should not be used, but the correct ModelData should be fetched from the model and position. This is needed for some blocks to render properly.

static void renderFacade(RenderLevelStageEvent event) {
if (event.getStage() != RenderLevelStageEvent.Stage.AFTER_TRIPWIRE_BLOCKS || FacadeHelper.areFacadesVisible()) {
static void renderFacade(AddSectionGeometryEvent event) {
Map<BlockPos, BlockState> facades = new Object2ObjectOpenHashMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The map allocation should be moved below the if (blockList == null) check to avoid allocating a redundant map for sections without facades (i.e. most sections, including empty ones).

renderTypes = ChunkRenderTypeSet.union(renderTypes, facadeRenderTypes);
}
return renderTypes;
return ChunkRenderTypeSet.of(RenderType.cutout());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be cached in a static field to avoid allocation.

@Rover656 Rover656 mentioned this pull request Jan 3, 2025
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants