Skip to content

Instantly share code, notes, and snippets.

@float3
float3 / keybase.md
Created October 3, 2021 23:41
keybase.md

Keybase proof

I hereby claim:

  • I am Float3 on github.
  • I am hill3 (https://keybase.io/hill3) on keybase.
  • I have a public key whose fingerprint is 137A 8777 BAE4 C121 47A1 1BA4 792F 6565 E9A0 CC50

To claim this, I am signing this object:

@float3
float3 / ShaderUtility.cs
Last active January 20, 2022 15:16
FallBack "Diffuse" and global Shader Keyword Replacer (this is probably only useful for vrc)
/*
Copyright 2018-2021 Lyuma, Float3
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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE O
@float3
float3 / LICENSE.md
Created November 14, 2021 19:03
all my public gists are under this License

MIT License

Copyright (c) 2021 3

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:

@float3
float3 / UnityBuiltin2019431f1.cs
Last active December 10, 2021 12:11
Information on the builtin unity 2019.4.31f1 shaders and post processing stack 3.1.1
using System.Collections.Generic;
namespace _Float3
{
public class UnityBuiltin2019431F1
{
//the keywords listed are only those used by the shaders listed below
//all of this information was found by using $grep
public static readonly HashSet<string> BuiltInGlobalShaderKeywords = new HashSet<string>(new[]
{
@float3
float3 / ShaderKeywordsUtility.cs
Last active January 31, 2022 09:11
ShaderKeywordsUtility
// Original ShaderKeywordsUtility by ScruffyRules#0879
// Thank you to Xiexe and all that tested!
// Licensed under the MIT License (see https://vrchat.com/legal/attribution)
// Updated by .3#0003
// https://gist.github.com/Float3/afce1f343d3c5f912fb8943bf25f7fcb
#if UNITY_EDITOR
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
@float3
float3 / ParallaxDepth.shader
Last active January 25, 2022 17:10
Example of how to output parallax depth in the fragment shader for better clipping/shadow receiving/fog etc.
// you can output depth in the frag shader by returning a struct that contains a element with the SV_DEPTH semantic
// or by adding it as a extra out parameter, also with the SV_DEPTH semantic.
// the latter is useful if you want to if guard it
// example 1:
// float4 frag(v2f i, uint facing : SV_IsFrontFace
// #ifdef DEPTH_PARALLAX
// ,out float depth : SV_DEPTH
// #endif
@float3
float3 / dfg.shader
Last active January 24, 2022 12:01
using nicer LUT dfg Fresnel in unity
// https://eheitzresearch.wordpress.com/240-2/
// Generating the dfg:
// https://github.com/google/filament/blob/main/tools/cmgen/src/cmgen.cpp
// make sure to generate the multiscatter dfg
[NonModifiableTextureData] [NoScaleOffset] _DFG ("DFG Lut", 2D) = "black" {}
@float3
float3 / ShaderPreprocessor.cs
Last active February 12, 2024 11:01
ShaderPreprocessor
#if UNITY_EDITOR
#region
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEditor.Build;
@float3
float3 / Bitpacking.cginc
Last active February 9, 2022 14:17
2 Bitpacking methods
// Method 1:
// by MerlinVR
// You can convert the uints to full precision floats using asfloat(half3ToUint(input)) and store floats using uintToHalf3(asuint(inputfloat))
// Packing/unpacking routines for saving integers to R16G16B16A16_FLOAT textures
// Heavily based off of https://github.com/apitrace/dxsdk/blob/master/Include/d3dx_dxgiformatconvert.inl
// For some reason the last 2 bits get stomped so we'll only allow uint14 for now :(
float uint14ToFloat(uint input)
{
@float3
float3 / UnityEditorKeyword.cs
Created February 13, 2022 16:58
this will set a shader keyword and make sure it's only true in editor and never in build by disabling before the build and stripping and shader variants that have that keyword
// to use this define
// #pragma shader_feature UNITY_EDITOR
// in your shader
#if UNITY_EDITOR
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Callbacks;