Jump to content

Leadwerks materials loading


Go to solution Solved by Josh,

Recommended Posts

  • 2 weeks later...
Posted

I am not sure what I am looking for or what appears wrong:

#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("Terrain Experiment", 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->SetClearColor(0.125);
    camera->SetFov(70);
    
    auto scene = LoadScene(world, "Maps/lvl7.map");

    //Camera controls
    auto actor = CreateActor(camera);
    actor->AddComponent<CameraControls>();

    //Main loop
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        if (window->KeyHit(KEY_SPACE))
        {
            scene = LoadScene(world, "Maps/lvl7.map");
        }

        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

 

Let's build cool stuff and have fun. :)

Posted

It looks like these materials have a material color of (255,255,255,255) and the texture has no alpha channel, or a solid opaque alpha channel, so there is no transparency even if the material is set to display transparency.

Untitled.thumb.jpg.454fa4ff15dd4a61203cfb0d344b2971.jpg

If I set the alpha channel of the material color to 128 the material appears transparent in Ultra:

Untitled2.thumb.jpg.0f1faa027fe44b4730538a0fc4f834fe.jpg

Let's build cool stuff and have fun. :)

Posted

Ok, so I'm guessing this was "hacked" in previous builds by the loader looking up the Alpha blend mode and assuming it should be transparent. Something must have changed since going to 1.0.1 so I brought this up as a "It was working before, and now it's not" issue. if it's a small change I need to do and will not effect the result in Leadwerks, I'll adjust.

No idea about the artifact with the ball launcher, might have to do with the spotlight.

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Posted

I think when I was previously testing it I had already set the material alpha. I also did some final adjustments to transparency, but the way it is working now appears to be correct.

Regarding the ball launcher model, I don't know what is wrong with the image above. How is it supposed to be different from that?

Let's build cool stuff and have fun. :)

Posted

I thought that was just the environment map reflection. It behaves like a cubemap reflection, moving with the camera but not changing when the camera rotates.

Let's build cool stuff and have fun. :)

Posted

The problem is definitely related to the cubemap coord shifting in the lighting code:

dist = BoxIntersectsRay(vec3(-0.5f),  vec3(0.5f), orig, -reflection);
if (dist > 0.0f)
{
	cubecoord = orig - reflection * dist;
	vec4 p = Plane(localposition, localnormal);
	if (PlaneDistanceToPoint(p, cubecoord) > 0.0f)
	{
		float sinfluence = min(influence, 1.0f - probespecular.a);
		u_MipCount = textureQueryLevels(textureCubeSampler[shadowMapID]);
		lod = materialInfo.perceptualRoughness * float(u_MipCount - 1); 
		probesample = textureLod(textureCubeSampler[shadowMapID], cubecoord, lod);
		probesample.rgb = min(probesample.rgb, 2.0f);
		probespecular.rgb += probesample.rgb * probesample.a * sinfluence;
		probespecular.a += sinfluence * probesample.a;
	}
	else
	{
		probespecular = vec4(1,0,0,1);
	}
}

image.thumb.jpeg.40a475ec17485e177d365258d34bb3d4.jpeg

Let's build cool stuff and have fun. :)

  • Solution
Posted

Okay, I removed that plane distance test and it appears to work fine. I am not sure why that was even in there. Maybe we will see a problem in the future that was supposed to solve, but I don't even know why it is in the code.

  • Like 2

Let's build cool stuff and have fun. :)

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.

×
×
  • Create New...