Search in sources :

Example 1 with AdvancedShadowCullingFrustum

use of net.coderbot.iris.shadows.frustum.advanced.AdvancedShadowCullingFrustum 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

Vector3f (com.mojang.math.Vector3f)1 BoxCuller (net.coderbot.iris.shadows.frustum.BoxCuller)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