Jump to content

Recommended Posts

Posted

BTW, NVCompress is in the Tools folder with a bunch of bat files you can use to just drag an image onto it and get the DDS in the format you want. There's also an option to turn a texture into a normal map, for quick and dirty normal maps.

You do not need to use DDS, but they load a lot faster than image files and don't require any plugins.

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

I have now tried a very basic setup for the new Hook-Feature, but can't get it to work :( 

While the setup works, it just does nothing in the loop.

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

using namespace UltraEngine;

class Environment : public Object
{
private:
    shared_ptr<World> _world;
public:
    Environment(shared_ptr<World> world);
    friend shared_ptr<Environment> CreateEnvironment(shared_ptr<World> world);
};

void CalculateEnvironment(VkCommandBuffer cbuffer, shared_ptr<Object> extra)
{
    //Vulkan code
    Print("Hello World");
}

Environment::Environment(shared_ptr<World> world)
{
    _world = world;
}

shared_ptr<Environment> CreateEnvironment(shared_ptr<World> world)
{
    auto env = make_shared<Environment>(world);
    world->AddHook(HOOKID_RENDER, CalculateEnvironment, env);
    return env;
}



int main(int argc, const char* argv[])
{
    //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 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);
    
    //Create a light
    auto light = CreateLight(world, LIGHT_DIRECTIONAL);
    light->SetRotation(35, 45, 0);

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

    //Entity component system
    auto actor = CreateActor(box);
    auto component = actor->AddComponent<Mover>();
    component->rotation.y = 45;

    auto environment = CreateEnvironment(world);

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

 

  • Windows 10 Pro 64-Bit-Version
  • NVIDIA Geforce 1080 TI
Posted

@klepto2If you add an object in the "extra" parameter, the function will get called. It shouldn't be required, but I made a small mistake.

Also, don't call Print() from the rendering thread, since it is not thread-safe. :rolleyes:

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

@Josh I have provided the extra parameter in the function:

 

 auto env = make_shared<Environment>(world);
    world->AddHook(HOOKID_RENDER, CalculateEnvironment, env);

The Print was just for testing, of course this should be removed.

 

[Edit:] 

I should mention taht it still isn't called in the render loop or otherwise :(

 

 

 

  • Haha 1
  • Windows 10 Pro 64-Bit-Version
  • NVIDIA Geforce 1080 TI
Posted

The library is updated and your code above works now.

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

Ok, i have now a setup where i can begin to start integrating the compute shaders (Textures are successfully created) and accessible.  

If i want to include my own ComputePipeline i need access to some more specific vulkan handles, eg: the vkDevice, maybe vkInstance etc. 

Maybe you can provide a struct containing all these in the Hook instead of just the Commandbuffer? Or is there another way to Dispatch a loaded ShaderModule  in UltraEngine? I have searched the UltraRender namespace as well, but i can't access the infos needed to manually create the Pipeline.

Any infos or ideas?

  • Windows 10 Pro 64-Bit-Version
  • NVIDIA Geforce 1080 TI
Posted

 

If you call UltraCore::GameEngine::Get()->renderingthreadmanager->device most everything will be there.

  • Thanks 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

@reepblueThis is what I usually do to make all sprite coordinates match up to the screen coordinates:

cam2d->SetPosition(float(framebuffer->size.x)*0.5f, float(framebuffer->size.y)*0.5f);

Then position 0,0 is the bottom-left of the screen.

  • Like 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

I didn't choose anything. Remember, there is no 2D graphics, just orthographic projection.

the force rock GIF

  • Like 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

There are some rendering problems I am working on now, but this is how a GUI gets created for 3D graphics:

    auto ui = CreateInterface(world, framebuffer->size);
    ui->SetRenderLayers(RENDERLAYER_1);
    
    auto button = CreateButton("Button", 20, 20, 100, 30, ui->root);
    
    ui->SetScale(displays[0]->scale);

Then in the main loop you need to pass events to the interface, since it is not connected to any window:

        while (PeekEvent())
        {
            const auto& e = WaitEvent();
            switch (e.id)
            {
            case EVENT_MOUSEDOWN:
            case EVENT_MOUSEUP:
            case EVENT_MOUSEMOVE:
            case EVENT_KEYDOWN:
            case EVENT_KEYUP:
            case EVENT_KEYCHAR:
                ui->ProcessEvent(e);
                break;

            case EVENT_WIDGETACTION:
                //if (e.source == button) Notify("Button pressed!");
                break;
            }
        }

You can pass the unmodified event like above, or you can pass events in from transformed coordinates in-game, like the clickable panels in Doom. In that case, you would call camera->SetRenderTarget() to make the camera render to a texture, and then you have in-game interfaces.

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

Small Update on compute shaders: 

I have now a small partly working Implementation which looks like this:

auto environment = initalize_atmosphere(world);
	auto cshader = ComputeShader::Create("Shaders\\Environment\\transmittance_gen.comp.spv");
	cshader->AddImageBinding(texture1, 0, WRITE);
	cshader->AddImageBinding(texture2, 1, READ);
	cshader->AddBufferBinding(environment, 2,1 READ);
	cshader->BeginDispatch(world,16,16,1,true);

The most magic is done in the BeginDispatch, this creates the proper LayoutInfo and Descriptorsets when not done yet, and registers a renderhook which then adds the proper commands to the cmdbuffer. I still need to figure some things out, but at least the compute shader is succesfully bound and can be seen in nsight :).

I will later add a DirectDispatch method which can be executed withot the rendering buffer, but therefore I need create a new separate Queue, etc.. But first i will have a first running version with the BeginDispatch approach.  

  • Like 2
  • Windows 10 Pro 64-Bit-Version
  • NVIDIA Geforce 1080 TI
Posted

I'm curious, are you really doing Vulkan programming yourself with this, or are you more just passing the values to another API?

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

Oh man, you have my respect. Damn, I will try to help as much as possible.

UltraRender is a sort of mid-layer API, but I am hesitant to try to expose or document it since it is a lot more complex and prone to changes.

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

Thank you, this is the atmosphere renderin in Leadwerks: 

And I think with the terrain benefits of ultraengine ( real spherical ) this is awesome.

  • Like 4
  • Windows 10 Pro 64-Bit-Version
  • NVIDIA Geforce 1080 TI
Posted

PNG does not work for some reason sometimes. I am waiting to update the system before I do anything about it.

  • Like 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

@klepto2 In the next build the hook will pass this stucture instead of just a command buffer:

    struct VkRenderer
    {
        VkDevice device;
        VkInstance instance;
        VkCommandBuffer commandbuffer;
    };

Is there any other data I should add to it?

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

This looks good, what might be a good addition would be the ability to remove hooks. I am currently designing my pipeline to have one shot and recurring pipelines. The atmosphere just needs one shot calculations, when some parameters have changed. Later the more complex fft calculation for oceans needs recurring updates each frame.

  • Windows 10 Pro 64-Bit-Version
  • NVIDIA Geforce 1080 TI
Guest
This topic is now closed to further replies.
×
×
  • Create New...