Search in sources :

Example 1 with Vector4f

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

the class ClearPassCreator method createClearPasses.

public static ImmutableList<ClearPass> createClearPasses(RenderTargets renderTargets, boolean fullClear, PackRenderTargetDirectives renderTargetDirectives) {
    final int maxDrawBuffers = GlStateManager._getInteger(GL21C.GL_MAX_DRAW_BUFFERS);
    // Sort buffers by their clear color so we can group up glClear calls.
    Map<Vector4f, IntList> clearByColor = new HashMap<>();
    renderTargetDirectives.getRenderTargetSettings().forEach((bufferI, settings) -> {
        // unboxed
        final int buffer = bufferI;
        if (fullClear || settings.shouldClear()) {
            Vector4f defaultClearColor;
            if (buffer == 0) {
                // colortex0 is cleared to the fog color (with 1.0 alpha) by default.
                defaultClearColor = null;
            } else if (buffer == 1) {
                // colortex1 is cleared to solid white (with 1.0 alpha) by default.
                defaultClearColor = new Vector4f(1.0f, 1.0f, 1.0f, 1.0f);
            } else {
                // all other buffers are cleared to solid black (with 0.0 alpha) by default.
                defaultClearColor = new Vector4f(0.0f, 0.0f, 0.0f, 0.0f);
            }
            Vector4f clearColor = settings.getClearColor().orElse(defaultClearColor);
            clearByColor.computeIfAbsent(clearColor, color -> new IntArrayList()).add(buffer);
        }
    });
    List<ClearPass> clearPasses = new ArrayList<>();
    clearByColor.forEach((clearColor, buffers) -> {
        int startIndex = 0;
        while (startIndex < buffers.size()) {
            // clear up to the maximum number of draw buffers per each clear pass.
            // This allows us to handle having more than 8 buffers with the same clear color on systems with
            // a max draw buffers of 8 (ie, most systems).
            int[] clearBuffers = new int[Math.min(buffers.size() - startIndex, maxDrawBuffers)];
            for (int i = 0; i < clearBuffers.length; i++) {
                clearBuffers[i] = buffers.getInt(startIndex);
                startIndex++;
            }
            // only clear depth if this is the first clear pass
            clearPasses.add(new ClearPass(clearColor, renderTargets.createFramebufferWritingToAlt(clearBuffers), clearPasses.isEmpty()));
            clearPasses.add(new ClearPass(clearColor, renderTargets.createFramebufferWritingToMain(clearBuffers), false));
        }
    });
    return ImmutableList.copyOf(clearPasses);
}
Also used : GlStateManager(com.mojang.blaze3d.platform.GlStateManager) PackRenderTargetDirectives(net.coderbot.iris.shaderpack.PackRenderTargetDirectives) List(java.util.List) IntList(it.unimi.dsi.fastutil.ints.IntList) ImmutableList(com.google.common.collect.ImmutableList) Vector4f(net.coderbot.iris.vendored.joml.Vector4f) Map(java.util.Map) HashMap(java.util.HashMap) IntArrayList(it.unimi.dsi.fastutil.ints.IntArrayList) GL21C(org.lwjgl.opengl.GL21C) RenderTargets(net.coderbot.iris.rendertarget.RenderTargets) ArrayList(java.util.ArrayList) Vector4f(net.coderbot.iris.vendored.joml.Vector4f) HashMap(java.util.HashMap) IntArrayList(it.unimi.dsi.fastutil.ints.IntArrayList) ArrayList(java.util.ArrayList) IntArrayList(it.unimi.dsi.fastutil.ints.IntArrayList) IntList(it.unimi.dsi.fastutil.ints.IntList)

Example 2 with Vector4f

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

the class DeferredWorldRenderingPipeline method prepareRenderTargets.

private void prepareRenderTargets() {
    // Make sure we're using texture unit 0 for this.
    RenderSystem.activeTexture(GL15C.GL_TEXTURE0);
    RenderTarget main = Minecraft.getInstance().getMainRenderTarget();
    renderTargets.resizeIfNeeded(main.width, main.height);
    final ImmutableList<ClearPass> passes;
    if (renderTargets.isFullClearRequired()) {
        renderTargets.onFullClear();
        passes = clearPassesFull;
    } else {
        passes = clearPasses;
    }
    Vector3d fogColor3 = CapturedRenderingState.INSTANCE.getFogColor();
    // NB: The alpha value must be 1.0 here, or else you will get a bunch of bugs. Sildur's Vibrant Shaders
    // will give you pink reflections and other weirdness if this is zero.
    Vector4f fogColor = new Vector4f((float) fogColor3.x, (float) fogColor3.y, (float) fogColor3.z, 1.0F);
    for (ClearPass clearPass : passes) {
        clearPass.execute(fogColor);
    }
}
Also used : Vector4f(net.coderbot.iris.vendored.joml.Vector4f) Vector3d(net.coderbot.iris.vendored.joml.Vector3d) RenderTarget(com.mojang.blaze3d.pipeline.RenderTarget)

Example 3 with Vector4f

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

the class CelestialUniforms method getUpPosition.

private static Vector4f getUpPosition() {
    com.mojang.math.Vector4f upVector = new com.mojang.math.Vector4f(0.0F, 100.0F, 0.0F, 0.0F);
    // Get the current GBuffer model view matrix, since that is the basis of the celestial model view matrix
    Matrix4f preCelestial = CapturedRenderingState.INSTANCE.getGbufferModelView().copy();
    // Apply the fixed -90.0F degrees rotation to mirror the same transformation in renderSky.
    // But, notably, skip the rotation by the skyAngle.
    preCelestial.multiply(Vector3f.YP.rotationDegrees(-90.0F));
    // Use this matrix to transform the vector.
    upVector.transform(preCelestial);
    return JomlConversions.toJoml(upVector);
}
Also used : Matrix4f(com.mojang.math.Matrix4f) Vector4f(net.coderbot.iris.vendored.joml.Vector4f)

Example 4 with Vector4f

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

the class CelestialUniforms method getCelestialPositionInWorldSpace.

private Vector4f getCelestialPositionInWorldSpace(float y) {
    com.mojang.math.Vector4f position = new com.mojang.math.Vector4f(0.0F, y, 0.0F, 0.0F);
    // TODO: Deduplicate / remove this function.
    Matrix4f celestial = new Matrix4f();
    celestial.setIdentity();
    // This is the same transformation applied by renderSky, however, it's been moved to here.
    // This is because we need the result of it before it's actually performed in vanilla.
    celestial.multiply(Vector3f.YP.rotationDegrees(-90.0F));
    celestial.multiply(Vector3f.ZP.rotationDegrees(sunPathRotation));
    celestial.multiply(Vector3f.XP.rotationDegrees(getSkyAngle() * 360.0F));
    position.transform(celestial);
    return JomlConversions.toJoml(position);
}
Also used : Matrix4f(com.mojang.math.Matrix4f) Vector4f(net.coderbot.iris.vendored.joml.Vector4f)

Example 5 with Vector4f

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

the class CelestialUniforms method getCelestialPosition.

private Vector4f getCelestialPosition(float y) {
    com.mojang.math.Vector4f position = new com.mojang.math.Vector4f(0.0F, y, 0.0F, 0.0F);
    Matrix4f celestial = CapturedRenderingState.INSTANCE.getGbufferModelView().copy();
    // This is the same transformation applied by renderSky, however, it's been moved to here.
    // This is because we need the result of it before it's actually performed in vanilla.
    celestial.multiply(Vector3f.YP.rotationDegrees(-90.0F));
    celestial.multiply(Vector3f.ZP.rotationDegrees(sunPathRotation));
    celestial.multiply(Vector3f.XP.rotationDegrees(getSkyAngle() * 360.0F));
    position.transform(celestial);
    return JomlConversions.toJoml(position);
}
Also used : Matrix4f(com.mojang.math.Matrix4f) Vector4f(net.coderbot.iris.vendored.joml.Vector4f)

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