yum-archive/Tooner

A toon shader for Unity's BIRP.

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

yumAdd shader inlining toolingb904835

master
1004 B47 linesraw
1#include "globals.cginc"
2#include "math.cginc"
3#include "pema99.cginc"
4
5#ifndef __TOONER_SCROLL
6#define __TOONER_SCROLL
7
8#if 0
9float _Scroll_Toggle;
10float _Scroll_Top;
11float _Scroll_Bottom;
12float _Scroll_Width;
13float _Scroll_Strength;
14float _Scroll_Speed;
15#endif
16
17float3 applyScroll(float3 p, float3 n, float3 avg_pos) {
18#if defined(_SCROLL)
19  float phase = glsl_mod(_Time[1] * _Scroll_Speed, 1.0);
20
21  float z1 = _Scroll_Top;
22  float z0 = _Scroll_Bottom;
23  float zc = (z1 - z0) * phase + z0;
24
25  float3 op = mul(unity_WorldToObject, float4(p, 1)).xyz;
26
27  float offset =
28    1 / (1 + pow(.5 * (zc - op.y) / _Scroll_Width, 6));
29
30  p -= avg_pos;
31  float3 axis = normalize(float3(
32      rand((int) p.x * 1.0E6),
33      rand((int) p.y * 1.0E6),
34      rand((int) p.z * 1.0E6)));
35  float theta = offset * .5;
36  float4 quat = get_quaternion(axis, theta);
37  p = rotate_vector(p, quat);
38  p += avg_pos;
39
40  return p + n * offset * _Scroll_Strength;
41#else
42  return p;
43#endif  // _SCROLL
44}
45
46#endif  // __TOONER_SCROLL
47