Jump to content

Probe Relections on Other Renderlayers


Recommended Posts

 

I was going to report this in the bug report, but I don't think this is really a bug. I noticed the reflections of my viewmodel (which were being rendered on a different layer) weren't reflecting the level probe. I suspected that this was because the probe is only set to renderlayer 1, and the example below proves this. It makes sense, but I expected the probes to affect all layers, but there might be a situation where you don't want that. 

The example and map attachment below demonstrates the conflict. I don't know what the best course of action would be. Should the probes render on all layers by default? Should there be an option to allow the mapper to set each entity to desired renderlayers? Or should this be left alone, and the programmer has to ensure the probes render on the desired renderlayers? 

#include "UltraEngine.h"
using namespace UltraEngine;

//#define TEMPFIX

int main(int argc, const char* argv[])
{
    RegisterComponents();

    auto cl = ParseCommandLine(argc, argv);

    //Load FreeImage plugin (optional)
    auto fiplugin = LoadPlugin("Plugins/FITextureLoader");

    //Get the displays
    auto displays = GetDisplays();

    //Create a window
    iVec2 windowsize = iVec2(1280, 720);
    WindowStyles windowstyle = WINDOW_CENTER | WINDOW_TITLEBAR;
    auto window = CreateWindow("Ultra Engine", 0, 0, windowsize.x * displays[0]->scale, windowsize.y * displays[0]->scale, displays[0], windowstyle);

    //Create a framebuffer
    auto framebuffer = CreateFramebuffer(window);

    //Create a world
    auto world = CreateWorld();

    //Load the map
    WString mapname = "Maps/coloredroom.ultra";
    auto scene = LoadMap(world, mapname);

    auto maincamera = CreateCamera(world);
    maincamera->SetPosition(0, 1.28, -1.92);

    auto camera2 = CreateCamera(world);
    camera2->SetClearMode(CLEAR_DEPTH);
    camera2->SetMatrix(maincamera->GetMatrix(true), true);
    camera2->SetFov(maincamera->GetFov());
    camera2->SetRange(maincamera->GetRange().x, maincamera->GetRange().y);
    camera2->SetRenderLayers(2);

    auto sphere = CreateSphere(world);
    sphere->SetPosition(0, 1.28, 0);

    auto mat = CreateMaterial();
    mat->SetShaderFamily(LoadShaderFamily("Shaders/PBR.fam"));
    mat->SetRoughness(0);
    mat->SetMetalness(1);
    sphere->SetMaterial(mat);
    mat = NULL;

    sphere->SetRenderLayers(2);

#ifdef TEMPFIX
    // Search all probes
    for (const auto& p : scene->entities)
    {
        auto probe = p->As<Probe>();
        if (probe)
        {
            probe->SetRenderLayers(1+2);
        }
    }
#endif

    //Main loop
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        world->Update();
        world->Render(framebuffer);

    }

    return 0;
}

 

coloredroom.zip

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

From your description, it sounds like the probes and render layers are working as intended? Is that correct?

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Yes (for the most part), but only after I figured out that the reflections were not showing on the viewmodel because it wasn't being rendered on the same layer as it. I'm not sure if this will add friction to new users.

In more recent testing, I've been getting black reflections when I changed the map without rebuilding the probes or in outdoor environments. I'd have to do more testing and make an example before I can file a bug report. 

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

Perhaps by default lights and probes should have their render layers set so they include all possible values? (Max unsigned integer)

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

2 minutes ago, Josh said:

Perhaps by default lights and probes should have their render layers set so they include all possible values? (Max unsigned integer)

That's what I'm thinking unless there's any reason for that not need to be the case. I really think the RENDERLAYER enum should come back and allow us to assign renderlayers in the editor. 

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...