question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Suggestion: Refactor MeshToonMaterial

See original GitHub issue

As suggested in https://github.com/mrdoob/three.js/pull/15105#issuecomment-453540970.

I have never seen a toon shader that supports hotspots, environment maps, or even maps for that matter… Or multiple lights.

A toon shader can be written in a few lines of code, and should not have extended Phong, which is way too flexible. I would have implemented it like MeshMatcapMaterial.

Alternative opinions, welcome.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:16 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
takahiroxcommented, Jun 24, 2020

About specular, the reason why I implemented so was from MMD default shader. Like her sleeve in the first picture in the link https://ascii.jp/elem/000/000/714/714544/index-2.html MMD specular is soft edge.

I personally want to remain the soft edge for MMD but I can understand it isn’t standard. So I don’t block changing. Instead if we change I’ll think of customizing shader for MMD with Node-based material (when it’s available in core), .onBeforeCompile(), or ShaderMaterial.

As #19609 I am going to implement MMD specific material in MMDLoader, so we no longer need to take care MMD for refactoring Toon material.

2reactions
gkjohnsoncommented, Apr 15, 2019

I’m all for rethinking the toon shader but can you elaborate on this a bit more?

I have never seen a toon shader that supports hotspots, environment maps, or even maps for that matter… Or multiple lights.

My understanding is that a toon shader is basically just mapping a color ramp to light intensity so it would seem that that should enable support for specular highlights through the stepped shading (though maybe not in the way they’re represented right now). The Octane and Arnold toon material docs both reference rendering specular highlights with the toon material, for example. Regarding maps the Octane docs give examples of using a roughness map to augment the shape of the color bands and something like a normal map should have the same effect.

I can’t find anything explicitly showing a toon material rendering with multiple lights (other than the final image in the Octane docs that shows two highlights) but this seems like a stylistic choice. I’m not sure if THREE allows a way to limit or choose which lights a material renders with but that would be a nice option. This write up on Zelda Wind Waker discusses how lighting changes dynamically based on closest light source, but maybe that’s considered to use case specific.

Read more comments on GitHub >

github_iconTop Results From Across the Web

MeshToonMaterial – three.js docs
MeshToonMaterial. A material implementing toon shading. Open in New Window. Controls. Scene. ambient light ... MeshToonMaterial( parameters : Object ).
Read more >
MeshToonMaterial - Three.js Tutorials - sbcode.net
Toon shading or Cel shading is a type of non-photorealistic rendering technique designed to make 3D computer graphics appear more cartoonish by using...
Read more >
three.js - JavaScript 3D library. - JsRepos
This code creates a scene, a camera, and a geometric cube, and it adds the cube to the scene. It then creates a...
Read more >
The three-ts-types from three-types - Giter Site
This repository is the home for the TypeScript types for three.js. Periodically the updates from this repository are pushed to DefinitelyTyped and released ......
Read more >
three.js JavaScript 3D library
The aim of the project is to create an easy to use, lightweight, 3D library with a default WebGL renderer. The library also...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found