Skip to content

Instantly share code, notes, and snippets.

@antonkudin
antonkudin / pipeGenerator.cs
Created September 26, 2023 13:48
Generates pipe mesh from mesh segments
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class pipeGenerator : MonoBehaviour
{
[SerializeField] Mesh straightMesh;
[SerializeField] Mesh elbowMesh;
[Space]
[SerializeField] Vector3[] pathPoints;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Profiling;
using UnityEngine.UI;
using System.Text;
using Unity.Profiling.LowLevel.Unsafe;
public class ReleaseBuildRecordCheck : MonoBehaviour
{
@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;
@atyuwen
atyuwen / opt_fsr.fxh
Last active May 17, 2024 11:09
An optimized AMD FSR implementation for Mobiles
//==============================================================================================================================
// An optimized AMD FSR's EASU implementation for Mobiles
// Based on https://github.com/GPUOpen-Effects/FidelityFX-FSR/blob/master/ffx-fsr/ffx_fsr1.h
// Details can be found: https://atyuwen.github.io/posts/optimizing-fsr/
// Distributed under the MIT License. Copyright (c) 2021 atyuwen.
// -- FsrEasuSampleH should be implemented by calling shader, like following:
// AH3 FsrEasuSampleH(AF2 p) { return MyTex.SampleLevel(LinearSampler, p, 0).xyz; }
//==============================================================================================================================
void FsrEasuL(
out AH3 pix,
@LotteMakesStuff
LotteMakesStuff / Flicker.cs
Created June 16, 2021 04:49
Quake/Halflife style light flicker
using UnityEngine;
public class Flicker : MonoBehaviour
{
public string LightStyle = "mmamammmmammamamaaamammma";
private Light light;
public float loopTime = 2f;
[SerializeField]
private int currentIndex = 0;
@runevision
runevision / Text2.cs
Last active December 15, 2022 10:01
Text2 extends the Unity UI Text class and makes hyphens and soft hypens work
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
// Text2 extends the Text component in Unity UI.
// It makes hyphens and soft hyphens work.
// Inserting soft hyphens in text can be tricky and confusing, given they are invisible,
// so you can instead also insert Hyphenation Point characters, which will be replaced by soft hyphens:
// https://www.compart.com/en/unicode/U+2027
public class Text2 : Text {
@totallyRonja
totallyRonja / MovingParticleContext.cs
Last active December 25, 2022 07:53
This script allows you to display movement of particle systems without them moving for tweaking them in the editor. This script is CC0, but I'd be happy if you credit me as Ronja(https://twitter.com/totallyRonja) and maybe give me some money for what I do (https://www.patreon.com/RonjaTutorials) (https://ko-fi.com/ronjatutorials)
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using UnityEngine;
using UnityEditor;
using UnityEditor.EditorTools;
// Tagging a class with the EditorTool attribute and no target type registers a global tool. Global tools are valid for any selection, and are accessible through the top left toolbar in the editor.
[EditorTool("Moving Particle Context")]
@Cyanilux
Cyanilux / GrassInstanced.hlsl
Last active January 27, 2024 12:15
Experiments with using DrawMeshInstancedIndirect with Shader Graph
// https://twitter.com/Cyanilux/status/1396848736022802435?s=20
#ifndef GRASS_INSTANCED_INCLUDED
#define GRASS_INSTANCED_INCLUDED
// ----------------------------------------------------------------------------------
// Graph should contain Boolean Keyword, "PROCEDURAL_INSTANCING_ON", Global, Multi-Compile.
// Must have two Custom Functions in vertex stage. One is used to attach this file (see Instancing_float below),
// and another to set #pragma instancing_options :
Shader "Hidden/JumpFloodOutline"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "PreviewType" = "Plane" }
Cull Off ZWrite Off ZTest Always