GithubHelp home page GithubHelp logo

About Light Sources about babylon-mmd HOT 4 OPEN

noname0310 avatar noname0310 commented on July 21, 2024
About Light Sources

from babylon-mmd.

Comments (4)

mono0218 avatar mono0218 commented on July 21, 2024

image
image

Codes already tried

const hemisphericLight = new HemisphericLight("HemisphericLight", new Vector3(0, 1, 0), scene);
        hemisphericLight.intensity = 1;
        hemisphericLight.specular.set(0, 0, 0);
        hemisphericLight.groundColor.set(1, 1, 1);

const directionalLight = new DirectionalLight("DirectionalLight", new Vector3(0.5, -1, 1), scene);
        directionalLight.intensity = 1;
        directionalLight.shadowMaxZ = 20;
        directionalLight.shadowMinZ = -15;
const directionalLight = new DirectionalLight("DirectionalLight", new Vector3(0, 75, -130), scene);
        directionalLight.direction = new Vector3(100,-75,-260)
        directionalLight.intensity = 10000;
        directionalLight.autoCalcShadowZBounds = false
        directionalLight.autoUpdateExtends = false
        directionalLight.shadowMaxZ = 1000
        directionalLight.shadowMinZ = -1000
        directionalLight.orthoTop = 1000
        directionalLight.orthoBottom = -1000
        directionalLight.orthoLeft = -1000
        directionalLight.orthoRight= -1000
        directionalLight.shadowOrthoScale = 1000

        const shadowGenerator = new ShadowGenerator(2048, directionalLight, true,);
        shadowGenerator.usePercentageCloserFiltering = true
        shadowGenerator.filteringQuality = ShadowGenerator.QUALITY_HIGH
        shadowGenerator.forceBackFacesOnly = false
        shadowGenerator.frustumEdgeFalloff = 0.1
        shadowGenerator.bias = 0.01;

I would appreciate any advice you could give me.

from babylon-mmd.

noname0310 avatar noname0310 commented on July 21, 2024

This appears to happen when the diffuse color of the model's material is not (1, 1, 1).

Some MMD models use the approach of setting the diffuse color to (0.5, 0.5, 0.5) and the ambient color to (1, 1, 1) to create a material that looks bright in the dark.

However, if we simply import the deffuse and ambient parameters into the StandardMaterial in babylon.js, we will get different lighting results due to the different way ambient color works in babylon.js.

In simple terms, this is due to the different behavior of babylon.js and MMD materials,
and can be resolved by applying either of the two codes below.

option1:

const pmxLoader = SceneLoader.GetPluginForExtension(".pmx") as PmxLoader; // If you're using a bpmx loader, modify this
const pmxMaterialBuilder = pmxLoader.materialBuilder as MmdStandardMaterialBuilder;
pmxMaterialBuilder.afterBuildSingleMaterial = (material): void => {
    material.diffuseColor.add(material.ambientColor);
    material.ambientColor.set(0, 0, 0);
};

option2:

scene.ambientColor = new Color3(1, 1, 1);

The second option is theoretically similar to MMD, although the first option usually yields better results

If you have any other questions, feel free to open an issue and I'll get back to you shortly.

from babylon-mmd.

noname0310 avatar noname0310 commented on July 21, 2024

If you're using post-processing, tone mapping may be the cause

defaultPipeline.imageProcessing.toneMappingEnabled = false;

from babylon-mmd.

noname0310 avatar noname0310 commented on July 21, 2024

In 0.41.0, the renderer code was refactored across the board, and you should now see exactly the same results as MMD.

from babylon-mmd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.