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

Adding depth option to the texture of guiOffscreenCanvas #1829

merged 2 commits into from Jan 2, 2017


None yet
4 participants

irei1as commented Nov 22, 2016

Related to:

These small changes fix the rendering in the named texture of a guiOffscreenCanvas with 3d views.
Without this change, the objects in the 3d view are copied as they're created and that causes depth issues (objects behind being rendered in front).

Creating the gui with the field "useDepth" as true enables the fix.
It's off by default so guiOffscreenCanvas that don't use 3d views or don't need the texture part won't get the extra workload of the fix.

-Example of its use-
Add these functions to a .cs script in a "Full" project and exec it:

   function createRearView(%depthtest)
         %tickObj = new ScriptTickObject(RearViewUpdater);
        %guiOffscreen = new GuiOffscreenCanvas() {
           targetSize = "300 300";
           targetFormat = "GFXFormatR8G8B8A8";
           targetName = "RearViewTexture";
           dynamicTarget = "1";
           useDepth = %depthtest; //this one to enable the depth fix
           numFences = "0";
           displayWindow = "1";
           position = "0 0";
           extent = "300 300";
           visible = "1";
           active = "1";
           new GameTSCtrl() {
              cameraZRot = "180";
              position = "0 0";
              extent = "300 300";
        %tickObj.guiOffCan = %guiOffscreen;
        %playGuiRearWindow = new GuiBitmapCtrl() {
           position = "100 100";
           extent = "150 150";
        %tickObj.miniWindow = %playGuiRearWindow;

  function RearViewUpdater::onInterpolateTick(%this, %delta)

  function RearViewUpdater::onRemove(%this)


After that, start the desert level. If you add a few TSStatic and half-bury them in the terrain the fix will be shown better.

Now, use in the console:

This will create a guiOffscreenCanvas with the fix disabled as its useDepth field is zero.

You'll see a small window showing the rear view of the soldier. This window has depth errors like objects not being correctly covered by the terrain.

Delete the window and the guiOffscreenCanvas with:

Finally use:

to create a guiOffscreenCanvas with the fix enabled (useDepth field is true).

Now the window should show the objects being correctly rendered.

irei1as added some commits Nov 22, 2016

Update guiOffscreenCanvas.h
Variables to add depth in the .cpp file.
Add a fix to the depth for the target texture
Fix to the named texture to have the 3d depth correctly rendered if a 3d view is inside the guiOffscreenCanvas.
It's disabled by default so it shouldn't change anything to projects that use guiOffscreenCanvas without the texture (like Oculus rendering).

This comment has been minimized.

Show comment
Hide comment

dottools Nov 22, 2016

Nicely done. Thanks for the PR.

dottools commented Nov 22, 2016

Nicely done. Thanks for the PR.

@Areloch Areloch added the Improvement label Nov 24, 2016


This comment has been minimized.

Show comment
Hide comment

Lopuska Jan 2, 2017


Just perfect. Thanks (:


Lopuska commented Jan 2, 2017

Just perfect. Thanks (:

@Lopuska Lopuska self-assigned this Jan 2, 2017

@Lopuska Lopuska merged commit d164781 into GarageGames:development Jan 2, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment