Toon shader bug fix


toon shader debug | Babylon.js Playground

The Teleport node makes WebGPU inoperative.

remove teleport node

alpha

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.

1 Like

I’ll have a look!

Here we are:
Optimization for NME: teleports will do nothing if the input node is … by deltakosh · Pull Request #16700 · BabylonJS/Babylon.js

3 Likes