Jump to content

SetColor not applied at all in release, and sometimes in debug


klepto2
 Share

Go to solution Solved by Josh,

Recommended Posts

This is a wierd one (at least it looks like a weird one) i have a simple scene with a terrain and a sphere.

the sphere is set to a red color.

In release: The result is always a white sphere but whith a correct looking terrain.

In debug: sometimes the same result as in release, but sometimes the sphere gets its color (and can be changed at runtime) but then the terrain is pure black as long as the sphere is in view.

 

#include "UltraEngine.h"
#include "ComponentSystem.h"
//#include "Steamworks/Steamworks.h"

using namespace UltraEngine;

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

#ifdef STEAM_API_H
    if (not Steamworks::Initialize())
    {
        RuntimeError("Steamworks failed to initialize.");
        return 1;
    }
#endif

    RegisterComponents();

    auto cl = ParseCommandLine(argc, argv);

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

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

    //Create a window
    auto window = CreateWindow("Ultra Engine", 0, 0, 1280 * displays[0]->scale, 720 * displays[0]->scale, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);

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

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

    auto camera = CreateCamera(world);
    camera->SetClearColor(0.125);
    camera->SetFov(70);
    camera->Move(0, 2, -8);
    camera->AddComponent<CameraControls>();


    //Create light
    auto light = CreateDirectionalLight(world);
    light->SetRotation(45, 35, 0);
    light->SetColor(2);
    world->RecordStats(true);


    auto main_instance = CreateTerrain(world, 512, 512);

    auto sphere = CreateSphere(world, 2.0, 32);
    sphere->SetColor(1.0, 0.0, 0.0);

    //Main loop
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        if(window->KeyHit(KEY_F1))
            sphere->SetColor(1.0, 0.0, 0.0);

        if (window->KeyHit(KEY_F2))
            sphere->SetColor(0.0, 1.0, 0.0);


        world->Update();
        world->Render(framebuffer);

#ifdef STEAM_API_H
        Steamworks::Update();
#endif
    }

#ifdef STEAM_API_H
    Steamworks::Shutdown();
#endif

    return 0;
}

image.thumb.png.de9c870460b9fd174371dd95df42a311.png

Above is release (everytime) /debug(not everytime)  ( color can't  be changed with F1/F2)

image.thumb.png.8a857731ce9aa4f3bae08683e09fc2fc.png

the same with debug build, sometimes the color works. (then the color can be changed with F1/F2)

  • Confused 1
  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

At this point I suspect a nasty memory overwrite in the terrain system. I am seeing behavior that does not otherwise make sense...

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

  • Solution

I found the cause.

In the visibility list, meshes are grouped by pipeline settings. This is all the different rendering settings, plus the shader in use.

The pipeline settings has a < operator for sorting. This is how the grouping is done.

I added a setting in the shader family to force bindless textures off, but did not add any sorting for this in the < operator in the pipeline settings class.

As a result, your sphere was probably getting rendered using the terrain shader. :D

Once I added the needed fix the problem went away.

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

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...