Jump to content

SpiderPig

Members
  • Posts

    2,285
  • Joined

  • Last visited

Posts posted by SpiderPig

  1. I can't figure this one out.  I was playing around with exporting from Blender and it displays on screen but only shows 1 LOD and no meshes for that LOD.  It's worth mentioning it has no materials or images, not sure why that'd make a difference though.

     

    EDIT :  It might be the newer GLTF export in blender.  The files that work are with "Khronos glTF Blender I/O v1.4.40" and the ones I've uploaded that don't work are "Khronos glTF Blender I/O v3.6.27".

    #include "UltraEngine.h"
    #include "Components/Mover.hpp"
    
    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();
    
        //Create a framebuffer
        auto framebuffer = CreateFramebuffer(window);
    
        //Create a camera
        auto camera = CreateCamera(world);
        camera->SetClearColor(0.125);
        camera->SetFov(70);
        camera->SetPosition(0, 5, -8);
    
        //Create a light
        auto light = CreateBoxLight(world);
        light->SetRotation(35, 45, 0);
        light->SetRange(-10, 10);
    
        auto model = LoadModel(world, "Models\\PineLarge_001.gltf");
    
        //Only one LOD and no meshes.
        //Output says LOD_1 was loaded but then deleted
    
        int l = 0;
        for (auto lod : model->lods) {
            auto m = 0;
            for (auto mesh : lod->meshes) {
                Notify("lod : " + String(l) + ", mesh : " + String(m), "");
                m++;
            }
            l++;
        }
    
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

     

    PineLarge.zip

  2. Here's a quick program and shader to test this out.  The shader works with inTexCoords.xy but not with inTexCoords.zw.

    #include "UltraEngine.h"
    #include "Components/Mover.hpp"
    
    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();
    
        //Create a framebuffer
        auto framebuffer = CreateFramebuffer(window);
    
        //Create a camera
        auto camera = CreateCamera(world);
        camera->SetClearColor(0.125);
        camera->SetFov(70);
        camera->SetPosition(0, 0, -3);
    
        //Create a light
        auto light = CreateBoxLight(world);
        light->SetRotation(35, 45, 0);
        light->SetRange(-10, 10);
    
        auto box = CreatePlane(world);
        box->SetRotation(-90.0f, 0.0f, 0.0f);
    
        auto material = LoadMaterial("Materials\\Test.mat");
        box->SetMaterial(material);
    
        auto mesh = box->lods[0]->meshes[0];
        mesh->SetVertexTexCoords(0, 0.0f, 0.0f, 1);
        mesh->SetVertexTexCoords(1, 1.0f, 0.0f, 1);
        mesh->SetVertexTexCoords(2, 0.0f, 1.0f, 1);
        mesh->SetVertexTexCoords(3, 1.0f, 1.0f, 1);
    
        //Main loop
        while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
        {
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

    Shader :

    #version 450
    #extension GL_GOOGLE_include_directive : enable
    #extension GL_ARB_separate_shader_objects : enable
    #extension GL_EXT_multiview : enable
    
    #include "../../../../../../../../UltraEngine/Templates/Common/Shaders/Base/TextureArrays.glsl"
    #include "../../../../../../../../UltraEngine/Templates/Common/Shaders/Base/Materials.glsl"
    
    
    layout(location = 5 ) in flat uint inMaterialIndex;
    layout(location = 2 ) in vec4 inTexCoords;
    
    layout(location = 0) out vec4 color[8];
    
    
    void main() {
    	color[0] = texture( texture2DSampler[ GetMaterialTextureHandle( materials[ inMaterialIndex ] , 0 ) ] , inTexCoords.zw );
    }

    Files :

    Shaders.zip

  3. 4 minutes ago, Josh said:

    They get converted into a quaternion so they can be stored in four bytes. :P

    I got the idea from Crytek.

    I've been looking through every piece of shader code for some wiggle room but you've stripped everything down to the bare minimum number of bytes needed so there's no room left for me. :P  But this is why Ultra is fast. ;)

    3 minutes ago, Josh said:

    You might be able to store your data in a texture, and then use the vertex ID as the lookup to get the extra data you want to retrieve.

    I was thinking that too.  I wanted to see if there were other ways first before I started on this.  Thanks!

  4. Can we not set a vertex's tangent or bitangent in Ultra?  I only found these in the Mesh class for vertices.

    virtual void SetVertexPosition(const uint32_t v, const Vec3& position);
    virtual void SetVertexNormal(const uint32_t v, const Vec3& normal);
    virtual void SetVertexTexCoords(const uint32_t v, const Vec2& texcoords, const int index = 0);
    virtual void SetVertexColor(const uint32_t v, const Vec4& color);

     

  5. I wonder if I can pass some custom floats per vertex to a fragment shader like this or does the extracting of the vertex colors in vert shader only work with values from 0.0f to 1.0f?

    mesh->SetVertexColor(0, (float)1200, (float)1400, (float)6450, (float)780);

     

  6. I found C++ in Leadwerks a lot faster than Lua.  If your making a small game then Lua is fine and a lot quicker to get results.  But if you want a large open world then C++ will be faster and give you more access to underlying commands in Leadwerks.  It's C++ all the way for me. 😎

    • Like 1
×
×
  • Create New...