Skip to content

Instantly share code, notes, and snippets.

View reveriejake's full-sized avatar

Jake Fletcher reveriejake

View GitHub Profile
@reveriejake
reveriejake / SpiralLoop.cs
Last active March 21, 2023 09:39
An example of a simplified spiral loop algorithm for iterating in a square.
public static class SpiralLoop
{
public static void ExecuteCenterToOutter(int width, System.Action<int, int> callback)
{
// Run the loop from the center outwards
for (int r = 0; r < width; r++)
{
// If we are on center, do not run the edge loops
if (r == 0)
{
@reveriejake
reveriejake / CSFastNoise.compute
Last active November 22, 2022 23:19
A set of compute shaders, hlsl shaders, and cs scripts that will generate and render a 3D surface given a set of noise parameters. The main feature being the 'FastNoiseGenerator.cs' script, which provides a single method call to generate 2D surface noise.
/* Creates a 1D array of noise values when provided with a 2D width and noise params.
* To be used in conjunction with FastNoiseLite HLSL. https://github.com/Auburn/FastNoise
*
* Created by: Jacob Fletcher
*/
#pragma kernel CSNoiseArray
#include "Include/PicoFastNoiseUtils.hlsl"
/* Written by Jacob Fletcher - 2022 | Free to alter and use! */
using UnityEngine;
namespace PicoGames
{
public static class GradientExtensions
{
/// <summary>
/// Converts the Gradient into a new texture.
@reveriejake
reveriejake / InstancePrefab.cs
Last active November 12, 2020 03:07
Simplified 'prefab' that allows you to draw thousands of objects to the screen. Many thanks to Mike from toqoz.fyi for his help in solving some issues I had. This code is Inspired by his blog from https://toqoz.fyi/thousands-of-meshes.html
using UnityEngine;
using System.Collections.Generic;
using UnityEngine.Rendering;
namespace PicoGames.Prototype
{
[System.Serializable]
public class InstancePrefab
{
public GameObject prefab;
@reveriejake
reveriejake / MeshCombiner.cs
Last active April 6, 2023 11:17
More advanced mesh combiner that takes in a parent gameobject and combines all child meshes regardless of material count or triangle count. Outputs a lit of generated gameobjects that contain the combined meshe(s). Could probably use some optimizations ;). Modified and improved from https://www.youtube.com/watch?v=6APzUgckV7U&ab_channel=CraigPerko
using UnityEngine;
using System.Collections.Generic;
using System.Linq;
namespace PicoGames
{
public class MeshCombiner
{
const int MAX_VERT_COUNT = 65535;
@reveriejake
reveriejake / MS2DTerrainChunk.cs
Created February 18, 2017 11:53
Pico Games - Marching Squares Algorithm Simple
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PicoGames.Common;
namespace PicoGames.Terrains.MS2D
{
public class MS2DTerrainChunk : MonoBehaviour
{
@reveriejake
reveriejake / MeshBuffer.cs
Created February 18, 2017 11:50
Pico Games - Unity MeshBuffer Class
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace PicoGames.Common
{
[ExecuteInEditMode]
[RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))]
public class MeshBuffer : MonoBehaviour
{