I currently have a single step toon shader using this simple behaviour (no anti-aliasing for the moment). As expected the result is a single straight line.

```
float ndotl = dot(normal, lightDir);
float result = step(0, ndotl);
```

But I would like to apply a Voronoi pattern on this straight line and break it to make it irregular using this pattern while keeping this hard separation. But I don't see any way to apply correctly the Voronoi pattern on the shading.

Here's how the Voronoi pattern is generated.

```
float2 g = floor(uv * density);
float2 f = frac(uv * density);
float result = 0.0;
float dist = 8.0;
for (int y = -1; y <= 1; y++)
{
for (int x = -1; x <= 1; x++)
{
float2 lattice = float2(x, y);
float2 uv2 = lattice + g;
float2x2 m = float2x2(15.27, 47.63, 99.41, 89.98);
uv2 = frac(sin(mul(uv2, m)) * 46839.32);
float offset = cos(uv2.x * angleOffset) * 0.5 + 0.5;
float d = distance(lattice + offset, f);
if (d < dist)
{
dist = d;
result = offset;
}
}
}
return result;
```

Any idea how I could mix Voronoi and single step toon shading ? Thanks a lot.

- Serverfault Help
- Superuser Help
- Ubuntu Help
- Webapps Help
- Webmasters Help
- Programmers Help
- Dba Help
- Drupal Help
- Wordpress Help
- Magento Help
- Joomla Help
- Android Help
- Apple Help
- Game Help
- Gaming Help
- Blender Help
- Ux Help
- Cooking Help
- Photo Help
- Stats Help
- Math Help
- Diy Help
- Gis Help
- Tex Help
- Meta Help
- Electronics Help
- Stackoverflow Help
- Bitcoin Help
- Ethereum Help