yum-archive/Tooner

A toon shader for Unity's BIRP.

git clone https://git.yummers.dev/yum-archive/Tooner

yumAdd two rim lighting slots2814e9b

v0.0.0
998 B39 linesraw
1#ifndef __CLONES_INC
2#define __CLONES_INC
3
4#if defined(_CLONES)
5
6#include "interpolators.cginc"
7#include "globals.cginc"
8
9void add_clones(in v2f clone_verts[3], inout TriangleStream<v2f> tri_out)
10{
11  if (_Clones_dx < 1E-6) {
12    return;
13  }
14
15  float factor = _Tess_Factor;
16  if (_Clones_Dist_Cutoff > 0 && length(_WorldSpaceCameraPos - clone_verts[0].worldPos) > _Clones_Dist_Cutoff) {
17    factor = 1;
18  }
19
20  uint n_clones = (uint) round(_Clones_Count);
21  for (uint i = 0; i < (uint) n_clones; i++) {
22    for (uint j = 0; j < 3; j++) {
23      v2f ii = clone_verts[j];
24      float3 objPos = mul(unity_WorldToObject, float4(ii.worldPos, 1)).xyz;
25      float offset = i;
26      offset = ((offset % 2) * 2 - 1) * (((offset) / 2) + 1) * _Clones_dx;
27      objPos.x += offset;
28      ii.worldPos = mul(unity_ObjectToWorld, float4(objPos, 1)).xyz;
29      ii.clipPos = UnityObjectToClipPos(objPos);
30      tri_out.Append(ii);
31    }
32    tri_out.RestartStrip();
33  }
34}
35
36#endif  // _CLONES
37
38#endif  // __CLONES_INC
39