Skip to content

Instantly share code, notes, and snippets.

View CynicatPro's full-sized avatar
🥝
Making cool things

CynicatPro CynicatPro

🥝
Making cool things
View GitHub Profile
using System;
using System.Collections.Generic;
using UnityEngine;
public static class Utilities {
// shifts all array elements to the right, inserting newValue at the beginning
public static void ShiftInto<T>(T[] array, T newValue) {
T carry = newValue;
for (int i=0; i<array.Length; i++) {
// this is basically swapping carry and the array index
// source: Math for Game Programmers: Noise-Based RNG
// https://www.youtube.com/watch?v=LWFzPP8ZbdU
public static class CynNoise {
const uint BIT_NOISE0 = 0xB5297A4D;
const uint BIT_NOISE1 = 0x68E31DA4;
const uint BIT_NOISE2 = 0x1B56C4E9;
const uint PRIME0 = 3175861097;
const uint PRIME1 = 198491317;
const uint PRIME2 = 6542989;
@CynicatPro
CynicatPro / OutlineShader.shader
Last active October 21, 2020 12:57
A simple outline shader for unity
Shader "Unlit/OutlineShader" {
Properties {
[HDR] _OutlineColor ("Outline Color", Color) = (1,1,1,1)
_OutlineRadius ("Outline Radius", Float) = 0.1
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 100
Pass {
using System;
using System.Collections.Generic;
using UnityEngine;
public static class VRMath {
#region Vector/Quaternion Functions
public static Quaternion FromToQuaternion(Quaternion from, Quaternion to) => to * Quaternion.Inverse(from);
public static Vector3 EulerDelta(Quaternion from, Quaternion to) {
var rot = to * Quaternion.Inverse(from);
using UnityEngine;
using UnityEngine.XR;
[DefaultExecutionOrder(-10000)]
public class VRSettings : MonoBehaviour {
public float resolutionScale = 1.4f;
void Awake() {
XRSettings.eyeTextureResolutionScale = resolutionScale;
Time.fixedDeltaTime = Time.timeScale / XRDevice.refreshRate;