-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debug Node (New) #3058
Debug Node (New) #3058
Changes from all commits
c0973b4
06b970a
b4582ed
407d92f
5db63fe
c9e5406
9547f03
ddd0521
e32a352
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -294,5 +294,4 @@ public int compare(RenderableChunk o1, RenderableChunk o2) { | |
return distance2 > distance ? -1 : 1; | ||
} | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,12 +18,14 @@ | |
import org.lwjgl.opengl.Display; | ||
import org.terasology.assets.ResourceUrn; | ||
import org.terasology.context.Context; | ||
import org.terasology.engine.SimpleUri; | ||
import org.terasology.monitoring.PerformanceMonitor; | ||
import org.terasology.rendering.dag.ConditionDependentNode; | ||
import org.terasology.rendering.dag.StateChange; | ||
import org.terasology.rendering.dag.stateChanges.EnableMaterial; | ||
import org.terasology.rendering.dag.stateChanges.SetInputTextureFromFbo; | ||
import org.terasology.rendering.opengl.FBO; | ||
import org.terasology.rendering.opengl.FBOManagerSubscriber; | ||
import org.terasology.rendering.opengl.SwappableFBO; | ||
import org.terasology.rendering.opengl.fbms.DisplayResolutionDependentFBOs; | ||
import org.terasology.rendering.world.WorldRenderer; | ||
|
||
|
@@ -34,29 +36,85 @@ | |
import static org.terasology.rendering.world.WorldRenderer.RenderingStage.LEFT_EYE; | ||
import static org.terasology.rendering.world.WorldRenderer.RenderingStage.MONO; | ||
|
||
public class CopyImageToScreenNode extends ConditionDependentNode { | ||
public class OutputToScreenNode extends ConditionDependentNode { | ||
private static final ResourceUrn DEFAULT_TEXTURED_MATERIAL_URN = new ResourceUrn("engine:prog.defaultTextured"); | ||
|
||
public CopyImageToScreenNode(Context context) { | ||
private DisplayResolutionDependentFBOs displayResolutionDependentFBOs; | ||
private WorldRenderer worldRenderer; | ||
|
||
private FBO lastUpdatedGBuffer; | ||
private FBO staleGBuffer; | ||
|
||
private StateChange bindFbo; | ||
|
||
public OutputToScreenNode(Context context) { | ||
super(context); | ||
|
||
displayResolutionDependentFBOs = context.get(DisplayResolutionDependentFBOs.class); | ||
worldRenderer = context.get(WorldRenderer.class); | ||
|
||
WorldRenderer worldRenderer = context.get(WorldRenderer.class); | ||
requiresCondition(() -> worldRenderer.getCurrentRenderStage() == MONO || worldRenderer.getCurrentRenderStage() == LEFT_EYE); | ||
|
||
addDesiredStateChange(new EnableMaterial(DEFAULT_TEXTURED_MATERIAL_URN)); | ||
|
||
addDesiredStateChange(new SetInputTextureFromFbo(0, FINAL_BUFFER, ColorTexture, | ||
context.get(DisplayResolutionDependentFBOs.class), DEFAULT_TEXTURED_MATERIAL_URN, "texture")); | ||
bindFbo = new SetInputTextureFromFbo(0, FINAL_BUFFER, ColorTexture, displayResolutionDependentFBOs, DEFAULT_TEXTURED_MATERIAL_URN, "texture"); | ||
addDesiredStateChange(bindFbo); | ||
|
||
SwappableFBO gBufferPair = displayResolutionDependentFBOs.getGBufferPair(); | ||
lastUpdatedGBuffer = gBufferPair.getLastUpdatedFbo(); | ||
staleGBuffer = gBufferPair.getStaleFbo(); | ||
} | ||
|
||
@Override | ||
public void process() { | ||
PerformanceMonitor.startActivity("rendering/copyImageToScreen"); | ||
PerformanceMonitor.startActivity("rendering/outputToScreen"); | ||
// The way things are set-up right now, we can have FBOs that are not the same size as the display (if scale != 100%). | ||
// However, when drawing the final image to the screen, we always want the viewport to match the size of display, | ||
// and not that of some FBO. Hence, we are manually setting the viewport via glViewport over here. | ||
glViewport(0, 0, Display.getWidth(), Display.getHeight()); | ||
renderFullscreenQuad(); | ||
PerformanceMonitor.endActivity(); | ||
} | ||
|
||
@Override | ||
public void handleCommand(String command, String... arguments) { | ||
switch (command) { | ||
case "setFbo": | ||
if (arguments.length != 1) { | ||
throw new RuntimeException("Invalid number of arguments; expected 1, received " + arguments.length + "!"); | ||
} | ||
|
||
FBO fbo; | ||
switch (arguments[0]) { | ||
case "engine:fbo.gBuffer": | ||
case "engine:fbo.lastUpdatedGBuffer": | ||
fbo = lastUpdatedGBuffer; | ||
break; | ||
case "engine:fbo.staleGBuffer": | ||
fbo = staleGBuffer; | ||
break; | ||
default: | ||
fbo = displayResolutionDependentFBOs.get(new SimpleUri(arguments[0])); | ||
|
||
if (fbo == null) { | ||
throw new RuntimeException(("No FBO is associated with URI '" + arguments[0] + "'")); | ||
} | ||
|
||
break; | ||
} | ||
setFbo(fbo); | ||
|
||
break; | ||
default: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's be more specific the line below. Let's write:
And please notice the apostrophes between quotes... |
||
throw new RuntimeException("Unrecognized command: '" + command + "'"); | ||
} | ||
} | ||
|
||
private void setFbo(FBO fbo) { | ||
removeDesiredStateChange(bindFbo); | ||
bindFbo = new SetInputTextureFromFbo(0, fbo, ColorTexture, displayResolutionDependentFBOs, DEFAULT_TEXTURED_MATERIAL_URN, "texture"); | ||
addDesiredStateChange(bindFbo); | ||
worldRenderer.requestTaskListRefresh(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,8 +31,6 @@ | |
* TODO: Better naming | ||
*/ | ||
public class DisplayResolutionDependentFBOs extends AbstractFBOsManager { | ||
public static final SimpleUri READONLY_GBUFFER = new SimpleUri("engine:fbo.readOnlyGBuffer"); | ||
public static final SimpleUri WRITEONLY_GBUFFER = new SimpleUri("engine:fbo.writeOnlyGBuffer"); | ||
public static final SimpleUri FINAL_BUFFER = new SimpleUri("engine:fbo.finalBuffer"); | ||
|
||
private SwappableFBO gBufferPair; | ||
|
@@ -50,13 +48,13 @@ public DisplayResolutionDependentFBOs(RenderingConfig renderingConfig, ScreenGra | |
} | ||
|
||
private void generateDefaultFBOs() { | ||
FBO readOnlyGBuffer = generateWithDimensions(new FBOConfig(READONLY_GBUFFER, FULL_SCALE, FBO.Type.HDR) | ||
FBO gBuffer1 = generateWithDimensions(new FBOConfig(new SimpleUri("engine:fbo.gBuffer1"), FULL_SCALE, FBO.Type.HDR) | ||
.useDepthBuffer().useNormalBuffer().useLightBuffer().useStencilBuffer(), fullScale); | ||
FBO writeOnlyGBuffer = generateWithDimensions(new FBOConfig(WRITEONLY_GBUFFER, FULL_SCALE, FBO.Type.HDR) | ||
FBO gBuffer2 = generateWithDimensions(new FBOConfig(new SimpleUri("engine:fbo.gBuffer2"), FULL_SCALE, FBO.Type.HDR) | ||
.useDepthBuffer().useNormalBuffer().useLightBuffer().useStencilBuffer(), fullScale); | ||
generateWithDimensions(new FBOConfig(FINAL_BUFFER, FULL_SCALE, FBO.Type.DEFAULT), fullScale); | ||
|
||
gBufferPair = new SwappableFBO(readOnlyGBuffer, writeOnlyGBuffer); | ||
gBufferPair = new SwappableFBO(gBuffer1, gBuffer2); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't these be named right away staleGBuffer and lastUpdatedGBuffer? Both in terms of variables and URIs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was discussed via slack and the new naming is correct, as at this stage there is no stale nor lastUpdated FBO: both haven't been touched yet. |
||
} | ||
|
||
@Override | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to rename PerformanceMonitor line 75:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted, I'll take care of this in the next commit!