Skip to content

Instantly share code, notes, and snippets.

@ivan-r-sigaev
ivan-r-sigaev / Perlin.cs
Last active July 25, 2025 19:54 — forked from Flafla2/Perlin.cs
Improved Perlin Noise Implementation in C#
// Algorithm inspired by https://gist.github.com/Flafla2/1a0b9ebef678bbce3215
public class PerlinGen
{
private readonly int[] p; // Randomly shuffled array of values from 0 to 255.
// Values are repeated twice to get performance boost
// from avoiding the use of modulo operator.
public PerlinGen(int seed)
{
🎮 THE FINALS 🕘 340 hrs 34 mins
🚓 Grand Theft Auto V Legacy 🕘 268 hrs 22 mins
🎮 SCP: Secret Laboratory 🕘 159 hrs 45 mins
🎮 Limbus Company 🕘 157 hrs 47 mins
🎮 Fall Guys 🕘 96 hrs 27 mins
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityToolbarExtender;
/// <summary>
@nkrkt
nkrkt / Singleton.cs
Created January 28, 2020 03:21
base class for singletons, which inherits from monobehaviour (Unity)
using UnityEngine;
/*
* Base class for singletons. Inherit from this class to create a monobehavior singleton.
* This is useful for manager classes, main game logic, or any 'static' class that you want handy access to or need monobehavior functionality.
*
* Usage:
* public class SomeManagerClass : Singleton<SomeManagerClass>
* {
* public bool someBool;
* }
@tntmeijs
tntmeijs / unitythreedimensionalperlinnoise.cs
Last active October 4, 2024 20:23
A 3D implementation using the 2D Perlin noise function of Unity3D.
public static float Noise3D(float x, float y, float z, float frequency, float amplitude, float persistence, int octave, int seed)
{
float noise = 0.0f;
for (int i = 0; i < octave; ++i)
{
// Get all permutations of noise for each individual axis
float noiseXY = Mathf.PerlinNoise(x * frequency + seed, y * frequency + seed) * amplitude;
float noiseXZ = Mathf.PerlinNoise(x * frequency + seed, z * frequency + seed) * amplitude;
float noiseYZ = Mathf.PerlinNoise(y * frequency + seed, z * frequency + seed) * amplitude;