use of net.coderbot.iris.shadows.frustum.BoxCuller in project Iris by IrisShaders.
the class ShadowRenderer method renderBlockEntities.
private void renderBlockEntities(MultiBufferSource.BufferSource bufferSource, PoseStack modelView, double cameraX, double cameraY, double cameraZ, float tickDelta, boolean hasEntityFrustum) {
profiler.push("build blockentities");
int shadowBlockEntities = 0;
BoxCuller culler = null;
if (hasEntityFrustum) {
culler = new BoxCuller(halfPlaneLength * (renderDistanceMultiplier * entityShadowDistanceMultiplier));
culler.setPosition(cameraX, cameraY, cameraZ);
}
for (BlockEntity entity : visibleBlockEntities) {
BlockPos pos = entity.getBlockPos();
if (hasEntityFrustum) {
if (culler.isCulled(pos.getX() - 1, pos.getY() - 1, pos.getZ() - 1, pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1)) {
continue;
}
}
modelView.pushPose();
modelView.translate(pos.getX() - cameraX, pos.getY() - cameraY, pos.getZ() - cameraZ);
BlockEntityRenderDispatcher.instance.render(entity, tickDelta, modelView, bufferSource);
modelView.popPose();
shadowBlockEntities++;
}
renderedShadowBlockEntities = shadowBlockEntities;
}
use of net.coderbot.iris.shadows.frustum.BoxCuller in project Iris by IrisShaders.
the class ShadowRenderer method createShadowFrustum.
private FrustumHolder createShadowFrustum(float renderMultiplier, FrustumHolder holder) {
// TODO: Cull entities / block entities with Advanced Frustum Culling even if voxelization is detected.
String distanceInfo;
String cullingInfo;
if ((packCullingState == OptionalBoolean.FALSE || packHasVoxelization || packHasIndirectSunBounceGi) && packCullingState != OptionalBoolean.TRUE) {
double distance = halfPlaneLength * renderMultiplier;
String reason;
if (packCullingState == OptionalBoolean.FALSE) {
reason = "(set by shader pack)";
} else if (packHasVoxelization) {
reason = "(voxelization detected)";
} else {
reason = "(indirect sunlight GI detected)";
}
if (distance <= 0 || distance > Minecraft.getInstance().options.renderDistance * 16) {
distanceInfo = +Minecraft.getInstance().options.renderDistance * 16 + " blocks (capped by normal render distance)";
cullingInfo = "disabled " + reason;
return holder.setInfo(new NonCullingFrustum(), distanceInfo, cullingInfo);
} else {
distanceInfo = distance + " blocks (set by shader pack)";
cullingInfo = "distance only " + reason;
BoxCuller boxCuller = new BoxCuller(distance);
holder.setInfo(new BoxCullingFrustum(boxCuller), distanceInfo, cullingInfo);
}
} else {
BoxCuller boxCuller;
double distance = halfPlaneLength * renderMultiplier;
String setter = "(set by shader pack)";
if (renderMultiplier < 0) {
distance = IrisVideoSettings.shadowDistance * 16;
setter = "(set by user)";
}
if (distance >= Minecraft.getInstance().options.renderDistance * 16) {
distanceInfo = Minecraft.getInstance().options.renderDistance * 16 + " blocks (capped by normal render distance)";
boxCuller = null;
} else {
distanceInfo = distance + " blocks " + setter;
if (distance == 0.0) {
cullingInfo = "no shadows rendered";
holder.setInfo(new CullEverythingFrustum(), distanceInfo, cullingInfo);
}
boxCuller = new BoxCuller(distance);
}
cullingInfo = "Advanced Frustum Culling enabled";
Vector4f shadowLightPosition = new CelestialUniforms(sunPathRotation).getShadowLightPositionInWorldSpace();
Vector3f shadowLightVectorFromOrigin = new Vector3f(shadowLightPosition.x(), shadowLightPosition.y(), shadowLightPosition.z());
shadowLightVectorFromOrigin.normalize();
return holder.setInfo(new AdvancedShadowCullingFrustum(CapturedRenderingState.INSTANCE.getGbufferModelView(), CapturedRenderingState.INSTANCE.getGbufferProjection(), shadowLightVectorFromOrigin, boxCuller), distanceInfo, cullingInfo);
}
return holder;
}
Aggregations