Skip to content

Instantly share code, notes, and snippets.

View rngtm's full-sized avatar
💭
I may be slow to respond.

rngtm rngtm

💭
I may be slow to respond.
View GitHub Profile
@rngtm
rngtm / sound04.glsl
Created November 24, 2021 16:23
GLSL Sound 04 - 和音を作るテスト
#define TAU (2.*3.14159265)
float DB(float db) { return pow(10.0, db/10.0); }
float sawWave(float phase)
{
return fract(TAU*phase);
}
float chordWave(float phase, int chord, int key)
{
@rngtm
rngtm / glslsound
Created November 23, 2021 17:30
GLSL Sound 03
#define PI acos(-1.0)
#define VOLUME pow(10.0, -5.0/10.0)
float DB(float db) { return pow(10.0, db/10.0); }
float random(float co) { return fract(sin(co*(91.3458)) * 47453.5453); }
struct Note
{
float freq;
};
@rngtm
rngtm / sound_trance.glsl
Last active November 23, 2021 09:46
GLSL Sound 02
#define PI acos(-1.0)
struct Note
{
float freq;
};
Note GetNote(int index)
{
Note n;
@rngtm
rngtm / GLSLSound 01
Last active November 23, 2021 06:24
GLSL Sound : 遺跡っぽいBGM
float Tone(int i)
{
return 420.0 * exp2(float(i + 2) / 12.0);
}
int g_key = 0;
#define PI acos(-1.0)
float SinWave(float time, float freq)
{
@rngtm
rngtm / TriangleTile.hlsl
Created July 17, 2021 03:47
Unity2021 ShaderGraph用 三角形タイル カスタムノード
void TriangleTile_float(
float2 UV,
float Scale,
out float Triangle,
out float2 TrianglePosition
)
{
#define N Scale
float2 p = UV;
p.x *= 0.86602; // sqrt(3)/2倍
@rngtm
rngtm / MobiusRing
Last active February 1, 2021 12:56
Houdini VEX でメビウスの輪
// tの分割数
int tDiv = 200;
// r
float rMin = -1; // rの最小値
float rMax = 1; // rの最大値
int rDiv = 2; // rの分割数
// t
float tMin = 0; // tの最小値
@rngtm
rngtm / HexagonTile.hlsl
Last active December 16, 2022 09:15
Unity ShaderGraphのCustomFunctionで六角形タイルを作るためのHLSLファイル
void HexagonTile_float(
float2 UV,
float Scale,
out float Hexagon, // 六角形
out float2 HexPos, // 六角形の位置
out float2 HexUV, // 六角形内のUVを出力
out float2 HexIndex // 六角形の番号
)
{
///////////////////////////////////////////////////////////////////
@rngtm
rngtm / TimeFrameConverter.cs
Last active March 5, 2020 00:08
時間 <->フレーム数 の相互変換ツール
using UnityEngine;
using UnityEditor;
namespace Tools
{
public class TimeFrameConverter : EditorWindow
{
static private Color darkColor = new Color(216f , 222f , 226f, 255f) / 255f;
static private GUIStyle rowStyle = null;
static private GUIStyle valueBoxStyle = null;
@rngtm
rngtm / Particle-AlphaBlended-Clamp.shader
Created January 9, 2020 14:53
TEXCOORD0.zで2値化するParticleSystem用シェーダー。 Unity2017.4.24f1で動作確認済み
Shader "Custom/Particles/Alpha Blended - Clamp(TEXCOORD0.z)" {
Properties{
_MainTex("Grayscale Texture", 2D) = "white" {}
}
Category{
Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" "PreviewType" = "Plane" }
Blend SrcAlpha OneMinusSrcAlpha // Alpha Blended
ColorMask RGB
Cull Off Lighting Off ZWrite Off
@rngtm
rngtm / random_walk_spread.pde
Last active January 5, 2019 16:29
ランダムウォークを複数回描画してpng出力するprocessingコード(.pde)
final boolean isSave = true; // save as png
final int FrameN = 4;
final int N = 5000; // random walk number
final int alpha = 15; // line alpha
// random walk parameter
final float startRadius = 45;
final float addRadius = 45;