Jump to content

Josh

Staff
  • Posts

    23,315
  • Joined

  • Last visited

Everything posted by Josh

  1. Okay, I fixed a bug in the OBJ loader that was flipping some faces. However, I do not know if the handedness of the physics matches the handedness of the renderer...
  2. It looks like the top and bottom have the opposite orientation as the sides, although I can't say for sure which is right. Maybe the physics system has a different handedness than the renderer...
  3. It appears to be loading correctly. Maybe the faces are all backwards, either in the shape, or they could be getting flipped in my loader...
  4. 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; }
  5. Currently it seems to not work at all: #include "UltraEngine.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, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); //Create a framebuffer auto framebuffer = CreateFramebuffer(window); //Create a world auto world = CreateWorld(); //Create a camera auto camera = CreateCamera(world); camera->SetFov(70); camera->SetClearColor(0.125); camera->SetPosition(0, 3, -6); camera->SetRotation(35, 0, 0); //Create light auto light = CreateBoxLight(world); light->SetRange(-20, 20); light->SetArea(20, 20); light->SetRotation(35, 35, 0); light->SetColor(3); //Create scene auto ground = CreateBox(world, 10, 1, 10); ground->SetPosition(0, -0.5, 0); ground->SetColor(0, 1, 0); auto wall = CreateBox(world, 1, 2, 4); wall->SetPosition(3, 0, 0); //Create navmesh auto navmesh = CreateNavMesh(world, 10, 5, 10, 4, 4); navmesh->SetDebugging(true); navmesh->Build(); //Create player auto player = CreateCylinder(world, 0.4, 1.8); player->SetColor(0, 0, 1); auto agent = CreateNavAgent(navmesh); player->Attach(agent); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { if (window->MouseHit(MOUSE_LEFT)) { auto mousepos = window->GetMousePosition(); auto rayinfo = camera->Pick(framebuffer, mousepos.x, mousepos.y); if (rayinfo.success) { agent->Navigate(rayinfo.position); } } world->Update(); world->Render(framebuffer); } return 0; }
  6. Above issues are now fixed.
  7. 1.0.3 Library is updated. Terrain collision updated to work with half-float height format.
  8. glTF files do not store external materials. I could add the material path in the "extras" info but it would create a discontinuity where Ultra would be loading external materials, but every modeling application would be loading something different. I think this would cause more problems than it solves. glTF files CAN store textures in different paths, but in practice this is never done, and it would always be relative to the glTF file itself, not to the project. So you would end up with a lot of paths like "../../Nature/rock.dds" which I think would be prone to breakage.
  9. I have it working now. The depth pre-pass seems to not be considering the discard mask. Load heightmap seems to not be working with colliision. But the missing functionailty is added. #include "UltraEngine.h" #include "Components/CameraControls.hpp" using namespace UltraEngine; const WString remotepath = "https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets"; int main(int argc, const char* argv[]) { //Get the display list auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Terrain Cut", 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->SetFov(70); camera->SetPosition(0, 100, -100); camera->SetRotation(45, 0, 0); camera->SetClearColor(0.125); camera->SetDepthPrepass(false); //Sunlight auto light = CreateDirectionalLight(world); light->SetRotation(45, 35, 0); light->SetColor(2); //Create terrain auto terrain = CreateTerrain(world, 512); //terrain->LoadHeightmap(remotepath + "/Terrain/512.r16"); terrain->SetScale(1, 1, 1); //Create base material auto ground = CreateMaterial(); auto diffusemap = LoadTexture(remotepath + "/Materials/Ground/river_small_rocks_diff_4k.dds"); auto normalmap = LoadTexture(remotepath + "/Materials/Ground/river_small_rocks_nor_gl_4k.dds"); ground->SetTexture(diffusemap, TEXTURE_DIFFUSE); ground->SetTexture(normalmap, TEXTURE_NORMAL); terrain->SetMaterial(ground); //Camera controls camera->AddComponent<CameraControls>(); shared_ptr<Entity> ball; //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { if (window->MouseHit(MOUSE_RIGHT)) { ball = CreateSphere(world); ball->SetMass(10); ball->SetPosition(camera->position); } if (window->MouseDown(MOUSE_LEFT)) { auto mousepos = window->GetMousePosition(); auto pickinfo = camera->Pick(framebuffer, mousepos.x, mousepos.y); if (pickinfo.success) { if (pickinfo.entity == terrain) { iVec2 pos; pos.x = Round(pickinfo.position.x) + terrain->resolution.x / 2; pos.y = Round(pickinfo.position.z) + terrain->resolution.y / 2; int radius = 10; for (int x = pos.x - radius; x < pos.x + radius; ++x) { for (int y = pos.y - radius; y < pos.y + radius; ++y) { terrain->SetTileHidden(x, y, not window->KeyDown(KEY_CONTROL)); } } } } } world->Update(); world->Render(framebuffer); } return 0; }
  10. Next build. The library takes a while to upload, so I tend to not update it more than once a day or so.
  11. If you have multiple materials referencing the same texture, it’s still just one texture
  12. I think that buffer gets dynamically resized, so it doesn't even matter if you hit the initial limit. The texture arrays on the other hand are fixed size, because they are declared in the shaders.
  13. Yes, each material will be unique, but it doesn't really matter. Rendering is grouped by shader family. The material is just a small structure stored in memory. Each mesh stores an index to the material, and its looked up in the shader itself, so it really has no effect on the performance of the rendering code.
  14. This is one way of storing a wide string. I have switched the editor over to store UTF-8 strings, but the client may still use character arrays like above. I think I'll eventually move that over to UTF8 as well, but it's okay as long as its working.
  15. Seems to be fixed in current build.
  16. This seems to be working okay in current build.
  17. 1.0.3 Library updated with fixes for terrain heightmap loading, picking, and normals calculation.
  18. 1.0.3 Alpha mask fixed in PBR shader. Asset editor will no longer load additional model LOD levels. Fixed bug in gltf shader family paths when saved. Fixed calculation of camera depth range in asset editor.
  19. This is correct: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Vendor/MSFT_texture_dds
  20. The image "PineLeaves_DIFF.png" does not look like it has an alpha channel, or has a completely solid alpha channel.
×
×
  • Create New...