Skip to content

Highly reflective objects using default cubemaps #240

Description

@JamesTKhan

Describe the bug
When gdx-gltf was added in, environmental maps were not really fleshed out. Mundus is using gdx-gltf's IBLBuilder.createOutdoor() method and this creates a basic outdoor area for environmental diffuse/specular maps which does not match the Mundus scenes environment / skybox at all.

Not sure what the solution will be yet but this will require some refactoring. More research is needed find out if we can generate these textures based on skybox ( I doubt it ) or if we need the user to provide them.

Related to: #236

Docs on gdx-gltf
https://github.com/mgsx-dev/gdx-gltf/blob/master/docs/IBL.md

Code within Mundus:

public void initPBR() {
    IBLBuilder iblBuilder = IBLBuilder.createOutdoor(dirLight);
    Cubemap diffuseCubemap = iblBuilder.buildIrradianceMap(512);
    Cubemap specularCubemap = iblBuilder.buildRadianceMap(10);
    iblBuilder.dispose();

    PBRTextureAttribute tex = (PBRTextureAttribute) environment.get(PBRTextureAttribute.BRDFLUTTexture);
    if (tex == null) {
        Texture brdfLUT = new Texture(Gdx.files.classpath("net/mgsx/gltf/shaders/brdfLUT.png"));
        environment.set(new PBRTextureAttribute(PBRTextureAttribute.BRDFLUTTexture, brdfLUT));
    }

    PBRCubemapAttribute specularEnv = (PBRCubemapAttribute) environment.get(PBRCubemapAttribute.SpecularEnv);
    if (specularEnv != null) {
        specularEnv.textureDescription.texture.dispose();
        specularEnv.textureDescription.texture = specularCubemap;
    } else {
        environment.set(PBRCubemapAttribute.createSpecularEnv(specularCubemap));
    }

    PBRCubemapAttribute diffuseEnv = (PBRCubemapAttribute) environment.get(PBRCubemapAttribute.DiffuseEnv);
    if (diffuseEnv != null) {
        diffuseEnv.textureDescription.texture.dispose();
        diffuseEnv.textureDescription.texture = diffuseCubemap;
    } else {
        environment.set(PBRCubemapAttribute.createDiffuseEnv(diffuseCubemap));
    }
}

To Reproduce
Steps to reproduce the behavior:

  1. Edit a models material make it fully metallic and low roughness.

Screenshots
On left you can see how it looks in a vanilla gdx-gltf app, on right with a metallic cube you can see it in Mundus as well, not matching the scene skybox at all
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions