Skip to content

Instantly share code, notes, and snippets.

View aras-p's full-sized avatar

Aras Pranckevičius aras-p

View GitHub Profile
@aras-p
aras-p / preprocessor_fun.h
Last active May 19, 2026 01:45
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@aras-p
aras-p / unity_6_empty_web_build.md
Last active May 10, 2026 11:22
Unity 6 "empty" web build file sizes

This short post by Defold people about "empty project build size" comparison between Defold, Unity and Godot (twitter, mastodon) sparked my interest.

It is curious that Godot builds seem to be larger than Unity? Would not have expected that! Anyway.

A way more extensive Unity "web" build comparison and analysics is over at https://github.com/JohannesDeml/UnityWebGL-LoadingTest but here are just my short notes in trying out Unity 6 (6.0.23 - Oct 2024).

Default (3D, URP) template

@aras-p
aras-p / building_oiio.md
Last active May 2, 2026 04:03
Building OpenImageIO from source locally

Windows

OIIO build instructions currently just say this for Windows:

Method 1 - from source I really need someone to write correct, modern docs about how to build from source on Windows.

So I decided to figure that out.

Easiest: get Blender first :)

@aras-p
aras-p / CustomMipImporter.cs
Created April 27, 2026 12:52
Unity Texture2D Custom Mipmap Importer
using UnityEngine;
using UnityEditor;
using System.IO;
using UnityEditor.AssetImporters;
[ScriptedImporter(2026_04_27, kFileExtension)]
public class CustomMipImporter : ScriptedImporter
{
public Texture2D[] m_Mips;
@aras-p
aras-p / foo.md
Created August 12, 2016 04:33
unity scene vs project vs game

There's no 100% clear view of what people mean by "project" or "game", but I think our docs & various materials would mean it like below.

Project typically talks about your, well, project in "source" form. "project folder" -- the whole folder with all your source files, that you work with. This has assets (textures, meshes, audio, animations, shaders etc.), game scripts and editor extensions (C#), various unity-specific files (scenes, prefabs, materials).

Game typically talks about the final end result, i.e. the thing you build from your project. It does not have to be a "game" of course. Sometimes (somewhat confusingly) the same thing is called "player" (BuildPlayer editor C# API).

Scene is a collection of objects typically operated on as a unit, usually for loading/unloading purposes during execution of your

@aras-p
aras-p / hg and git snippets and stats.md
Last active December 14, 2025 14:03
hg churn and log cheat sheet, ono graphql

Git

Fetch single branch (trunk): git fetch origin trunk:trunk (add -u flag when already on that branch)

Make a new worktree (similar to hg share): git worktree add --no-checkout --detach ../mynewfolder

Converting Hg repo to Git:

; get https://github.com/frej/fast-export somewhere
@aras-p
aras-p / prefix.shader
Created September 4, 2016 15:56
Prefix to compile Shadertoy shaders to Vulkan/SPIR-V
// pasting this in front of most shadertoys allows them to be compiled with:
// glslangValidator -V inputFile.frag -o outputFile.spv
#version 430
layout(binding = 1, std140) uniform glob {
uniform vec3 iResolution;
uniform float iGlobalTime;
uniform float iTimeDelta;
uniform int iFrame;
uniform float iFrameRate;
uniform float iChannelTime[4];
@aras-p
aras-p / stb_c_lexer
Last active November 26, 2025 21:19
// stb_c_lexer.h 0.01 -- public domain Sean Barrett 2013
// lexer for making little C-like languages with recursive-descent parsers
//
// This file provides both the interface and the implementation.
// To instantiate the implementation,
// #define STB_C_LEXER_IMPLEMENTATION
// in *ONE* source file, before #including this file.
//
// The default configuration is fairly close to a C lexer, although
// suffixes on integer constants are not handled (you can override this).
@aras-p
aras-p / DebugNode.hlsl
Created January 3, 2020 10:37
"Print a value" custom function node code for Unity ShaderGraph
// Quick try at doing a "print value" node for Unity ShaderGraph.
// Tested on Unity 2019.2.17 with ShaderGraph 6.9.2.
//
// Use with CustomFunction node, with two inputs:
// - Vector1 Value, the value to display,
// - Vector2 UV, the UVs of area to display at.
// And one output:
// - Vector4 Color, the color.
// Function name is DoDebug.
@aras-p
aras-p / foo.md
Last active October 7, 2025 16:28
Controlling fixed function states from materials/scripts in Unity

(typing off the top of my head, might not compile)

Since Unity 4.3:

In the shader, instead of writing Cull Off, write Cull [_MyCullVariable], the value will be fetched from the material or global float/int variable _MyCullVariable then.

You could have it be part of material, e.g. inside Properties block:

[Enum(Off,0,Front,1,Back,2)] _MyCullVariable ("Cull", Int) = 1