Skip to content

Commit

Permalink
Qa/checkstyle (#76)
Browse files Browse the repository at this point in the history
* qa corerendering, shorten lines.

* qa corerendering, declaration order, no * import.

* qa corerendering, - unused imports.

* qa corerendering, whitespace after comma.

* qa corerendering, constant upper case, intellij suggestion of final vars.

* qa corerendering, javadoc contains deprecated flag.

* qa corerendering, - unused logger.

* chore: remove unused imports

---------

Co-authored-by: jdrueckert <[email protected]>
  • Loading branch information
soloturn and jdrueckert authored Dec 17, 2023
1 parent b01eb17 commit eb5e106
Show file tree
Hide file tree
Showing 15 changed files with 160 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,29 @@
// SPDX-License-Identifier: Apache-2.0
package org.terasology.corerendering.rendering;

import org.terasology.corerendering.rendering.dag.nodes.*;
import org.terasology.corerendering.rendering.dag.nodes.AlphaRejectBlocksNode;
import org.terasology.corerendering.rendering.dag.nodes.ApplyDeferredLightingNode;
import org.terasology.corerendering.rendering.dag.nodes.BackdropNode;
import org.terasology.corerendering.rendering.dag.nodes.BackdropReflectionNode;
import org.terasology.corerendering.rendering.dag.nodes.BufferClearingNode;
import org.terasology.corerendering.rendering.dag.nodes.DeferredMainLightNode;
import org.terasology.corerendering.rendering.dag.nodes.DeferredPointLightsNode;
import org.terasology.corerendering.rendering.dag.nodes.DownSamplerForExposureNode;
import org.terasology.corerendering.rendering.dag.nodes.FinalPostProcessingNode;
import org.terasology.corerendering.rendering.dag.nodes.InitialPostProcessingNode;
import org.terasology.corerendering.rendering.dag.nodes.LateBlurNode;
import org.terasology.corerendering.rendering.dag.nodes.OpaqueBlocksNode;
import org.terasology.corerendering.rendering.dag.nodes.OpaqueObjectsNode;
import org.terasology.corerendering.rendering.dag.nodes.OutlineNode;
import org.terasology.corerendering.rendering.dag.nodes.OutputToScreenNode;
import org.terasology.corerendering.rendering.dag.nodes.OverlaysNode;
import org.terasology.corerendering.rendering.dag.nodes.PrePostCompositeNode;
import org.terasology.corerendering.rendering.dag.nodes.RefractiveReflectiveBlocksNode;
import org.terasology.corerendering.rendering.dag.nodes.ShadowMapNode;
import org.terasology.corerendering.rendering.dag.nodes.SimpleBlendMaterialsNode;
import org.terasology.corerendering.rendering.dag.nodes.ToneMappingNode;
import org.terasology.corerendering.rendering.dag.nodes.UpdateExposureNode;
import org.terasology.corerendering.rendering.dag.nodes.WorldReflectionNode;
import org.terasology.engine.context.Context;
import org.terasology.engine.core.subsystem.DisplayDevice;
import org.terasology.engine.rendering.cameras.Camera;
Expand Down Expand Up @@ -34,15 +56,15 @@

public class CoreRenderingModule extends ModuleRendering {

private static int initializationPriority = 1;

private DisplayResolutionDependentFbo displayResolutionDependentFbo;
private ShadowMapResolutionDependentFbo shadowMapResolutionDependentFbo;
private ImmutableFbo immutableFbo;

private ShadowMapNode shadowMapNode;
private DisplayDevice displayDevice;

private static int initializationPriority = 1;

// Created in renderingModuleRegistry trough reflection and Constructor calling
public CoreRenderingModule(Context context) {
super(context);
Expand Down Expand Up @@ -103,7 +125,8 @@ private void addGBufferClearingNodes(RenderGraph renderGraph) {
// FULL_SCALE, FBO.Type.HDR, fullScale);
BufferPair gBufferPair = new BufferPair(legacyGBuffers.getLastUpdatedFbo(), legacyGBuffers.getStaleFbo());

BufferClearingNode lastUpdatedGBufferClearingNode = new BufferClearingNode("lastUpdatedGBufferClearingNode", context, providingModule,
BufferClearingNode lastUpdatedGBufferClearingNode = new BufferClearingNode(
"lastUpdatedGBufferClearingNode", context, providingModule,
GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
lastUpdatedGBufferClearingNode.addInputFboConnection(1, gBufferPair.getPrimaryFbo());
lastUpdatedGBufferClearingNode.addOutputBufferPairConnection(1, gBufferPair);
Expand All @@ -123,7 +146,8 @@ private void addSkyNodes(RenderGraph renderGraph) {
// don't make them output buffer pair when they only clear 1 of the buffers. Prone to error
Node backdropNode = new BackdropNode("backdropNode", providingModule, context);
renderGraph.connectBufferPair(lastUpdatedGBufferClearingNode, 1, backdropNode, 1);
((AbstractNode) backdropNode).addOutputBufferPairConnection(1, lastUpdatedGBufferClearingNode.getOutputBufferPairConnection(1).getBufferPair());
((AbstractNode) backdropNode).addOutputBufferPairConnection(
1, lastUpdatedGBufferClearingNode.getOutputBufferPairConnection(1).getBufferPair());

renderGraph.addNode(backdropNode);
//renderGraph.connect(lastUpdatedGBufferClearingNode, backdropNode);
Expand Down Expand Up @@ -198,8 +222,10 @@ private void add3dDecorationNodes(RenderGraph renderGraph) {
private void addReflectionAndRefractionNodes(RenderGraph renderGraph) {
Node applyDeferredLightingNode = renderGraph.findNode("CoreRendering:applyDeferredLightingNode");

FboConfig reflectedBufferConfig = new FboConfig(BackdropReflectionNode.REFLECTED_FBO_URI, HALF_SCALE, FBO.Type.DEFAULT).useDepthBuffer();
BufferClearingNode reflectedBufferClearingNode = new BufferClearingNode("reflectedBufferClearingNode", providingModule, context, reflectedBufferConfig,
FboConfig reflectedBufferConfig =
new FboConfig(BackdropReflectionNode.REFLECTED_FBO_URI, HALF_SCALE, FBO.Type.DEFAULT).useDepthBuffer();
BufferClearingNode reflectedBufferClearingNode = new BufferClearingNode(
"reflectedBufferClearingNode", providingModule, context, reflectedBufferConfig,
displayResolutionDependentFbo, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
renderGraph.addNode(reflectedBufferClearingNode);

Expand All @@ -211,12 +237,16 @@ private void addReflectionAndRefractionNodes(RenderGraph renderGraph) {
renderGraph.connectFbo(reflectedBackdropNode, 1, worldReflectionNode, 1);
renderGraph.addNode(worldReflectionNode);

FboConfig reflectedRefractedBufferConfig = new FboConfig(RefractiveReflectiveBlocksNode.REFRACTIVE_REFLECTIVE_FBO_URI, FULL_SCALE, FBO.Type.HDR).useNormalBuffer();
BufferClearingNode reflectedRefractedBufferClearingNode = new BufferClearingNode("reflectedRefractedBufferClearingNode", providingModule,
context, reflectedRefractedBufferConfig, displayResolutionDependentFbo, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
FboConfig reflectedRefractedBufferConfig = new FboConfig(
RefractiveReflectiveBlocksNode.REFRACTIVE_REFLECTIVE_FBO_URI, FULL_SCALE, FBO.Type.HDR).useNormalBuffer();
BufferClearingNode reflectedRefractedBufferClearingNode = new BufferClearingNode(
"reflectedRefractedBufferClearingNode", providingModule,
context, reflectedRefractedBufferConfig, displayResolutionDependentFbo,
GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
renderGraph.addNode(reflectedRefractedBufferClearingNode);

Node chunksRefractiveReflectiveNode = new RefractiveReflectiveBlocksNode("chunksRefractiveReflectiveNode", providingModule, context);
Node chunksRefractiveReflectiveNode = new RefractiveReflectiveBlocksNode(
"chunksRefractiveReflectiveNode", providingModule, context);
renderGraph.connectBufferPair(applyDeferredLightingNode, 1, chunksRefractiveReflectiveNode, 1);
renderGraph.connectFbo(reflectedRefractedBufferClearingNode, 1, chunksRefractiveReflectiveNode, 1);
renderGraph.connectFbo(worldReflectionNode, 1, chunksRefractiveReflectiveNode, 2);
Expand Down Expand Up @@ -266,30 +296,37 @@ private void addBloomNodes(RenderGraph renderGraph) {
}

private void addExposureNodes(RenderGraph renderGraph) {
SimpleBlendMaterialsNode simpleBlendMaterialsNode = (SimpleBlendMaterialsNode) renderGraph.findNode("CoreRendering:simpleBlendMaterialsNode");
// FboConfig gBuffer2Config = displayResolutionDependentFbo.getFboConfig(new SimpleUri("CoreRendering:fbo.gBuffer2")); // TODO: Remove the hard coded value here
DownSamplerForExposureNode exposureDownSamplerTo16pixels = new DownSamplerForExposureNode("exposureDownSamplerTo16pixels", providingModule,
SimpleBlendMaterialsNode simpleBlendMaterialsNode =
(SimpleBlendMaterialsNode) renderGraph.findNode("CoreRendering:simpleBlendMaterialsNode");
// TODO: Remove the hard coded value here
// FboConfig gBuffer2Config = displayResolutionDependentFbo.getFboConfig(new SimpleUri("CoreRendering:fbo.gBuffer2"));
DownSamplerForExposureNode exposureDownSamplerTo16pixels =
new DownSamplerForExposureNode("exposureDownSamplerTo16pixels", providingModule,
context, displayResolutionDependentFbo, FBO_16X16_CONFIG, immutableFbo);
renderGraph.connectFbo(simpleBlendMaterialsNode, 1, exposureDownSamplerTo16pixels, 1);
renderGraph.addNode(exposureDownSamplerTo16pixels);

DownSamplerForExposureNode exposureDownSamplerTo8pixels = new DownSamplerForExposureNode("exposureDownSamplerTo8pixels", providingModule, context,
DownSamplerForExposureNode exposureDownSamplerTo8pixels =
new DownSamplerForExposureNode("exposureDownSamplerTo8pixels", providingModule, context,
immutableFbo, FBO_8X8_CONFIG, immutableFbo);
renderGraph.connectFbo(exposureDownSamplerTo16pixels, 1, exposureDownSamplerTo8pixels, 1);
renderGraph.addNode(exposureDownSamplerTo8pixels);


DownSamplerForExposureNode exposureDownSamplerTo4pixels = new DownSamplerForExposureNode("exposureDownSamplerTo4pixels", providingModule, context,
DownSamplerForExposureNode exposureDownSamplerTo4pixels =
new DownSamplerForExposureNode("exposureDownSamplerTo4pixels", providingModule, context,
immutableFbo, FBO_4X4_CONFIG, immutableFbo);
renderGraph.connectFbo(exposureDownSamplerTo8pixels, 1, exposureDownSamplerTo4pixels, 1);
renderGraph.addNode(exposureDownSamplerTo4pixels);

DownSamplerForExposureNode exposureDownSamplerTo2pixels = new DownSamplerForExposureNode("exposureDownSamplerTo2pixels", providingModule, context,
DownSamplerForExposureNode exposureDownSamplerTo2pixels =
new DownSamplerForExposureNode("exposureDownSamplerTo2pixels", providingModule, context,
immutableFbo, FBO_2X2_CONFIG, immutableFbo);
renderGraph.connectFbo(exposureDownSamplerTo4pixels, 1, exposureDownSamplerTo2pixels, 1);
renderGraph.addNode(exposureDownSamplerTo2pixels);

DownSamplerForExposureNode exposureDownSamplerTo1pixel = new DownSamplerForExposureNode("exposureDownSamplerTo1pixel", providingModule, context,
DownSamplerForExposureNode exposureDownSamplerTo1pixel =
new DownSamplerForExposureNode("exposureDownSamplerTo1pixel", providingModule, context,
immutableFbo, FBO_1X1_CONFIG, immutableFbo);
renderGraph.connectFbo(exposureDownSamplerTo2pixels, 1, exposureDownSamplerTo1pixel, 1);
renderGraph.addNode(exposureDownSamplerTo1pixel);
Expand Down Expand Up @@ -339,10 +376,11 @@ private void addFinalPostProcessingNodes(RenderGraph renderGraph) {
renderGraph.connectFbo(firstLateBlurNode, 1, secondLateBlurNode, 1);
renderGraph.addNode(secondLateBlurNode);

FinalPostProcessingNode finalPostProcessingNode = new FinalPostProcessingNode("finalPostProcessingNode", providingModule, context/*finalIn1*/);
FinalPostProcessingNode finalPostProcessingNode =
new FinalPostProcessingNode("finalPostProcessingNode", providingModule, context/*finalIn1*/);
renderGraph.connectBufferPair(initialPostProcessingNode, 1, finalPostProcessingNode, 1);
renderGraph.connectFbo(toneMappingNode,1, finalPostProcessingNode, 1);
renderGraph.connectFbo(secondLateBlurNode, 1, finalPostProcessingNode,2);
renderGraph.connectFbo(toneMappingNode, 1, finalPostProcessingNode, 1);
renderGraph.connectFbo(secondLateBlurNode, 1, finalPostProcessingNode, 2);
renderGraph.addNode(finalPostProcessingNode);

// renderGraph.connect(toneMappingNode, firstLateBlurNode, secondLateBlurNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,10 @@ public void setDependencies(Context context) {
addOutputBufferPairConnection(1, bufferPairConnection);

int texId = 0;
addDesiredStateChange(new SetInputTextureFromFbo(texId++, lastUpdatedGBuffer, DepthStencilTexture, displayResolutionDependentFBOs, SSAO_MATERIAL_URN, "texDepth"));
addDesiredStateChange(new SetInputTextureFromFbo(texId++, lastUpdatedGBuffer, NormalsTexture, displayResolutionDependentFBOs, SSAO_MATERIAL_URN, "texNormals"));
addDesiredStateChange(new SetInputTextureFromFbo(texId++, lastUpdatedGBuffer, DepthStencilTexture, displayResolutionDependentFBOs,
SSAO_MATERIAL_URN, "texDepth"));
addDesiredStateChange(new SetInputTextureFromFbo(texId++, lastUpdatedGBuffer, NormalsTexture, displayResolutionDependentFBOs,
SSAO_MATERIAL_URN, "texNormals"));
addDesiredStateChange(new SetInputTexture2D(texId, generateNoiseTexture().getId(), SSAO_MATERIAL_URN, "texNoise"));

if (ssaoSamples == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public class BackdropNode extends AbstractNode implements WireframeCapable {
private static final int STACKS = 128;
private static final int RADIUS = 1024;

SphereBuilder builder = new SphereBuilder();

private WorldRenderer worldRenderer;
private BackdropProvider backdropProvider;

Expand All @@ -75,8 +77,6 @@ public class BackdropNode extends AbstractNode implements WireframeCapable {
private float turbidity;

private final Mesh sphereMesh;
SphereBuilder builder = new SphereBuilder();

public BackdropNode(String nodeUri, Name providingModule, Context context) {
super(nodeUri, providingModule, context);

Expand Down Expand Up @@ -160,7 +160,8 @@ public void process() {

// Shader Parameters

skyMaterial.setFloat3("zenith", getAllWeatherZenith(backdropProvider.getSunDirection(false).y, turbidity), true);
skyMaterial.setFloat3("zenith", getAllWeatherZenith(backdropProvider.getSunDirection(false).y, turbidity),
true);
skyMaterial.setFloat("turbidity", turbidity, true);
skyMaterial.setFloat("colorExp", backdropProvider.getColorExp(), true);
skyMaterial.setFloat4("skySettings", sunExponent, moonExponent, skyDaylightBrightness, skyNightBrightness, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class BufferClearingNode extends AbstractNode {
private int clearingMask;
private FBO fbo;
/**
* @deprecated
* Constructs the node by requesting the creation (if necessary) of the FBO to be cleared
* and by requesting for this FBO to be bound by the time process() gets executed. Also
* stores the clearing mask, for use in process().
Expand All @@ -34,7 +35,8 @@ public class BufferClearingNode extends AbstractNode {
* Non GL_*_BIT values will be accepted but might eventually generate an opengl error.
* @throws IllegalArgumentException if fboConfig, fboManager are null and if clearingMask is zero.
*/@Deprecated
public BufferClearingNode(String nodeUri, Name providingModule, Context context, FboConfig fboConfig, BaseFboManager fboManager, int clearingMask) {
public BufferClearingNode(String nodeUri, Name providingModule, Context context, FboConfig fboConfig, BaseFboManager fboManager,
int clearingMask) {
super(nodeUri, providingModule, context);

boolean argumentsAreValid = validateArguments(fboConfig, fboManager, clearingMask);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,19 @@ public void setDependencies(Context context) {
DisplayResolutionDependentFbo displayResolutionDependentFBOs = context.get(DisplayResolutionDependentFbo.class);

int textureSlot = 0;
addDesiredStateChange(new SetInputTextureFromFbo(textureSlot++, lastUpdatedGBuffer, DepthStencilTexture, displayResolutionDependentFBOs, LIGHT_GEOMETRY_MATERIAL_URN, "texSceneOpaqueDepth"));
addDesiredStateChange(new SetInputTextureFromFbo(textureSlot++, lastUpdatedGBuffer, NormalsTexture, displayResolutionDependentFBOs, LIGHT_GEOMETRY_MATERIAL_URN, "texSceneOpaqueNormals"));
addDesiredStateChange(new SetInputTextureFromFbo(textureSlot++, lastUpdatedGBuffer, LightAccumulationTexture, displayResolutionDependentFBOs, LIGHT_GEOMETRY_MATERIAL_URN, "texSceneOpaqueLightBuffer"));
addDesiredStateChange(new SetInputTextureFromFbo(textureSlot++, lastUpdatedGBuffer, DepthStencilTexture,
displayResolutionDependentFBOs, LIGHT_GEOMETRY_MATERIAL_URN, "texSceneOpaqueDepth"));
addDesiredStateChange(new SetInputTextureFromFbo(textureSlot++, lastUpdatedGBuffer, NormalsTexture,
displayResolutionDependentFBOs, LIGHT_GEOMETRY_MATERIAL_URN, "texSceneOpaqueNormals"));
addDesiredStateChange(new SetInputTextureFromFbo(textureSlot++, lastUpdatedGBuffer, LightAccumulationTexture,
displayResolutionDependentFBOs, LIGHT_GEOMETRY_MATERIAL_URN, "texSceneOpaqueLightBuffer"));
if (renderingConfig.isDynamicShadows()) {
addDesiredStateChange(new SetInputTextureFromFbo(textureSlot++, getInputFboData(1), DepthStencilTexture, shadowMapResolutionDependentFBOs, LIGHT_GEOMETRY_MATERIAL_URN, "texSceneShadowMap"));
addDesiredStateChange(new SetInputTextureFromFbo(textureSlot++, getInputFboData(1), DepthStencilTexture,
shadowMapResolutionDependentFBOs, LIGHT_GEOMETRY_MATERIAL_URN, "texSceneShadowMap"));

if (renderingConfig.isCloudShadows()) {
addDesiredStateChange(new SetInputTexture2D(textureSlot, "engine:perlinNoiseTileable", LIGHT_GEOMETRY_MATERIAL_URN, "texSceneClouds"));
addDesiredStateChange(new SetInputTexture2D(textureSlot, "engine:perlinNoiseTileable",
LIGHT_GEOMETRY_MATERIAL_URN, "texSceneClouds"));
}
}
}
Expand Down
Loading

0 comments on commit eb5e106

Please sign in to comment.