Search in sources :

Example 1 with RenderLodLevel

use of io.xol.chunkstories.renderer.chunks.ChunkRenderDataHolder.RenderLodLevel 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)

Aggregations

RenderPass (io.xol.chunkstories.api.rendering.pass.RenderPass)1 ShadingType (io.xol.chunkstories.api.rendering.world.chunk.ChunkMeshDataSubtypes.ShadingType)1 RenderLodLevel (io.xol.chunkstories.renderer.chunks.ChunkRenderDataHolder.RenderLodLevel)1 Matrix4f (org.joml.Matrix4f)1 Vector3d (org.joml.Vector3d)1 Vector3f (org.joml.Vector3f)1