klepto2 Posted July 20, 2023 Share Posted July 20, 2023 With the latest Version, the terrainsystem doesn't use the tessellation pipeline when you set something like this: camera->SetTessellation(12.0); other geometry works fine. Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Josh Posted July 20, 2023 Share Posted July 20, 2023 Confirmed: #include "UltraEngine.h" #include "Components/CameraControls.hpp" 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->SetTessellation(4.0); //camera->SetDepthPrepass(false); //camera->SetWireframe(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", 100); //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); rocks->SetDisplacement(4, -2); //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->SetMaterial(x, y, rocks, 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; } 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 July 21, 2023 Solution Share Posted July 21, 2023 Fixed! I'm seeing a lot of stair-stepping on the example above. It looks like it is occurring at a higher frequency than the heightmap data itself... 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 July 21, 2023 Share Posted July 21, 2023 The displacement map is using BC4 compression, so I would say displacement maps probably should not use any compression at all. 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...
klepto2 Posted July 22, 2023 Author Share Posted July 22, 2023 Since the latest update (terrain-normals) it seems the terrainsystem is broken. this sample (https://www.ultraengine.com/learn/Terrain_SetMaterial?lang=cpp) shows no terrain at all. (only when you comment out the LoadHeightmap the terrain shows up) And in my code it shows with LoadHeightmap (using a png instead of r16) but still the terrain is flat. Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Josh Posted July 22, 2023 Share Posted July 22, 2023 If you do this it will work: //Create terrain auto terrain = CreateTerrain(world, 512); terrain->LoadHeightmap("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Terrain/512.r16", 100); //terrain->SetScale(1, 100, 1); However, I think I am going to change this behavior.... 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...
klepto2 Posted July 22, 2023 Author Share Posted July 22, 2023 Or to make it work as before, you can set the default back to 1.0 instead of 1000.0. With 1.0 it works as expected: terrain->LoadHeightmap("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Terrain/1024.r16",1); terrain->SetScale(1, 100, 1); Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
klepto2 Posted July 22, 2023 Author Share Posted July 22, 2023 Ok, with r16 maps it works now. Other image formats (png) still leads to flat terrain, even with provided scale parameter. Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Josh Posted July 22, 2023 Share Posted July 22, 2023 an 8-bit PNG is pretty useless. You will have severe stair-stepping artifacts. I can add it in, but you won't want to use those. 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...
klepto2 Posted July 22, 2023 Author Share Posted July 22, 2023 well, not in every case : Source of the heightmap: https://johnflower.org/heightmap/mt-ruapehu-mt-ngauruhoe and the code how i apply the height: terrain->SetScale(tscale, scale, tscale); auto pixmap = LoadPixmap("Heightmaps/hm_nz.png"); pixmap = pixmap->Resize(terrain->resolution.x, terrain->resolution.y); float low_p = 1.0; for (int x = 0; x < terrain->resolution.x; x++) for (int y = 0; y < terrain->resolution.y; y++) { auto h = pixmap->Sample(iVec2(x, y)).r; terrain->SetHeight(x, y,h); //auto h = terrain->GetHeight(x, y); if (h < low_p) low_p = h; } terrain->SetPosition(0.0, -1.0 * (low_p * scale), 0.0); Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
klepto2 Posted July 22, 2023 Author Share Posted July 22, 2023 btw, the mappingscale is not taken into account when texturing the terrain. Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Josh Posted July 22, 2023 Share Posted July 22, 2023 Looks like that is a high-precision PNG: 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...
klepto2 Posted July 22, 2023 Author Share Posted July 22, 2023 thats why i said, not in every case In my opinion pixmap is pixmap, if a user wants to use other formats than r16, then why not. Just make a disclaimer, that low precision can lead to artifacts. 1 Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI 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.