Skip to content

Instantly share code, notes, and snippets.

// original : https://stackoverflow.com/a/38974483
public class SeekableAesStream : Stream
{
private Stream baseStream;
private AesManaged aes;
private ICryptoTransform encryptor;
public bool autoDisposeBaseStream { get; set; } = true;
/// <param name="salt">//** WARNING **: MUST be unique for each stream otherwise there is NO security</param>
@edom18
edom18 / CaptureRendererFeature.cs
Last active September 9, 2023 22:43
Unity URPのScriptableRendererFeatureで画面をキャプチャ
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
public class CaptureRendererFeature : ScriptableRendererFeature
{
public event System.Action<CaptureRendererFeature> OnCaptured;
[SerializeField] private RenderPassEvent _renderPassEvent = RenderPassEvent.AfterRenderingOpaques;
@edom18
edom18 / convert-struct.cs
Created February 13, 2022 23:31
Convert a struct array to a byte array with GCHandle
[StructLayout(LayoutKind.Sequential)]
public struct Pixel32
{
public byte r;
public byte g;
public byte b;
public byte a;
}
// -----------------------
@edom18
edom18 / RectangleMask.hlsl
Created November 20, 2019 07:23
This code provide a mask for free aspect rectangle.
Shader "NrealRoom/ViewMask"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
_Width("Width", Float) = 10.0
}
SubShader
{
Cull Off ZWrite Off ZTest Always
@edom18
edom18 / file0.txt
Created December 8, 2018 23:36
[WebGL] レイマーチングでアンチエイリアス(FXAA)してみる ref: https://qiita.com/edo_m18/items/c211fea23b4747a8da3c
maxLuma = max(nw,ne,sw,se)
contrast = max(nw,ne,sw,se,m) - min(nw,ne,sw,se,m)
if(contrast >= max(minThreshold, maxLuma * threshold))
@edom18
edom18 / file0.txt
Created November 23, 2018 03:59
gdbを使ってCのデバッグを行うメモ ref: https://qiita.com/edo_m18/items/fee0ab976bf9181f5712
$ apt-get build-dep gdb
$ apt-get source gdb
$ cd gdb-7.7.1 # 適宜、DLされたバージョンに置き換えてください
$ ./configure --enable-tui=yes
$ make
# grab a coffee
$ sudo make install
@edom18
edom18 / 0.0以下の分岐
Last active June 27, 2024 14:34
[コードリーディング vol.1] レイマーチングによる波表現を読み解く ref: https://qiita.com/edo_m18/items/a575606a60b21f0d2c57
if (hmid < 0.0)
{
tx = tmid;
hx = hmid;
}
@edom18
edom18 / Domain-warping
Last active June 27, 2024 14:34
フラクタルブラウン運動とドメインワープ ref: https://qiita.com/edo_m18/items/e4d7a084cdbbfdc7863c
/**
* Fractal Brownian Motion
*
* Reference: https://thebookofshaders.com/13/
*
* See also: http://www.iquilezles.org/www/articles/morenoise/morenoise.htm
* : http://www.iquilezles.org/www/articles/warp/warp.htm
*/
const vec3 mixColor1 = vec3(0.8, 0.35, 0.12);
@edom18
edom18 / file0.txt
Last active June 27, 2024 14:35
ゼロから作るDeepLearning -Pythonで学ぶディープラーニングの理論と実装-を読んだメモ ~ニューラルネットワーク編~ ref: https://qiita.com/edo_m18/items/f5ab5cd2d1293bee15c2
\begin{eqnarray}
y {=}
\begin{cases}
0 & : (b + w_1 x_1 + w_2 x_2) \leq 0 \\\
1 & : (b + w_1 x_1 + w_2 x_2) > 0
\end{cases}
\end{eqnarray}
@edom18
edom18 / AOの計算
Created September 27, 2018 05:04
レイマーチングでAmbient Occlusion ref: https://qiita.com/edo_m18/items/63dbacb57db3b7734483
// なんちゃってAOを計算する
//
// +-----------------+--------------------+
// | ro = Ray Origin | rd = Ray Direction |
// +-----------------+--------------------+
vec4 genAmbientOcclusion(vec3 ro, vec3 rd)
{
vec4 totao = vec4(0.0);
float sca = 1.0;