Jump to content

SpiderPig

Developers
  • Posts

    2,277
  • Joined

  • Last visited

Everything posted by SpiderPig

  1. So the max instance count is about 65k but does that include things like sub-passes and meshes? I mean can we have 65,000 instanced cubes or with 2 sub-passes are we limited to only 32,000 cubes? Also, with your Instanced geometry benchmark code, I've added in swept culling and a few more cubes. Even with swept culling enabled it doesn't make much difference. In my game I only have a few thousand instances and it doesn't hep much there either. Can I turn off culling for particular objects or all of them? I'd like to test the performance of both options. #include "UltraEngine.h" #include "ComponentSystem.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { const int count = 32; RegisterComponents(); //Get the displays auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Instanced Geometry", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); //Create framebuffer auto framebuffer = CreateFramebuffer(window); //Create world auto world = CreateWorld(); //Create camera auto camera = CreateCamera(world); camera->SetPosition(0, 0, -count * 2); camera->SetClearColor(0.125); camera->SetDepthPrepass(false); camera->AddComponent<CameraControls>(); camera->SetSweptCulling(true); camera->SetOcclusionCullingMode(false); //Create box auto box = CreateBox(world); box->SetCollider(NULL); auto mtl = CreateMaterial(); mtl->SetColor(0.5f); mtl->SetShaderFamily(LoadShaderFamily("Shaders/Unlit.fam")); box->SetMaterial(mtl); //Create instances std::vector<shared_ptr<Entity> > boxes; boxes.reserve(count * count * count); int x, y, z; for (x = 0; x < 32; ++x) { for (y = 0; y < 32; ++y) { for (z = 0; z < 64; ++z) { auto inst = box->Instantiate(world); inst->SetPosition(3.0f + float(x - 1 - (count / 2)) * 2, 3.0f + float(y - 1 - (count / 2)) * 2, 3.0f + float(z - 1 - (count / 2)) * 2); boxes.push_back(inst); } } } box = NULL; //Fps display auto font = LoadFont("Fonts/arial.ttf"); auto sprite = CreateSprite(world, font, "", 14); world->RecordStats(true); sprite->SetRenderLayers(2); sprite->SetPosition(2, framebuffer->size.y - font->GetHeight(14) - 2, 0); auto orthocam = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); orthocam->SetRenderLayers(2); orthocam->SetClearMode(ClearMode(0)); orthocam->SetPosition(float(framebuffer->size.x) * 0.5f, float(framebuffer->size.y) * 0.5f, 0); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { //Check for failed renderer initialization while (PeekEvent()) { const auto e = WaitEvent(); if (e.id == EVENT_STARTRENDERER and e.data == 0) { Notify(L"Renderer failed to intialize.\n\n" + e.text, "Ultra Engine", true); return 0; } } sprite->SetText("FPS: " + String(world->renderstats.framerate)); world->Update(); world->Render(framebuffer, false); } return 0; }
  2. I think I've fixed it! Thanks very much for your help, with your input it made me look in the right places. It was the sun direction calculation, I had missed a simple multiplication.
  3. Okay, this position makes the sky black. sun_pos = Vec3(-0.324064016,0.825100005,-0.462809354); Yet changing the y to be 0.835 instead of 0.825 works. sun_pos = Vec3(-0.324064016,0.835100005,-0.462809354); Its a shader issue. I'm getting closer.
  4. I just noticed your texture creation method; _dataTexture = CreateTexture(TEXTURE_2D, 64, 32, TEXTURE_RGBA32, {}, 1, TEXTURE_DEFAULT, TEXTUREFILTER_NEAREST); I leave my type as TEXTURE_RGBA and convert to floats like this - float BytesToFloat( in vec4 pixel ) { return intBitsToFloat( ( int( ( pixel.w * 255.0f ) ) << 24 ) | ( int( ( pixel.z * 255.0f ) ) << 16 ) | ( int( ( pixel.y * 255.0f ) ) << 8 ) | int( ( pixel.x * 255.0f ) ) ); } Would that function still work with the type TEXTURE_RGBA32 you think? I also use TexelFetch instead of sample.
  5. Sweet! That should work better. As far as using the buffer, I had it working fine on some smaller applications which leads me to believe there's a bug with my shader. Pity we can't debug shaders....
  6. Something that tells me it's not a problem with SetPixels is that if I poke the buffer with a constant value it doesn't flicker - ever. sun_pos = Vec3(1, 1, 0).Normalize(); auto index = 0; buffer->PokeFloat(index, sun_pos.x); buffer->PokeFloat(index + 4, sun_pos.y); buffer->PokeFloat(index + 8, sun_pos.z); texture->SetPixels(buffer);
  7. I can't seem to reproduce this on a smaller scale. It's more than likely an issue with the shader itself but I can't for the life of me narrow it down. Anyway I've attached code and shaders if someone would like to take a look as well. It's like the shader doesn't like some of the vectors of the sun position and it causes it to flicker black sometimes. Any help is appreciated, I'll be tackling this in the shadows. #include "UltraEngine.h" #include "ComponentSystem.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { auto displays = GetDisplays(); auto window = CreateWindow("Ultra Engine", 0, 0, 1280 * displays[0]->scale, 720 * displays[0]->scale, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); auto framebuffer = CreateFramebuffer(window); auto world = CreateWorld(); world->RecordStats(true); auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetFov(70); camera->Move(0, 2, 0); camera->AddComponent<CameraControls>(); auto light = CreateDirectionalLight(world); light->SetRotation(45, 35, 0); light->SetColor(2); auto plane = CreatePlane(world, 100, 100); auto sphere = CreateSphere(world, 512, 32); auto mat = LoadMaterial("Materials\\DynamicSky\\DynamicSky.mat"); sphere->SetMaterial(mat); auto size = 8; auto buffer = CreateBuffer(size * size * 4); auto texture = CreateTexture(TEXTURE_2D, size, size); mat->SetTexture(texture, 15); while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { Vec3 speed = Vec3(0.02, 0, 0); light->Turn(speed.x, speed.y, speed.z); auto yoffset = 300; auto dir = Vec3(light->matrix.k.x, light->matrix.k.y, light->matrix.k.z).Normalize(); auto sun_raw_pos = Vec3(-dir.x, -dir.y, -dir.z); auto camera_range = camera->GetRange().y; auto sun_pos = Vec3(-dir.x, -dir.y + (yoffset / camera_range), -dir.z).Normalize(); auto index = 0; buffer->PokeFloat(index, sun_pos.x); buffer->PokeFloat(index + 4, sun_pos.y); buffer->PokeFloat(index + 8, sun_pos.z); texture->SetPixels(buffer); auto stats = world->renderstats; window->SetText("FPS : " + WString(stats.framerate) + " --- verts : " + WString(stats.vertices) + " --- polys : " + WString(stats.polygons) + " --- instances : " + WString(stats.instances)); world->Update(); world->Render(framebuffer, false); } return 0; }
  8. I've been using a texture to store variables for a lot of my shaders. I've just decided today to see if I can update those variables in real-time. While it does work, I am seeing a bit of flicking - which in this case I'm assuming is due the to fact that when I'm setting a textures pixels there may be a few shader updates were that information is either gone or invalid? I've tried both render hooks as well. HOOKID_TRANSFER reduces it a bit but not completely. Just wondering if this is a good idea before I continue with it. buffer->PokeInt(index, value); texture->SetPixels(buffer);
  9. SpiderPig

    MSAA + Effects

    Looks awesome.
  10. SpiderPig

    MSAA + Effects

    Don't forget godrays
  11. Nope. VS2019 doesn't crash either. Is this normal? I'm sure it never used to be.
  12. No just the one. I'm doing an experiment in VS22... this program below doesn't crash. It does give some warnings. But in some situations it won't even do that. I think in my issue above I'm accessing an element in the array that goes beyond it's size. But it should crash at the array saying it's trying to access an an element that does not exist. I'm going to test this in VS19... it might be a bug with 2022. #include <iostream> int main() { int* myArray = new int[256]; for (int index = 0; index <= 256; index++) { myArray[index] = index; } int value = myArray[300];//will crash here if I make it 512 instead of 300 }
  13. Project won't compile in VS2019 unless build tools v143 is installed but it seems it can't be installed on older version. It can only be used with VS2022. Changing the build tools to use 2019's v142 results in other errors. Probably because it needs something that v142 lacks.
  14. VS2022 is terrible with intellisense not working as it should (mainly with larger projects) and crashes not showing the right info. Like this, I've got an access violation because it says spawn is empty, yet I'm checking if it's nullptr before I execute that code and it's always worked before. Unless there's a better way of checking a shared_ptr is empty?? This code has always worked until I change something else that seems irrelevant - obviously it's not, but... I've had many similar errors that when I finally track down the issue it has nothing do to with what VS is telling me. The only thing that might make this type of error possible is multi-threading but I'm not using threads. Hence I'd like to try using VS2019 and see if that gives me any better info. The only problems with shared_ptr's it seems is that some crashes do take you to weird headers and give wrong debugging info. I am curious if anyone else has had problems like this...
  15. Should Ultra be able to be compiled in VS2019?
  16. That is interesting. After about a minute the spheres vanish for 10 or so seconds too. Near to two minutes they vanish again and the shadows do to. Well on my end anyway. Visual Studio shows RAM all over the place, it stabilizes for a bit but then climbs again.
  17. It is defiantly slow. But I think it might be the fact it's an .svg file and that it has to be rasterised into a usable texture in the rendering thread so it can be drawn. I know this was the same for setting a font for the first time too.
  18. SpiderPig

    Artifacts Fixed!

    Great stuff! Glad it didn't take as long as you thought it would.
  19. Here's a small example on how physics on a moving object can be achieved. The physics objects are different to their visual counter parts so that they can be calculated without any rotation. Then using matrix magic the physics position and rotation can be transformed to any moving target. #include "UltraEngine.h" using namespace UltraEngine; Vec3 mousepos = Vec3(0.0f); float move_adjustment = 0.1f; float move_speed = 1.0f; float lookspeed = 0.1f; float looksmoothing = 0.5f; bool enable_camera = true; void UpdatePhysics(shared_ptr<Entity> source, shared_ptr<Entity> target, shared_ptr<Entity> platform = nullptr) { auto pos = source->GetPosition(); auto rot = source->GetRotation(); if (platform != nullptr) { auto matrix = platform->GetMatrix(); matrix = matrix.Inverse(); matrix.t = Vec4(0, 0, 0, 1); pos = TransformPoint(pos, Mat4(), matrix); rot = TransformRotation(rot, Mat4(), matrix); } target->SetPosition(pos); target->SetRotation(rot); } int main(int argc, const char* argv[]) { auto displays = GetDisplays(); auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); auto world = CreateWorld(); auto framebuffer = CreateFramebuffer(window); auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetFov(70); camera->SetPosition(0, 10, -5); auto light = CreateDirectionalLight(world); light->SetRotation(35, 45, 0); auto floor = CreateBox(world, 10.0f, 0.1f, 10.0f); floor->SetCollider(nullptr); floor->SetPosition(0.0f, -3.0f, 0.0f); floor->SetMaterial(LoadMaterial("Materials\\Developer\\grid01.mat")); auto box = CreateBox(world); box->SetCollider(nullptr); box->SetPosition(2.0f, 2.0f, 0.0f); auto ref = CreateBox(world); ref->SetCollider(nullptr); ref->SetPosition(11, 0, 0); auto player = CreateCylinder(world); player->SetCollider(nullptr); player->SetPosition(0.0f, 5.0f, 0.0f); auto cam_pivot = CreatePivot(world); cam_pivot->SetParent(player); cam_pivot->SetPosition(0.0f, 1.8f, 0.0f); camera->SetParent(cam_pivot); camera->SetPosition(0.0f, 0.0f, -3.0f); camera->SetDebugPhysicsMode(true); //Create physics objects auto f2 = CreatePivot(world); auto ff2 = CreateBoxCollider(10.0f, 0.1f, 10.0f); f2->SetCollider(ff2); f2->SetPosition(0, -3, 0); f2->SetCollisionType(COLLISION_SCENE); auto b2 = CreatePivot(world); auto bb2 = CreateBoxCollider(1.0f, 1.0f, 1.0f); b2->SetCollider(bb2); b2->SetMass(1.0f); b2->SetPosition(2.0f, 2.0f, 0.0f); b2->SetCollisionType(COLLISION_PROP); //player physics object auto player_phys = CreatePivot(world); auto cyl = CreateCylinderCollider(0.5f, 1.0f); player_phys->SetCollider(cyl); player_phys->SetPhysicsMode(PHYSICS_PLAYER); player_phys->SetCollisionType(COLLISION_PLAYER); player_phys->SetMass(1.0f); player_phys->SetPosition(0, 5, 0); bool stage = 0; while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { if (window->KeyHit(KEY_F2) == true) { camera->SetWireframe(!camera->GetWireframe()); } if (window->KeyHit(KEY_F3) == true) { camera->SetDebugPhysicsMode(!camera->GetDebugPhysicsMode()); } if (window->KeyHit(KEY_F4) == true) { enable_camera = !enable_camera; } if (enable_camera) { auto _displaySize = window->GetSize(); float cx = Round((float)_displaySize.x / 2.0f); float cy = Round((float)_displaySize.y / 2.0f); auto mpos = Vec3(window->GetMousePosition().x, window->GetMousePosition().y, window->GetMousePosition().z); window->SetMousePosition(cx, cy); mpos = mpos * looksmoothing + mousepos * (1 - looksmoothing); auto dx = (mpos.x - cx) * lookspeed; auto dy = (mpos.y - cy) * lookspeed; auto camrot = cam_pivot->GetRotation(); camrot.x += dy; camrot.y += dx; cam_pivot->SetRotation(camrot); mousepos = mpos; } floor->Turn(0.0f, 0.1f, 0.0f); auto y_angle = cam_pivot->GetRotation().y; auto move = 0.0f, strafe = 0.0f; if (window->KeyDown(KEY_W)) { move = 1.0f; } else if (window->KeyDown(KEY_S)) { move = -1.0f; } if (window->KeyDown(KEY_A)) { strafe = -1.0f; } else if (window->KeyDown(KEY_D)) { strafe = 1.0f; } player_phys->SetInput(y_angle, move, strafe); if (window->KeyHit(KEY_P)) { b2->AddForce(0,200,0); } UpdatePhysics(b2, box, floor); UpdatePhysics(player_phys, player, floor); world->Update(); world->Render(framebuffer); } return 0; }
  20. I think I've nearly got paths & roads working. The answer was using A* pathfinding but stopping whenever it hit an existing path. This way each access point will link up to an existing path. The only problem I can see thus far is some paths are created parallel to each other when in reality they should merge to one or the other. I'll have to experiment with some sort of neighbour check that will weight a path towards an existing one if it's close enough. For now though I think it's time to get a spline mesh going.
  21. I think it did. Josh is currently doing a bit of work on the rendering stuff he said.
  22. Just curious, did you restart the editor after creating it manually?
  23. Your numeric values should be numbers instead of strings. Not sure if this is why it's not showing up though... maybe try creating one ".h" file and another ".cpp" file for the definitions. I think this changed a while back so it might need both files as well as the json file now. Take a look at the default components to see how they work. { "component": { "properties": [ { "name": "m_WalkSpeed", "label": "Walk Speed", "value": 5.0 }, { "name": "m_SprintSpeed", "label": "Sprint Speed", "value": 10.0 } ] } }
×
×
  • Create New...