Skip to content

Instantly share code, notes, and snippets.

View EricHu33's full-sized avatar

EricHu EricHu33

View GitHub Profile
@EricHu33
EricHu33 / DrawFullScreenFeature.cs
Last active April 16, 2022 21:48
An example of how to write custom grab pass renderer feature in Unity URP
namespace UnityEngine.Rendering.Universal
{
public enum BufferType
{
CameraColor,
Custom
}
public class DrawFullScreenFeature : ScriptableRendererFeature
{
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" }
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" }
@EricHu33
EricHu33 / InstancedIndirect.hlsl
Last active October 6, 2022 14:01
Instance Indirect Sample for Shadergraph
#ifndef INSTANCED_INDIRECT_INCLUDED
#define INSTANCED_INDIRECT_INCLUDED
struct MeshTransformData
{
float3 Position;
float4 Rotation;
float3 Scale;
float4 Color;
};
@EricHu33
EricHu33 / TestController.cs
Last active December 5, 2022 05:43
async and burst direct call test
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Mathematics;
using Unity.Burst;
using UnityEngine.Profiling;
using Unity.Collections;
using UnityEngine.UI;
using System.Threading.Tasks;
@EricHu33
EricHu33 / AsyncJobController.cs
Created December 4, 2022 04:20
Example of using async with job system
using System.Collections;
using System.Threading.Tasks;
using UnityEngine;
using Unity.Jobs;
using Unity.Collections;
using Unity.Profiling;
struct NumberIncrementJob : IJob
{
public NativeArray<float> Numbers;
@EricHu33
EricHu33 / RenderObjectsPass.cs
Created May 2, 2023 08:10 — forked from wonkee-kim/RenderObjectsPass.cs
Unity URP sample -RenderObjects's RenderPass
using System.Collections.Generic;
using UnityEngine.Rendering.Universal;
using UnityEngine.Rendering;
using UnityEngine.Scripting.APIUpdating;
namespace UnityEngine.Experimental.Rendering.Universal
{
[MovedFrom("UnityEngine.Experimental.Rendering.LWRP")] public class RenderObjectsPass : ScriptableRenderPass
{
RenderQueueType renderQueueType;
@EricHu33
EricHu33 / ColorBlit.shader
Created January 28, 2024 14:44
Custom Shader code for URP's Full Screen Pass Renderer Feature
//sample code of custom shader that using unity's blit texture(from Blit.hlsl) so this shader is same as a posteffect shadergraph code.
//and can be use in the urp's built in Full Screen Pass Renderer Feature(unity 2022+)
Shader "ColorBlit"
{
Properties
{
_Intensity("_Intensity", Range(0,1)) = 0
}
SubShader
@EricHu33
EricHu33 / gist:1020f1b36c0fcb646fb5d8931c31dd08
Last active July 3, 2024 21:34
Clean all missing scripts in Unity Gameobject, attached this script into the root of the gameobject. right click and call "RemoveMissingScript"
[ExecuteInEditMode]
public class YourComponent : MonoBehaviour
{
[ContextMenu("remove missing script")]
public void RemoveMissingScript()
{
var transforms = GetComponentsInChildren<Transform>(true);
foreach (var childTransform in transforms)
{
var components = childTransform.GetComponents<Component>();