Skip to content

Instantly share code, notes, and snippets.

View Vavassor's full-sized avatar

Andrew Dawson Vavassor

View GitHub Profile
@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 October 6, 2025 03:54
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.
//
// 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.
//
// This shader is for Unity's built in render pipeline.
//
// MIT License
// Copyright (c) 2025 Andrew Dawson
//
@Vavassor
Vavassor / lerp.js
Last active February 26, 2021 17:27
Linear Interpolation
/**
* Linearly interpolate, or produce a point that is a given fraction of the way
* between two other points.
*
* This is equivalent to the weighted arithmetic mean of the two points,
* where t is the weight.
*
* @param {number} v0 the starting bound, returned when t=0
* @param {number} v1 the ending bound, returned when t=1
* @param {number} t the fraction between the given data points, also called the interpolant
@Vavassor
Vavassor / rotate.c
Created March 20, 2019 21:23
Rotate a 2D vector by i turns of 90 degrees.
#include <math.h>
#include <stdio.h>
typedef union Float2
{
struct
{
float x;
float y;
};