Jump to content

Dreikblack

Members
  • Posts

    331
  • Joined

  • Last visited

Posts posted by Dreikblack

  1. After recent update material for skybox can't be loaded from zip package

    1. Make Materials.zip with Materials folder inside

    2. Rename usual Materials folder to exclude loading from non-package

    Standard start.ultra map

    #include "UltraEngine.h"
    #include "ComponentSystem.h"
    
    using namespace UltraEngine;
    
    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
        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 package = LoadPackage("Materials.zip");
        package->FileType("");
    
        //Load the map
        WString mapname = "Maps/start.ultra";
        if (cl["map"].is_string()) mapname = std::string(cl["map"]);
        auto scene = LoadMap(world, mapname);
    
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            world->Update();
            world->Render(framebuffer);
        }
    
        return 0;
    }

     

  2. After one of last updates Entity::Copy() started copy original entity tags. I don't know if it's intended but it was not a case before and took me a while to discover exact issue,

    #include "UltraEngine.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->SetPosition(0, 0, -4);
    
        //Create a light
        auto light = CreateBoxLight(world);
        light->SetRotation(45, 35, 0);
        light->SetRange(-10, 10);
        light->SetColor(2);
    
        //Create a model
        auto model = CreateBox(world);
        model->SetColor(0, 0, 1);
        model->AddTag("Test");
        auto model2 = model->Copy(world);
        int tagCount = world->GetTaggedEntities("Test").size();
        Print(tagCount);
        window->SetText("tag count " + WString(tagCount));
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

     

  3. Thanks! Updated loops as it was in Outline.frag and now it works. I did not that before because it looked wrong but with unlit sprite now it's looks as should be.

    image.thumb.png.4ecd2a741c1951cd05d3ea96f3f03e2d.png

    Updated shader code:

    #version 450
    #extension GL_ARB_separate_shader_objects : enable
    
    layout(binding = 0) uniform sampler2DMS DepthBuffer;
    layout(binding = 1) uniform sampler2D ColorBuffer;
    
    uniform int Thickness = 5;
    
    #include "../Base/CameraInfo.glsl"
    #include "../Utilities/Dither.glsl"
    #include "../Utilities/DepthFunctions.glsl"
    
    layout(location = 0) out vec4 outColor;
    
    void main()
    {
    	vec2 BufferSize = vec2(DrawViewport.z, DrawViewport.w);
        ivec2 coord = ivec2(gl_FragCoord.x, gl_FragCoord.y);
    	outColor = vec4(0.0f);
        int count = textureSamples(DepthBuffer);
    	const int m = max(0, (Thickness - 1) / 2);
        float depth;
        //Handle selected objects
    	for (int n = 0; n < count; ++n)
    	{
    		bool done = false;
    		depth = texelFetch(DepthBuffer, coord, n).r;
    		if (depth < 1.0f)
    		{
    			vec2 pixelsize = vec2(1.0f) / BufferSize;
    			for (int x = -m; x <= m; ++x)
    			{
    				for (int y = -m; y <= m; ++y)
    				{
    					if (x == 0 && y == 0) continue;
    					float neighbour = texelFetch(DepthBuffer, coord + ivec2(x, y), n).r;
    					if (neighbour == 1.0f)
    					{
    						outColor += texelFetch(ColorBuffer, coord, gl_SampleID);
    						done = true;
    						break;
    					}
    				}
    				if (done) break;
    			}
    		}
    	}
    	outColor /= float(count);
    }

    Updated example:

    #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, 1200, 800, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
    
        //Create a world
        auto world = CreateWorld();
        world->RecordStats();
    
        //Create a framebuffer
        auto framebuffer = CreateFramebuffer(window);
    
        //Create a camera
        auto camera = CreateCamera(world);
        camera->SetClearColor(0.125);
        camera->SetFov(50);
        camera->SetPosition(0, 0, -3);
    
        //Create a light
        auto light = CreateDirectionalLight(world);
        light->SetColor(1);
        
        //Create a box
        auto box = CreateBox(world);
        box->SetColor(1, 0, 0);
        auto outlineBox = CreateBox(world);
        outlineBox->SetColor(0, 1, 0);
        box->SetPosition(-1, 0, 0);
    
        auto material = CreateMaterial();
        auto unlitShader = LoadShaderFamily("Shaders/Unlit.fam");
        material->SetShaderFamily(unlitShader);
        outlineBox->SetMaterial(material);
        outlineBox->SetPosition(box->GetPosition());
        outlineBox->SetParent(box);
    
        //Create a box2 
        auto box2 = CreateBox(world);
        box2->SetColor(1, 0, 0);
        auto outlineBox2 = CreateBox(world);
        outlineBox2->SetColor(0, 0, 1);
    
        auto material2 = CreateMaterial();
        material2->SetShaderFamily(unlitShader);
        outlineBox2->SetMaterial(material);
    
        box2->SetPosition(1, 0, 0);
        outlineBox2->SetPosition(1, 0, 0);
        outlineBox2->SetParent(box2);
    
        //Entity component system
        auto component = box->AddComponent<Mover>();
        component->rotationspeed.y = 45;
    
        auto component2 = box2->AddComponent<Mover>();
        component2->rotationspeed.y = 45;
    
        //------------------------------------------------------------------------------------  
        //------------------------------------------------------------------------------------  
    
        //Render to texture
        outlineBox->SetRenderLayers(2);
        outlineBox2->SetRenderLayers(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/MultipleOutlines.fx"));
        cam2->SetLighting(false);
        cam2->SetUniform(0, "Thickness", 10);
    
        auto sz = framebuffer->GetSize();
        auto texbuffer = CreateTextureBuffer(sz.x, sz.y);
        auto pixels = CreatePixmap(sz.x, sz.y, TEXTURE_RGBA);
        auto tex = CreateTexture(TEXTURE_2D, sz.x, sz.y, pixels->format, { pixels }, 1, TEXTURE_DEFAULT, TEXTUREFILTER_NEAREST);
        texbuffer->SetColorAttachment(tex);
        cam2->SetRenderTarget(texbuffer);
    
        ////Display overlay
        auto sprite = CreateSprite(world, sz.x, sz.y);
        sprite->SetRenderLayers(4);
        auto mtl = CreateMaterial();
        mtl->SetShaderFamily(unlitShader);
        mtl->SetTransparent(true);
        mtl->SetTexture(texbuffer->GetColorAttachment());
        sprite->SetMaterial(mtl);
    
        auto cam3 = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
        cam3->SetClearMode(CLEAR_DEPTH);
        cam3->SetRenderLayers(4);
        cam3->SetPosition(sz.x * 0.5f, sz.y * 0.5f, 0);
        cam3->SetLighting(false);
    
        //------------------------------------------------------------------------------------  
        //------------------------------------------------------------------------------------  
    
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            world->Update();
            world->Render(framebuffer, false);
            window->SetText(world->renderstats.framerate);
        }
        return 0;
    }

     

    • Like 1
  4. 3 hours ago, Josh said:

    you can try this to disable linear filtering:

    Almost there - colors still a little bit off:

    image.thumb.png.00e3ea8c6b0246f3b6f2a0c3c9eee206.png

    3 hours ago, Josh said:

    t by ignoring colors that have a red value over 0.99

    I use different colors, not only full red/green etc. so it's not an option for me i guess.

    I will try to experiment a bit with a shader code now.

  5. Or probably it's another issue that just appears with big thickness. Then i still idk what am i missing

    With closes look i noticed that in the game outline have right color in closest to model 1-3 pixels and surround by white pixels beyond them.

    Still have no idea why it's not same for example.

  6. Manage partially reproduce an issue in text example

    Without unlit sprite:

    image.png.010c5bc78111f3961699dc0f9633f55b.png

    With unlit sprite (white color in outlines):

    image.thumb.png.381a92455c6dd68e5e5ffd27f433d671.png

    Code:

    #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, 1200, 800, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
    
        //Create a world
        auto world = CreateWorld();
        world->RecordStats();
    
        //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, -3);
    
        //Set environment maps
        const WString remotepath = "https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets";
        auto specmap = LoadTexture(remotepath + "/Materials/Environment/Storm/specular.dds");
        auto diffmap = LoadTexture(remotepath + "/Materials/Environment/Storm/diffuse.dds");
        world->SetEnvironmentMap(specmap, ENVIRONMENTMAP_BACKGROUND);
        world->SetEnvironmentMap(specmap, ENVIRONMENTMAP_SPECULAR);
        world->SetEnvironmentMap(diffmap, ENVIRONMENTMAP_DIFFUSE);
    
        //Create a light
        //auto light = CreateBoxLight(world);
        //light->SetRotation(35, 45, 0);
        //light->SetRange(-10, 10);
        auto light = CreateDirectionalLight(world);
        light->SetColor(2);
        camera->SetFog(true);
        camera->SetFogColor(0.5, 0.5, 0.5f, 1);
        
        //Create a box
        auto box = CreateBox(world);
        box->SetColor(1, 0, 0);
        auto outlineBox = CreateBox(world);
        outlineBox->SetColor(0, 1, 0);
        box->SetPosition(-1, 0, 0);
    
        auto material = CreateMaterial();
        auto unlitShader = LoadShaderFamily("Shaders/Unlit.fam");
        material->SetShaderFamily(unlitShader);
        outlineBox->SetMaterial(material);
        outlineBox->SetPosition(box->GetPosition());
        outlineBox->SetParent(box);
    
        //Create a box2 
        auto box2 = CreateBox(world);
        box2->SetColor(1, 0, 0);
        auto outlineBox2 = CreateBox(world);
        outlineBox2->SetColor(0, 0, 1);
    
        auto material2 = CreateMaterial();
        material2->SetShaderFamily(unlitShader);
        outlineBox2->SetMaterial(material);
    
        box2->SetPosition(1, 0, 0);
        outlineBox2->SetPosition(1, 0, 0);
        outlineBox2->SetParent(box2);
    
        //Entity component system
        auto component = box->AddComponent<Mover>();
        component->rotationspeed.y = 45;
    
        auto component2 = box2->AddComponent<Mover>();
        component2->rotationspeed.y = 45;
    
    
        //------------------------------------------------------------------------------------  
        //------------------------------------------------------------------------------------  
    
        //Render to texture
        outlineBox->SetRenderLayers(2);
        outlineBox2->SetRenderLayers(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/MultipleOutlines.fx"));
        cam2->SetLighting(false);
        cam2->SetUniform(0, "Thickness", 20);
    
        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->SetRenderLayers(4);
        auto mtl = CreateMaterial();
        mtl->SetShaderFamily(unlitShader);
        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);
        cam3->SetLighting(false);
    
        //------------------------------------------------------------------------------------  
        //------------------------------------------------------------------------------------  
    
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            world->Update();
            world->Render(framebuffer, false);
            window->SetText(world->renderstats.framerate);
        }
        return 0;
    }

     

  7. Snippet from the game code: just in case if it will help to notice what i may miss:

    outlineCamera = CreateCamera(gameWorld);
    outlineCamera->SetClearColor(0, 0, 0, 0);
    outlineCamera->SetRenderLayers(OUTLINE_RENDER_LAYER);
    outlineCamera->SetFov(gameCamera->GetFov());
    outlineCamera->SetMatrix(gameCamera->matrix);
    outlineCamera->AddPostEffect(LoadPostEffect(AppDir() + "/Shaders/MultipleOutlines.fx"));
    outlineCamera->SetPosition(gameCamera->GetPosition(true));
    outlineCamera->SetRotation(gameCamera->GetRotation(true));
    outlineCamera->SetParent(gameCamera);
    outlineCamera->SetLighting(false);
    
    auto texbuffer = CreateTextureBuffer(sz.x, sz.y);
    outlineCamera->SetRenderTarget(texbuffer);
    
    auto tacticCamera = gameCamera->GetComponent<TacticCamera>();
    tacticCamera->outlineCamera = outlineCamera;
    
    displayOverlaySprite = CreateSprite(gameWorld, sz.x, sz.y);
    displayOverlaySprite->SetRenderLayers(OUTLINE_OVERLAY_LAYER);
    auto displayOverlayMaterial = CreateMaterial();
    auto unlitShader = LoadShaderFamily("Shaders/Unlit.fam");
    displayOverlayMaterial->SetShaderFamily(unlitShader);
    displayOverlayMaterial->SetTransparent(true);
    displayOverlayMaterial->SetTexture(texbuffer->GetColorAttachment());
    displayOverlaySprite->SetMaterial(displayOverlayMaterial);
    displayOverlaySprite->SetShadows(false);
    
    overlayCamera = CreateCamera(gameWorld, PROJECTION_ORTHOGRAPHIC);
    overlayCamera->SetClearMode(CLEAR_DEPTH);
    overlayCamera->SetRenderLayers(OUTLINE_OVERLAY_LAYER);
    overlayCamera->SetPosition(sz.x * 0.5f, sz.y * 0.5f, 0);
    overlayCamera->SetLighting(false);

     

  8. Well, with unlit on overlay sprite colors now are not black but somehow still not correct at all - a lot of extra white color where it should just solid green or yellow on the pic

    image.thumb.png.eebc4edf845a89aee74977f8f5e75374.png

    Somehow simple test example still have no such visual artifacts.

    In the game fps increase now 80% tho.

  9. For some reason in my game outlines became black when i do it for overlay camera. In test example it works fine tho. In both cases i do use unlit shader for mat of outline models. Any idea what might cause it? Btw fps increases is around 10% with that.

  10. Is there any way to optimize multiply outlines? It's still reducing fps twice which is bigger problem now after switching to OpenGL.

    Shader itself does not seems to be a problem and stays FPS is same i don't apply shader. FPS is increases if i hide extra cameras or change SetRenderLayers.

  11. Press space to add text for left button. Right button have a several lines initially but looks as should be.

    image.png.9c61baea894963e09deab6fbbcd03cdc.png

    • #include "UltraEngine.h"
      
      using namespace UltraEngine;
      
      int main(int argc, const char* argv[])
      {
          //Get the displays
          auto displays = GetDisplays();
      
          //Create window
          auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0]);
      
          //Create framebuffer
          auto framebuffer = CreateFramebuffer(window);
      
          //Create world
          auto world = CreateWorld();
      
          //Create main camera
          auto camera = CreateCamera(world);
          camera->SetPosition(0, 0, -3);
      
          //Load a font
          auto font = LoadFont("Fonts/arial.ttf");
      
          //Create user interface with a semi-transparent background
          auto ui = CreateInterface(world, font, framebuffer->size);
          ui->background->SetColor(0, 0, 0, 0.5);
      
          //Create widget
          iVec2 sz = ui->background->ClientSize();
          auto button = CreateButton("Button", 100, 200, 150, 30, ui->background);
      
          auto button2 = CreateButton("Button2", 500, 200, 150, 30, ui->background);
          for (int i = 0; i < 5; i++)
          {
              button2->AddText("\ntest");
          }
      
          //Create camera
          auto orthocamera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
          orthocamera->SetClearMode(CLEAR_DEPTH);
          orthocamera->SetPosition(float(framebuffer->size.x) * 0.5f, float(framebuffer->size.y) * 0.5f, 0);
      
          //UI will only appear in orthographic camera
          orthocamera->SetRenderLayers(2);
          ui->SetRenderLayers(2);
      
          while (true)
          {
              if (window->KeyHit(KEY_SPACE))
              {
                  button->AddText("\ntest");
              }
              while (PeekEvent())
              {
                  const Event ev = WaitEvent();
                  switch (ev.id)
                  {
                  case EVENT_WINDOWCLOSE:
                      if (ev.source == window)
                      {
                          return 0;
                      }
                      break;
                  default:
                      ui->ProcessEvent(ev);
                      break;
                  }
              }
      
              world->Update();
              world->Render(framebuffer);
          }
          return 0;
      }

       

    • Thanks 1
  12. Maybe it's only with Cyrillic not sure

    #include "UltraEngine.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, 800, 600, displays[0]);
    
        //Create User Interface
        auto ui = CreateInterface(window);
    
        //Create widget
        auto label1 = CreateLabel("Test", 20, 20, 120, 30, ui->root);
        auto label2 = CreateLabel("Тест", 20, 50, 120, 30, ui->root, LABEL_BORDER | LABEL_CENTER | LABEL_MIDDLE);
    
        while (window->Closed() == false)
        {
            WaitEvent();
        }
        return 0;
    }

     

  13. Made own icon for Quake Tactics.exe:

     

    26571783_SignofDoomed.png.f2bad464d7989bbb10e4dca8b8ea9cd0.png

     

     

    • New weapon - Laser rifle. Long range, special piercing shot damage all units in the shot line
    • New enemy - Enforcer. Slow but fully armored and has a laser rifle as a long range weapon. Enforcer can be now blew up by attacking his back (orange bar shows HP for backpack)
    • Changed area weapon trigger zone shape a bit for better detection
    • Bot’s unit can now keep its turn if detect something if bot team turn was not ended yet
    • Grunts will shoot if can’t came close enough for point blank
    • Now weapon distance is also shown with a circle when action dialog is up
    • Arrow under units to show in which way they will be pushed and potential damage in unit bars from bump damage
    • Fixed outlines
    • A lot of fixes for GUI and controls

     

    • Like 5
  14. 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
  15. I'm not sure what new changes in Outline shader in last update supposed to fix but colors seems to be off again (shape at right side have same color in a code as outline at left)

    image.png.dd362c9e373baa610f9f0fec447dda52.png

  16. Fxied MultipleOutlines.frag:

    #version 450
    #extension GL_ARB_separate_shader_objects : enable
    
    layout(binding = 0) uniform sampler2DMS DepthBuffer;
    layout(binding = 1) uniform sampler2D ColorBuffer;
    
    uniform int Thickness = 5;
    
    #include "../Base/CameraInfo.glsl"
    #include "../Utilities/Dither.glsl"
    #include "../Utilities/DepthFunctions.glsl"
    
    layout(location = 0) out vec4 outColor;
    
    void main()
    {
        ivec2 coord = ivec2(gl_FragCoord.x, gl_FragCoord.y);
    	outColor = vec4(0.0f);
        int count = textureSamples(DepthBuffer);
        float depth;
        //Handle selected objects
    	for (int n = 0; n < count; ++n)
    	{
    		depth = texelFetch(DepthBuffer, coord, n).r;
    		if (depth < 1.0f)
    		{
    			const int m = max(0, (Thickness - 1) / 2);
    			vec2 pixelsize = vec2(1.0f) / BufferSize;
    
    			for (int x = -m; x <= m; ++x)
    			{
    				for (int y = -m; y <= m; ++y)
    				{
    					if (x == 0 && y == 0) continue;
    					float neighbour = texelFetch(DepthBuffer, coord + ivec2(x, y), n).r;
    
    					if (neighbour == 1.0f)
    					{
    						outColor += texelFetch(ColorBuffer, coord, gl_SampleID);
    						break;
    					}
    				}
    			}
    		}
    	}
    	outColor /= float(count);
    }

     

    • Like 1
  17. 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
  18. Quote
    #include "UltraEngine.h"
    
    using namespace UltraEngine;
    
    int main(int argc, const char* argv[])
    {
        //Get the displays
        auto displays = GetDisplays();
    
        //Create window
        auto window = CreateWindow("Ultra Engine", 0, 0, 800, 600, displays[0]);
    
        //Create user interface
        auto ui = CreateInterface(window);
    
        //Create a pixmap
        auto pixmap = LoadPixmap("spaceshipBH7.dds");
        pixmap = pixmap->Resize(128, 128);
    
        //Show the pixmap
        ui->root->SetPixmap(pixmap);
    
        while (true)
        {
            const Event ev = WaitEvent();
            switch (ev.id)
            {
            case EVENT_WINDOWCLOSE:
                return 0;
                break;
            }
        }
    
        return 0;
    }

     

    spaceshipBH7.zip

  19. #include "UltraEngine.h"
    
    using namespace UltraEngine;
    
    int main(int argc, const char* argv[])
    {
        auto package = LoadPackage("Data.zip");
        if (package == nullptr) { Notify("No Package Found"); }
        package->FileType("");
    
        auto plugin = LoadPlugin("Plugin\\FITextureLoader");
    
        if (!plugin)
            Notify("No plugin Found");
        else
            Notify("Plugin Found");
    
        auto displays = GetDisplays();
        auto window = CreateWindow("Ultra Engine", 0, 0, 500, 500, displays[0], WINDOW_DEFAULT);
        auto framebuffer = CreateFramebuffer(window);
    
        auto world = CreateWorld();
        auto font = LoadFont("Fonts\\arial.ttf");
        auto ui = CreateInterface(world, font, framebuffer->GetSize());
        ui->SetRenderLayers(2);
        auto uiCamera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
        uiCamera->SetPosition((float)framebuffer->GetSize().x * 0.5f, (float)framebuffer->GetSize().y * 0.5f, 0);
        uiCamera->SetRenderLayers(2);
        uiCamera->SetClearMode(CLEAR_DEPTH);
        ui->LoadColorScheme("Style.json");
        auto btn = CreateButton("TEST", 10, 10, 100, 100, ui->root);
    
        auto dir = LoadDir("Ru");
        for (WString localFile : dir)
        {
            btn->SetText(localFile);
            Print(localFile);
        }
    
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

     

    Data.zip

  20. 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;
    }

     

  21. 1)  entity.name = "name"

    2) Only in maps - map.entities. For World only tagged and in area

    3) Just set an integer bigger than 6 with Entity:SetCollisionType. btw @Josh CollisionType enum seems being not exposed in LUA

    local NEW_COLLISION = 7

    box1:SetCollisionType(NEW_COLLISION)

    https://www.ultraengine.com/learn/Entity_SetCollisionType?lang=lua

    https://www.ultraengine.com/learn/World_SetCollisionResponse?lang=lua

    4) No GetTag() atm but it should be possible to iterate entity.tags but in my test example it return nil so probably not exposed in LUA @Josh

    5) Not sure what you mean :unsure:

    Maybe you want that:

    for n, entity in pairs(world:GetTaggedEntities("tag")) do
        local entity = Entity(entity)
        Print(entity.name)
    end
    • Thanks 1
×
×
  • Create New...