Skip to content

Instantly share code, notes, and snippets.

View unitycoder's full-sized avatar
‏‏‎

mika unitycoder

‏‏‎
View GitHub Profile
@NegInfinity
NegInfinity / GlobeVisualizer.cs
Created July 26, 2022 17:46
Spherical Worlds in Unity Tests - subdivision of sphere into tetrahedra, cube and adjusted cube
/*
#License:
MIT. Copyrigh 2022 Victor "NegInfinity" Eremin.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@nilpunch
nilpunch / BlurImage.shader
Last active April 25, 2025 16:47
Blur for UI elements. Compatible with Built in RP, HDRP, URP and SRP.
Shader "UI/BlurImage"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
[Space(50)]
_BlurX ("X Blur", Range(0.0, 0.5)) = 0.001
_BlurY ("Y Blur", Range(0.0, 0.5)) = 0.001
@h3r2tic
h3r2tic / kajiya-all-the-jiggarays.md
Last active May 22, 2022 00:22
kajiya ray count breakdown

There are two types of rays being traced: shadow and "gbuffer". The latter return gbuffer-style information from hit points, and don't recursively launch more rays. Lighting is done in a deferred way. There is just one light: the sun.

  • irradiance cache: usually fewer than 16k cache entries:

    • main trace: 4/entry * (1 gbuffer ray + 1 shadow ray for the sun)
    • restir validation trace: 4/entry * (1 gbuffer ray + 1 shadow ray for the sun)
    • accessibility check: 16/entry short shadow rays
  • sun shadow pass: 1/pixel shadow ray

  • final gather done at half-res; every third frame is a ReSTIR validation frame, and instead of tracing new candidates, it checks the old ones, and updates their radiance. in addition to that, the validation frame also traces very short contact rays; on paper it seems like it would be doing more work, but it's actually slightly cheaper, so I'm counting conservatively here:

@AlexMerzlikin
AlexMerzlikin / UniversalRenderPipelineTemplateWithDotsInstancing.shader
Last active February 17, 2025 05:36
Template unlit URP shader that supports DOTS instancing to use as a guide to create shaders for BatchRendererGroup since BRG only works with DOTS instancing compatible shaders. Unfortunately, the official docs about it haven't helped me that much, and I thought others might face the same issues.
Shader "Universal Render Pipeline/Custom/UnlitWithDotsInstancing"
{
Properties
{
_BaseMap ("Base Texture", 2D) = "white" {}
_BaseColor ("Base Colour", Color) = (1, 1, 1, 1)
}
SubShader
{
@tombuben
tombuben / Internal-MotionVectors.shader
Created March 31, 2022 19:13
Simple extension of the built in Unity Standard shader to properly support motion vectors with cutout transparency
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
Shader "New/Internal-MotionVectors"
{
//BEGIN(Tomas.Bubenicek): Properties taken directly from Standard.shader
Properties
{
_Color("Color", Color) = (1,1,1,1)
_MainTex("Albedo", 2D) = "white" {}
@ScottJDaley
ScottJDaley / Outline.shader
Last active May 12, 2025 04:36
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
using System;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Jobs;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Rendering;
public class SimpleBRGExample : MonoBehaviour
{
@yasirkula
yasirkula / PaddingIgnoringImage.cs
Last active October 17, 2024 03:00
Modified version of Image component that ignores the sprite's padding in Unity
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Sprites;
using UnityEngine.UI;
#if UNITY_2017_4 || UNITY_2018_2_OR_NEWER
using UnityEngine.U2D;
#endif
#if UNITY_EDITOR
using UnityEditor;
@dwilliamson
dwilliamson / ModifiedMarchingCubes.js
Created February 8, 2022 16:20
Transvoxel's Modified Marching Cubes Lookup Tables
//
// Lookup Tables for Transvoxel's Modified Marching Cubes
//
// Unlike the original paper (Marching Cubes: A High Resolution 3D Surface Construction Algorithm), these tables guarantee
// a closed mesh "whose connected components are continuous and free of holes."
//
// Rotations are prioritised over inversions so that 3 of the 6 cases containing ambiguous faces are never added. 3 extra
// cases are added as a post-process, overriding inverses through custom-build rotations to eliminate the rest.
//
// Uses the exact same co-ordinate system as https://gist.github.com/dwilliamson/c041e3454a713e58baf6e4f8e5fffecd
@Vixxd
Vixxd / .gitignore
Last active August 20, 2024 12:08
Bakery Lightmapper .gitignore for Unity
########################################
# Bakery .gitignore
# Ignore: https://geom.io/bakery/wiki/index.php?title=How_do_I...#How_do_I_use_git.2Fcollab.2Fother_version_control_system_with_Bakery.3F
# Never ignore: https://geom.io/bakery/wiki/index.php?title=How_do_I...#How_do_I_share_a_scene_with_someone_who_doesn.E2.80.99t_have_Bakery_installed.3F
########################################
############# BAKERY ASSETS ############
# Ignore Bakery Assets folder
/[Aa]ssets/Bakery/*