Skip to content

Instantly share code, notes, and snippets.

@Split82
Split82 / UnityShadersCheatSheet.shader
Created April 17, 2018 10:07
Unity Shaders Cheat Sheet
Shader "Name" {
Properties {
_Name ("display name", Range (min, max)) = number
_Name ("display name", Float) = number
_Name ("display name", Int) = number
_Name ("display name", Color) = (number,number,number,number)
_Name ("display name", Vector) = (number,number,number,number)
@JarkkoPFC
JarkkoPFC / sphere_screen_extents.h
Last active April 3, 2025 14:20
Calculates view space 3D sphere extents on the screen
struct vec3f {float x, y, z;};
struct vec4f {float x, y, z, w;};
struct mat44f {vec4f x, y, z, w;};
//============================================================================
// sphere_screen_extents
//============================================================================
// Calculates the exact screen extents xyzw=[left, bottom, right, top] in
// normalized screen coordinates [-1, 1] for a sphere in view space. For
// performance, the projection matrix (v2p) is assumed to be setup so that
@Phyronnaz
Phyronnaz / SampleHeightmap_Bicubic.ispc
Last active February 17, 2024 09:32
Bicubic heightmap interpolation in ISPC
// MIT License
//
// Copyright (c) 2023 Voxel Plugin
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@runevision
runevision / BurstMethodTester.cs
Last active April 5, 2025 08:05
Using Unity Burst directly on methods without jobs - unofficial example code
using Unity.Burst;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Jobs;
using UnityEngine;
// This example code demonstrates using Unity Burst directly on a static method without jobs.
// Unity NativeArrays can't be used directly in Unity Burst methods (only in Burst jobs),
// so we have to pass pointers to arrays instead.
@a-gruzdev
a-gruzdev / EnumArray.cs
Last active December 13, 2024 16:05
Fixed length array associated with any enum and with handy PropertyDrawer
using System;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
[Serializable]
public class EnumArray<E, T> : ISerializationCallbackReceiver where E : Enum
{
public static readonly int s_Length;