use of io.xol.chunkstories.core.rendering.passes.WaterPass in project chunkstories-core by Hugobros3.
the class RenderingEventsListener method onRenderPassesInitialization.
@EventHandler
public void onRenderPassesInitialization(RenderPassesInitEvent event) {
RenderPasses pipeline = event.getPasses();
WorldRenderer worldRenderer = pipeline.getWorldRenderer();
SkyRenderer sky = new DefaultSkyRenderer(event.getPasses().getRenderingInterface().getWorldRenderer());
worldRenderer.setSkyRenderer(sky);
SkyPass skyPass = new SkyPass(pipeline, "sky", worldRenderer.getSkyRenderer());
pipeline.registerRenderPass(skyPass);
// gbuffer uses the zBuffer and outputs albedo/normal/materials
GBuffersOpaquePass gBuffers = new GBuffersOpaquePass(pipeline, "gBuffers", new String[] { "sky.zBuffer!" }, new String[] { "albedoBuffer", "normalBuffer", "voxelLightBuffer", "specularityBuffer", "materialsBuffer" /*"zBuffer"*/
});
pipeline.registerRenderPass(gBuffers);
DecalsPass decals = new DecalsPass(pipeline, "decals", new String[] { "gBuffers.albedoBuffer!", "gBuffers.zBuffer" }, new String[] {});
pipeline.registerRenderPass(decals);
WaterPass waterPass = new WaterPass(pipeline, "water", new String[] { "decals.albedoBuffer", "gBuffers.normalBuffer", "gBuffers.voxelLightBuffer", "gBuffers.specularityBuffer", "gBuffers.materialsBuffer", "gBuffers.zBuffer" }, new String[] {/*"albedoBuffer", "normalBuffer", "voxelLightBuffer", "specularityBuffer", "materialsBuffer", "zBuffer"*/
}, sky);
pipeline.registerRenderPass(waterPass);
boolean shadows = client.getConfiguration().getBooleanOption("client.rendering.shadows");
// a shadowmap pass requires no previous buffer and just outputs a shadowmap
ShadowPass sunShadowPass = null;
if (shadows) {
sunShadowPass = new ShadowPass(pipeline, "shadowsSun", new String[] {}, new String[] { "shadowMap" }, sky);
// note we could generalize the shadowmappass to not only the sun but also the moon, point and spotlights
pipeline.registerRenderPass(sunShadowPass);
}
// aka shadows_apply in the current code, it takes the gbuffers and applies the shadowmapping to them, then outputs to the shaded pixels buffers already filled with the far terrain pixels
ApplySunlightPass applySunlight = new ApplySunlightPass(pipeline, "applySunlight", new String[] { "water.albedoBuffer", "water.normalBuffer", "water.voxelLightBuffer", "water.specularityBuffer", "water.materialsBuffer", "water.zBuffer", "sky.shadedBuffer!" }, new String[] {/*"shadedBuffer"*/
}, sunShadowPass);
if (shadows)
applySunlight.requires.add("shadowsSun.shadowMap");
pipeline.registerRenderPass(applySunlight);
boolean gi = client.getConfiguration().getBooleanOption("client.rendering.globalIllumination") && shadows;
if (gi) {
GiPass giPass = new GiPass(pipeline, "gi", new String[] { "water.albedoBuffer", "water.normalBuffer", "water.zBuffer" }, new String[] { "giBuffer" }, sunShadowPass);
pipeline.registerRenderPass(giPass);
}
DefferedLightsPass lightsPass = new DefferedLightsPass(pipeline, "lights", new String[] { "applySunlight.shadedBuffer!", "water.albedoBuffer", "water.normalBuffer", "water.zBuffer" }, new String[] {});
pipeline.registerRenderPass(lightsPass);
// far terrain needs the shaded buffer from sky and outputs it, as well with a zbuffer
FarTerrainPass farTerrain = new FarTerrainPass(pipeline, "farTerrain", new String[] { "lights.shadedBuffer!", "gBuffers.specularityBuffer!", "gBuffers.zBuffer!" }, new String[] {/*"shadedBuffer", "zBuffer", "specularityBuffer"*/
});
pipeline.registerRenderPass(farTerrain);
BloomPass bloomPass = new BloomPass(pipeline, "bloom", new String[] { "farTerrain.shadedBuffer" }, new String[] { "bloomBuffer" });
pipeline.registerRenderPass(bloomPass);
ForwardPass forward = new ForwardPass(pipeline, "forward", new String[] { "farTerrain.shadedBuffer!", "farTerrain.zBuffer!" }, new String[] {});
pipeline.registerRenderPass(forward);
ReflectionsPass reflections = new ReflectionsPass(pipeline, "reflections", new String[] { "farTerrain.shadedBuffer", "gBuffers.normalBuffer", "gBuffers.voxelLightBuffer", "farTerrain.specularityBuffer", "farTerrain.zBuffer" }, new String[] { "reflectionsBuffer" }, sky);
pipeline.registerRenderPass(reflections);
// the pass declared as 'final' is considered the last one and it's outputs are shown to the screen
PostProcessPass postprocess = new PostProcessPass(pipeline, "final", new String[] { "water.albedoBuffer", "forward.shadedBuffer", "farTerrain.zBuffer", "bloom.bloomBuffer", "reflections.reflectionsBuffer", "farTerrain.specularityBuffer" }, sunShadowPass);
if (gi)
postprocess.requires.add("gi.giBuffer");
pipeline.registerRenderPass(postprocess);
}
Aggregations