Search in sources :

Example 6 with Vector4f

use of net.coderbot.iris.vendored.joml.Vector4f in project Iris by IrisShaders.

the class Vector4Uniform method updateValue.

private void updateValue() {
    Vector4f newValue = value.get();
    if (!newValue.equals(cachedValue)) {
        cachedValue.set(newValue.x(), newValue.y(), newValue.z(), newValue.w());
        IrisRenderSystem.uniform4f(location, cachedValue.x(), cachedValue.y(), cachedValue.z(), cachedValue.w());
    }
}
Also used : Vector4f(net.coderbot.iris.vendored.joml.Vector4f)

Example 7 with Vector4f

use of net.coderbot.iris.vendored.joml.Vector4f 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)

Example 8 with Vector4f

use of net.coderbot.iris.vendored.joml.Vector4f in project Iris by IrisShaders.

the class ClearPass method execute.

public void execute(Vector4f defaultClearColor) {
    // TODO: viewport if needed for custom buffer sizes
    framebuffer.bind();
    Vector4f color = Objects.requireNonNull(defaultClearColor);
    if (this.color != null) {
        color = this.color;
    }
    RenderSystem.clearColor(color.x, color.y, color.z, color.w);
    RenderSystem.clear(clearFlags, Minecraft.ON_OSX);
}
Also used : Vector4f(net.coderbot.iris.vendored.joml.Vector4f)

Example 9 with Vector4f

use of net.coderbot.iris.vendored.joml.Vector4f in project Iris by IrisShaders.

the class DispatchingDirectiveHolder method processDirective.

public void processDirective(ConstDirectiveParser.ConstDirective directive) {
    final ConstDirectiveParser.Type type = directive.getType();
    final String key = directive.getKey();
    final String value = directive.getValue();
    if (type == ConstDirectiveParser.Type.BOOL) {
        BooleanConsumer consumer = booleanConstVariables.get(key);
        if (consumer != null) {
            if ("true".equals(value)) {
                consumer.accept(true);
            } else if ("false".equals(value)) {
                consumer.accept(false);
            } else {
                Iris.logger.error("Failed to process " + directive + ": " + value + " is not a valid boolean value");
            }
            return;
        }
        if (IrisLogging.ENABLE_SPAM) {
            // Only logspam in dev
            Iris.logger.info("Found potential unhandled directive: " + directive);
        }
        typeCheckHelper("int", intConstVariables, directive);
        typeCheckHelper("int", stringConstVariables, directive);
        typeCheckHelper("float", floatConstVariables, directive);
        typeCheckHelper("vec4", vec4ConstVariables, directive);
    } else if (type == ConstDirectiveParser.Type.INT) {
        // GLSL does not actually have a string type, so string constant directives use "const int" instead.
        Consumer<String> stringConsumer = stringConstVariables.get(key);
        if (stringConsumer != null) {
            stringConsumer.accept(value);
            return;
        }
        IntConsumer intConsumer = intConstVariables.get(key);
        if (intConsumer != null) {
            try {
                intConsumer.accept(Integer.parseInt(value));
            } catch (NumberFormatException e) {
                Iris.logger.error("Failed to process " + directive, e);
            }
            return;
        }
        if (IrisLogging.ENABLE_SPAM) {
            // Only logspam in dev
            Iris.logger.info("Found potential unhandled directive: " + directive);
        }
        typeCheckHelper("bool", booleanConstVariables, directive);
        typeCheckHelper("float", floatConstVariables, directive);
        typeCheckHelper("vec4", vec4ConstVariables, directive);
    } else if (type == ConstDirectiveParser.Type.FLOAT) {
        FloatConsumer consumer = floatConstVariables.get(key);
        if (consumer != null) {
            try {
                consumer.accept(Float.parseFloat(value));
            } catch (NumberFormatException e) {
                Iris.logger.error("Failed to process " + directive, e);
            }
            return;
        }
        if (IrisLogging.ENABLE_SPAM) {
            // Only logspam in dev
            Iris.logger.info("Found potential unhandled directive: " + directive);
        }
        typeCheckHelper("bool", booleanConstVariables, directive);
        typeCheckHelper("int", intConstVariables, directive);
        typeCheckHelper("int", stringConstVariables, directive);
        typeCheckHelper("vec4", vec4ConstVariables, directive);
    } else if (type == ConstDirectiveParser.Type.VEC4) {
        Consumer<Vector4f> consumer = vec4ConstVariables.get(key);
        if (consumer != null) {
            if (!value.startsWith("vec4")) {
                Iris.logger.error("Failed to process " + directive + ": value was not a valid vec4 constructor");
            }
            String vec4Args = value.substring("vec4".length()).trim();
            if (!vec4Args.startsWith("(") || !vec4Args.endsWith(")")) {
                Iris.logger.error("Failed to process " + directive + ": value was not a valid vec4 constructor");
            }
            vec4Args = vec4Args.substring(1, vec4Args.length() - 1);
            String[] parts = vec4Args.split(",");
            for (int i = 0; i < parts.length; i++) {
                parts[i] = parts[i].trim();
            }
            if (parts.length != 4) {
                Iris.logger.error("Failed to process " + directive + ": expected 4 arguments to a vec4 constructor, got " + parts.length);
            }
            try {
                consumer.accept(new Vector4f(Float.parseFloat(parts[0]), Float.parseFloat(parts[1]), Float.parseFloat(parts[2]), Float.parseFloat(parts[3])));
            } catch (NumberFormatException e) {
                Iris.logger.error("Failed to process " + directive, e);
            }
            return;
        }
        typeCheckHelper("bool", booleanConstVariables, directive);
        typeCheckHelper("int", intConstVariables, directive);
        typeCheckHelper("int", stringConstVariables, directive);
        typeCheckHelper("float", floatConstVariables, directive);
    }
}
Also used : Consumer(java.util.function.Consumer) FloatConsumer(it.unimi.dsi.fastutil.floats.FloatConsumer) BooleanConsumer(it.unimi.dsi.fastutil.booleans.BooleanConsumer) IntConsumer(java.util.function.IntConsumer) Vector4f(net.coderbot.iris.vendored.joml.Vector4f) BooleanConsumer(it.unimi.dsi.fastutil.booleans.BooleanConsumer) FloatConsumer(it.unimi.dsi.fastutil.floats.FloatConsumer) IntConsumer(java.util.function.IntConsumer)

Example 10 with Vector4f

use of net.coderbot.iris.vendored.joml.Vector4f in project Iris by IrisShaders.

the class Vector3Uniform method truncated.

static Vector3Uniform truncated(int location, Supplier<Vector4f> value) {
    Vector3f held = new Vector3f();
    return new Vector3Uniform(location, () -> {
        Vector4f updated = value.get();
        held.set(updated.x(), updated.y(), updated.z());
        return held;
    });
}
Also used : Vector4f(net.coderbot.iris.vendored.joml.Vector4f) Vector3f(net.coderbot.iris.vendored.joml.Vector3f)

Aggregations

Vector4f (net.coderbot.iris.vendored.joml.Vector4f)10 Matrix4f (com.mojang.math.Matrix4f)3 ImmutableList (com.google.common.collect.ImmutableList)1 RenderTarget (com.mojang.blaze3d.pipeline.RenderTarget)1 GlStateManager (com.mojang.blaze3d.platform.GlStateManager)1 Vector3f (com.mojang.math.Vector3f)1 BooleanConsumer (it.unimi.dsi.fastutil.booleans.BooleanConsumer)1 FloatConsumer (it.unimi.dsi.fastutil.floats.FloatConsumer)1 IntArrayList (it.unimi.dsi.fastutil.ints.IntArrayList)1 IntList (it.unimi.dsi.fastutil.ints.IntList)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Consumer (java.util.function.Consumer)1 IntConsumer (java.util.function.IntConsumer)1 RenderTargets (net.coderbot.iris.rendertarget.RenderTargets)1 PackRenderTargetDirectives (net.coderbot.iris.shaderpack.PackRenderTargetDirectives)1 BoxCuller (net.coderbot.iris.shadows.frustum.BoxCuller)1 CullEverythingFrustum (net.coderbot.iris.shadows.frustum.CullEverythingFrustum)1