Skip to content

Instantly share code, notes, and snippets.

const DIRS: [Point; 4] = [Point(1, 0), Point(0, 1), Point(-1, 0), Point(0, -1)];
type FindPathResult = (Vec<Point>, usize);
#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, PartialOrd, Ord)]
pub struct Point(pub isize, pub isize);
impl Add for Point {
type Output = Point;
fn add(self, r: Point) -> <Self as std::ops::Add<Point>>::Output {
@Refsa
Refsa / GrabPassBlit.shader
Last active January 21, 2024 20:23
Grab Screen Feature for URP 2.0
Shader "Hidden/GrabPassBlit"
{
Properties { }
SubShader
{
Tags { "RenderType"="Opaque" }
Pass
{
Name "FinalBlit"
@Refsa
Refsa / Usage.cs
Last active August 10, 2023 06:18
DrawMeshInstancedIndirect with ShaderGraph and URP
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine;
class Render : MonoBehaviour
{
struct DrawData
{
public Vector3 Pos;
public Quaternion Rot;
@Refsa
Refsa / BlurEffect.compute
Last active November 9, 2023 08:24
Unity URP custom render feature for UI Blur
#pragma kernel Downscale
#pragma kernel GaussianBlurVertical
#pragma kernel GaussianBlurHorizontal
#pragma kernel BoxBlur
Texture2D<float4> _Source;
RWTexture2D<float4> _Dest;
float _Amount;
float2 _Size;
public class OptionException : System.Exception
{
public OptionException(string message) : base(message) { }
}
public struct Option<T>
{
T _value;
@Refsa
Refsa / URPSimpleLit.shader
Created October 31, 2020 09:03
Unity - Shader showing how to write a Simple Lit shader for Unity URP
Shader "Custom/URPSimpleLit"
{
Properties
{
_Color ("Color", Color) = (1,0,0,1)
}
SubShader
{
Tags {
"RenderPipeline" = "UniversalPipeline"
@Refsa
Refsa / SnakeOneLine.cs
Created October 6, 2020 09:26
Snake in "one line"
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class SnakeOneLine : MonoBehaviour
{
void OnEnable()
{
var quadgo = GameObject.CreatePrimitive(PrimitiveType.Quad);
@Refsa
Refsa / ReColors.cs
Last active October 13, 2020 12:08
All colors from https://simple.wikipedia.org/wiki/List_of_colors for use in Unity
// Colors scraped from https://simple.wikipedia.org/wiki/List_of_colors
public static class ReColors
{
public static readonly Color AMARANTH = new Color(229f / 255f, 43f / 255f, 80f / 255f);
public static readonly Color AMBER = new Color(255f / 255f, 191f / 255f, 0);
public static readonly Color AMETHYST = new Color(153f / 255f, 102f / 255f, 204f / 255f);
public static readonly Color APRICOT = new Color(251f / 255f, 206f / 255f, 177f / 255f);
public static readonly Color AQUAMARINE = new Color(127f / 255f, 255f / 255f, 212f / 255f);
public static readonly Color AZURE = new Color(0, 127f / 255f, 255f / 255f);
@Refsa
Refsa / GrabScreenFeature.cs
Last active April 9, 2024 13:04
Unity URP custom grab pass
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
public class GrabScreenFeature : ScriptableRendererFeature
{
[System.Serializable]
public class Settings