Skip to content

Instantly share code, notes, and snippets.

View psuong's full-sized avatar

Porrith Suong psuong

View GitHub Profile
Shader "Custom/Warlocracy/CharacterShader"
{
Properties
{
_MainTex ("Sprite Texture", 2D) = "white" {}
_OutlineColor ("Outline Color", Color) = (1,1,1,1)
_OutlineWidth ("Outline Width", float) = 2
[HideInInspector] _Color ("Tint", Color) = (1,1,1,1)
[HideInInspector] _RendererColor ("RendererColor", Color) = (1,1,1,1)
@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,
@jeffvella
jeffvella / BurstLogger.cs
Last active November 1, 2023 18:38
BurstLogger
// MIT LICENSE Copyright (c) 2020 Jeffrey Vella
// https://gist.github.com/jeffvella/dee1a82bd5edfcdc9d3067d8c038f95c/edit
using Unity.Burst;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Entities;
using Unity.Jobs.LowLevel.Unsafe;
using UnityEngine;
using UnityEngine;
using UnityEngine.LowLevel;
using UnityEngine.PlayerLoop;
public static class AddPlayerLoopCallback
{
// Add a callback to the PreUpdate phase
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
static void Setup()
{
Shader "Hidden/JumpFloodOutline"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "PreviewType" = "Plane" }
Cull Off ZWrite Off ZTest Always
@jeffvella
jeffvella / NativeDebugger.cs
Last active September 28, 2023 13:17
Debug Logger that works in burst and any thread.
using System;
using System.Diagnostics;
using Unity.Burst;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Jobs.LowLevel.Unsafe;
using Unity.Mathematics;
using UnityEditor;
using Debug = UnityEngine.Debug;
using System.Runtime.CompilerServices;
using UnityEngine;
public class MeshBlit : MonoBehaviour
{
public RenderTexture rt;
public Mesh mesh;
public Material material;
public Vector3 meshPosition = new Vector3(0.5f, 0.5f, -1);
@jeffvella
jeffvella / ProfilerMarker.cs
Last active May 11, 2020 21:21
How to add burst job timing to the profiler.
public unsafe class JobTestSystem : JobComponentSystem
{
private ProfilerMarker _marker;
protected override void OnCreateManager()
{
_marker = new ProfilerMarker("Job1z");
}
protected override JobHandle OnUpdate(JobHandle inputDeps)
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Unity.Burst;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Entities;
using UnityEngine;
using UnityEngine.Profiling;
@jeffvella
jeffvella / GameData.cs
Created October 9, 2019 18:08
Experiment with ScriptableObject entity conversion
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Entities;
using Unity.Mathematics;
using UnityEngine;
public struct LevelDataComponent : IComponentData