Skip to content

Instantly share code, notes, and snippets.

View Vavassor's full-sized avatar

Andrew Dawson Vavassor

View GitHub Profile
@Vavassor
Vavassor / Indexed Color.shader
Created October 12, 2026 20:16
Palette color shader with color cycling for Unity game engine
// This is a palette color shader for Unity game engine. It supports color cycling/palette shifting.
//
// The "index" is a greyscale image where each value is used to look up a color in the "palette" image.
// The palette can be any horizontal gradient.
//
// Blurring indices can look up the wrong color in the palette. So use an index with sharp pixels and no anti-aliasing.
// For mipmaps, generate mipmaps using nearest neighbor filter. Which can be done using GIMP by exporting as a .dds file.
// Or turn off mipmaps in the texture settings, or in this shader using the "filter mode."
//
// This shader is from this post: https://x.com/Vavassor/status/2109723733430517917
@Vavassor
Vavassor / Unlit Billboard Points.shader
Last active October 6, 2026 20:58
Unlit Billboard Geometry Shaders
// Billboards are a flat image or sprite that always face the camera. This shader creates a billboard for each point
// in a point cloud. (a mesh using MeshTopology.Points)
//
// This shader is for Unity's built in render pipeline.
//
// MIT License
// Copyright (c) 2025 Andrew Dawson
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
@Vavassor
Vavassor / Wire Surface.shader
Created November 19, 2025 20:13
Wire Shader for Unity's built in render pipeline. Based on Phone-wire AA by Humus
// Wire shader that prevents prevent thin wires from becoming disconnected pixels at a distance.
//
// The wire drawing method is based on "Phone-wire AA" by Emil Persson aka Humus.
// https://www.humus.name/index.php?page=3D&ID=89
//
// MIT License
// Copyright © 2025 Andrew Dawson
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
@Vavassor
Vavassor / PropManagerEditor.cs
Created November 8, 2025 00:15
VRChat U# example for setting a singleton manager reference on many objects, using a button.
using UdonSharpEditor;
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(PropManager)), CanEditMultipleObjects]
public class PropManagerEditor : UnityEditor.Editor
{
public override void OnInspectorGUI()
{
if (UdonSharpGUI.DrawDefaultUdonSharpBehaviourHeader(target)) return;
@Vavassor
Vavassor / IntSetting.cs
Created October 14, 2025 22:18
VRChat U# Integer Sync Example
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
public class IntSetting : UdonSharpBehaviour
{
[SerializeField, UdonSynced] private int valueSync;
public void SetValue(int newValue)
@Vavassor
Vavassor / Lit Shader Template.shader
Last active December 17, 2025 19:44
Lit shader template for Unity game engine's built-in render pipeline
// This is a lit shader example that doesn't use surface shaders.
// It supports forward rendering in the Built-in render pipeline. (BiRP)
//
// Annoyingly, it's not possible to support baked emission without a custom inspector,
// because there's no other way to set globalIlluminationFlags. So if baked emissions are required,
// switch the inspector to debug mode and change the flags manually.
Shader "Orchid Seal/Lit Shader Template"
{
Properties
{
@Vavassor
Vavassor / Blend Modes.hlsl
Created September 11, 2025 20:16
Photoshop Blend Modes in HLSL
// Photoshop Blend Modes in HLSL
#ifndef OSP_BLEND_MODE_HLSL_
#define OSP_BLEND_MODE_HLSL_
// The following blend modes are trivial! "s" is the backdrop and "t" is the top color.
// Add (Linear Dodge): s + t
// Darken: min(s, t)
// Divide: s / t
// Lighten: max(s, t)
// Multiply: s * t
@Vavassor
Vavassor / Blend Modes.txt
Last active July 29, 2025 23:21
Photoshop blend modes in Unity ShaderLab
Photoshop blend modes in Unity ShaderLab
About Blend Modes
https://docs.unity3d.com/6000.0/Documentation/Manual/SL-Blend.html
The following modes are used for combining the output of a shader to the framebuffer. (the screen, basically) If you wish to blend colors within a shader, instead see this article "Photoshop Blend Modes in HLSL" by Ryan Juckett. https://www.ryanjuckett.com/photoshop-blend-modes-in-hlsl/
// Additive (aka Linear Dodge)
Blend One One
@Vavassor
Vavassor / TransformUtilities.cs
Created February 14, 2025 10:33
Transform math without the Transform component in Unity
using UnityEngine;
public static class TransformUtilities
{
/*
Transforms represent a position, orientation (rotation), and scale of an object. They also
represent a translation, rotation, and dilation relative to position (0, 0, 0),
rotation (0, 0, 0, 1), and scale (1, 1, 1).
When a transform is applied to another, it is translated, rotated, and dilated. It combines transformations.
// Billboards are a flat image or sprite that always face the camera.
//
// For a single billboard, put the material on Unity's Quad mesh. You may want to try enabling GPU instancing on the
// material, because this shader disables batching! Billboarding uses the object pivot, but batching combines meshes
// so they all have one pivot.
//
// To use multiple billboards in one mesh choose Vertex as the Pivot Mode. For this you need a mesh that is a bunch of
// separate quads, each scaled down to a point. In Unity mesh import settings, make sure "Weld Vertices" is
// unchecked so they don't get welded together. Then this shader can display the billboards.
//