Giter VIP home page Giter VIP logo

babylon-mtoon-material's Introduction

babylon-mtoon-material

npm version CircleCI semantic-release

Unity Santarh/MToon Shader WebGL porting to babylon.js.

Some settings will be ignored or generates inconsistent lighting.

When you use babylon.js-beta.17 or older, please use v1.9.0.

About MToon(ja)

Features

  • Some StandardMaterial abilities
    • Lighting
    • Multiview
    • LogarithmicDepth
    • Fog
    • Bones in shader
    • MorphTargets in shader
    • Shadow
    • EffectFallback
    • Instances
    • ClipPlane
    • AmbientColor
    • Alpha CutOff
  • Textures & Color values
    • Diffuse
    • Emissive
    • Bump
    • Shade(shaded diffuse rate with red channel)
    • Receive Shadow(received shadow rate with red channel)
    • Shading Grade(shading grade rate with red channel)
    • Rim
    • MatCap
    • Outline Width(outline width rate with red channel)
  • UV Animation(Scroll, Rotation)
  • Serialize Support

These are not covered.

  • Specular
  • Vertex Color

Usage

This material will be automatically assined to VRM/VCI model within babylon-vrm-loader.

Also you can explicitly assign MToonMaterial to any meshes.

Browser

Live preview at CodePen is here.

<!DOCTYPE html>
<html>
    <head>
        <title>Babylon.js MToon Material</title>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, user-scalable=no">
    </head>
    <body>
        <main id="wrapper">
            <canvas id="renderCanvas"></canvas>
        </main>
        <script src="https://preview.babylonjs.com/babylon.max.js"></script>
        <script src="https://unpkg.com/babylon-mtoon-material/dist/index.js"></script>
        <script>
            // example usage from https://github.com/BabylonJS/Babylon.js
            const canvas = document.getElementById('renderCanvas');
            const engine = new BABYLON.Engine(canvas, true, {preserveDrawingBuffer: true, stencil: true});
            const scene = new BABYLON.Scene(engine);
            const camera = new BABYLON.FreeCamera('camera1', new BABYLON.Vector3(0, 5, -10), scene);
            camera.setTarget(BABYLON.Vector3.Zero());
            camera.attachControl(canvas, false);
            new BABYLON.HemisphericLight('light1', new BABYLON.Vector3(0, 1, 0), scene);
            const sphere = BABYLON.Mesh.CreateSphere('sphere1', 16, 2, scene, false, BABYLON.Mesh.FRONTSIDE);
            sphere.position.y = 1;

            // Assign MToonMaterial
            sphere.material = new MToonMaterial('mat1', scene);

            engine.runRenderLoop(function(){
                scene.render();
            });
            window.addEventListener('resize', function(){
                engine.resize();
            });
        </script>
    </body>
</html>

npm

$ npm install --save @babylonjs/core babylon-mtoon-material
// in index.js
import { Mesh } from '@babylonjs/core';
import { MToonMaterial } from 'babylon-mtoon-material';

// initializing

const sphere = BABYLON.Mesh.CreateSphere('Sphere', 16, 1, scene);
sphere.material = new MToonMaterial('MtoonMaterial', scene);

Contributing

See CONTRIBUTING.md.

Build

$ yarn install --frozen-lockfile
$ yarn build

Debugging MToonMaterial

$ yarn install --frozen-lockfile
$ yarn debug

You can see inspector on http://localhost:8080/

Test

# executes tslint
$ yarn lint
# executes jest testing with puppetter
$ yarn test

Related Links

Licenses

see LICENSE.

This project uses babylon.js with Apache License, Version 2.0.

This project is based on MToon with MIT License.

babylon-mtoon-material's People

Contributors

il-m-yamagishi avatar semantic-release-bot avatar greenkeeper[bot] avatar

Watchers

 avatar

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.