Here's one way to code the answer. We still compute the diffuse component, but
no longer take a maximum value, since we're going to compare it to uBorder. The
comparison here then changes the diffuse value so it gives a cartoony effect.
Here's a more compact solution, using a conditional operator instead of a
full-blown if, then, else statement. This critical angle rule is entirely
arbitrary of course. You could even try more elaborate rules. For example, this
code gives three levels of illumination. It gives an image with a different
feel, a bit more depth and a little less cartoony. This type of effect was
almost impossible with the old fixed function pipeline. With shaders it's easy
to experiment with different illumination models.
実は解決策の1つは拡散成分を計算しつつも
最大値は取らないことです なぜならuBorderと比較し
拡散値を変更すればアニメ調の効果が得られるからです
これらを凝縮したやり方は条件演算子を
使う方法です
この臨界角のルール適用は人それぞれですし
もっと複雑なルールを試すこともできます 例えば
このコードは3段階のライトを算出し これにより
質感の違いや少し深みのある画像が得られます
このように固定機能パイプラインでは無理だった実験が
シェーダでは簡単になりました