Skip to content

Instantly share code, notes, and snippets.

@dogles
dogles / markovjr_tech_notes.md
Last active June 27, 2024 09:41
Markov Jr. Technical Notes

Introduction

Markov Jr. is an open source C# application that creates procedural content primarily via applying Markov rewrite rules to a 2D or 3D grid. A rewrite rule has an input and output pattern, which essentially specifies what pattern to look for in the existing grid, and what to replace it with.

For example, given a 2D grid, this would replace any white dot with a white cross:

***/*W*/*** :: *W*/WWW/*W*

The left hand side is the rule input, and the right hand side is the output. The / character is used to delimit rows, and space is used to delimit Z-layers (in 3D grids). The input rule above translates to the 2D pattern:

@vermorel
vermorel / Half.cs
Last active November 26, 2023 22:43
C# Half-precision data type
/// ================ Half.cs ====================
/// The code is free to use for any reason without any restrictions.
/// Ladislav Lang (2009), Joannes Vermorel (2017)
using System;
using System.Diagnostics;
using System.Globalization;
namespace SystemHalf
{
@aras-p
aras-p / mvp.js
Created June 6, 2011 17:30
UNITY_MATRIX_MVP et al equivalents in script
// world, view, projection matrices
var world = obj.transform.localToWorldMatrix;
var view = cam.worldToCameraMatrix;
var proj = cam.projectionMatrix;
// the actual projection matrix used in shaders
// is actually massaged a bit to work across all platforms
// (different Z value ranges etc.)
var gpuProj = GL.GetGPUProjectionMatrix (proj, false);
var gpuMV = view * world; // UNITY_MATRIX_MV