Skip to content

Instantly share code, notes, and snippets.

View Torgo13's full-sized avatar

TW0 Torgo13

View GitHub Profile
@unitycoder
unitycoder / OptimalSpatialHashing.cs
Created October 6, 2024 14:16 — forked from adammyhre/OptimalSpatialHashing.cs
Unity Spatial Hashing with Jobs and Burst
using System;
using Unity.Burst;
using Unity.Collections;
using Unity.Jobs;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class OptimalSpatialHashing : MonoBehaviour {
@unitycoder
unitycoder / VertexBillboard.shader
Created September 4, 2024 21:49 — forked from camnewnham/VertexBillboard.shader
Point cloud shaders
Shader "Points/Billboard"
{
Properties
{
_PointSize("PointSize", Range(0, 0.1)) = 0.01
[Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend("Source Blend", Float) = 1 // "One"
[Enum(UnityEngine.Rendering.BlendMode)] _DstBlend("Destination Blend", Float) = 0 // "Zero"
[Enum(UnityEngine.Rendering.CompareFunction)] _ZTest("Depth Test", Float) = 4 // "LessEqual"
[Enum(DepthWrite)] _ZWrite("Depth Write", Float) = 1 // "On"
}
@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.
@LizzyFox-code
LizzyFox-code / collections.md
Last active February 17, 2025 22:23
Unity.Collections cheat sheet

Unity.Collections cheat sheet

The collections provided by this package fall into three categories:

  • The collection types in Unity.Collections whose names start with Native- have safety checks for ensuring that they're properly disposed and are used in a thread-safe manner.
  • The collection types in Unity.Collections.LowLevel.Unsafe whose names start with Unsafe- do not have these safety checks.
  • The remaining collection types are not allocated and contain no pointers, so effectively their disposal and thread safety are never a concern. These types hold only small amounts of data.

Allocators

@LizzyFox-code
LizzyFox-code / mathematics.md
Created January 24, 2024 15:54
Unity.Mathematics cheat sheet
@runevision
runevision / Shadows.cginc
Last active January 1, 2025 21:33
Water Foam Particle Shader
UNITY_DECLARE_SHADOWMAP(_SunCascadedShadowMap);
float4 _SunCascadedShadowMap_TexelSize;
#define GET_CASCADE_WEIGHTS(wpos, z) getCascadeWeights_splitSpheres(wpos)
#define GET_SHADOW_FADE(wpos, z) getShadowFade_SplitSpheres(wpos)
#define GET_SHADOW_COORDINATES(wpos,cascadeWeights) getShadowCoord(wpos,cascadeWeights)
/**
* Gets the cascade weights based on the world position of the fragment and the poisitions of the split spheres for each cascade.
@mkarneim
mkarneim / CustomUberPost.shader
Created August 4, 2023 12:26
UberPost.shader that also works together with Oculus Quest Passthrough mode
Shader "CustomUberPost" // "Hidden/Universal Render Pipeline/UberPost"
{
HLSLINCLUDE
#pragma exclude_renderers gles
#pragma multi_compile_local_fragment _ _DISTORTION
#pragma multi_compile_local_fragment _ _CHROMATIC_ABERRATION
#pragma multi_compile_local_fragment _ _BLOOM_LQ _BLOOM_HQ _BLOOM_LQ_DIRT _BLOOM_HQ_DIRT
#pragma multi_compile_local_fragment _ _HDR_GRADING _TONEMAP_ACES _TONEMAP_NEUTRAL
#pragma multi_compile_local_fragment _ _FILM_GRAIN
#pragma multi_compile_local_fragment _ _DITHERING
@Cyanilux
Cyanilux / CustomRendererFeature.cs
Last active February 1, 2025 14:37
Custom ScriptableRendererFeature/ScriptableRenderPass example for URP 2022+. From https://www.cyanilux.com/tutorials/custom-renderer-features/#full-example
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
public class CustomRendererFeature : ScriptableRendererFeature {
public class CustomRenderPass : ScriptableRenderPass {
private Settings settings;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
public class GlitchRenderFeature : ScriptableRendererFeature {
class CustomRenderPass : ScriptableRenderPass {
private Settings settings;
private FilteringSettings filteringSettings;