Jump to content

Renders Stats Fluctuate when Rotating Light


SpiderPig
 Share

Recommended Posts

Not positive if this is a bug to be honest and if it is it may well be fixed in the next update, but just in case - In my game rotating the directional light to mimic the sun causes the vertex, polygon and instance count to slowly ramp up to about 20x then it will slowly decrease and then ramp up again.  (I have 1.2 million verts in my game and it can get up to 30million before repeating the cycle)  The code below shows the stats fluctuating in the window title albeit at a lesser extent than in my game.

Should the vertex, polygon and instance counts fluctuate with a moving / rotating light source?  And by that much?

#include "Engine.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, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
    auto world = CreateWorld();
    world->RecordStats();

    auto framebuffer = CreateFramebuffer(window);

    auto camera = CreateCamera(world);
    camera->SetClearColor(0.125);
    camera->SetFov(70);
    camera->SetPosition(10, 10, -8);

    auto light = CreateDirectionalLight(world);
    light->SetRotation(35, 45, 0);

    
    auto floor = CreateBox(world, 128);
    floor->Move(0, -64, 0);

    vector<shared_ptr<Entity>> boxes;
    for (int z = 0; z < 25; z++) {
        for (int x = 0; x < 25; x++) {
            auto e = CreateSphere(world);
            e->SetPosition(x, 0.0f, z, true);
            boxes.push_back(e);
        }
    }

    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        Vec3 day_speed = Vec3(0.5, 0, 0);
        light->Turn(day_speed.x, day_speed.y, day_speed.z);

        auto stats = world->renderstats;
        WString text = "FPS : [" + WString(stats.framerate) + "] - ";
        text += "Verts : [" + WString(stats.vertices) + "] - ";
        text += "Polys : [" + WString(stats.polygons) + "] - ";
        text += "Insts : [" + WString(stats.instances) + "] - ";
        text += "Shadow Polys : [" + WString(stats.shadowpolygons) + "]";

        window->SetText(text);

        world->Update();
        world->Render(framebuffer, false);
    }

    return 0;
}

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...