Skip to content

Instantly share code, notes, and snippets.

@ScottJDaley
ScottJDaley / RenderObjectsToTextureFeature.cs
Created September 6, 2022 19:31
Example of a URP Renderer Feature that can render objects (by layer mask) to a global texture
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
public class RenderObjectsToTextureFeature : ScriptableRendererFeature
{
public RenderObjectsToTexturePass.Settings Settings = new();
@ScottJDaley
ScottJDaley / Convolution3x3.hlsl
Last active June 8, 2023 09:40
Custom function for Unity shader graph to perform image processing convolutions
static float2 kernel3UVs[9] = {
float2(-1, 1), float2(0, 1), float2(1, 1),
float2(-1, 0), float2(0, 0), float2(1, 0),
float2(-1, -1), float2(0, -1), float2(1, -1),
};
void DoubleKernel3x3_float(Texture2D Texture, SamplerState Sampler, float TexelWidth, float TexelHeight, float2 UV,
float3x3 KernelX, float3x3 KernelY, float Thickness, out float Out)
{
const float2 texelSize = float2(TexelWidth, TexelHeight);
const float2 offset = Thickness / texelSize;
@ScottJDaley
ScottJDaley / Outline.shader
Last active April 2, 2024 03:09
Wide Outlines Renderer Feature for URP and ECS/DOTS/Hybrid Renderer
// Original shader by @bgolus, modified slightly by @alexanderameye for URP, modified slightly more
// by @gravitonpunch for ECS/DOTS/HybridRenderer.
// https://twitter.com/bgolus
// https://medium.com/@bgolus/the-quest-for-very-wide-outlines-ba82ed442cd9
// https://alexanderameye.github.io/
// https://twitter.com/alexanderameye/status/1332286868222775298
Shader "Hidden/Outline"
{
Properties
@ScottJDaley
ScottJDaley / Components.cs
Created July 8, 2021 16:21
Save and Load for Unity ECS using SerializeUtility
[Serializable]
public struct SaveTag : IComponentData { }
[Serializable]
public struct MissingRenderMeshTag : IComponentData { }
[Serializable]
public struct MissingPhysicsColliderTag : IComponentData { }
[Serializable]