# Toon shader bug fix

**URL:** <https://forum.babylonjs.com/t/toon-shader-bug-fix/58774>\
**Category:** Questions\
**Tags:** material\
**Created:** [June 1, 2025, 6:27pm UTC](https://forum.babylonjs.com/t/toon-shader-bug-fix/58774 "2025-06-01T18:27:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lun](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/lun/32/19231_2.png) [@Lun](https://forum.babylonjs.com/u/Lun)\
**Post date:** [June 1, 2025, 6:27pm UTC](https://forum.babylonjs.com/t/toon-shader-bug-fix/58774/1 "2025-06-01T18:27:42Z")

</div>

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/7/c/7c31d7ab60456171290bb7379a5910982d10fd6b.jpeg)  
[toon shader debug | Babylon.js Playground](https://playground.babylonjs.com/#0SS0DK#110)

The Teleport node makes WebGPU inoperative.

---

<div class="post-metadata">

**Author:** ![Lun](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/lun/32/19231_2.png) [@Lun](https://forum.babylonjs.com/u/Lun)\
**Post date:** [June 1, 2025, 8:28pm UTC](https://forum.babylonjs.com/t/toon-shader-bug-fix/58774/2 "2025-06-01T20:28:22Z")

</div>

> **[Babylon.js Playground](https://playground.babylonjs.com/#0SS0DK%23115)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

remove teleport node

alpha

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [June 2, 2025, 8:57am UTC](https://forum.babylonjs.com/t/toon-shader-bug-fix/58774/3 "2025-06-02T08:57:04Z")

</div>

The problem is that there are too many variables (`varying`) being passed from the vertex to the fragment shader. It seems that WebGPU reserves one or two additional variables compared to WebGL for its own use, which explains why it works in WebGL but not in WebGPU.

One solution is to merge multiple variables into a single one. For example, you can merge `shadowIntensity`, `specularIntensity`, `rimIntensity`, and `ambientIntensity` into a single `vec4` instead of having 4 separate floats, which count as 4 different variables.

However, I think we should fix our teleport node so that we don’t introduce a “varying” when the teleported variable is an input variable: we should just reuse the same uniform in the fragment shader. cc @Deltakosh

[EDIT] I changed the category to “Questions” because I think it fits better with your discussion thread.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [June 2, 2025, 3:02pm UTC](https://forum.babylonjs.com/t/toon-shader-bug-fix/58774/4 "2025-06-02T15:02:57Z")

</div>

I’ll have a look!

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [June 2, 2025, 4:18pm UTC](https://forum.babylonjs.com/t/toon-shader-bug-fix/58774/5 "2025-06-02T16:18:34Z")

</div>

Here we are:  
[Optimization for NME: teleports will do nothing if the input node is … by deltakosh · Pull Request #16700 · BabylonJS/Babylon.js](https://github.com/BabylonJS/Babylon.js/pull/16700)
