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
Shader "Misha/Schwartzschild" | |
{ | |
Properties | |
{ | |
[Header(Black Hole)] | |
_EventHorizonRadius("Event Horizon Radius", Range(0.0, 0.5)) = 0.075 | |
[Header(Accretion)] | |
[HDR] _AccretionColor("Color", Color) = (1,1,1,1) |
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
/* | |
Based on the Anti-aliased Euclidean distance transform described by Stefan Gustavson and | |
Robin Strand. For further information, see https://contourtextures.wikidot.com/ and | |
https://web.archive.org/web/20220503051209/https://weber.itn.liu.se/~stegu/edtaa/ | |
The algorithm is an adapted version of Stefan Gustavson's code, it inherits the copyright | |
statement below, which applies to this file only. | |
The rewrite with Unity Burst support makes the execution 40 times faster by default, | |
and 75 times faster if the passed in textures are both of type TextureFormat.RGBAFloat. |
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 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. |
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 UnityEngine.EventSystems; | |
using UnityEngine.Rendering; | |
using UnityEngine.UIElements; | |
#if ENABLE_INPUT_SYSTEM | |
using UnityEngine.InputSystem.UI; | |
#endif | |
#if UNITY_EDITOR | |
using UnityEditor; |
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.Net; | |
using Mono.Debugger.Soft; | |
using static System.Console; | |
static int PidToPort(int pid) => 56000 + (pid % 1000); | |
var pid = 49149; // process ID of the Unity Editor or the IL2CPP Game | |
var ip = IPAddress.Loopback; // IP where the Unity Editor/Game is running |
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; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using UnityEngine; | |
namespace UnityUtilities | |
{ | |
/// <summary> | |
/// A replacement for `Task.Run()` that cancels tasks when entering or | |
/// exiting play mode in the Unity editor (which doesn't happen by default). |
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
// For the new DOTS animation. Although you need to use DrawMeshInstanced yourself, Hybrid renderer does not support instanced | |
// props for builtin. | |
Shader "Custom/VertexSkinning" | |
{ | |
Properties | |
{ | |
_Color ("Color", Color) = (1,1,1,1) | |
_MainTex ("Albedo (RGB)", 2D) = "white" {} | |
_Glossiness ("Smoothness", Range(0,1)) = 0.5 |
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 Sample | |
{ | |
static int gsN = 127; // N(N+1)/2 = 8128 < 2^{13} | |
static float gsB = 2 * gsN + 1; | |
static float gsB2 = gsB * gsB; | |
static float gsFactor = (gsN - 1) * Mathf.Sqrt(0.5f); | |
static float gsInvFactor = 1.0f / gsFactor; | |
public static ushort CompressNormal(Vector3 normal) | |
{ |
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
/** A fragment shader to convert NV12 to RGB. | |
* Input textures Y - is a block of size w*h. | |
* texture UV is of size w*h/2. | |
* Remember, both U and V are individually of size w/2*h/2, but they are interleaved. | |
* The layout looks like this : | |
* ---------- | |
* | | | |
* | Y | size = w*h | |
* | | | |
* |________| |
NewerOlder