Skip to content

Instantly share code, notes, and snippets.

View EricHu33's full-sized avatar

EricHu EricHu33

View GitHub Profile
@FreyaHolmer
FreyaHolmer / GpuPrinter.cginc
Last active May 24, 2025 08:58
A unity shader .cginc to draw numbers in the fragment shader - see the first comment below for example usage!
///////////////////////////////////////////////////////////////////////////////
// ABOUT: A unity Shader .cginc to draw numbers in the fragment shader
// AUTHOR: Freya Holmér
// LICENSE: Use for whatever, commercial or otherwise!
// Don't hold me liable for issues though
// But pls credit me if it works super well <3
// LIMITATIONS: There's some precision loss beyond 3 decimal places
// CONTRIBUTORS: yes please! if you know a more precise way to get
// decimal digits then pls lemme know!
// GetDecimalSymbolAt() could use some more love/precision
Shader "URP/CustomLighting"
{
Properties
{
_BaseColor ("Base Color", Color) = (1, 1, 1, 1)
}
SubShader
{
Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "UniversalMaterialType" = "SimpleLit" "IgnoreProjector" = "True" "ShaderModel" = "4.5" }
@Cyanilux
Cyanilux / UnlitDepthNormalsFeature.cs
Last active August 14, 2022 13:04
Renders Unlit Opaque objects into CameraNormalsTexture for SSAO Depth Normals mode
/*
Render Unlit Opaque objects into CameraNormalsTexture for SSAO Depth Normals mode.
If you need Alpha clipping or vertex displacement, you'll need to use Depth mode,
or edit the generated shader code to add in the DepthNormals pass instead.
This is meant as an alternative if you don't need those.
For depthNormalsMat, I'm using a blank PBR/Lit SG with passIndex set to 4 (corresponds to it's DepthNormals pass).
*/
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
@totallyRonja
totallyRonja / MaterialGradientDrawer.cs
Last active March 31, 2025 13:38
A Material Property Drawer for the [Gradient] attribute which lets you edit gradients and adds them to the shader as textures. More information here: https://twitter.com/totallyRonja/status/1368704187580682240
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;
public class MaterialGradientDrawer : MaterialPropertyDrawer {
private int resolution;
@alexanderameye
alexanderameye / DepthNormalsFeature.cs
Created December 23, 2019 11:04
DepthNormalsFeature
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
public class DepthNormalsFeature : ScriptableRendererFeature
{
class DepthNormalsPass : ScriptableRenderPass
{
int kDepthBufferBits = 32;
private RenderTargetHandle depthAttachmentHandle { get; set; }