Skip to content

Instantly share code, notes, and snippets.

@muripoLife
muripoLife / ray_marching_templete.txt
Last active December 19, 2019 05:17
自分用のレイマーチングチートシートを作ってみた。 ref: http://qiita.com/muripo_life/items/dd75b82176d4ed09ebfe
/*
*******************************************************************************
レイマーチングチートシート
*******************************************************************************
*/
/* 精度修飾子の宣言 */
precision mediump float;
/* WebGLで受け渡された変数 */
@muripoLife
muripoLife / file0.txt
Last active February 5, 2017 08:24
GLSLレイマーチング研究_距離関数について勉強してみた01(距離関数と球) ref: http://qiita.com/muripo_life/items/eb7ec78b08dc39beddd0
「距離」の定義を満たす関数
@muripoLife
muripoLife / file0.txt
Last active February 9, 2017 11:38
GLSLレイマーチング研究_距離関数について勉強してみた02(unsigned(符号なし)のBoxの関数をいじる) ref: http://qiita.com/muripo_life/items/cbb81371bea70bfc2cd7
sqrt(max(abs(p.x)-0.5,0.0) * max(abs(p.x)-0.5,0.0) + max(abs(p.y)-0.5,0.0) * max(abs(p.y)-0.5,0.0) + max(abs(p.z)-0.5,0.0) * max(abs(p.z)-0.5,0.0))
@muripoLife
muripoLife / file0.txt
Created February 9, 2017 12:37
GLSLレイマーチング研究_距離関数について勉強してみた03(Round Box関数をいじる) ref: http://qiita.com/muripo_life/items/a6705d83d13f00800c44
length(max(q - vec3(【x軸方向の長さ】, 【y軸方向の長さ】, 【y軸方向の長さ】), 0.0))) - r
r:半径
@muripoLife
muripoLife / file0.txt
Last active February 16, 2017 15:35
GLSLレイマーチング研究_距離関数について勉強してみた04(signed(符号あり)のBoxの関数をいじる) ref: http://qiita.com/muripo_life/items/7397d096a5adcb3183e7
vec3 d = abs(p) - vec3(0.5, 0.5, 0.5);
return min(max(d.x, max(d.y, d.z)), 0.0) + sqrt(max(d.x, 0.0) * max(d.x, 0.0) + max(d.y, 0.0) * max(d.y, 0.0) + max(d.z, 0.0) * max(d.z, 0.0))
@muripoLife
muripoLife / file0.txt
Last active February 26, 2017 01:27
GLSLレイマーチング研究_距離関数について勉強してみた05(Torusの関数をいじる(距離関数導出編)) ref: http://qiita.com/muripo_life/items/1736da4175028e3fb2b7
S(u,v) =
\begin{pmatrix}
(R + r \cos u) \cos v \\
(R + r \cos u) \sin v \\
r \sin u
\end{pmatrix}
, (0 \leq u, v \leq 2 \pi), (0 < r < R)
@muripoLife
muripoLife / file0.txt
Last active February 26, 2017 02:08
GLSLレイマーチング研究_距離関数について勉強してみた06(Torusの関数をいじる(いじる編)) ref: http://qiita.com/muripo_life/items/3c2e23bd25a8c03b3714
// length使わない方法
float r = 0.3;
float R = 1.0;
return sqrt(p.x*p.x+p.y*p.y+p.z*p.z + R*R - 2.0 * R * sqrt(p.x*p.x+p.y*p.y) ) - r;
@muripoLife
muripoLife / file0.txt
Created February 26, 2017 11:04
GLSLレイマーチング研究_距離関数について勉強してみた07(Cylinderの関数をいじる) ref: http://qiita.com/muripo_life/items/b953f41eb6ae7ae40d24
S(u,v) =
\begin{pmatrix}
(c_x + r \cos u) \\
h \\
(c_z + r \sin u)
\end{pmatrix}
\\
(0<h,r), h:高さ,r:半径,\\
c_x:円の中心のx座標、c_z:円の中心のz座標
@muripoLife
muripoLife / file0.txt
Created February 28, 2017 12:55
GLSLレイマーチング研究_距離関数について勉強してみた08(Coneの関数をいじる) ref: http://qiita.com/muripo_life/items/8b7906860272d288927f
S(u,v) =
\begin{pmatrix}
\frac{c_y}{\sqrt{c_x}}v \cos u \\
\frac{c_y}{\sqrt{c_x}}v \sin u \\
v
\end{pmatrix}
\\
c_x:coneの鋭角度合、c_y:三角錐の半径
@muripoLife
muripoLife / file0.txt
Created March 3, 2017 13:07
GLSLレイマーチング研究_距離関数について勉強してみた09(Planeの関数をいじる) ref: http://qiita.com/muripo_life/items/074f69a5f0bac74e71e6
n_{x}x+n_{y}y+n_{z}z=n_{w}