Skip to content

Instantly share code, notes, and snippets.

View runewake2's full-sized avatar

Sam Wronski runewake2

View GitHub Profile
@runewake2
runewake2 / GenericObjectPool.cs
Created March 1, 2017 06:23
Unity 3D Generic Object Pool for pooling a set object.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Creates a cached object pool for reduced memory thrashing.
// Developed as a part of World of Zero, an interactive programming YouTube channel: youtube.com/worldofzerodevelopment
public class GenericObjectPool : MonoBehaviour
{
public int count;
public GameObject prefab;
using System;
namespace CSharp7PatternMatching
{
// Built for World of Zero: https://youtu.be/PQucU3VFiBA
class Program
{
static void Main(string[] args)
{
for (int i = 1; i < 100; ++i)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/*
* Construct a bridge as a tracked object moves across it.
* Created as a part of World of Zero
* See it in action here: https://youtu.be/GaQBLD7bGCM
*/
public class BridgeBuilder : MonoBehaviour
@runewake2
runewake2 / RevealingShader.shader
Created April 1, 2017 20:19
Shader that only renders when inside a light cone.
// Developed as a part of World of Zero: https://youtu.be/b4utgRuIekk
Shader "Custom/RevealingShader" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
_LightDirection("Light Direction", Vector) = (0,0,1,0)
_LightPosition("Light Position", Vector) = (0,0,0,0)
@runewake2
runewake2 / datacube.ino
Created April 2, 2017 03:43
Data Cube arduino code for reading serial information and displaying it as pixels on a neopixel light strip.
// DATA CUBE
// Written as a part of World of Zero see: youtube.com/worldofzerodevelopment
// for videos on creating this and other fun projects
#include <Adafruit_NeoPixel.h>
#define PIN 6
#define N_LEDS 240
typedef struct {
uint8_t r;
@runewake2
runewake2 / TriplanarTesselatedShader.shader
Created April 2, 2017 19:33
Initial pass at a triplanar tesselated shader as created in this video: https://youtu.be/KCKN44-dMOY
// Upgrade NOTE: replaced '_World2Object' with 'unity_WorldToObject'
Shader "Custom/TriPlanarTesselatedShader" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
_Displacement("Displacement", Range(0, 1.0)) = 0.3
_EdgeLength("Edge length", Range(2,50)) = 5
@runewake2
runewake2 / Dice.cs
Created May 24, 2017 04:40
Dice Roller used to determine which side of a dice has been rolled. Generic implementation capable of working for any number of sided object.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Written as part of World of Zero
// Video available here: https://youtu.be/hmDF9PvMDVw
public class Dice : MonoBehaviour
{
public SideResults selectedResult;
public int selectedVector;
@runewake2
runewake2 / VoxelShader.shader
Created June 23, 2017 03:54
Unity Voxel Terrain basic blended shader. https://youtu.be/btOs50kk9IA
// Developed as part of World of Zero: www.worldofzero.com
Shader "Custom/VoxelShader" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_Texture1("Texture 1 (RGB)", 2D) = "white" {}
_Texture2("Texture 2 (RGB)", 2D) = "white" {}
_Texture3("Texture 3 (RGB)", 2D) = "white" {}
_Texture1Height("Texture 1 Height (R)", 2D) = "black" {}
_Texture2Height("Texture 2 Height (R)", 2D) = "black" {}
@runewake2
runewake2 / GrassPhysics.cs
Created July 6, 2017 22:46
Grass Physics.CS class from Simulating Grass Physics and Trampling in Compute Shaders video: https://youtu.be/gF1LZNOUb9w
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GrassPhysics : MonoBehaviour
{
[HideInInspector] public ComputeShader calculationEngine;
public Texture2D initialInput;
public Texture2D springynessMap;
@runewake2
runewake2 / FancyBoxShader.shader
Created July 13, 2017 05:28
Shader code from Transformation Matrices Shader video on World of Zero
// Shader developed for the Transformation Matrices Shader video on World of Zero.
// https://www.youtube.com/watch?v=VzhxginBhdc
// Developed for Boxes/Cubes but should work anywhere
Shader "Custom/FancyBoxShader" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
_OriginOffset ("Offset", Float) = 0.0