Skip to content

Instantly share code, notes, and snippets.

View daneobyrd's full-sized avatar

daneobyrd

View GitHub Profile
@Anthelmed
Anthelmed / RaymarchSDF.hlsl
Last active October 18, 2023 21:26
A Texture3D SDF function to be used inside Unity shader graph
#ifndef RAYMARCHSDFINCLUDE_INCLUDED
#define RAYMARCHSDFINCLUDE_INCLUDED
#define STEPS 256
#define MAX_DISTANCE 500
#define MIN_DISTANCE 0.001
#if !SHADERGRAPH_PREVIEW
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
@ErikRikoo
ErikRikoo / ContinuousInputHandler.cs
Last active October 19, 2021 21:07
A useful script that allows you to run the method ApplyInputValue continuously while pressing a button in the new Unity Input System
using System.Collections;
using UnityEngine;
using UnityEngine.InputSystem;
public abstract class ContinuousInputHandler<InputType> : MonoBehaviour
where InputType : struct
{
private InputType m_ReadValue;
@staggartcreations
staggartcreations / GlobalShaderParams.cs
Last active January 18, 2024 08:40
Component for passing values through Shader.SetGlobalXXX
using System;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
[ExecuteInEditMode]
public class GlobalShaderParams : MonoBehaviour
{
@dondragmer
dondragmer / PrefixSort.compute
Created January 20, 2021 23:32
An optimized GPU counting sort
#pragma use_dxc //enable SM 6.0 features, in Unity this is only supported on version 2020.2.0a8 or later with D3D12 enabled
#pragma kernel CountTotalsInBlock
#pragma kernel BlockCountPostfixSum
#pragma kernel CalculateOffsetsForEachKey
#pragma kernel FinalSort
uint _FirstBitToSort;
int _NumElements;
int _NumBlocks;
bool _ShouldSortPayload;
@keijiro
keijiro / pugrad.md
Last active November 15, 2021 09:42

Pugrad

photo

Pugrad is a color gradient generator for Unity that supports commonly-used perceptually uniform colormaps.

At the moment, Pugrad supports the following colormaps:

@cjaube
cjaube / RenderingPipelineDefines.cs
Created May 29, 2020 02:38
Generate Unity #define directives for selected rendering pipelines.
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
using UnityEngine.Rendering;
[InitializeOnLoad]
public class RenderingPipelineDefines
{
enum PipelineType
@aras-p
aras-p / DebugNode.hlsl
Created January 3, 2020 10:37
"Print a value" custom function node code for Unity ShaderGraph
// Quick try at doing a "print value" node for Unity ShaderGraph.
// Tested on Unity 2019.2.17 with ShaderGraph 6.9.2.
//
// Use with CustomFunction node, with two inputs:
// - Vector1 Value, the value to display,
// - Vector2 UV, the UVs of area to display at.
// And one output:
// - Vector4 Color, the color.
// Function name is DoDebug.
@HAliss
HAliss / CurveDissolve.shader
Last active June 7, 2022 17:26
Creates a monochromatic texture with color values from a given animation curve
Shader "Custom/CurveDissolve"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Noise("Noise", 2D) = "white" {}
_CurveTexture("Curve texture", 2D) = "white" {}
_Cutoff("Cutoff", Range(0,1)) = 0
_Glossiness ("Smoothness", Range(0,1)) = 0.5
@HAliss
HAliss / ShaderTextureCombiner.cs
Created March 6, 2019 10:25
Texture combiner tool that uses a shader to combine different textures to specific color channels.
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
public class ShaderTextureCombiner : EditorWindow {
//Input textures
@sebbbi
sebbbi / FastUniformLoadWithWaveOps.txt
Last active March 29, 2025 07:34
Fast uniform load with wave ops (up to 64x speedup)
In shader programming, you often run into a problem where you want to iterate an array in memory over all pixels in a compute shader
group (tile). Tiled deferred lighting is the most common case. 8x8 tile loops over a light list culled for that tile.
Simplified HLSL code looks like this:
Buffer<float4> lightDatas;
Texture2D<uint2> lightStartCounts;
RWTexture2D<float4> output;
[numthreads(8, 8, 1)]