Jump to content

SpiderPig

Members
  • Posts

    2,285
  • Joined

  • Last visited

Posts posted by SpiderPig

  1. Okay.  Here's a better example then.  No Interface, just a rotating sprite.  I'd want to have MSAA working for a camera that renders sprites or any other 3D object on top of a 3D scene.

    #include "Engine.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);
    
        //Create a model
        auto box = CreateBox(world);
    
        //Create a light
        auto light = CreateBoxLight(world);
        light->SetRange(-5, 5);
        light->SetRotation(34, 45, 0);
    
        //Create camera
        auto orthocamera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
        orthocamera->SetMSAA(4);
        orthocamera->SetClearMode(CLEAR_DEPTH);
        orthocamera->SetPosition(float(framebuffer->size.x) * 0.5f, float(framebuffer->size.y) * 0.5f, 0);
        orthocamera->SetRenderLayers(2);
    
        auto sprite = CreateSprite(world, 64, 64);
        sprite->SetRenderLayers(2);
        sprite->SetPosition(256, 256);
    
        while (true)
        {
            box->Turn(0, 1, 0);
            sprite->Turn(0, 0, 0.25);
    
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

     

  2. The 3D scene vanishes in this example with MSAA enabled.

    #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);
    
        //Create a model
        auto box = CreateBox(world);
    
        //Create a light
        auto light = CreateBoxLight(world);
        light->SetRange(-5, 5);
        light->SetRotation(34, 45, 0);
    
        //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", sz.x / 2 - 75, sz.y / 2 - 15, 150, 30, ui->background);
    
        //Create camera
        auto orthocamera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
        orthocamera->SetMSAA(4);
        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);
    
        auto sprite = CreateSprite(world, 64, 64);
        sprite->SetRenderLayers(2);
        sprite->SetPosition(256, 256);
    
        while (true)
        {
            box->Turn(0, 1, 0);
            sprite->Turn(0, 0, 0.25);
    
            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;
    }

     

  3. DynamicLine.zip

    I've only noticed these things since the OpenGL build.  It could be because now there are compile times involved.

    If you edit the attached frag file, it loads it twice and the changes are not applied.  This is the console output after a single edit of DynamicLine.frag.  If you change the color in the attached frag shader you'll see this in the console but the box will not change color.

    Loading shader module "Materials/DynamicLine/DynamicLine.frag"
    Loading shader module "Materials/DynamicLine/DynamicLine.frag"

    If you edit the material, all changes are applied but it still loads it twice.

    Deleting shader family "Materials/DynamicLine/DynamicLine.fam"
    Loading shader family "Materials/DynamicLine/DynamicLine.fam"
    Deleting shader family "Materials/DynamicLine/DynamicLine.fam"
    Loading shader family "Materials/DynamicLine/DynamicLine.fam"

    With some shaders I've seen it do it 4 times.  It's annoying because as the files get bigger it takes longer to compile.

    #include "Engine.h"
    
    using namespace UltraEngine;
    
    int main(int argc, const char* argv[])
    {
        auto displays = GetDisplays();
        auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
        auto framebuffer = CreateFramebuffer(window);
        auto world = CreateWorld();
        world->SetGravity(0.0f, -2.0f, 0.0f);
    
        auto camera = CreateCamera(world);
        camera->SetClearColor(0.125);
        camera->SetPosition(0, 0, -2);
    
        auto light = CreateDirectionalLight(world);
        light->SetRotation(35, 35, 0);
    
        auto box = CreateBox(world);
        box->SetColor(0, 1, 0);
    
        auto mat = LoadMaterial("Materials\\DynamicLine\\DynamicLine.mat");
        box->SetMaterial(mat);
    
        auto watcher = CreateFileSystemWatcher("Materials");
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            while (PeekEvent()) {
                auto ev = WaitEvent();
    
                if (ev.id == EVENT_FILECHANGE or ev.id == EVENT_FILECREATE)
                {
                    //Look for a loaded asset with this file path
                    auto asset = FindCachedAsset(ev.text);
                    if (asset)
                    {
                        asset->Reload();
                    }
                }
            }
    
            box->Turn(0.0f, 0.1f, 0.0f);
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

     

  4. I might be wrong in what I'm seeing - but based on the console output it seems that loading this material is loading the PBR shader family as the root even though I've specified Unlit.fam as the root in DynamicLine.fam.  Even if this output is correct, it's loading the PBR then deleting it, then loading it again.

    DynamicLine.zip

    ShaderNotLoadingUnlitFamily.thumb.png.ba111cf5919df7babb1296288b6aa245.png

    #include "Engine.h"
    
    using namespace UltraEngine;
    
    int main(int argc, const char* argv[])
    {
        auto displays = GetDisplays();
        auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
        auto framebuffer = CreateFramebuffer(window);
        auto world = CreateWorld();
        world->SetGravity(0.0f, -2.0f, 0.0f);
    
        auto camera = CreateCamera(world);
        camera->SetClearColor(0.125);
        camera->SetPosition(0, 0, -2);
    
        auto light = CreateDirectionalLight(world);
        light->SetRotation(35, 35, 0);
    
        auto box = CreateBox(world);
        box->SetColor(0, 1, 0);
    
        auto mat = LoadMaterial("Materials\\DynamicLine\\DynamicLine.mat");
        box->SetMaterial(mat);
    
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
    
    
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

     

  5. That's right.  I've pretty much got that then.  All I'd have to do is change the extension and add the missing data structures.  Seeing as Blender doesn't support BC7 I was thinking of auto converting any png textures to the correct dds format on export with a small program made with ultra.

  6. I dare say it's not hard, its just time consuming.  The main issue I had was finding out the right stuff to access in blender from python, but google was the answer there.  There's also the Leadwerks mdl exporter for blender.  Maybe that could be converted to suit this rather than starting again?

  7. 16 minutes ago, Andy90 said:

    The second, and in my opinion better, approach is to handle the clothes separately from the player model itself. This means having a blank model for your player and attaching the clothes to it. However, I'm not sure if this is possible. Additionally, I'm uncertain about how to do this.

    I started a system for this in Leadwerks and will eventually move it to Ultra.  Basically I had an animated player character who wore just underwear.

    Then I made each piece of clothing seperatly.

    I can't remember specifics, but each clothing had to have the animated shaders and the same armature applied to it as the player.  Like I said, can't remeber how I did it exactly but that's the gist of it! 🙂

  8. Yeah I see your points.

    1 hour ago, Josh said:

    For your purposes, it sounds like it's not the file format that matters so much, but the export process you have set up. If so, you could probably export glTF files just as easily using the same process, but if your current approach is working then by all means use it.

    50/50.  With GLTF the export process for each LOD is time consuming.  But yes, the same export process of my format could be added to the default GLTF exporter for blender but then there's still these issues.

    • Doesn't store LOD's
    • Doesn't use one material across multiple files or even LOD's
      • Which results in lots of work within the editor to edit just one aspect of one model.

    None of that really matters if your just dragging in a model and then never touch it again.  But how many people are honestly never going to edit / or create a custom asset?  Ultra isn't a 3D editor.

    1 hour ago, Josh said:

    It sounds like you are moving a lot of work from the Ultra editor into Blender, and you are setting up a very specific scene in Blender so it works with your export process. This is fine if it works for you.

    Yes, that is what I've done.  But only because GLTF is not good enough.

    1 hour ago, Josh said:

    In my view, there is no need for any "source file" anymore because glTF is the source file, as well as the final game-ready file.

    Are there actually many asset sites that deal in GLTF?  Every time I download something it's FBX.  So if I ever have to re-download it, technically FBX is the source file.

    I know I can't convince you. :D  But I honestly think that the GLTF process is a serious flaw and makes an efficient workflow hard to set up.  I can't be the only one who's going to be exporting hundreds of assets from a 3D editing software.

  9. Regarding the conversation of ASIMP and GLTF in the workshop today - I think all problems are solved by creating a unique format for Ultra.  My exporter for blender (although only for static models - for now ;) ), with a few clicks I have everything exported that works straight away.

    I can't speak for other peoples workflow, but this is mine in a nutshell.

    • Buy / Make assets
    • Store them in a library folder so that they can be used in any project (also serves as a backup)
    • Load them in blender and save the blend file in the same library folder
    • Fine tune the mesh and materials.  Make a mesh collider if needed (some already have one)
    • My Format:
      • Export to Ultra - done!
    • GLTF
      • Export LOD0
      • Export LOD1
      • Export LOD2
      • Export LOD3
      • Export Collider Mesh
      • Load the editor
      • Open each material
        • Convert textures
      • Open the model and load the collider from the mesh
        • Delete the GLTF for this collider

    If I need to edit the model or material further.

    • Open blender
    • Edit things
    • My Format
      • Export to Ultra
    • GLTF
      • All of the above again!

    If I edit the material in the editor, then my source in blender is no longer the same.  99% of the time any change I want to make will apply to all projects, so I want it changed in the source file (.blend) not in the lone project.

    If GLTF or any other format doesn't improve on the current workflow.  There's no way I'm staying with GLTF. :wacko:

    • Upvote 1
  10. I see what you mean.  It would be no "easy" task for the user, but for those of use who know how all the positioning would be done in a shader function.  The idea of a MeshLayer class would be to construct a grid of meshes from a single object.  Then in our shader function we could write some code that could sample a texture to offset the mesh in that cell, to get some randomness (and even height).  The only thing it would be suited for is large quantity of objects that follow a sort of grid like pattern.  (3D grid would be even better).  Like foliage; city blocks and maybe even large swarms of enemies or insects that could be swapped in for an actual model the closer the player got to them - like a boid system.  I'm sure there are more uses.

    I will write something like this myself if not.  I'm not as smart as you so it would take me more than 3 days. :D

     

  11. I'm watching the video of todays workshop.  Your mesh layers does exactly what I need 😁 and I agree with the others about how it should be a seperate class from the terrain.  Somthing we can use idenpenantly would be very powerfull.  Firstly I could use it for my voxel terrain foliage system - which is the exact same as yours but can work in caves and such too.  Also it could be used for making cities with huge amounts of buildings and I'm sure many other things too.  🙂  What do you think about this?

  12. It would kind of be a post effect, yeah.  Okay, so the colour texture is first written to by the 3D camera, then added too with the UI camera.  At the very least I might be able to capture a screen shot and use that as the texture.  Wouldn't be real-time but it might look good.

×
×
  • Create New...