Jump to content

Leadwerks materials loading


reepblue
 Share

Go to solution Solved by Josh,

Recommended Posts

My Leadwerks glass materials no longer work correctly upon reloading lvl7.

image.thumb.png.1b4d2eff40593f579a98a66c30b7e64e.png

Also getting this gross artifact.

image.thumb.png.789fde80c669e3046cc8c401037f657d.png

Nott sure if you wanted to move off of this thread for minor bugs, but decided to post these here.

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

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

Link to comment
Share on other sites

  • 2 weeks later...

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;
}

 

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

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

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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?

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

14 minutes ago, Josh said:

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?

There's this over casting shadow I caught on the top left of the launcher. 

image.png.b0a480f48e6cd1a8b8ecce7274970e59~2.png

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

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

Link to comment
Share on other sites

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

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

  • Solution

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

My job is to make tools you love, with the features you want, and performance you can't live without.

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...