Jump to content

SpiderPig

Members
  • Posts

    2,335
  • Joined

  • Last visited

Everything posted by SpiderPig

  1. Tried again, setting all of them to massive numbers like 10,000 but nothing changes...
  2. He's saying we need an example project or the code so we can reproduce the error. I usally create a new project and do the bare minimum that shows the error happing. ?
  3. Did quick test and it didn't solve it, will have another go later. Maybe each stage needs setting uniformly?
  4. I have a large world and there are heights exceeding 2000m, this quick code example shows that at a height higher than 660m the shadow disappears but interestingly the stats still say it's being drawn. Can anyone else confirm this? Is there shadow range for the world or something or is this a bug? #include "App.h" using namespace Leadwerks; App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {} App::~App() { delete world; delete window; } Model* box; Camera* camera; bool wireframe = false; bool App::Start() { window = Window::Create("Shadows",50,50, 1024, 768); window->Show(); context = Context::Create(window); world = World::Create(); DirectionalLight* light = DirectionalLight::Create(); light->SetRotation(35, 35, 35); float offsetY = 670.0f;//Increase to 670.0f and shadow disapears. camera = Camera::Create(); camera->Move(0, 1 + offsetY, -2); box = Model::Box(); box->Move(0, 1 + offsetY, 0); Pivot* centre = Pivot::Create(); int xGrid = 3; int zGrid = 3; int vertIndex = 0; Model* mdl = Model::Create(); Surface* surface = mdl->AddSurface(); for (int z = 0; z < zGrid; z++) { for (int x = 0; x < xGrid; x++) { surface->AddVertex(x, offsetY, z,0,1,0); if (z != 0 && x != 0) { surface->AddTriangle(vertIndex, vertIndex - xGrid, vertIndex - 1); surface->AddTriangle(vertIndex - xGrid, vertIndex - xGrid - 1, vertIndex - 1); } vertIndex++; } } surface->Update(); mdl->UpdateAABB(Entity::LocalAABB | Entity::GlobalAABB); return true; } bool App::Loop() { if (window->KeyHit(Key::Escape) == true) { return false; } if (window->KeyHit(Key::F1) == true) { camera->GetDebugPhysicsMode() == true ? camera->SetDebugPhysicsMode(false) : camera->SetDebugPhysicsMode(true); } if (window->KeyHit(Key::F2) == true) { if (wireframe == true) { camera->SetDrawMode(0); wireframe = false; } else { camera->SetDrawMode(2); wireframe = true; } } Vec3 rot = box->GetRotation(); rot.x += 0.2f; rot.y += 0.2f; rot.z += 0.2f; box->SetRotation(rot); Time::Update(); world->Update(); world->Render(); context->SetBlendMode(Blend::Alpha); context->DrawStats(10.0f, 10.0f, true); context->Sync(true); return true; } EDIT : It seems to be fine in the editor. I have some objects at a Y position of 23000.0
  5. Just discovered this code does it too, but again only in release mode. Perhaps the releasing of any object is not working correctly? bool App::Loop() { if (window->KeyHit(Key::Escape) == true) { return false; } if (window->KeyHit(Key::F1) == true) { camera->GetDebugPhysicsMode() == true ? camera->SetDebugPhysicsMode(false) : camera->SetDebugPhysicsMode(true); } if (window->KeyHit(Key::F2) == true) { if (wireframe == true) { camera->SetDrawMode(0); wireframe = false; } else { camera->SetDrawMode(2); wireframe = true; } } Model* box = Model::Box(); box->Release(); //<- Increases memory used in Release mode Time::Update(); world->Update(); world->Render(); context->SetBlendMode(Blend::Alpha); context->DrawStats(10.0f, 10.0f, true); context->Sync(true); return true; } EDIT : Been watching the debug version of this for nearly 2 minutes and while Leadwerks says a constant memory usage, the diagnostics tools window of Visual Studio shows a steady increase. About 1MB a minute.
  6. Unfortunately it didn't work. But I did notice something interesting, it only happens in release mode. I've also noticed that in release mode the memory usually fluctuates a bit for about 20 seconds then stabilizes, but not in debug mode or at least for not as long... Maybe internally the release mode function is missing some garbage collection stage...?
  7. This is the code to just show the problem, but I'm doing something pretty much the same in game. The only difference is, the code will only generate a shape if it's changed, like if the player has moved around on the terrain. I have my own large terrain class and generating all this data at the start will take enormous amounts of memory and time. (this was my first approach) Unless there is a way to edit the vertices of the shape itself then I'm stuck with deleting and remaking it every time it's needed. It's actually not as slow as you might think either, most of the patches I need form 4x4 grid. So as long as I don't try to create a thousand of them at once, there's no frame drop.
  8. Just tried it with no success. Also tried opting out of Betas but still nothing. Haven't tried 4.4 yet because there was a few errors to sort out first. Evan just create a simple box shape increases the memory used, albeit a bit slower. bool App::Loop() { if (window->KeyHit(Key::Escape) == true) { return false; } if (window->KeyHit(Key::F1) == true) { camera->GetDebugPhysicsMode() == true ? camera->SetDebugPhysicsMode(false) : camera->SetDebugPhysicsMode(true); } if (window->KeyHit(Key::F2) == true) { if (wireframe == true) { camera->SetDrawMode(0); wireframe = false; } else { camera->SetDrawMode(2); wireframe = true; } } Shape* shape = Shape::Box();//memeory leak here? shape->Release(); Time::Update(); world->Update(); world->Render(); context->SetBlendMode(Blend::Alpha); context->DrawStats(10.0f, 10.0f, true); context->Sync(true); return true; }
  9. I create a collision patch for my terrain on the fly with the following code which increases the memory usage over time. Commenting out creating the shape seams to stop it. #include "App.h" using namespace Leadwerks; App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {} App::~App() { delete world; delete window; } Model* box; Camera* camera; bool wireframe = false; bool App::Start() { window = Window::Create("PolyMesh",50,50, 1024, 768); window->Show(); context = Context::Create(window); world = World::Create(); DirectionalLight* light = DirectionalLight::Create(); light->SetRotation(35, 35, 35); camera = Camera::Create(); box = Model::Box(); box->Move(0, 0, 2); return true; } bool App::Loop() { if (window->KeyHit(Key::Escape) == true) { return false; } if (window->KeyHit(Key::F1) == true) { camera->GetDebugPhysicsMode() == true ? camera->SetDebugPhysicsMode(false) : camera->SetDebugPhysicsMode(true); } if (window->KeyHit(Key::F2) == true) { if (wireframe == true) { camera->SetDrawMode(0); wireframe = false; } else { camera->SetDrawMode(2); wireframe = true; } } Vec3 rot = box->GetRotation(); rot.x += 0.2f; rot.y += 0.2f; rot.z += 0.2f; box->SetRotation(rot); //Make a collsion surface on the fly for terrain/////////////////// int xGrid = 3; int zGrid = 3; int vertIndex = 0; Surface* surface = Surface::Create(); for (int z = 0; z < zGrid; z++) { for (int x = 0; x < xGrid; x++) { surface->AddVertex(x, 0.0f, z); if (z != 0 && x != 0) { surface->AddTriangle(vertIndex, vertIndex - xGrid, vertIndex - 1); surface->AddTriangle(vertIndex - xGrid, vertIndex - xGrid - 1, vertIndex - 1); } vertIndex++; } } Shape* shape = Shape::PolyMesh(surface);//memory leak here? //box->SetShape(shape); shape->Release(); surface->Release(); ////////////////////////////////////////////////////////////////////// Time::Update(); world->Update(); world->Render(); context->SetBlendMode(Blend::Alpha); context->DrawStats(10.0f, 10.0f, true); context->Sync(true); return true; }
  10. Right-o. I found the issue. In Visual Studio an application by default is only allowed to access 2GB of memory. I guess this to insure that the released application wont use all of the 4GB of ram on a 32bit system so that the operating system will still run? Anyway, in VS2017 you can enable large Addresses in Property Pages->Linker->System. This fixed the issue but I think it's only increased to around 3GB, I'm not sure. Will keep reading and maybe look into exporting it as a 64bit app. Not sure how this will work with Leadwerks 4 yet... Some links below; https://msdn.microsoft.com/en-us/library/wz223b1z.aspx https://stackoverflow.com/questions/5686459/what-is-the-maximum-memory-available-to-a-c-application-on-32-bit-windows Hopefully someone finds this info useful. ?
  11. In my game I store six 2049 x 2049 height-maps in a dynamically created array, like this; size_t mapSize = 2049 * 2049; float* map = new float[mapSize];//approx 16mb When the app closes they are destroyed like this; delete[] map; As far as I can tell, the more data I load in this way, the app will eventually crash with a "bad_alloc" or "memory exception". It doesn't crash when it allocates for the new map I'm loading, it crashes later on when I'm allocating storage for something else. It could be another set of 16mb or the set of 50mb being allocated. Everything will be fine until I add another map. I've tried various things to rule out corrupted files and what not. I've also run the windows "memory diagnostic" just to verify that the ram is working. It should be, I've never had memory issues even with some high RAM demanding games. This is my error catching code too, the memory used is only about 700mb in total. RAM usage is nearly 5gb in the task manager out of 32gb system total. //Class header float* w1_map; float* w2_map; float* w3_map; float* w4_map; float* w5_map; float* w6_map; //class cpp void cFragment::InitMaps() { size_t _mapSize = 2049 * 2049; try { w1_map = new float[mapSize]; w2_map = new float[mapSize]; w3_map = new float[mapSize]; w4_map = new float[mapSize]; w5_map = new float[mapSize]; w6_map = new float[mapSize]; } catch (std::bad_alloc) { long _usedMemory = System::GetMemoryUsage(); std::stringstream _stream; _stream << "Used Memory : " << _usedMemory << "\nFunction : cFragment::InitMaps()\n\nClick OK to Terminate Program."; MessageBox(Window::GetCurrent()->GetHandle(), _stream.str().c_str(), "BAD ALLOC", MB_OK); exit(NULL); } } So I guess my questions are these; Has anyone else had similar issues? Are there limits to how much can be allocated to one pointer? Are there limits to the amount of consecutive calls to "new[]"? I have a 64bit system, but as I understand it L4 and visual studio are 32bit, so the most RAM that can be allocated for the entire application is 4gb?
  12. Your right, I eventually found that out. And it works really well. On my GTX 980Ti I rendered 1.6 million billboard trees at 100fps. Can't complain with that.
  13. I ended up finding a way, below is a snippet of code on how i got it to work. It's not as exact as using trig functions like cos(), sin() and atan2(), but the speed outweighs the accuracy. And it's not off by much. There's still a few things I can do to perfect it. ? float _diffX = _camPos.x - _mdlPos.x; float _diffZ = _camPos.z - _mdlPos.z; Vec2 _yVec = Vec2(_diffX, _camPos.z - _mdlPos.z).Normalize(); float _xzPart = sqrt((_diffX * _diffX) + (_diffZ * _diffZ)); Vec2 _xVec = Vec2(_camPos.y - _mdlPos.y, _xzPart).Normalize(); const float magicNumber = 6.343830794f; const float radToPi = 57.29577951f; const float sinCos45 = 0.707106781f; if (_yVec.x <= 0.0f && _yVec.y <= 0.0f) {//bottomLeft if (_yVec.x >= -sinCos45) { _yAngle = ((-_yVec.x) * radToPi) + (-_yVec.x * magicNumber); } else { _yAngle = 90.0f - (((-_yVec.y) * radToPi) + (-_yVec.y * magicNumber)); } } else if (_yVec.x > 0.0f && _yVec.y < 0.0f) {//bottomRight if (_yVec.x <= sinCos45) { _yAngle = -((_yVec.x * radToPi) + (_yVec.x * magicNumber)); } else { _yAngle = -90.0f + (((-_yVec.y) * radToPi) + (-_yVec.y * magicNumber)); } } else if (_yVec.x > 0.0f && _yVec.y > 0.0f) {//TopRight if (_yVec.x <= sinCos45) { _yAngle = (_yVec.x * radToPi) + (_yVec.x * magicNumber) - 180.0f; } else { _yAngle = (((-_yVec.y) * radToPi) + (-_yVec.y * magicNumber)) - 90.0f; } } else if (_yVec.x <= 0.0f && _yVec.y > 0.0f) {//TopLeft if (_yVec.x >= -sinCos45) { _yAngle = 180.0f - ((-_yVec.x * radToPi) + (-_yVec.x * magicNumber)); } else { _yAngle = 90.0f + ((_yVec.y * radToPi) + (_yVec.y * magicNumber)); } } if (_xVec.x <= 0.0f && _xVec.y <= 0.0f) {//bottomLeft if (_xVec.x >= -sinCos45) { _xAngle = ((-_xVec.x) * radToPi) + (-_xVec.x * magicNumber); } else { _xAngle = 90.0f - (((-_xVec.y) * radToPi) + (-_xVec.y * magicNumber)); } } else if (_xVec.x > 0.0f && _xVec.y < 0.0f) {//bottomRight if (_xVec.x <= sinCos45) { _xAngle = -((_xVec.x * radToPi) + (_xVec.x * magicNumber)); } else { _xAngle = -90.0f + (((-_xVec.y) * radToPi) + (-_xVec.y * magicNumber)); } } else if (_xVec.x > 0.0f && _xVec.y > 0.0f) {//TopRight if (_xVec.x <= sinCos45) { _xAngle = (_xVec.x * radToPi) + (_xVec.x * magicNumber) - 180.0f; } else { _xAngle = (((-_xVec.y) * radToPi) + (-_xVec.y * magicNumber)) - 90.0f; } } else if (_xVec.x <= 0.0f && _xVec.y > 0.0f) {//TopLeft if (_xVec.x >= -sinCos45) { _xAngle = 180.0f - ((-_xVec.x * radToPi) + (-_xVec.x * magicNumber)); } else { _xAngle = 90.0f + ((_xVec.y * radToPi) + (_xVec.y * magicNumber)); } }
  14. I'm currently trying to write a shader that makes every triangle of the mesh point to the position of the camera regardless of the camera's rotation. I think I can multiply the vertex positions in the vertex shader by a one of the matrices but I'm not sure which one or how. And I think the camera matrix will rotate the triangle to the same orientation as the camera and not just point to it's position? Basically I need the vertex shader (or geometry if it's easier) to do what Entity::Point() does but on each triangle and not the mesh as a whole. Anyone got any ideas on how to do this? ? EDIT : I've been getting the direction the camera like this; normalize(vsModelVertexPosition.xyz - cameraposition)
  15. Love it! Can't wait to see some awsome games made with "Turbo Game Engine"
  16. Looking forward to hearing more on this. On the subject of lighting, are there techniques around that allow infinite distance shadow rendering?
  17. I would like to see your approach to lighting. Very interested to see how it effects performance.
  18. Works now, thanks Ma-Shell!
  19. I had a GUI class before the in built system was available and I'd rather not go through and replace everything if I can help it. Run this code and you'll see the issue. Your code macklebee draws the text with transparency on a solid background. I want the entire image to be completely transparent. Then I will draw what I need to on it. Then it will be drawn over the top of previously drawn items. Buffer* buffer; bool App::Start() { window = Window::Create("Test"); window->Show(); context = Context::Create(window); world = World::Create(); Camera* camera = Camera::Create(); buffer = Buffer::Create(1024, 768, 1, 0); return true; } bool App::Loop() { if (window->KeyHit(Key::Escape) == true) { return false; } world->Update(); world->Render(); context->SetBlendMode(Blend::Alpha); buffer->Enable(); buffer->SetColor(0, 0, 0, 0); buffer->Clear(); //buffer alpha is not being cleared context->SetColor(1, 0, 0, 1); context->DrawRect(80, 50, 100, 100); context->Enable(); context->SetColor(1, 1, 1, 1); context->DrawRect(10, 10, 100, 100); //white rectangle not showing. context->DrawImage(buffer->GetColorTexture(), 0, 0); context->SetBlendMode(Blend::Solid); context->Sync(); return true; } If I set the buffers alpha to 0, shouldn't it be transparent except for the red rectangle?
  20. I accidentally added an extra 1 in SetColor() when typing the post, sorry. Besides that, all the info is there. I've created a buffer and am drawing it to the context (not a materiel). The reason is so that any UI that may overlap other UI can be drawn to this buffer and then drawn last with context->DrawImage() on top of the whole screen. The drawing to the buffer works fine, but the buffer has to be cleared every frame so that previous drawings are gone. Which brings me to asking, how to clear the buffer with transparency because SetColor(1,1,1,0) (I think) should set it to complete transparency regardless of the RGB values. But it's not. I tried your suggestion with setting it as the current buffer first then calling context->SetBlendMode() but it still is just the RGB values, no alpha. If I draw the newly made buffer without clearing first, the image is totally transparent and only shows the drawings like it should, but it needs to be cleared ready for the next frame.
  21. I'm using a buffer to draw some 2D graphics too but can't seam to clear the buffer with transparency. I looked at the forum here for the info regarding buffers and 2D drawing; I tried clearing the buffer with this code but only get a white screen; //App Start Buffer* topLevelBuffer = Buffer::Create(1024, 768, 1, 0); //Draw Loop topLevelBuffer->SetColor(1, 1, 1, 0); topLevelBuffer->Clear(); topLevelBuffer->Enable(); DrawUI(topLevelBuffer); _context->Enable(); _context->DrawImage(topLevelBuffer->GetColorTexture(), 0, 0); Anyone had any luck with clearing to a transparent buffer?
  22. In C++, after you render the world you can just draw to the context. World->Update() World->Render() Context->DrawRect() Context->Sync()
  23. Hi, you can call Window::GetCurrent () and Context:: GetCurrent(). To access the camera in all classes however, I create a global variable that each class can access.
×
×
  • Create New...