IceBurger Posted December 29, 2023 Share Posted December 29, 2023 The culling is noticeably slower than the camera movement. At first I didn't really think this was a "bug" per se, because I had over 8000 models in the scene; however, it is still noticeable (although to a lower extent) with model counts as low as 4. The models have between 0 and 1024 vertices (with most having 0). I do this code for each model: model->AddMesh(mesh); model->UpdateBounds(); model->Staticize(); Here is a video of this happening with 8000 models (7600 of which have no vertices): Another thing I tried was to filter out models with zero vertices from being created (I thought maybe that was the problem), but that didn't stop the issue (even for as little as 4 remaining models). 1 Quote i now hate love C++ Beeeeeeeeeeeeeep~~This is a test of the emergency signature system~~Beeeeeeeeeeeeeep RX 6800XT | i5-13600KF | 32GB DDR5 | 1440p is perfect Link to comment Share on other sites More sharing options...
SpiderPig Posted December 30, 2023 Share Posted December 30, 2023 I've noticed this too. It's been like this for a while, especially in DEBUG mode. I think it's because of the separate rendering thread. Pretty sure Josh said a fix is planned. Quote Link to comment Share on other sites More sharing options...
Josh Posted December 30, 2023 Share Posted December 30, 2023 If you are running in debug mode, I think this is okay. How is the result in release mode? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
IceBurger Posted December 30, 2023 Author Share Posted December 30, 2023 6 minutes ago, Josh said: If you are running in debug mode, I think this is okay. How is the result in release mode? I noticed it in release mode too, but I haven't tested it as extensively. Quote i now hate love C++ Beeeeeeeeeeeeeep~~This is a test of the emergency signature system~~Beeeeeeeeeeeeeep RX 6800XT | i5-13600KF | 32GB DDR5 | 1440p is perfect Link to comment Share on other sites More sharing options...
reepblue Posted December 30, 2023 Share Posted December 30, 2023 I imagine you'll still notice it on slower hardware but it'll be less obvious than Debug. Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
Josh Posted December 30, 2023 Share Posted December 30, 2023 There is a feature that is currently disabled called a "swept frustum". We can experiment with this in 0.9.3: 1 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted January 22 Share Posted January 22 I am having trouble finding a convex hull implementation that doesn't triangulate the results. Could write my own but it might take a couple of days to get right... Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted January 23 Share Posted January 23 I was able to integrate the convex hull solver from the Bullet Physics library and it seems to work okay. Testing... Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Solution Josh Posted January 23 Solution Share Posted January 23 Implemented Camera:SetSweptCulling and it works nicely. Will be in next build. #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*2, 720*2, 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); camera->AddComponent<CameraControls>(); bool swept = true; camera->SetSweptCulling(true); window->SetText("Swept culling enabled"); //Create a light auto light = CreateDirectionalLight(world); light->SetRotation(45, 35, 0); light->SetColor(2); std::vector<shared_ptr<Entity> > boxes; //Create a model auto model = CreateBox(world); for (int x = 0; x < 100; ++x) { for (int y = 0; y < 5; ++y) { auto inst = model->Instantiate(world); inst->SetPosition(x * 2 - 100, y * 2 - 4, 8); boxes.push_back(inst); } } model = nullptr; //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { if (window->KeyHit(KEY_SPACE)) { swept = not swept; camera->SetSweptCulling(swept); if (swept) { window->SetText("Swept culling enabled"); } else { window->SetText("Swept culling disabled"); } } world->Update(); world->Render(framebuffer); } return 0; } 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
SpiderPig Posted January 23 Share Posted January 23 Awsome can't wait to test 😁 Quote Link to comment Share on other sites More sharing options...
klepto2 Posted January 23 Share Posted January 23 The swept culling works nicely, but i noticed that it is not working with terrains. As soon as a terrain is visible i get a "vector subscript out of range" exception: > $PROJECTNAME_d.exe!std::vector<class UltraEngine::Vec3,class std::allocator<class UltraEngine::Vec3> >::operator[](unsigned __int64) Unbekannt $PROJECTNAME_d.exe!UltraEngine::Culling::CullingTerrain::Draw(class std::shared_ptr<class UltraEngine::Culling::CameraVisibilityList> &,class std::map<class std::shared_ptr<class UltraEngine::Render::RenderMesh>,class std::shared_ptr<class UltraEngine::Culling::SurfaceBatch>,struct std::less<class std::shared_ptr<class UltraEngine::Render::RenderMesh> >,class std::allocator<struct std::pair<class std::shared_ptr<class UltraEngine::Render::RenderMesh> const ,class std::shared_ptr<class UltraEngine::Culling::SurfaceBatch> > > > &,class std::shared_ptr<class UltraEngine::Culling::CullingWorld>,class std::shared_ptr<class UltraEngine::Culling::CullingBuffer>,class std::shared_ptr<class UltraEngine::Culling::CullingCamera>,class std::shared_ptr<class UltraEngine::Render::RenderCamera>,bool,int) Unbekannt $PROJECTNAME_d.exe!UltraEngine::Culling::CullingOctreeNode::DrawEntities(class std::shared_ptr<class UltraEngine::Culling::CameraVisibilityList> &,class std::map<class std::shared_ptr<class UltraEngine::Render::RenderMesh>,class std::shared_ptr<class UltraEngine::Culling::SurfaceBatch>,struct std::less<class std::shared_ptr<class UltraEngine::Render::RenderMesh> >,class std::allocator<struct std::pair<class std::shared_ptr<class UltraEngine::Render::RenderMesh> const ,class std::shared_ptr<class UltraEngine::Culling::SurfaceBatch> > > > &,class std::shared_ptr<class UltraEngine::Culling::CullingWorld>,class std::shared_ptr<class UltraEngine::Culling::CullingBuffer>,class std::shared_ptr<class UltraEngine::Culling::CullingCamera>,class std::shared_ptr<class UltraEngine::Render::RenderCamera>,class UltraEngine::Vec3 const &,int,int,bool,int) Unbekannt $PROJECTNAME_d.exe!UltraEngine::Culling::CullingOctreeNode::Draw(class std::shared_ptr<class UltraEngine::Culling::CameraVisibilityList> &,class std::map<class std::shared_ptr<class UltraEngine::Render::RenderMesh>,class std::shared_ptr<class UltraEngine::Culling::SurfaceBatch>,struct std::less<class std::shared_ptr<class UltraEngine::Render::RenderMesh> >,class std::allocator<struct std::pair<class std::shared_ptr<class UltraEngine::Render::RenderMesh> const ,class std::shared_ptr<class UltraEngine::Culling::SurfaceBatch> > > > &,class std::shared_ptr<class UltraEngine::Culling::CullingWorld>,class std::shared_ptr<class UltraEngine::Culling::CullingBuffer>,class std::shared_ptr<class UltraEngine::Culling::CullingCamera>,class std::shared_ptr<class UltraEngine::Render::RenderCamera>,class UltraEngine::Vec3 const &,int,bool,bool,int) Unbekannt $PROJECTNAME_d.exe!UltraEngine::Culling::CullingCamera::BuildVisibilityLists(class std::shared_ptr<class UltraEngine::Culling::CullingWorld>,class std::shared_ptr<class UltraEngine::Culling::CullingBuffer>,class std::shared_ptr<class UltraEngine::Culling::VisibilityList>) Unbekannt $PROJECTNAME_d.exe!UltraEngine::Culling::CullingWorld::BuildVisibilityLists(class std::shared_ptr<class UltraEngine::Culling::CullingBuffer>,class std::shared_ptr<class UltraEngine::Culling::CullingWorld>) Unbekannt $PROJECTNAME_d.exe!UltraEngine::Culling::CullingThreadManager::Update(bool) Unbekannt $PROJECTNAME_d.exe!UltraEngine::Core::ThreadManager::EntryPoint(class std::shared_ptr<class UltraEngine::Object>) Unbekannt $PROJECTNAME_d.exe!UltraEngine::Thread::thread_function(void *) Unbekannt ucrtbased.dll!00007ff985793010() Unbekannt kernel32.dll!00007ffa6a8e7344() Unbekannt ntdll.dll!00007ffa6c1026b1() Unbekannt 1 Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
SpiderPig Posted January 23 Share Posted January 23 I literally just discovered this too. Was about to make a post. EDIT : I can confirm also that it works as expected. Quote Link to comment Share on other sites More sharing options...
Josh Posted January 23 Share Posted January 23 Easy fix. #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("Ultra Engine", 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, 50, 0); camera->SetRotation(45, 0, 0); camera->SetClearColor(0.125); camera->SetSweptCulling(true); //Sunlight auto light = CreateDirectionalLight(world); light->SetRotation(45, 35, 0); light->SetColor(2); //Create terrain auto terrain = CreateTerrain(world, 512); terrain->LoadHeightmap("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Terrain/512.r16"); 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_BASE); 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_BASE); rocks->SetTexture(normalmap, TEXTURE_NORMAL); rocks->SetTexture(dispmap, TEXTURE_DISPLACEMENT); int rocklayer = terrain->AddLayer(rocks); //Apply material based on terrain slope for (int x = 0; x < terrain->resolution.x; ++x) { for (int y = 0; y < terrain->resolution.y; ++y) { float slope = terrain->GetSlope(x, y); if (slope > 15.0f) { float wt = Min((slope - 15.0f) / 10.0f, 1.0f); terrain->SetLayerWeight(rocklayer, x, y, wt); } } } //Camera controls camera->AddComponent<CameraControls>(); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { world->Update(); world->Render(framebuffer); } return 0; } 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.