Jump to content

SpiderPig

Developers
  • Posts

    2,272
  • Joined

  • Last visited

Posts posted by SpiderPig

  1. A different error but it might help pinpoint this problem... just simply creating the terrain crashes to "encodeData" or something like that.

    #include "UltraEngine.h"
    #include "ComponentSystem.h"
    
    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);
    
        //Sunlight
        auto light = CreateDirectionalLight(world);
        light->SetRotation(45, 35, 0);
        light->SetColor(2);
    
        //Create terrain
        auto terrain = CreateTerrain(world, 512, 512, 2048);
        //terrain->LoadHeightmap("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Terrain/512.r16");
        //terrain->SetScale(1, 100, 1);
    
        //Create base material
        /*auto ground = CreateMaterial();
        auto diffusemap = LoadTexture("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Materials/Ground/river_small_rocks_diff_2k.dds");
        auto normalmap = LoadTexture("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Materials/Ground/river_small_rocks_nor_gl_2k.dds");
        ground->SetTexture(diffusemap, TEXTURE_BASE);
        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_BASE);
        rocks->SetTexture(normalmap, TEXTURE_NORMAL);
        rocks->SetTexture(dispmap, TEXTURE_DISPLACEMENT);
    
        int rocklayer = terrain->AddLayer(rocks);
    
        //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->SetLayerWeight(rocklayer, x, y, 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;
    }

     

  2. Did this and it seems to work nice.

    if (enable_lighting == true && (RenderFlags & RENDERFLAGS_NO_LIGHTING) == 0)

    Only issue left to solve are the edges of the shadows are very harsh.  If I can use a single bit as a Boolean to disable lighting I may also be able to use a few bits to determine the distance from the light source so that I can soften the edges.  ^_^

    RayCastHeightMap_002.thumb.png.f7daac98b7b1776377c5d8651334942c.png

  3. This iteration is a bit slower but looks a lot nicer.  The shadows are just multiplied by the final color so fragments within the shadow are still having light calculated on them.  @Josh Can I make a bool variable in the fragment shader to simply not calculate lighting for certain pixels?

    Something like this perhaps?  EDIT : There's a RENDERFLAGS_NO_LIGHTING right there.... I might play with that :D

    if(canDoLighting == true) {
        if ((RenderFlags & RENDERFLAGS_NO_LIGHTING) == 0)
        {
            RenderLighting(material, materialInfo, vertexWorldPosition.xyz, n, v, NdotV, f_diffuse, f_specular, renderprobes, ibldiffuse, iblspecular);
            if (!renderprobes)
            {
                ibldiffuse = vec4(0.0f);
                iblspecular = vec4(0.0f);
                f_specular = vec3(0.0);// we don't want specular reflection in probe renders since it is view-dependent
            }
        }
        else
        {
            renderprobes = false;
            f_diffuse.rgb = materialInfo.c_diff * AmbientLight;
            f_specular = vec3(0.0f);// we don't want specular reflection in probe renders since it is view-dependent
        }
    }

    RayCastHeightMap_001.thumb.png.363fc74a73e65889f1f65fc8d96bc700.png

  4. This file causes LoadModel() to hang rather than crash.  Is there some sort of secret header that all model files should have? <_<

    To confirm - this is not with any plugin I've made, this is just loading a file that doesn't have much data and is in a format that LoadModel() doesn't recognise.

    I've also seen LoadModel hang and rapidly increase RAM usage into the tens of GB.

    CausesHang.zip

  5. As discussed bender has some issues with converting FBX to GLTF.  What would be nice is to have a feature in the Model Editor that allows us to add the animations from another model onto the current model.

    Mixamo (as far as I know) only exports one animation per FBX file.  SO using that means we could have a few dozen models of the same thing with different animations.  Currently the only way to merge them is through blender or some other software.  :)

    • Upvote 1
  6. After some discussion with @Andy90 there is another problem that I'm not sure has been raised yet... so here it is.

    This FBX has been exported from Mixamo.

    If you drag it into a folder in the editor it will convert perfectly.

    If you open the GLTF in the asset editor the animation is present and working, however if you then save the model from the asset editor you get a notification that says it has "animations that won't be saved".

    So you can only save the model if you don't want to keep the animation.

    V0.9.4 BTW

    Walk Forward.zip

  7. I was creating the file with a buffer but changed to WriteFile but it still throws an error in LoadModel and crashes the application.  This is how I'm creating the model file.

    void SaveModel(WString filepath, shared_ptr<Model> model) {
    
        auto version = 1;
        auto file = WriteFile(filepath);
        auto total_lods = model->lods.size();
    
        file->WriteInt(version);
        file->WriteInt(total_lods);
        for (auto lod_index = 0; lod_index < total_lods; lod_index++) {
    
            auto total_meshes = model->lods[lod_index]->meshes.size();
            file->WriteInt(total_meshes);
    
            for (auto mesh_index = 0; mesh_index < total_meshes; mesh_index++) {
                auto mesh = model->lods[lod_index]->meshes[mesh_index];
                auto total_vertices = mesh->CountVertices();
                auto total_indices = mesh->CountPrimitives();
    
                //Save Vertices
                file->WriteInt(total_vertices);
                for (auto vert_index = 0; vert_index < total_vertices; vert_index++) {
                    auto vertex_position = mesh->GetVertexPosition(vert_index);
                    auto vertex_normal = mesh->GetVertexNormal(vert_index);
                    auto vertex_texcoords = mesh->GetVertexTexCoords(vert_index);
    
                    file->WriteFloat(vertex_position.x);
                    file->WriteFloat(vertex_position.y);
                    file->WriteFloat(vertex_position.z);
    
                    file->WriteFloat(vertex_normal.x);
                    file->WriteFloat(vertex_normal.y);
                    file->WriteFloat(vertex_normal.z);
    
                    file->WriteFloat(vertex_texcoords.x);
                    file->WriteFloat(vertex_texcoords.y);
                }
    
                //Save Indices
                file->WriteInt(total_indices);
                for (auto indice_index = 0; indice_index < total_indices; indice_index++) {
                    auto v0 = mesh->GetPrimitiveVertex(indice_index, 0);
                    auto v1 = mesh->GetPrimitiveVertex(indice_index, 1);
                    auto v2 = mesh->GetPrimitiveVertex(indice_index, 2);
    
                    file->WriteInt(v0);
                    file->WriteInt(v1);
                    file->WriteInt(v2);
                }
            }
        }
    
        file->Close();
    }

     

×
×
  • Create New...