Skip to content

Instantly share code, notes, and snippets.

View ta-david-yu's full-sized avatar

Ta David Yu ta-david-yu

View GitHub Profile
@FreyaHolmer
FreyaHolmer / GpuPrinter.cginc
Last active February 17, 2026 17:42
A unity shader .cginc to draw numbers in the fragment shader - see the first comment below for example usage!
///////////////////////////////////////////////////////////////////////////////
// ABOUT: A unity Shader .cginc to draw numbers in the fragment shader
// AUTHOR: Freya Holmér
// LICENSE: Use for whatever, commercial or otherwise!
// Don't hold me liable for issues though
// But pls credit me if it works super well <3
// LIMITATIONS: There's some precision loss beyond 3 decimal places
// CONTRIBUTORS: yes please! if you know a more precise way to get
// decimal digits then pls lemme know!
// GetDecimalSymbolAt() could use some more love/precision
@laytan
laytan / renderer.odin
Last active November 2, 2025 13:45
Example Odin font renderer using fontstash and WebGPU
package vendor_wgpu_example_fontstash
import intr "base:intrinsics"
import "core:fmt"
import "core:math/linalg"
import sa "core:container/small_array"
import fs "vendor:fontstash"
import "vendor:wgpu"
@jakubtomsu
jakubtomsu / fontstash_sokol_gfx.odin
Last active November 2, 2025 13:50
Example font renderer using fontstash and sokol_gfx in Odin
// This is an example usage of vendor:fontstash with sokol_gfx.
// By Jakub Tomšů
//
// https://gist.github.com/jakubtomsu/5ee4fdfee23df893f6f61b4692dcf895
//
// This won't compile on it's own, but it contains all of the interesting parts.
// It should be pretty obvious how to modify it to your needs, if not let me know.
//
// The genral per-frame work is this:
// - renderer_draw_text appends quads to a cpu-side buffer
@DaseinPhaos
DaseinPhaos / hot_reload.odin
Last active December 1, 2025 08:52
demonstrates how to hot reload config files on debug builds with odin
package hot_reload
when ODIN_DEBUG==true {
import "core:path/filepath"
import "core:os"
import "core:sync"
import "core:time"
import "core:strings"
import "core:thread"
}
import "core:fmt"
// 오차가 계속 누적되는 듯
glm::vec3 angle = glm::eulerAngles(B.rotation);
angle = glm::degrees(angle);
ImGui::SliderFloat3("Rotation", (float*)&angle, -180.f, 180.f);
angle.y = glm::clamp(angle.y, -91.f, 91.f);
B.rotation = glm::radians(angle);
y에 90을 넣어도, 다시 들어올때는 89.98 정도가 나옴
eulerAngles 함수는 -90 ~ 90 이 제한임 // https://gamedev.stackexchange.com/questions/183771/euler-angle-and-quaternion-conversion-become-weird-when-yaw-is-bigger-than-90-de
// based on xxhash32
unsigned int hash(char *data, size_t len)
{
unsigned int hash;
if (len < 4) {
// load 3 bytes, overlapping if len < 3
static unsigned char offset1[4] = { 0,0,1,1 };
static unsigned char offset2[4] = { 0,0,0,2 };
unsigned int h = data[0] + (data[offset1[len]]<<8) + (data[offset2[len]]<<16);
h = xxprime1 + h*xxprime2;
@TheAllenChou
TheAllenChou / SdfQuantize.cginc
Last active July 6, 2020 14:33
Smooth Quantization of Signed Distance Field Sample Points
float3 quantize(float3 p, float cellSize, float strength)
{
float3 r = p / cellSize;
float3 f = floor(r);
float3 t = r - f;
return (f + smoothstep(0.0f, 1.0f, strength * (t - 0.5f) + 0.5f)) * cellSize;
}
@raysan5
raysan5 / custom_game_engines_small_study.md
Last active May 1, 2026 19:01
A small state-of-the-art study on custom engines

CUSTOM GAME ENGINES: A Small Study

a_plague_tale

WARNING: Article moved to separate repo to allow users contributions: https://github.com/raysan5/custom_game_engines

A couple of weeks ago I played (and finished) A Plague Tale, a game by Asobo Studio. I was really captivated by the game, not only by the beautiful graphics but also by the story and the locations in the game. I decided to investigate a bit about the game tech and I was surprised to see it was developed with a custom engine by a relatively small studio. I know there are some companies using custom engines but it's very difficult to find a detailed market study with that kind of information curated and updated. So this article.

Nowadays lots of companies choose engines like [Unreal](https:

How Unity's ECS Unity.Transforms works.

A breakdown of how Unity's new ECS-based hierarchical transform system works.

Hierarchy

Let's first consider Unity's hierarchy implementation, which is almost entirely separate from the transform system. The only things shared are the Parent and Child component types. This is an important note, as it means no diff information about the hierarchy is communicated to the larger transform system. _There is

@TheAllenChou
TheAllenChou / Seek.cs
Last active February 2, 2025 16:22
Value Seeking
// example of how to move a current value towards a target value at a constant speed
// without going over the target value
// formula is the same for vectors of any dimension
Vector3 Seek(Vector3 currentValue, Vector3 targetValue, float maxSpeed, float dt)
{
// delta/difference from current value to target value
Vector3 delta = targetValue - currentValue;
// don't take the square root of magnitude yet
// so we can potentially early out on degenerate case of currenvValue ~= targetValue