Skip to content

Instantly share code, notes, and snippets.

@koturn
koturn / PtrToStringAnsi.vb
Created October 9, 2025 16:44
C文字列(UTF-8)からVBAの文字列(UTF-16)に変換する例
Private Declare PtrSafe Function lstrlenA Lib "kernel32" (ByVal lpString As LongPtr) As Long
Private Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
ByRef Destination As Any, _
ByVal Source As LongPtr, _
ByVal Length As Long)
Public Function PtrToStringAnsi(ByVal pStr As LongPtr) As String
Dim nLen As Long
Dim s As String
@koturn
koturn / compare_original_custom.sql
Created October 4, 2025 00:24
lilToonのシェーダーリソースのDB(SQLite3)を作成するスクリプト
SELECT
i.base_name,
c.base_name AS base_name_custom,
sm.member_name,
i.file_name AS file_name_internal,
c.file_name AS file_name_container,
i.shader_name,
c.shader_name_fmt,
i.tagval_render_type,
c.tagval_render_type AS tagval_render_type_custom,
@koturn
koturn / sqlite3_csvimport.sh
Last active October 4, 2025 11:08
SQLite3でNULLを考慮してCSVインポートを行うためのラッパースクリプト
#!/bin/bash
set -eu
import_schema='imp'
##
## Show help text of this script.
##
## stdout: Help text of this program.
@koturn
koturn / SQLiteSpecialTables.md
Last active October 29, 2025 02:48
SQLiteの特殊テーブル

sqlite_schema / sqlite_master / sqlite_temp_schema / sqlite_temp_master

公式サイトの説明

内容

カラム名 説明
type TEXT The sqlite_schema.type column will be one of the following text strings: 'table', 'index', 'view', or 'trigger' according to the type of object defined. The 'table' string is used for both ordinary and virtual tables.
name TEXT The sqlite_schema.name column will hold the name of the object. UNIQUE and PRIMARY KEY constraints on tables cause SQLite to create internal indexes with names of the form "sqlite_autoindex_TABLE_N" where TABLE is replaced by the name of the table that contains the constraint and N is an integer beginning with 1 and increasing by one with each constraint seen in the table definition. In a WITHOUT ROWID table, there is no sqlite_schema entry for the PRIMARY KEY, but the "sqlite_autoindex_TABLE_N" name is set aside for the PRIMARY KEY as if the sqlite_schema entry did
@koturn
koturn / CalcNormal.md
Created July 17, 2025 19:10
Tetrahedron Teqniqueの導出

陰関数の法線ベクトル

陰関数 $f$$f: \mathbb{R}^3 \mapsto \mathbb{R}$ )の正規化法線ベクトル $\boldsymbol{n}$$\boldsymbol{n} \in \mathbb{R^3}$ ) は下記のように求められる.

$$ \begin{align} \boldsymbol{n} &= normalize(\nabla f( \boldsymbol{p} )) \ &= normalize \begin{pmatrix} \dfrac{\partial f(\boldsymbol{p})}{\partial x} \

@koturn
koturn / Light Volume PBR.shader.shader
Created May 27, 2025 19:57
VRCLightVolumesのサンプルコード(Amplify Shader Editorの出力)を人間向けに読みやすくしたやつ
Shader "Light Volume Samples/Light Volume PBR"
{
Properties
{
_MainTex("Albedo", 2D) = "white" {}
_Color("Color", Color) = (1,1,1,1)
[NoScaleOffset]_MetallicGlossMap("Metal AO Smoothness", 2D) = "white" {}
_Metallic("Metallic", Range( 0 , 1)) = 0
_Glossiness("Smoothness", Range( 0 , 1)) = 1
_OcclusionStrength("AO", Range( 0 , 1)) = 1
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
#if !NET9_0_OR_GREATER
using Lock = object;
#endif // !NET9_0_OR_GREATER
@koturn
koturn / unpack_unitypackage.bash
Created May 8, 2024 14:46
unitypackageを展開するbashスクリプト
#!/bin/bash
set -eu
if [ $# -lt 1 ]; then
echo Invalid arguments 1>&2
echo [USAGE]
echo $0 UNITYPACKAGE
exit 1
fi
@koturn
koturn / ListUtil.cs
Last active March 18, 2025 11:39
List<T>の内部の配列を取得するやつ(with Static Type Cache)
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
namespace Koturn
{
/// <summary>
/// Provides some utility methods of <see cref="List{T}"/>.
@koturn
koturn / ToggleKeywordUtil.cs
Created September 16, 2023 15:18
Unityのシェーダーで[Toggle]が付与されているプロパティのキーワードをC#側から切り替えるやつ(シェーダー側の定義が主)
using System;
using System.Linq.Expressions;
using System.Reflection;
using UnityEditor;
using UnityEngine;
namespace Koturn
{
/// <summary>