Jump to content

Outline shader bugs


Dreikblack
 Share

Go to solution Solved by Josh,

Recommended Posts

After one of last updates outline shader got couple bugs:

1. Color is darker than should be

2. Outline not match model edge fully

3. Also for some reason it's looks thinner (1 pixel) than should be with same value of Thickness (3)

image.png.af41f9ff442478121cdf3975a52f1eed.png

#include "UltraEngine.h"
#include "ComponentSystem.h"

using namespace UltraEngine;

int main(int argc, const char* argv[])
{
    //Get the displays
    auto displays = GetDisplays();

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

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

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

    //Create a camera
    auto camera = CreateCamera(world);
    camera->SetClearColor(0.125);
    camera->SetFov(70);
    camera->SetPosition(1, 0, -2);

    //Create a light
    auto light = CreateBoxLight(world);
    light->SetRotation(35, 45, 0);
    light->SetRange(-10, 10);

    Vec4 color(0, 1, 0, 1);

    //Create a box
    auto box = CreateBox(world);

    //Render to texture
    box->SetRenderLayers(1 + 2);
    auto cam2 = CreateCamera(world);
    cam2->SetClearColor(0, 0, 0, 0);
    cam2->SetRenderLayers(2);
    cam2->SetFov(camera->GetFov());
    cam2->SetMatrix(camera->matrix);
    cam2->AddPostEffect(LoadPostEffect("Shaders/Outline.fx"));
    auto sz = framebuffer->GetSize();
    auto texbuffer = CreateTextureBuffer(sz.x, sz.y);
    cam2->SetRenderTarget(texbuffer);

    //Display overlay
    auto sprite = CreateSprite(world, sz.x, sz.y);
    sprite->SetColor(color);
    sprite->SetRenderLayers(4);
    auto mtl = CreateMaterial();
    sprite->SetMaterial(mtl);
    mtl->SetTransparent(true);
    mtl->SetTexture(texbuffer->GetColorAttachment());
    auto cam3 = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
    cam3->SetClearMode(CLEAR_DEPTH);
    cam3->SetRenderLayers(4);
    cam3->SetPosition(sz.x * 0.5f, sz.y * 0.5f, 0);

    auto box2 = CreateBox(world);
    box2->SetPosition(1, 0, 0);
    box2->SetColor(color);

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

 

Link to comment
Share on other sites

Here is an example program. The thickness parameter will work in the next build that goes up:

#include "UltraEngine.h"
#include "ComponentSystem.h"

using namespace UltraEngine;

int main(int argc, const char* argv[])
{
    //Get the displays
    auto displays = GetDisplays();

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

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

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

    //Create a camera
    auto camera = CreateCamera(world);
    camera->SetClearColor(0.125);
    camera->SetFov(70);
    camera->SetPosition(0, 0, -2);

    //Create a light
    auto light = CreateBoxLight(world);
    light->SetRotation(35, 45, 0);
    light->SetRange(-10, 10);

    //Create a box
    auto box = CreateBox(world);

    camera->AddPostEffect(LoadPostEffect("Shaders/Outline.fx"));
    //camera->SetUniform(0, "Thickness", 50);

    //Main loop
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        box->Turn(0, 1, 0);
        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

image.thumb.png.65282694d6a658c49f6287114d05bce5.png

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

It works now. I believe this is fixed. I don't understand what is supposed to happen in the code you posted, so please let me know if anything is not right.

  • Thanks 1

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

6 hours ago, Josh said:

I don't understand what is supposed to happen in the code you posted

It was just showing a visual issues. Anyway these issues seems to be resolved. I even managed to fix my multi outlines shader as well by researching a delta in usual outline shader

image.thumb.png.a3ef66f434e2069a7643d8b73c71f0b9.png

  • Like 1
Link to comment
Share on other sites

I don't know what that image means. I found some logical errors that were causing the outlines in the editor to be the wrong color. Now they work correctly in the editor.

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

It's from my example in my first post. And i already explained what it means... Outline color is darker than should be.

Changed a code to make it even more obvious

#include "UltraEngine.h"
#include "ComponentSystem.h"

using namespace UltraEngine;

int main(int argc, const char* argv[])
{
    //Get the displays
    auto displays = GetDisplays();

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

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

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

    //Create a camera
    auto camera = CreateCamera(world);
    camera->SetClearColor(0.125);
    camera->SetFov(70);
    camera->SetPosition(1, 0, -2);

    //Create a light
    auto light = CreateBoxLight(world);
    light->SetRotation(35, 45, 0);
    light->SetRange(-10, 10);

    Vec4 color(0, 1, 0, 1);

    //Create a box
    auto box = CreateBox(world);

    //Render to texture
    box->SetRenderLayers(1 + 2);
    auto cam2 = CreateCamera(world);
    cam2->SetClearColor(0, 0, 0, 0);
    cam2->SetRenderLayers(2);
    cam2->SetFov(camera->GetFov());
    cam2->SetMatrix(camera->matrix);
    cam2->AddPostEffect(LoadPostEffect("Shaders/Outline.fx"));
    cam2->SetUniform(0, "Thickness", 50);
    auto sz = framebuffer->GetSize();
    auto texbuffer = CreateTextureBuffer(sz.x, sz.y);
    cam2->SetRenderTarget(texbuffer);

    //Display overlay
    auto sprite = CreateSprite(world, sz.x, sz.y);
    sprite->SetColor(color);
    sprite->SetRenderLayers(4);
    auto mtl = CreateMaterial();
    sprite->SetMaterial(mtl);
    mtl->SetTransparent(true);
    mtl->SetTexture(texbuffer->GetColorAttachment());
    auto cam3 = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
    cam3->SetClearMode(CLEAR_DEPTH);
    cam3->SetRenderLayers(4);
    cam3->SetPosition(sz.x * 0.5f, sz.y * 0.5f, 0);

    auto box2 = CreateBox(world);
    box2->SetPosition(2, 0, 0);
    box2->SetColor(color);

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

image.thumb.png.aef647b8a6b1d48e68149901ba26ccd1.png

  • Thanks 1
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...