Jump to content

klepto2

Developers
  • Posts

    854
  • Joined

  • Last visited

Posts posted by klepto2

  1. If i remember correctly Josh uses the FXAA-Light version of FXAA and not the real nvidia one here. In the light version you can try to alter the 

    #define FXAA_SPAN_MAX 8.0

    but that might also lead to artifacts. 

    I am currently trying to implement the nvidia way, there you can pass more quality options to the function, but it might be a bit slower than the original one.

    I will come back later today to let you know what i have till then.

    • Thanks 1
  2. Some small additions i wanted to test with the current scintilla version:

    • how to make autocomplete better than in Leadwerks (it was firstly in there, but then changed to an opt-in feature, due to problems)
    • Line indention
    • Calltips (not even tried them in Leadwerks time)

    image.thumb.gif.6f56c8259564da84faa8dbb72d9467bd.gif

     

    • Like 1
  3. You can try to implement some kind of virtualization. If all elements in you list are of the same size, you can just create as much as is visible. If you scroll you can recycle the ones which are out of view and put them in a cache. Then you calculate which items are in view and you pop the items from the cache and update there position. If the size changes and more items are visible than are in the cache, just create new items.

    • Like 1
    • Upvote 1
  4. Some minor issues regarding panelstyles and clipping:

    #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();
    
        //Load a font
        auto font = LoadFont("Fonts/arial.ttf");
    
        //Create user interface
        auto ui = CreateInterface(world, font, framebuffer->size);
        iVec2 sz = ui->root->ClientSize();
        auto mainPanel = CreatePanel(0, 0, sz.x, sz.y, ui->root);
        mainPanel->SetColor(Vec4(1.0, 0.0, 0.0, 1.0), WIDGETCOLOR_BACKGROUND);
        //Create widget
        sz = mainPanel->ClientSize();
        auto panel1 = CreatePanel(5, 5, 300, sz.y - 10, mainPanel);
        auto panel2 = CreatePanel(5 + 305, 5, 300, sz.y - 10, mainPanel, PANEL_BORDER);
        auto panel3 = CreatePanel(5 + 610, 5, 300, sz.y - 10, mainPanel, PANEL_GROUP);
        auto tabber = CreateTabber(5 + 915, 5, 300, sz.y - 10, mainPanel);
        tabber->AddItem("Tabber");
        panel3->SetText("Group");
    
        sz = panel1->ClientSize();
        auto scrollBar1V = CreateSlider(sz.x - 20, 0, 20, sz.y, panel1, SLIDER_SCROLLBAR | SLIDER_VERTICAL);
        auto scrollBar1H = CreateSlider(0, sz.y-20, sz.x-20, 20, panel1, SLIDER_SCROLLBAR | SLIDER_HORIZONTAL);
    
        sz = panel2->ClientSize();
        auto scrollBar2V = CreateSlider(sz.x - 20, 0, 20, sz.y, panel2, SLIDER_SCROLLBAR | SLIDER_VERTICAL);
        auto scrollBar2H = CreateSlider(0, sz.y - 20, sz.x - 20, 20, panel2, SLIDER_SCROLLBAR | SLIDER_HORIZONTAL);
    
        sz = panel3->ClientSize();
        auto scrollBar3V = CreateSlider(sz.x - 20, 0, 20, sz.y, panel3, SLIDER_SCROLLBAR | SLIDER_VERTICAL);
        auto scrollBar3H = CreateSlider(0, sz.y - 20, sz.x - 20, 20, panel3, SLIDER_SCROLLBAR | SLIDER_HORIZONTAL);
    
        sz = tabber->ClientSize();
        auto scrollBar4V = CreateSlider(sz.x - 20, 0, 20, sz.y, tabber, SLIDER_SCROLLBAR | SLIDER_VERTICAL);
        auto scrollBar4H = CreateSlider(0, sz.y - 20, sz.x - 20, 20, tabber, SLIDER_SCROLLBAR | SLIDER_HORIZONTAL);
    
        //Create camera
        auto camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
        camera->SetPosition(float(framebuffer->size.x) * 0.5f, float(framebuffer->size.y) * 0.5f, 0);
    
        while (true)
        {
            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;
    }

    image.thumb.png.9927dbdf592cfb76159ae2fa4428482c.png

  5. It is a slightly modified and updated to the latest version of ultraengine of this: 

    It is not rendered in Vulkan directly, so it will not work when rendered to a texture, but for general purpose ingame editors it will work as well as if it is directly attached to a window. I just needed to modify some syntax changes and change some scrolling and draw behavior.

     

     

    • Like 2
  6. Updated my Repo here: https://github.com/klepto2/UltraEngineUtilities

    Added a ShaderWatcher:

    It establishes a FilesystemWatch and keeps track of all used shaders in Shaderfamilies.

    - Runtime compilation of shaders

    - Automatically reloading shader assets after compilation

    - Error-Reports for each shader

    Missing: Handling Renaming and Deletion of json files

    Known issues:

    Notepadd++ uses a way to save files which will trigger the FILECHANGED - EVENT multiple times. I guess i need some way to store some hashvalues for the files.

     

    #include "UltraEngine.h"
    #include "ComponentSystem.h"
    
    #include "include\Utilities.h"
    
    using namespace UltraEngine;
    using namespace UltraEngine::Utilities::Shader;
    
    int main(int argc, const char* argv[])
    {
        auto watcher = CreateShaderWatcher();
        watcher->Start();
        ...
    }

     

    • Like 2
  7. I have published a first version of the compilation class: 

    https://github.com/klepto2/UltraEngineUtilities

    the watcher class will come later.

    #include "UltraEngine.h"
    #include "ComponentSystem.h"
    
    #include "include\Utilities.h"
    
    using namespace UltraEngine;
    using namespace UltraEngine::Utilities::Shader;
    
    int main(int argc, const char* argv[])
    {
        auto compiler = CreateShaderCompiler();
        auto result = compiler->Compile("Shaders/GUI/WidgetBlock.frag", "Shaders/GUI/WidgetBlock.frag.spv");
        if (result->IsSuccesfull())
        {
            Print("Shader compiled succesfully!");
            for (auto f : result->GetIncludedFiles())
            {
                Print("Shader includes: " + f);
            }
        }
        else
        {
            Print("Shader compilation failed!");
            Print(result->GetError());
        }
        ...
    }

     

    • Upvote 1
  8. A small update on the shader reload: 

    In this gif you can see, that i am editing an included file (Fragment.glsl) This file is used by many shaders so changing this file needs to recompile all dependent main shader files, which you see here. (i changed the lod lookup to a fixed value of 0 which leads to a clear representation of the reflection (just for demonstration) )  I also have improved the compile times as i have moved the Compilation to Multithreading, which makes it much faster than the batch file approach. I am now working on a better error handling, As you can see in the gif, currently the same error is printed for each compiled shader. I want to make it more streamlined, The idea is to create an error log at the end, after all files are compiled. When this is finished i will make this piece of code open source, so Josh and others can include this if they need it.

    image.thumb.gif.27b8012157769c155f4dba604b190554.gif

    • Like 3
  9. Some more progress:

    Realtime Shader editing while the program is running:

    image.thumb.gif.5bef374d648364d849880715c4e31637.gif

    It uses the FindCachedAsset function together with the FileSystemWatcher. Another feature: it even supports the editing of includes on the fly. So when you edit for example the Lightning.glsl file, the code will find all dependent main shaders and recompile them on the fly.

    • Like 2
  10. just a small proof of concept i made:

    image.thumb.png.f93a5978fa29042a0c4124bd015e9780.png

    The top line  ShaderValidator::ShaderCompiler::Compile(); is the interessting part.

    This method parses all json shaderfamilies and extracts the required shader files and tries to locate the correct source and target. then it takes all of the found shaders and recompiles them to Spirv-binary files in code before any shader is loaded.

    • Upvote 1
  11. I have 2 ideas for making the Shader and postprocess pipeline a bit more flexible and to keep the innerarchitecture mostly untouched:

    Postprocessing:

    1. Add a method (preferable static, to let later plugins or  where you can assign a named Texture, something like:
      1. PostEffect::RegisterTexture("MyCustomTex");
      2. PostEffect::SetTexture("MyCustomTex", mytexture);
      3. in the json file you can now access them like depth, etc. Just the binding code might be a bit adjusted on your end.

    Generel shaders:

    • The current shader system is super fast because you more or less make everything available to every shader. With this in mind, i thought about something like the precompiler for components, but on the fly.
    • with libs like shaderc or glslang it is possible to compile shaders to SPIR-V on the fly in the code.
      • Add something like Shader::AddBufferData("BufferName", "Layout",size, &object);
      • With this we could modify e.G.: UniformBlocks.glsl and add the new buffer data to the pipeline
      • On start when the first shader is about to be loaded the UniformBlocks.glsl is validated against the possible current one.
        • If the validation is succesfull, just use the latest shaders and go on
        • if the UniformBlocks.glsl is different from the new generated one: rebuild all shaders like you already do with the batch file.
    • This would make the system a bit more flexible for additions, but will also maintain the speed you get from less binding switches.

     

    • Like 1
    • Thanks 1
    • Upvote 1
  12. Josh, after all these bug reports you have solved recently ,and I just want to say: 

    Thank you. 

    UltraEngine is coming along very nice, and it is much better than I ever have thought it will be. The speed is really incredible, and the API is nice and smooth (of course there is space for improvements, but this will always be the case). Just a small sample:

    In one of my researches (I posted it earlier in this thread), I started rendering a scene with a large terrain and a pseudo water plane (all tessellated).  To test a feature I wanted to implement, I needed some kind of cascade rendering of the scene from multiple viewports (in this case 3). So I rendered the complete scene with lights terrain etc. 4 times, 1 time for the main viewport and 3 times for the cascades to a viewport (512,512) with an attached pfx shader with around 10-12 subpasses. And long story short: the speed was nearly the same as if I would render just the normal viewport. Of course there is some impact, but the same scene in Leadwerks would make it slow down to maybe 5 fps, if not less. In UltraEngine this still runs at 60fps.

    This is amazing !!!  

     

     

    • Like 1
    • Upvote 3
  13. No, there is a function it is called something like getmeterialtextureindex or so. There you can pass the current material and the index u are using. The function then returns the internal index you need to lookup in the array.

     

    take a look in pbr/fragment.glsl and search for textureid.

    • Thanks 2
  14. 4 hours ago, Josh said:

    Update

    Currently it's not really possible without using a pixmap, which would only work with image data in system memory, but it would probably not be too difficult to add an option for this, probably a Widget::SetTexture() method.

    What do you propose? Something like Camera::SetClipPlane(const Plane& p, const int index)?

    Yes, I know the method is in the camera class but commented out. as I think it would require changes to the vertex shaders, like in Leadwerks. But it would be nice to have a way to cut out everything by plane. Also, it would make water refraction possible, when the global refraction is no option (don’t know when, just mentioning it for completeness ;) )

  15. A small experiment to recreate an effect i used in my ocean for Leadwerks:

    image.thumb.gif.4ccf4a59fe138f790fc9fe4d69ffdfbf.gif

    This is uses a second camera with an attached postprocess effect which renders a distance and direction map from a topdown view. It consists of many passes but is still amazingly fast:

    1. Render everything but water in a texturebuffer where you store the texcoords for every pixel higher than the water level
    2. depending on the texture resolution: perform a JFA (https://www.shadertoy.com/view/WlGyR3) in multiple step sizes
    3. store the distance of each pixel to the shore

    You can see that this is not very accurate as i am currently only render a full cascade for the entire world. But you can get the idea behind it. 

    Unfortunatly UltraEngine currently has no access to clipmaps which leads to the artifact you can see when the sphere is above water. But once clipmaps are reintroduced this should be a no-brainer to solve.

    • Like 2
  16. Terrain - SetHeight bug:

    #include "UltraEngine.h"
    #include "ComponentSystem.h"
    
    using namespace UltraEngine;
    
    int main(int argc, const char* argv[])
    {
        //Get the display list
        auto displays = GetDisplays();
    
        //Create a window
        auto window = CreateWindow("Terrain Paint", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
    
        //Create a world
        auto world = CreateWorld();
        world->SetAmbientLight(0);
    
        //Create a framebuffer
        auto framebuffer = CreateFramebuffer(window);
    
        //Create a camera
        auto camera = CreateCamera(world);
        camera->SetFov(70);
        camera->SetPosition(0, 100, -100);
        camera->SetRotation(45, 0, 0);
        camera->SetClearColor(0.125);
    
        //Sunlight
        auto light = CreateDirectionalLight(world);
        light->SetRotation(45, 35, 0);
        light->SetColor(2);
    
        //Create terrain
        auto terrain = CreateTerrain(world, 512);
        terrain->SetScale(1, 100, 1);
    
        //Create base material
        auto ground = CreateMaterial();
        auto diffusemap = LoadTexture("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Materials/Ground/river_small_rocks_diff_4k.dds");
        auto normalmap = LoadTexture("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Materials/Ground/river_small_rocks_nor_gl_4k.dds");
        ground->SetTexture(diffusemap, TEXTURE_DIFFUSE);
        ground->SetTexture(normalmap, TEXTURE_NORMAL);
        terrain->SetMaterial(ground);
    
        //Create paint material
        auto rocks = CreateMaterial();
        diffusemap = LoadTexture("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Materials/Ground/Rocks_Dirt_Ground_2k.dds");
        normalmap = LoadTexture("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Materials/Ground/Rocks_Dirt_Ground_2k_dot3.dds");
        auto dispmap = LoadTexture("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Materials/Ground/Rocks_Dirt_Ground_2k_disp.dds");
        rocks->SetTexture(diffusemap, TEXTURE_DIFFUSE);
        rocks->SetTexture(normalmap, TEXTURE_NORMAL);
        rocks->SetTexture(dispmap, TEXTURE_DISPLACEMENT);
    
        //Camera controls
        auto actor = CreateActor(camera);
        actor->AddComponent<CameraControls>();
    
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            if (window->MouseDown(MOUSE_LEFT))
            {
                auto mousepos = window->GetMousePosition();
                auto pickinfo = camera->Pick(framebuffer, mousepos.x, mousepos.y);
                if (pickinfo.success)
                {
                    if (pickinfo.entity == terrain)
                    {
                        iVec2 pos;
                        pos.x = Round(pickinfo.position.x) + terrain->resolution.x / 2;
                        pos.y = Round(pickinfo.position.z) + terrain->resolution.y / 2;
                        int radius = 20;
                        for (int x = pos.x - radius; x < pos.x + radius; ++x)
                        {
                            for (int y = pos.y - radius; y < pos.y + radius; ++y)
                            {
                                float strength = 1.0f - Vec3(x, y, 0).DistanceToPoint(Vec3(pos.x, pos.y, 0)) / float(radius);
                                if (strength <= 0.0f) continue;
                                terrain->SetHeight(x, y,  terrain->GetHeight(x,y) + 0.005 * strength);
                            }
                        }
                    }
                }
            }
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }
     	Terrain_test_d.exe!std::vector<class std::shared_ptr<class UltraEngine::Model>,class std::allocator<class std::shared_ptr<class UltraEngine::Model> > >::operator[](unsigned __int64)	Unbekannt
     	Terrain_test_d.exe!UltraEngine::Terrain::UpdatePatchBounds(void)	Unbekannt
     	Terrain_test_d.exe!UltraEngine::Terrain::Finalize(void)	Unbekannt
     	Terrain_test_d.exe!UltraEngine::World::Render(class std::shared_ptr<class UltraEngine::Framebuffer>,bool,int)	Unbekannt
    >	Terrain_test_d.exe!main(int argc, const char * * argv) Zeile 87	C++
     	[Externer Code]	
    

    you get this error as soon as you try to modify the terrain with SetHeight: Expression: vector subscript out of range

     

  17. UltraEngine has a Legacy-Importer which can load the Leadwerks files (map, mat. tex, etc.) while not everything is supported right now you already can load maps created with the Leadwerks Editor. but keep in mind, that the Legacy materials and models will use a different shader family, so you might not get PBR out of the box in Leadwerks maps.

    • Like 1
  18. In the latest version, the UI is not rendered correclty:

    image.thumb.png.949a0bbd52aedc43b3d9a2269d60046c.png

    There are 100 items in the list and below are 2 tabbers. If you look closely the tabbers are visible, but only the text in a dark grayish color.

    #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(0, 0, -3);
        camera->SetViewport(200, 0, framebuffer->size.x -200, framebuffer->size.y);
    
        auto uiCamera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
        uiCamera->SetRenderLayers(RENDERLAYER_1);
        uiCamera->SetClearMode(CLEAR_DEPTH);
        uiCamera->SetPosition(framebuffer->size.x / 2, framebuffer->size.y / 2);
        auto ui = CreateInterface(world, LoadFont("Fonts/arial.ttf"), iVec2(200, framebuffer->size.y));
        ui->SetRenderLayers(RENDERLAYER_1);
    
        auto sz = ui->root->ClientSize();
        auto listbox = CreateListBox(5, 5, sz.x - 10, 200, ui->root, LISTBOX_DEFAULT)->As<ListBox>();
        auto tabber = CreateTabber(5, 205, sz.x - 10, sz.y - 205, ui->root)->As<Tabber>();
        tabber->AddItem("Settings", true);
        tabber->AddItem("Output");
    
        for (int i = 0; i < 100; i++)
        {
            listbox->AddItem("Item " + String(i));
        }
    
        //Create a light
        auto light = CreateBoxLight(world);
        light->SetRotation(35, 45, 0);
        light->SetRange(-10, 10);
    
        //Create a box
        auto box = CreateBox(world);
        box->SetColor(0,0,1);
    
        //Entity component system
        auto actor = CreateActor(box);
        auto component = actor->AddComponent<Mover>();
        component->rotation.y = 45;
    
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            if (PeekEvent())
            {
                auto ev = WaitEvent();
                ui->ProcessEvent(ev);
            }
    
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

     

  19. 14 hours ago, Josh said:

    Update

    • Fix for textures not loading correctly from plugins, may fix validation error
    • Fixed shader family reloading issue

    Works :)

    10 hours ago, Josh said:

    Final steps:

    • The SSR shader needs to detect and calculate indirect lighting based on whether the material that wrote each pixel uses PBR, Spec/Gloss, or classic shading. These each use a different calculation of specular reflection.
    • Clean shader code up a bit.
    • Make sure the spec/gloss appearance is correct. A lot of Sketchfab models use this glTF extension.
    • ASyncRender will be renamed to AsyncRender

    Nice :)

    I would like to add some small thing to the list:

    if you clean up the shader code, then you might consider to reanable the mappingscale feature (currently SetMappingScale has no effect, pbr and terrain)

    Also if possible: readd the animation texture feature with volume textures, this would make life a lot easier.

    and minor feature request: add some more methods to access some major properties:

    • Camera:
      • GetMatrix() (projection, view, etc.)
      • GetFrustumn
    • Terrain: 
      • a way to get the heightmap texture (not only the pixmap) --> support for gpu based heightmap generation
      • a way to get  / set the alpha mask for each material --> better support for serialization 

     

×
×
  • Create New...