Skip to content

Instantly share code, notes, and snippets.

View mutaphysis's full-sized avatar
🏠
Working from home

Henrik Hinrichs mutaphysis

🏠
Working from home
View GitHub Profile
@EddieCameron
EddieCameron / EdgeDetect.cs
Created September 3, 2017 00:08
EdgeDetection in new Unity Postprocessing Stack
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
[Serializable]
[PostProcess( typeof( EdgeDetectRenderer ), PostProcessEvent.BeforeStack, "Custom/EdgeDetectNormals" )]
public sealed class EdgeDetect : PostProcessEffectSettings {
public enum EdgeDetectMode {
@Borod4r
Borod4r / UnityShaders.xml
Last active October 25, 2021 13:26
Basic syntax highlight for Unity ShaderLab code in Project Rider
<!--
Basic syntax highlight for Unity ShaderLab code in Project Rider.
v1.0
Download this file and put it into your "filetypes" folder.
Windows Vista, 7, 8, 10:
<SYSTEM DRIVE>\Users\<USER ACCOUNT NAME>\.Rider10\config\filetypes
Mac OS X:
@cobbpg
cobbpg / Unity-hotswapping-notes.md
Last active February 17, 2024 19:04
Unity hotswapping notes

Unity hotswapping notes

Unity has built-in support for hotswapping, which is a huge productivity booster. This feature works not only with graphics assets like bitmaps and meshes, but also with code: if you edit the source and save it, the editor will save the state of the running game, compile and load the new code, then load the saved state and continue where it left off. Unfortunately, this feature is very easy to break, and most available 3rd party plugins have little regard for it.

It looks like there’s a lot of confusion about hotswapping in Unity, and many developers are not even aware of its existence – which is no wonder if their only experience is seeing lots of errors on the console when they forget to stop the game before recompiling... This document is an attempt to clear up some of this confusion.

Nota bene, I’m not a Unity developer, so everything below is based on blog posts and experimentation. Corrections are most welcome!

The basic flow of hotswapping

@daoshengmu
daoshengmu / SAO.glsl
Created April 26, 2015 16:30
SAO shader on Three.js
precision highp float;
precision highp int;
uniform mat4 viewMatrix;
uniform vec3 cameraPosition;
#extension GL_OES_standard_derivatives : enable
uniform float cameraNear;
uniform float cameraFar;
uniform bool onlyAO;
uniform vec2 size;
@pyrtsa
pyrtsa / example.cpp
Last active August 29, 2015 13:56
C++1y: Using user-defined literals for making `std::chrono::duration`s
#include <chrono>
constexpr auto operator "" _days (unsigned long long n) { return std::chrono::hours(24 * n); }
constexpr auto operator "" _h (unsigned long long n) { return std::chrono::hours(n); }
constexpr auto operator "" _min (unsigned long long n) { return std::chrono::minutes(n); }
constexpr auto operator "" _s (unsigned long long n) { return std::chrono::seconds(n); }
constexpr auto operator "" _ms (unsigned long long n) { return std::chrono::milliseconds(n); }
constexpr auto operator "" _µs (unsigned long long n) { return std::chrono::microseconds(n); }
constexpr auto operator "" _ns (unsigned long long n) { return std::chrono::nanoseconds(n); }
# Get Sublime Text to use your rvm ruby without hardcoding a `$USER`.
#
# Include the configurations below the commend in the appropriate file listed below:
#
# - OS X ST2: ~/Library/Application Support/Sublime Text 2/Packages/Ruby/Ruby.sublime-build
# - OS X ST3: ~/Library/Application Support/Sublime Text 3/Packages/User/Ruby.sublime-build
# - Linux ST2: ~/.config/sublime-text-2/Packages/Ruby/Ruby.sublime-build
# - Linux ST3: ~/.config/sublime-text-3/Packages/User/Ruby.sublime-build
{
@transitive-bullshit
transitive-bullshit / billboard_sao.frag
Created September 30, 2013 21:08
WebGL GLSL SAO (Scalable Ambient Obscurance) fragment shader. SAO is a more efficient method for computing SSAO (Screen-Space Ambient Occlusion). Converts the g-buffer to an occlusion buffer which estimates local ambient occlusion at each fragment in screen-space. For details on the technique itself, see: McGuire et al [12] http://graphics.cs.wi…
// total number of samples at each fragment
#define NUM_SAMPLES {{ numSamples }}
#define NUM_SPIRAL_TURNS {{ numSpiralTurns }}
#define USE_ACTUAL_NORMALS {{ useActualNormals }}
#define VARIATION {{ variation }}
uniform sampler2D sGBuffer;
@bzgeb
bzgeb / TriggerContainerEditor.cs
Created September 28, 2012 14:52
Example Drag & Drop area in a custom inspector for the Unity editor
using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomEditor (typeof(TriggerContainer))]
public class TriggerContainerEditor : Editor
{
private SerializedObject obj;