Search in sources :

Example 1 with RenderPass

use of io.xol.chunkstories.api.rendering.pass.RenderPass in project chunkstories by Hugobros3.

the class OpenGLRenderingContext method setCurrentShader.

private Shader setCurrentShader(ShaderGL shader) {
    if (shader != currentlyBoundShader) {
        texturingConfiguration.clear();
        attributesConfiguration.clear();
        currentlyBoundShader = shader;
        RenderPass currentPass = this.getCurrentPass();
        if (currentPass != null) {
            currentPass.setupShader(this, shader);
            currentPass.autoBindInputs(this, shader);
        }
    }
    return currentlyBoundShader;
}
Also used : RenderPass(io.xol.chunkstories.api.rendering.pass.RenderPass)

Example 2 with RenderPass

use of io.xol.chunkstories.api.rendering.pass.RenderPass in project chunkstories by Hugobros3.

the class ChunkMeshesRenderer method renderChunks.

@Override
public void renderChunks(RenderingInterface renderingInterface) {
    RenderPass currentPass = renderingInterface.getCurrentPass();
    List<ChunkRenderCommand> culledChunks = currentPass.name.startsWith("shadow") ? culledChunksShadow : culledChunksNormal;
    ShadingType shadingType = currentPass.name.startsWith("water") ? ShadingType.LIQUIDS : ShadingType.OPAQUE;
    if (currentPass.name.startsWith("shadow"))
        renderingInterface.currentShader().setUniform1f("useVoxelCoordinates", 1f);
    Matrix4f matrix = new Matrix4f();
    for (ChunkRenderCommand command : culledChunks) {
        matrix.identity();
        matrix.translate(new Vector3f(command.displayWorldX, command.displayWorldY, command.displayWorldZ));
        renderingInterface.setObjectMatrix(matrix);
        Vector3d chunkPos = new Vector3d(command.displayWorldX + 16, command.displayWorldY + 16, command.displayWorldZ + 16);
        double distance = renderingInterface.getCamera().getCameraPosition().distance(chunkPos);
        RenderLodLevel lodToUse;
        lodToUse = distance < Math.max(64, world.getClient().getConfiguration().getIntOption("client.rendering.viewDistance") / 4.0) ? RenderLodLevel.HIGH : RenderLodLevel.LOW;
        ((ClientChunk) command.chunk).getChunkRenderData().renderPass(renderingInterface, lodToUse, shadingType);
    }
    if (currentPass.name.startsWith("shadow"))
        renderingInterface.currentShader().setUniform1f("useVoxelCoordinates", 0f);
}
Also used : ShadingType(io.xol.chunkstories.api.rendering.world.chunk.ChunkMeshDataSubtypes.ShadingType) Matrix4f(org.joml.Matrix4f) RenderLodLevel(io.xol.chunkstories.renderer.chunks.ChunkRenderDataHolder.RenderLodLevel) Vector3d(org.joml.Vector3d) Vector3f(org.joml.Vector3f) RenderPass(io.xol.chunkstories.api.rendering.pass.RenderPass)

Example 3 with RenderPass

use of io.xol.chunkstories.api.rendering.pass.RenderPass in project chunkstories by Hugobros3.

the class ChunkMeshesRenderer method renderChunksExtras.

@Override
public void renderChunksExtras(RenderingInterface renderingInterface) {
    RenderPass currentPass = renderingInterface.getCurrentPass();
    List<ChunkRenderCommand> culledChunks = currentPass.name.startsWith("shadow") ? culledChunksShadow : culledChunksNormal;
    for (ChunkRenderCommand command : culledChunks) {
        ChunkRenderDataHolder holder = ((ClientChunk) command.chunk).getChunkRenderData();
        holder.renderExtras(renderingInterface);
    }
}
Also used : RenderPass(io.xol.chunkstories.api.rendering.pass.RenderPass) ClientChunk(io.xol.chunkstories.world.chunk.ClientChunk)

Example 4 with RenderPass

use of io.xol.chunkstories.api.rendering.pass.RenderPass in project chunkstories by Hugobros3.

the class RenderingGraph method render.

public void render(RenderingInterface renderer) {
    if (shouldRebuildGraph) {
        RenderPassesInitEvent event = new RenderPassesInitEvent(this);
        renderer.getClient().getPluginManager().fireEvent(event);
        resolveGraphOrder();
        resolveInputs();
        shouldRebuildGraph = false;
        logger.debug("Printing resolved passes order:\n----------");
        if (executionOrder != null) {
            for (RenderPass pass : executionOrder) {
                logger.debug("pass:" + pass.name + pass.getClass().getName());
            }
        }
    }
    if (executionOrder != null) {
        for (RenderPass pass : executionOrder) {
            this.currentPassBeingRendered = pass;
            pass.render(renderer);
        }
    }
}
Also used : RenderPass(io.xol.chunkstories.api.rendering.pass.RenderPass) RenderPassesInitEvent(io.xol.chunkstories.api.events.rendering.RenderPassesInitEvent)

Example 5 with RenderPass

use of io.xol.chunkstories.api.rendering.pass.RenderPass in project chunkstories by Hugobros3.

the class RenderingGraph method resolveGraphOrder.

private void resolveGraphOrder() {
    RenderPass finalPass = getRenderPass("final");
    List<RenderPass> dependencies = new ArrayList<>();
    nodes.clear();
    try {
        recursivelyAddNodes(finalPass, null);
        while (nodes.size() > 0) {
            // Find a node with no children
            Node noChildrenNode = null;
            for (Node node : nodes.values()) {
                if (node.children.size() == 0) {
                    noChildrenNode = node;
                    break;
                }
            }
            if (noChildrenNode == null)
                throw new CycleException("could not find a node without children, we have a loop!");
            // Add it to the sequence of operations
            dependencies.add(noChildrenNode.pass);
            // remove that node from the list
            nodes.remove(noChildrenNode.pass.name);
            // remove any mention of it in the other nodes
            final Node n2 = noChildrenNode;
            nodes.forEach((s, n) -> n.children.remove(n2));
        }
        executionOrder = new RenderPass[dependencies.size()];
        for (int i = 0; i < executionOrder.length; i++) {
            executionOrder[i] = dependencies.get(i);
        }
    } catch (CycleException e) {
        e.printStackTrace();
    }
}
Also used : ArrayList(java.util.ArrayList) RenderPass(io.xol.chunkstories.api.rendering.pass.RenderPass)

Aggregations

RenderPass (io.xol.chunkstories.api.rendering.pass.RenderPass)8 RenderPassesInitEvent (io.xol.chunkstories.api.events.rendering.RenderPassesInitEvent)1 Shader (io.xol.chunkstories.api.rendering.shader.Shader)1 Texture (io.xol.chunkstories.api.rendering.textures.Texture)1 Texture2D (io.xol.chunkstories.api.rendering.textures.Texture2D)1 ShadingType (io.xol.chunkstories.api.rendering.world.chunk.ChunkMeshDataSubtypes.ShadingType)1 GiPass (io.xol.chunkstories.core.rendering.passes.gi.GiPass)1 RenderLodLevel (io.xol.chunkstories.renderer.chunks.ChunkRenderDataHolder.RenderLodLevel)1 ClientChunk (io.xol.chunkstories.world.chunk.ClientChunk)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Matrix4f (org.joml.Matrix4f)1 Vector3d (org.joml.Vector3d)1 Vector3f (org.joml.Vector3f)1