This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.Rendering; | |
public class AsyncCPUTexture<T> where T:struct { | |
protected bool active = false; | |
protected AsyncGPUReadbackRequest req; | |
protected Vector2Int size; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Kern32 { | |
[DllImport("kernel32.dll", EntryPoint = "CopyMemory", SetLastError = false)] | |
public static extern void CopyMemory(System.IntPtr dest, System.IntPtr src, uint count); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef NOISE_SIMPLEX_FUNC | |
#define NOISE_SIMPLEX_FUNC | |
/* | |
Description: | |
Array- and textureless CgFx/HLSL 2D, 3D and 4D simplex noise functions. | |
a.k.a. simplified and optimized Perlin noise. | |
The functions have very good performance | |
and no dependencies on external data. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
namespace Gist { | |
public static class BoxMuller { | |
public const float TWO_PI = 2f * Mathf.PI; | |
public static Vector2 Gaussian() { | |
var u1 = Random.value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Threading; | |
namespace Gist { | |
public static class Parallel { | |
static AutoResetEvent[] _resets; | |
public static void For(int fromInclusive, int toExclusive, System.Action<int> body) { | |
var numThreads = 2 * System.Environment.ProcessorCount; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
namespace Gist { | |
/* | |
* A speed-improved simplex noise algorithm for 2D, 3D and 4D in Java. | |
* | |
* Based on example code by Stefan Gustavson ([email protected]). | |
* Optimisations by Peter Eastman ([email protected]). | |
* Better rank ordering method by Stefan Gustavson in 2012. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef __DEPTH_CGINC__ | |
#define __DEPTH_CGINC__ | |
float Z2EyeDepth(float z) { | |
return unity_OrthoParams.w < 0.5 | |
? LinearEyeDepth(z) | |
: ((_ProjectionParams.z - _ProjectionParams.y) * z + _ProjectionParams.y); | |
} | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
namespace nobnak.Blending { | |
public class AutoHideCursor : MonoBehaviour { | |
public float hideAfterSeconds = 3f; | |
public float thresholdInPixels = 3f; | |
float _lastTime; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UVWorld : MonoBehaviour { | |
Mesh _mesh; | |
Vector3[] _vertices; | |
int[] _triangles; | |
Vector2[] _uvs; | |
Vector3[] _normals; | |
Triangle2D[] _uvTris; | |
void Awake() { | |
_mesh = GetComponent<MeshFilter>().sharedMesh; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
namespace Gist { | |
public static class LensShift { | |
public static void Frustum(this Camera cam, out float left, out float right, out float bottom, out float top, out float near, out float far) { | |
near = cam.nearClipPlane; | |
far = cam.farClipPlane; |
NewerOlder