Skip to content

Instantly share code, notes, and snippets.

View klutch's full-sized avatar

Graeme Collins klutch

View GitHub Profile
@klutch
klutch / UnityShadersCheatSheet.shader
Created August 17, 2019 14:15 — forked from Split82/UnityShadersCheatSheet.shader
Unity Shaders Cheat Sheet
Shader "Name" {
Properties {
_Name ("display name", Range (min, max)) = number
_Name ("display name", Float) = number
_Name ("display name", Int) = number
_Name ("display name", Color) = (number,number,number,number)
_Name ("display name", Vector) = (number,number,number,number)
struct PixelShaderOutput
{
float4 ColorA : COLOR0;
float4 ColorB : COLOR1;
float4 ColorC : COLOR2;
};
PixelShaderOutput PixelShaderFunction(VertexShaderOutput input)
{
PixelShaderOutput output;
@klutch
klutch / ShrinkAndDestroyScript.cs
Created March 30, 2015 19:43
ShrinkAndDestroyScript
using UnityEngine;
using System.Collections;
public class ShrinkAndDestroyScript : MonoBehaviour
{
public float time = 0.75f;
public iTween.EaseType easeType;
public float delay = 0f;
public bool destroyParent = false;
@klutch
klutch / BaseDestructibleScript.cs
Created March 6, 2015 22:07
Misc Destructible Terrain Scripts
using UnityEngine;
using System.Collections.Generic;
public class BaseDestructibleScript : MonoBehaviour
{
public List<string> tags;
public PhysicsMaterial2D chunkPhysicsMaterial;
virtual public void onCollision(GameObject collisionObject)
{
@klutch
klutch / gist:7151711
Created October 25, 2013 08:59
Fluid pixel shader
sampler baseSample : register(s0);
sampler postSource : register(s1);
float2 renderSize;
float4 LiquidPS(float2 texCoord:TEXCOORD0) : COLOR0
{
// Base texture has density information in the red channel,
// and x and y velocity in the green and blue channels.
float4 base = tex2D(baseSample, texCoord);
float alpha = step(0.5, base.a) * 0.8;
@klutch
klutch / gist:6709748
Created September 26, 2013 04:04
Some UI snippets. Warning: contains very ugly code.
abstract public class Screen : ITranslatable
{
protected ScreenSystem _screenSystem;
protected SpriteBatch _spriteBatch;
protected GamePadState _newGamepadState;
protected GamePadState _oldGamepadState;
protected KeyboardState _newKeyState;
protected KeyboardState _oldKeyState;
protected MouseState _newMouseState;
protected MouseState _oldMouseState;
@klutch
klutch / gist:5652781
Created May 26, 2013 13:25
Testing full screen toggle in MonoGame (WindowsGL)
#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.GamerServices;
#endregion