Thirsty Panther Posted January 23, 2023 Share Posted January 23, 2023 Getting gaps in my terrain textures. Quote Link to comment Share on other sites More sharing options...
Josh Posted January 23, 2023 Share Posted January 23, 2023 Is that the background of the world showing through the geometry, or a texturing problem? Is tessellation enabled? What GPU do you have? 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...
Thirsty Panther Posted January 23, 2023 Author Share Posted January 23, 2023 Not sure if its the background. It only appears where the flat ground meets a mountain. The rest of the terrain is fine. I don't think I have tessellation enabled. I will check this out today. My graphics card: Nvidia GeForce GTX 1060. Quote Link to comment Share on other sites More sharing options...
Josh Posted January 23, 2023 Share Posted January 23, 2023 Is the camera clear color white, or maybe that is a skybox peeking through? 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...
Canardia Posted January 23, 2023 Share Posted January 23, 2023 Why is the lower texture corner rounded? Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Yue Posted January 24, 2023 Share Posted January 24, 2023 Is it the texture in the corners with something white? Quote Link to comment Share on other sites More sharing options...
Thirsty Panther Posted January 24, 2023 Author Share Posted January 24, 2023 Enabling tessellation didn't fix the problem. I used camera->SetTessellation(4); as shown in the example in the documentation. This only made my camera movement jerky. The Camera clear color is set to 0.125. Changing this made no difference. The background is the Storm skybox from the Github. I commented this out and made no difference. I think the problem may lie in my textures. 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted January 24, 2023 Share Posted January 24, 2023 Okay, I was trying to determine whether it was a pixel shader problem or whether those were cracks in the geometry 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...
Thirsty Panther Posted January 24, 2023 Author Share Posted January 24, 2023 Update: I thought I found the problem. I simplified my program to only one texture. I went through each one of my 5 textures until I found that RockCiff_A is not the same as Rock_Cliff_A. Eureka! problem solved. Unfortunately not, I added all the textures back in and the problem persisted. Further investigation led me to suspect the weighting I was giving each material was the cause of the problem. Here is my code. for (int x = 0; x < terrain->resolution.x; ++x) { for (int y = 0; y < terrain->resolution.y; ++y) { // Sample noise function at this point of the terrain const double noise = perlin.normalizedOctave2D((x * 0.01), (y * 0.01), 5); terrain->SetElevation(x, y, noise * 100); float slope = abs(terrain->GetSlope(x, y)); if (slope < 5) { terrain->SetMaterial(x, y, grass, 0.7f); } else if (slope>5 && slope < 10) { terrain->SetMaterial(x, y, rocks, 0.7f); } else if (slope >10 && slope < 40) { terrain->SetMaterial(x, y, cliff, 0.7f); } else { terrain->SetMaterial(x, y, snow, 0.7f); } } If the weight is 0.6f or less then no problem. Once you go over 0.65f then the artifact returns. I don't fully understand how the weighting works. Quote Link to comment Share on other sites More sharing options...
Josh Posted January 24, 2023 Share Posted January 24, 2023 Can you post some code I can run to produce the error? 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...
Thirsty Panther Posted January 24, 2023 Author Share Posted January 24, 2023 #include "UltraEngine.h" #include "ComponentSystem.h" #include "PerlinNoise.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { //Get the display list auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Terrain Experiment", 0, 0, 1920, 1080, 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); //Sunlight auto light = CreateDirectionalLight(world); light->SetRotation(45, 35, 0); light->SetColor(1); //Set environment maps const WString remotepath = "https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets"; auto specmap = LoadTexture(remotepath + "/Materials/Environment/Storm/specular.dds"); auto diffmap = LoadTexture(remotepath + "/Materials/Environment/Storm/diffuse.dds"); world->SetEnvironmentMap(specmap, ENVIRONMENTMAP_BACKGROUND); world->SetEnvironmentMap(specmap, ENVIRONMENTMAP_SPECULAR); world->SetEnvironmentMap(diffmap, ENVIRONMENTMAP_DIFFUSE); auto mtl = CreateMaterial(); mtl->SetRoughness(0.25); mtl->SetMetalness(0.5); auto ball = CreateSphere(world); ball->SetMaterial(mtl); //Create terrain from noise map auto terrain = CreateTerrain(world, 512); terrain->SetScale(1, 100, 1); const siv::PerlinNoise::seed_type seed = 656621u; const siv::PerlinNoise perlin{ seed }; //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 ground rocks 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); //Create grass material auto grass = CreateMaterial(); diffusemap = LoadTexture("Materials/Grass01_albedo.dds"); normalmap = LoadTexture("Materials/Grass01_normal.dds"); dispmap = LoadTexture("Materials/Grass01_height.dds"); grass->SetTexture(diffusemap, TEXTURE_DIFFUSE); grass->SetTexture(normalmap, TEXTURE_NORMAL); grass->SetTexture(dispmap, TEXTURE_DISPLACEMENT); //Create cliff rocks material auto cliff = CreateMaterial(); diffusemap = LoadTexture("Materials/Rock_Cliff_albedo.dds"); normalmap = LoadTexture("Materials/Rock_Cliff_A_normal.dds"); dispmap = LoadTexture("Materials/Rock_Cliff_height.dds"); cliff->SetTexture(diffusemap, TEXTURE_DIFFUSE); cliff->SetTexture(normalmap, TEXTURE_NORMAL); cliff->SetTexture(dispmap, TEXTURE_DISPLACEMENT); //Create snow material auto snow = CreateMaterial(); diffusemap = LoadTexture("Materials/Snow_albedo.dds"); normalmap = LoadTexture("Materials/Snow_normal.dds"); dispmap = LoadTexture("Materials/Snow_height.dds"); snow->SetTexture(diffusemap, TEXTURE_DIFFUSE); snow->SetTexture(normalmap, TEXTURE_NORMAL); snow->SetTexture(dispmap, TEXTURE_DISPLACEMENT); // Apply material based on noise function output for (int x = 0; x < terrain->resolution.x; ++x) { for (int y = 0; y < terrain->resolution.y; ++y) { // Sample noise function at this point of the terrain const double noise = perlin.normalizedOctave2D((x * 0.01), (y * 0.01), 5); terrain->SetElevation(x, y, noise * 100); float slope = abs(terrain->GetSlope(x, y)); if (slope < 5) { terrain->SetMaterial(x, y, grass, 0.6f); } else if (slope>5 && slope < 10) { terrain->SetMaterial(x, y, rocks, 0.6f); } else if (slope >10 && slope < 40) { terrain->SetMaterial(x, y, cliff, 0.6f); } else { terrain->SetMaterial(x, y, snow, 0.6f); } } } //Camera controls auto actor = CreateActor(camera); actor->AddComponent<CameraControls>(); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { world->Update(); world->Render(framebuffer); } return 0; } This is my full code. I use Ryo Suzuki Perlin Noise library from here. My textures Textures.zip from Textures.com. The other assets are from UltrEngine Github. Quote Link to comment Share on other sites More sharing options...
Josh Posted January 25, 2023 Share Posted January 25, 2023 Okay, I have the same effect, although I had to replace those 0.6 numbers with something higher. Investigating now... 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...
Canardia Posted January 25, 2023 Share Posted January 25, 2023 One thing I noticed in your code: when slope is exactly 5 or 10 you paint snow. 1 Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Josh Posted January 25, 2023 Share Posted January 25, 2023 1 minute ago, Canardian said: One thing I noticed in your code: when slope is exactly 5 or 10 you paint snow. Good catch! However, the artifact still appears with this code: if (slope < 5) { terrain->SetMaterial(x, y, grass, 1.0f); } else if (slope < 10) { terrain->SetMaterial(x, y, rocks, 1.0f); } else if (slope < 40) { terrain->SetMaterial(x, y, cliff, 1.0f); } else { terrain->SetMaterial(x, y, snow, 1.0f); } 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 25, 2023 Share Posted January 25, 2023 In fact you don't even need textures, and just two materials will do it: #include "UltraEngine.h" #include "ComponentSystem.h" #include "PerlinNoise.hpp" using namespace UltraEngine; int main(int argc, const char* argv[]) { //Get the display list auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Terrain Experiment", 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); //Sunlight auto light = CreateDirectionalLight(world); light->SetRotation(45, 35, 0); light->SetColor(1); //Set environment maps const WString remotepath = "https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets"; auto specmap = LoadTexture(remotepath + "/Materials/Environment/Storm/specular.dds"); auto diffmap = LoadTexture(remotepath + "/Materials/Environment/Storm/diffuse.dds"); world->SetEnvironmentMap(specmap, ENVIRONMENTMAP_BACKGROUND); world->SetEnvironmentMap(specmap, ENVIRONMENTMAP_SPECULAR); world->SetEnvironmentMap(diffmap, ENVIRONMENTMAP_DIFFUSE); //Create terrain from noise map auto terrain = CreateTerrain(world, 256); terrain->SetScale(1, 100, 1); const siv::PerlinNoise::seed_type seed = 656621u; const siv::PerlinNoise perlin{ seed }; //Create base material auto ground = CreateMaterial(); ground->SetColor(0.25, 1, 0.25, 1); terrain->SetMaterial(ground); auto grass = CreateMaterial(); grass->SetColor(1, 0.25, 0.25, 1); for (int x = 0; x < terrain->resolution.x; ++x) { for (int y = 0; y < terrain->resolution.y; ++y) { // Sample noise function at this point of the terrain const double noise = perlin.normalizedOctave2D((x * 0.01), (y * 0.01), 5); terrain->SetElevation(x, y, noise * 100); float slope = abs(terrain->GetSlope(x, y)); if (slope < 5) { terrain->SetMaterial(x, y, grass, 1.0f); } } } //Camera controls auto actor = CreateActor(camera); actor->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...
Josh Posted January 25, 2023 Share Posted January 25, 2023 Okay, I have discovered something...stay tuned... 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 25, 2023 Share Posted January 25, 2023 I'm pretty sure I understand now why this is happening but I need to think about the most optimal solution... 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...
Solution Josh Posted January 25, 2023 Solution Share Posted January 25, 2023 The fix is up now. It's just a modified shader, so you will need to sync your project files to get it. 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...
Thirsty Panther Posted January 26, 2023 Author Share Posted January 26, 2023 Confirmed this is fixed. Quote 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.