Search in sources :

Example 1 with BoxCuller

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;
}
Also used : BoxCuller(net.coderbot.iris.shadows.frustum.BoxCuller) BlockPos(net.minecraft.core.BlockPos) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity)

Example 2 with BoxCuller

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;
}
Also used : BoxCuller(net.coderbot.iris.shadows.frustum.BoxCuller) CullEverythingFrustum(net.coderbot.iris.shadows.frustum.CullEverythingFrustum) Vector4f(net.coderbot.iris.vendored.joml.Vector4f) AdvancedShadowCullingFrustum(net.coderbot.iris.shadows.frustum.advanced.AdvancedShadowCullingFrustum) Vector3f(com.mojang.math.Vector3f) NonCullingFrustum(net.coderbot.iris.shadows.frustum.fallback.NonCullingFrustum) CelestialUniforms(net.coderbot.iris.uniforms.CelestialUniforms) BoxCullingFrustum(net.coderbot.iris.shadows.frustum.fallback.BoxCullingFrustum)

Aggregations

BoxCuller (net.coderbot.iris.shadows.frustum.BoxCuller)2 Vector3f (com.mojang.math.Vector3f)1 CullEverythingFrustum (net.coderbot.iris.shadows.frustum.CullEverythingFrustum)1 AdvancedShadowCullingFrustum (net.coderbot.iris.shadows.frustum.advanced.AdvancedShadowCullingFrustum)1 BoxCullingFrustum (net.coderbot.iris.shadows.frustum.fallback.BoxCullingFrustum)1 NonCullingFrustum (net.coderbot.iris.shadows.frustum.fallback.NonCullingFrustum)1 CelestialUniforms (net.coderbot.iris.uniforms.CelestialUniforms)1 Vector4f (net.coderbot.iris.vendored.joml.Vector4f)1 BlockPos (net.minecraft.core.BlockPos)1 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)1