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;
}
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);
}
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);
}
}
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);
}
}
}
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();
}
}
Aggregations