便利関数まとめ （自分用）

# 概要
主にシェーダーで使う用の便利関数まとめ（自分用）．
随時追加していきます．

# 0. HLSL 組み込み関数
## 0.1 lerp
線形補間
```math
\mathrm{lerp}(x,y,s) = (1-s)x + sy
```

<p class="codepen" data-height="500" data-default-tab="html,result" data-slug-hash="MWNoRvp" data-pen-title="f_0_1_lerp" data-editable="true" data-user="Yuri-Tsukimi" style="height: 500px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;">
  <span>See the Pen <a href="https://codepen.io/Yuri-Tsukimi/pen/MWNoRvp">
  f_0_1_lerp</a> by Yuri Tsukimi (<a href="https://codepen.io/Yuri-Tsukimi">@Yuri-Tsukimi</a>)
  on <a href="https://codepen.io">CodePen</a>.</span>
</p>
<script async src="https://cpwebassets.codepen.io/assets/embed/ei.js"></script>

## 0.2 smoothstep
3次補間 （ハーマイト補間）
```math
\begin{align}
&\mathrm{smoothstep}(0,1,s) = s^2(3-2s) \\
&\mathrm{smoothstep}(a,b,s) = \mathrm{smoothstep}\left(0,1,\frac{x-a}{b-a}\right)
\end{align}
```

<p class="codepen" data-height="500" data-default-tab="html,result" data-slug-hash="NWQgmXG" data-pen-title="Untitled" data-editable="true" data-user="Yuri-Tsukimi" style="height: 500px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;">
  <span>See the Pen <a href="https://codepen.io/Yuri-Tsukimi/pen/NWQgmXG">
  Untitled</a> by Yuri Tsukimi (<a href="https://codepen.io/Yuri-Tsukimi">@Yuri-Tsukimi</a>)
  on <a href="https://codepen.io">CodePen</a>.</span>
</p>
<script async src="https://cpwebassets.codepen.io/assets/embed/ei.js"></script>

# 1. 非線形補間
## 1.1 smoothstep の疑似的な逆関数
適当に作った関数なので数学的には全然逆関数じゃないです．あんまり形も似てない...
```math
\mathrm{f_{1.1}}(x,a) =\mathrm{lerp}\left(\frac{(2x)^{\frac{1}{a}}}{2},1-\frac{(2(1-x))^{\frac{1}{a}}}{2},x\right)
```

<p class="codepen" data-height="500" data-default-tab="html,result" data-slug-hash="vYoZMdP" data-pen-title="f_1_1_psudo_inv_smoothstep" data-editable="true" data-user="Yuri-Tsukimi" style="height: 500px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;">
  <span>See the Pen <a href="https://codepen.io/Yuri-Tsukimi/pen/vYoZMdP">
  f_1_1_psudo_inv_smoothstep</a> by Yuri Tsukimi (<a href="https://codepen.io/Yuri-Tsukimi">@Yuri-Tsukimi</a>)
  on <a href="https://codepen.io">CodePen</a>.</span>
</p>
<script async src="https://cpwebassets.codepen.io/assets/embed/ei.js"></script>

## 1.2 smoothstep の疑似的な逆関数 その2
smoothstep がほぼサインカーブなので arcsin で近似します．
```math
\mathrm{f_{1,2}}(x) = \frac{\mathrm{arcsin}(2x-1)}{\pi}+0.5
```

<p class="codepen" data-height="500" data-default-tab="html,result" data-slug-hash="VwoWOYo" data-pen-title="Untitled" data-editable="true" data-user="Yuri-Tsukimi" style="height: 500px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;">
  <span>See the Pen <a href="https://codepen.io/Yuri-Tsukimi/pen/VwoWOYo">
  Untitled</a> by Yuri Tsukimi (<a href="https://codepen.io/Yuri-Tsukimi">@Yuri-Tsukimi</a>)
  on <a href="https://codepen.io">CodePen</a>.</span>
</p>
<script async src="https://cpwebassets.codepen.io/assets/embed/ei.js"></script>