Jump to content

klepto2

Developers
  • Posts

    927
  • Joined

  • Last visited

Everything posted by klepto2

  1. This is the sunset with a more artistic sun
  2. small progress: i rendered a dynamic cubemap succesfully. The images are taken from the nvidia nsight, as of the CreateTexture / SetEnvironemnt problem i can't display it in UltraEngine.
  3. Another small bug report: 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 mtl = CreateMaterial(); mtl->SetRoughness(0.25); mtl->SetMetalness(0.5); box->SetMaterial(mtl); auto specmap = LoadTexture("Materials/Environment/Storm/specular.dds"); auto diffmap = LoadTexture("Materials/Environment/Storm/diffuse.dds"); // error INVALID_IMAGE_LAYOUT --> IMAGE_LAYOUT_UNDEFINED // auto envSky = CreateTexture(TEXTURE_CUBE, 256, 256, TEXTURE_RGBA, {}, 6, TEXTURE_DEFAULT , TEXTUREFILTER_LINEAR, 0); // THIS ONE SEEMS TO WORK, AT LEAST NO ERROR auto envSky = CreateTexture(TEXTURE_CUBE, 256, 256, TEXTURE_RGBA, {}, 6, TEXTURE_STORAGE, TEXTUREFILTER_LINEAR, 0); //EVEN WITH SET TO envSKY (created Cubemap) the Background is set to specmap instead. world->SetEnvironmentMap(envSky, ENVIRONMENTMAP_BACKGROUND); world->SetEnvironmentMap(specmap, ENVIRONMENTMAP_SPECULAR); world->SetEnvironmentMap(diffmap, ENVIRONMENTMAP_DIFFUSE); bool sky = false; //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { if (window->KeyHit(KEY_SPACE)) { sky = !sky; world->SetEnvironmentMap(sky ? specmap : envSky, ENVIRONMENTMAP_BACKGROUND); world->SetEnvironmentMap(sky ? specmap : envSky, ENVIRONMENTMAP_SPECULAR); } world->Update(); world->Render(framebuffer); } return 0; }
  4. That looks really nice small question: How to create a cubemap with custom mipmaps? vector<shared_ptr<Pixmap>> mipchain; for (int i = 0; i < 6; i++) { iVec2 size = iVec2(256, 256); auto pixmap = CreatePixmap(size, TEXTURE_RGBA32); //mipchain.push_back(pixmap); while (size.x > 1) { size /= 2; pixmap = CreatePixmap(size, TEXTURE_RGBA32); mipchain.push_back(pixmap); } } auto envSky = CreateTexture(TEXTURE_CUBE, 256, 256, TEXTURE_RGBA32, mipchain , 6, TEXTURE_STORAGE | TEXTURE_MIPMAPS | TEXTURE_GENMIPMAPS , TEXTUREFILTER_LINEAR, 0); envSky->BuildMipmaps(); I always get "mipmap incorrect size" error. I have tried it with just a single mipchain (just for one face), multiple like in this sample and various size limits.
  5. Yes, to get the ComputeShaders (mainly for fft or the atmospheric scattering) was very tricky to implement in leadwerks, some missing things like native 3d textures. UltraEngine already has eveything we need, and the latest additions to hook into it the rendering pipeline and get easy access to some underlying types makes it much easier. On the other hand, you need to think a bit different than as in Leadwrks Engine. eg: Textures etc. are really only initialised once they are rendered. But thats nice, just needs a different thinking and makes it ultra fast.
  6. I know, but for the scattering i might need a bit more According to some papers i will split up the data into PushConstants and uniform buffers, where the push constants will contain the repeatedly changing data and the uniform buffer maybe the more static once. UniformBuffer was just the beginning, i will try to integrate as much buffer types as possible, this will give a lot more freedom.
  7. New Progress on the compute_front thx Jsoh for the fast updates struct ComputeTestData { float size; float padding1; float padding2; float padding3; Vec4 color; }; 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.1, -1); auto plg = LoadPlugin("Plugins/KTX2TextureLoader"); auto ball = CreateSphere(world, 0.5, 32); auto specmap = LoadTexture("Materials/Environment/Storm/specular.dds"); auto diffmap = LoadTexture("Materials/Environment/Storm/diffuse.dds"); world->SetEnvironmentMap(specmap, ENVIRONMENTMAP_BACKGROUND); world->SetEnvironmentMap(specmap, ENVIRONMENTMAP_SPECULAR); world->SetEnvironmentMap(diffmap, ENVIRONMENTMAP_DIFFUSE); camera->Point(ball); //auto environment = initalize_atmosphere(world); auto targetTexture = CreateTexture(TextureType::TEXTURE_2D, 256, 256, TextureFormat::TEXTURE_RGBA32, {},1,TEXTURE_STORAGE); auto cshader = ComputeShader::Create("Shaders\\Environment\\simple_test.comp.spv"); ComputeTestData data; data.size = 50.0; data.color = Vec4(1.0, 1.0, 1.0, 1.0); int targetIndex = cshader->AddTargetImage(targetTexture); int bufferIndex = cshader->AddUniformBuffer(&data, sizeof(data), false); cshader->BeginDispatch(world, 16, 16, 1, true); auto mtl = CreateMaterial(); mtl->SetRoughness(0.25); mtl->SetMetalness(0.5); mtl->SetTexture(targetTexture, 0); ball->SetMaterial(mtl); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { if (window->KeyHit(KEY_A)) { data.size = 5.0; data.color = Vec4(1.0, 0.0,0.0, 1.0); cshader->Update(bufferIndex); cshader->BeginDispatch(world, 16, 16, 1, true); } if (window->KeyHit(KEY_S)) { data.size = 50.0; data.color = Vec4(0.0, 1.0, 0.0, 1.0); cshader->Update(bufferIndex); cshader->BeginDispatch(world, 16, 16, 1, true); } //camera->UpdateControls(window); world->Update(); world->Render(framebuffer); } return 0; } I can now add ImageTargets, Samplers and UniformBuffers and even update the uniforms on demand. The technique is that ad first just a barebone description of the layout is saved. The Dispatch command adds a Transfer Hook to the rendering pipeline and at the first time the concrete layout and shader descriptors are setup, also the writedescriptros are setup. Then if a buffer needs an update, this buffer is updated in the hook before the dispatch is send to the command buffer.
  8. Yeah, the last thing should work. You need to reset the interator to the next item when using erase in a loop. https://devptr.com/c-remove-elements-from-vector-in-loop-while-iterating/#:~:text=To delete single element from,start%2C end-1).
  9. repeated = true, works, but for one time hooks i get this: > Environment_d.exe!std::_Vector_const_iterator<class std::_Vector_val<struct std::_Simple_types<struct UltraEngine::Object::Hook> > >::_Compat(class std::_Vector_const_iterator<class std::_Vector_val<struct std::_Simple_types<struct UltraEngine::Object::Hook> > > const &) Unbekannt File: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include\vector Line: 186 Expression: vector iterators incompatible Also is it correct: in HOO_RENDER the cmdbuffer is in recording state, but in RENDER_TRANSFER it is not. So i need to handle that by myself?
  10. Now i have another problem: i have this exception in the rendering loop once i start using hooks: File: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include\vector Line: 1587 Expression: vector erase iterator outside range
  11. Will try it. Updating now Update: Works
  12. I get this error in debug mode: Fehler LNK2019 Verweis auf nicht aufgelöstes externes Symbol "__std_find_trivial_4" in Funktion ""int * __cdecl __std_find_trivial<int,int>(int *,int *,int)" (??$__std_find_trivial@HH@@YAPEAHPEAH0H@Z)". Environment C:\Users\Shadow\Documents\Ultra Engine\Environment\UltraEngine_d.lib(Skeleton.obj) 1
  13. Hi Josh, for full access to the texture i need the VkSampler to also textures as input to a shader. Maybe like GetViewHandle you could add GetSamplerHandle?
  14. I use the LoadShaderModule from UltraEngine and the provided info from the Texture (GetViewHandle). Everything else is plain Vulkan, no middle layer involved. It is also currently very limited as i have only implemnted the Image binding, next is buffer binding and a lot of refactoring as vulkan is a pain to keep track of all possibilities.
  15. Again some progress auto targetTexture = CreateTexture(TextureType::TEXTURE_2D, 256, 256, TextureFormat::TEXTURE_RGBA32, {},1,TEXTURE_STORAGE); auto cshader = ComputeShader::Create("Shaders\\Environment\\checkerboard_gen.comp.spv"); cshader->GetPipelineBuilder() ->AddImageBinding(targetTexture); cshader->BeginDispatch(world, 16, 16, 1, true); auto mtl = CreateMaterial(); mtl->SetRoughness(0.25); mtl->SetMetalness(0.5); mtl->SetTexture(targetTexture, 0); this code actually works and results in this: a small generated checkerboard texture generated by a compute shader
  16. I personally like it more if I can handle all these things my self. So a removehook would be best. For everything else I first need to get everything working and let my mind fully transition from OpenGL to vulkan again ( which is hard after working with OpenGL for a long time ). If Someone understand this, it is you
  17. 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.
  18. Will check it. I haven‘t looked at this for a while, but I think it will be just some adjustments.
  19. Thank you, this is the atmosphere renderin in Leadwerks: And I think with the terrain benefits of ultraengine ( real spherical ) this is awesome.
  20. Complete vulkan programing on my own, well besides some researches done previous. I am trying to implement https://github.com/ebruneton/precomputed_atmospheric_scattering Currently which was successfully in Leadwerks engine. This implementation can provide real-time luminance and reflection textures for pbr pipelines.
  21. 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.
  22. 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?
  23. @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
  24. 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; }
×
×
  • Create New...