use of io.xol.chunkstories.api.rendering.shader.Shader in project chunkstories-core by Hugobros3.
the class BreakingBlockDecal method render.
public void render(RenderingInterface renderingInterface) {
Shader decalsShader = renderingInterface.useShader("decal_cracking");
renderingInterface.getCamera().setupShader(decalsShader);
renderingInterface.setCullingMode(CullingMode.DISABLED);
renderingInterface.setBlendMode(BlendMode.MIX);
renderingInterface.getRenderTargetManager().setDepthMask(false);
int phases = 6;
int phase = (int) (phases * miningProgress.progress);
decalsShader.setUniform1f("textureScale", 1f / 6);
decalsShader.setUniform1f("textureStart", 1f / 6 * phase);
// decalType.getTexture();
Texture2D diffuseTexture = renderingInterface.textures().getTexture("./textures/voxel_cracking.png");
diffuseTexture.setTextureWrapping(true);
diffuseTexture.setLinearFiltering(false);
renderingInterface.bindAlbedoTexture(diffuseTexture);
renderingInterface.bindAttribute("vertexIn", vertexBuffer.asAttributeSource(VertexFormat.FLOAT, 3, 4 * (3 + 2), 0));
renderingInterface.bindAttribute("texCoordIn", vertexBuffer.asAttributeSource(VertexFormat.FLOAT, 2, 4 * (3 + 2), 4 * 3));
renderingInterface.draw(Primitive.TRIANGLE, 0, size);
renderingInterface.getRenderTargetManager().setDepthMask(true);
}
use of io.xol.chunkstories.api.rendering.shader.Shader in project chunkstories-core by Hugobros3.
the class GBuffersOpaquePass method render.
@Override
public void render(RenderingInterface renderingInterface) {
if (fbo != null) {
GameWindow gameWindow = pipeline.getRenderingInterface().getWindow();
renderingInterface.getRenderTargetManager().setConfiguration(fbo);
renderingInterface.getRenderTargetManager().clearBoundRenderTargetAll();
// Set fixed-function parameters
renderingInterface.setDepthTestMode(DepthTestMode.LESS_OR_EQUAL);
renderingInterface.setBlendMode(BlendMode.DISABLED);
renderingInterface.setCullingMode(CullingMode.COUNTERCLOCKWISE);
Shader opaqueBlocksShader = renderingInterface.useShader("blocks_opaque");
Texture2D blocksAlbedoTexture = gameWindow.getClient().getContent().voxels().textures().getDiffuseAtlasTexture();
Texture2D blocksNormalTexture = gameWindow.getClient().getContent().voxels().textures().getNormalAtlasTexture();
Texture2D blocksMaterialTexture = gameWindow.getClient().getContent().voxels().textures().getMaterialAtlasTexture();
renderingInterface.bindAlbedoTexture(blocksAlbedoTexture);
renderingInterface.bindNormalTexture(blocksNormalTexture);
renderingInterface.bindMaterialTexture(blocksMaterialTexture);
renderingInterface.bindTexture2D("lightColors", renderingInterface.textures().getTexture("./textures/environement/light.png"));
renderingInterface.bindTexture2D("vegetationColorTexture", worldRenderer.getWorld().getGenerator().getEnvironment().getGrassTexture(renderingInterface));
// renderingInterface.bindTexture2D("vegetationColorTexture", getGrassTexture());
// Set texturing arguments
blocksAlbedoTexture.setTextureWrapping(false);
blocksAlbedoTexture.setLinearFiltering(false);
blocksAlbedoTexture.setMipMapping(false);
blocksAlbedoTexture.setMipmapLevelsRange(0, 4);
blocksNormalTexture.setTextureWrapping(false);
blocksNormalTexture.setLinearFiltering(false);
blocksNormalTexture.setMipMapping(false);
blocksNormalTexture.setMipmapLevelsRange(0, 4);
blocksMaterialTexture.setTextureWrapping(false);
blocksMaterialTexture.setLinearFiltering(false);
blocksMaterialTexture.setMipMapping(false);
blocksMaterialTexture.setMipmapLevelsRange(0, 4);
// World stuff
opaqueBlocksShader.setUniform1f("mapSize", world.getSizeInChunks() * 32);
opaqueBlocksShader.setUniform1f("overcastFactor", world.getWeather());
opaqueBlocksShader.setUniform1f("wetness", world.getGenerator().getEnvironment().getWorldWetness(renderingInterface.getCamera().getCameraPosition()));
opaqueBlocksShader.setUniform1f("time", worldRenderer.getAnimationTimer());
opaqueBlocksShader.setUniform1f("animationTimer", worldRenderer.getAnimationTimer());
opaqueBlocksShader.setUniform2f("screenSize", gameWindow.getWidth(), gameWindow.getHeight());
renderingInterface.getCamera().setupShader(opaqueBlocksShader);
renderingInterface.setObjectMatrix(new Matrix4f());
worldRenderer.getChunksRenderer().renderChunks(renderingInterface);
worldRenderer.getChunksRenderer().renderChunksExtras(renderingInterface);
worldRenderer.getEntitiesRenderer().renderEntities(renderingInterface);
worldRenderer.getParticlesRenderer().renderParticles(renderingInterface);
}
}
use of io.xol.chunkstories.api.rendering.shader.Shader in project chunkstories-core by Hugobros3.
the class GiPass method render.
public void render(RenderingInterface renderer) {
cameraPosition.set(renderer.getCamera().getCameraPosition());
cameraDirection.set(renderer.getCamera().getViewDirection());
Shader giShader = renderer.useShader("gi");
renderer.getRenderTargetManager().setConfiguration(renderingToA ? fboAccumulationA : fboAccumulationB);
renderer.setDepthTestMode(DepthTestMode.ALWAYS);
renderer.setBlendMode(BlendMode.DISABLED);
if (shadowPass != null) {
renderer.bindTexture2D("shadowMap", (Texture2D) shadowPass.resolvedOutputs.get("shadowMap"));
giShader.setUniform1f("shadowMapResolution", ((Texture2D) shadowPass.resolvedOutputs.get("shadowMap")).getWidth());
giShader.setUniform1f("shadowVisiblity", shadowPass.getShadowVisibility());
giShader.setUniformMatrix4f("shadowMatrix", shadowPass.getShadowMatrix());
}
renderer.getRenderTargetManager().clearBoundRenderTargetAll();
renderer.getRenderTargetManager().setDepthMask(true);
renderer.bindTexture2D("previousBuffer", !renderingToA ? accumulationA : accumulationB);
renderer.bindTexture2D("previousConfidence", !renderingToA ? confidenceA : confidenceB);
renderer.bindTexture2D("previousZ", !renderingToA ? zBufferA : zBufferB);
giShader.setUniformMatrix4f("previousProjectionMatrix", previousProjectionMatrix);
giShader.setUniformMatrix4f("previousModelViewMatrix", previousModelViewMatrix);
giShader.setUniformMatrix4f("previousProjectionMatrixInv", previousProjectionMatrixInv);
giShader.setUniformMatrix4f("previousModelViewMatrixInv", previousModelViewMatrixInv);
if (cameraPosition.distance(oldCameraPosition) != 0.0f || cameraDirection.distance(oldCameraDirection) != 0.0f) {
// System.out.println("moved! : " + cameraPosition.distance(oldCameraPosition) + "or " + cameraDirection.distance(oldCameraDirection));
giShader.setUniform1i("keepPreviousData", 0);
accumulatedSamples = 0;
} else {
giShader.setUniform1i("keepPreviousData", 1);
}
accumulatedSamples++;
voxels4gi.update(renderer);
voxels4gi.setupForRendering(renderer);
boolean lf = true;
accumulationA.setLinearFiltering(lf);
accumulationB.setLinearFiltering(lf);
confidenceA.setLinearFiltering(lf);
confidenceB.setLinearFiltering(lf);
giShader.setUniform1f("animationTimer", worldRenderer.getAnimationTimer() + accumulatedSamples);
giShader.setUniform1f("overcastFactor", worldRenderer.getWorld().getWeather());
giShader.setUniform1f("wetness", worldRenderer.getWorld().getGenerator().getEnvironment().getWorldWetness(cameraPosition));
worldRenderer.getSkyRenderer().setupShader(giShader);
renderer.getCamera().setupShader(giShader);
renderer.drawFSQuad();
previousProjectionMatrix.set(renderer.getCamera().getProjectionMatrix4f());
previousModelViewMatrix.set(renderer.getCamera().getModelViewMatrix4f());
previousProjectionMatrixInv.set(renderer.getCamera().getProjectionMatrix4fInverted());
previousModelViewMatrixInv.set(renderer.getCamera().getModelViewMatrix4fInverted());
renderingToA = !renderingToA;
oldCameraPosition.set(cameraPosition);
oldCameraDirection.set(cameraDirection);
}
use of io.xol.chunkstories.api.rendering.shader.Shader in project chunkstories-core by Hugobros3.
the class NearbyVoxelsVolumeTexture method setupForRendering.
public void setupForRendering(RenderingInterface renderingContext) {
renderingContext.bindTexture3D("currentChunk", test);
Shader shader = renderingContext.currentShader();
shader.setUniform1i("voxel_size", size);
shader.setUniform1f("voxel_sizef", 0.0f + size);
shader.setUniform3f("voxelOffset", offsetX * 32, offsetY * 32, offsetZ * 32);
}
use of io.xol.chunkstories.api.rendering.shader.Shader in project chunkstories-core by Hugobros3.
the class CloudsRenderer method renderClouds.
public void renderClouds(RenderingInterface renderingContext) {
bake(renderingContext);
if (baked <= 0)
return;
// ShaderProgram cloudsShader = ShadersLibrary.getShaderProgram("clouds");
renderingContext.useShader("clouds");
// renderingContext.setCurrentShader(cloudsShader);
renderingContext.getCamera().setupShader(renderingContext.currentShader());
skyRenderer.setupShader(renderingContext.currentShader());
renderingContext.currentShader().setUniform3f("sunPos", skyRenderer.getSunPosition());
Shader cloudsShader = renderingContext.currentShader();
cloudsShader.setUniform1f("time", (world.getTime() % 10000) / 10000f);
cloudsShader.setUniform1f("overcastFactor", world.getWeather());
renderingContext.setCullingMode(CullingMode.DISABLED);
// glDisable(GL_CULL_FACE);
// cloudsMesh.bind();
renderingContext.bindAttribute("vertexIn", cloudsMesh.asAttributeSource(VertexFormat.FLOAT, 3, (4 * 3 + 4 * 3 + 4), 0));
renderingContext.bindAttribute("normalIn", cloudsMesh.asAttributeSource(VertexFormat.FLOAT, 3, (4 * 3 + 4 * 3 + 4), 4 * 3));
renderingContext.bindAttribute("alphaIn", cloudsMesh.asAttributeSource(VertexFormat.FLOAT, 1, (4 * 3 + 4 * 3 + 4), 4 * 6));
// renderingContext.setVertexAttributePointerLocation("vertexIn", 3, GL_FLOAT, false, (4 * 3 + 4 * 3 + 4), 0);
// renderingContext.setVertexAttributePointerLocation("normalIn", 3, GL_FLOAT, false, (4 * 3 + 4 * 3 + 4), (4 * 3));
// renderingContext.setVertexAttributePointerLocation("alphaIn", 1, GL_FLOAT, false, (4 * 3 + 4 * 3 + 4), (4 * 3 + 4 * 3));
renderingContext.draw(Primitive.TRIANGLE, 0, baked);
// cloudsMesh.drawElementsTriangles(baked);
}
Aggregations