Skip to content

Instantly share code, notes, and snippets.

View noisecrime's full-sized avatar

NoiseCrime noisecrime

View GitHub Profile
@benblo
benblo / SceneUtility.cs
Created April 15, 2014 13:29
Utility to open all scenes of a Unity project and process them: resave, refactor data, etc. To be used with EditorCoroutines: https://gist.github.com/benblo/10732554
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using Object = UnityEngine.Object;
using UnityEditor;
namespace Swing.Editor
{
// SM3.0+
SubShader {
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 3.0
#pragma multi_compile_fwdbase
#include "MyCode.cginc"
ENDCG
@frarees
frarees / MinMaxSliderAttribute.cs
Last active December 5, 2024 23:26
MinMaxSlider for Unity
// https://frarees.github.io/default-gist-license
using System;
using UnityEngine;
[AttributeUsage(AttributeTargets.Field, Inherited = true, AllowMultiple = false)]
public class MinMaxSliderAttribute : PropertyAttribute
{
public float Min { get; set; }
public float Max { get; set; }
@aras-p
aras-p / Projector Light.shader
Last active September 9, 2024 14:33
Projector shaders without fixed function
Shader "Projector/Light" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_ShadowTex ("Cookie", 2D) = "" {}
_FalloffTex ("FallOff", 2D) = "" {}
}
Subshader {
Pass {
ZWrite Off
@Farfarer
Farfarer / SmoothingAngleFix.cs
Last active February 2, 2017 15:27
Auto-fix Unity's tangent space generation when importing models.
// Place this file into a directory called Editor inside of your Assets directory.
// Unity 5.3+:
// Models imported after you do that will have:
// - Normals set to Import.
// - Set the bool "useMikk" to true:
// Tangents set to Calculate Tangent Space (MikkTSpace).
// - Set the bool "useMikk" to false:
// Tangents set to Split Tangents (UnityTSpace).
@aras-p
aras-p / shadow_filter.md
Created August 9, 2013 21:02
hacking shadow filtering in unity

Forward rendering:

  • Most of "shadow sampling" is in AutoLight.cginc include file somewhere in Unity.
  • Now, if you copy that file into your project somewhere, and have some shaders in the same folder - then these shaders will use yur local "hijacked" copy.
  • In all the functions that sample shadowmap, you could for example add more taps etc.

Deferred lighting:

  • most of shadow sampling code is in Internal-PrePassCollectShadows.shader / Internal-PrePassLighting.shader.
  • copy these built-in shaders into Resources folder of your project (Resources so they are always included into game build)
  • restart Unity and hack them.
@mstevenson
mstevenson / SaveFBX.cs
Created August 5, 2013 20:05
ASCII FBX file exporter for Unity. Extracted from Michal Mandrysz's Unity Summer of Code 2009 external lightmapping project.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using UnityEditor;
using UnityEngine;
/*
@masa795
masa795 / UnityTextures.cs
Created June 17, 2013 14:12
Unityが持っているアイコンを表示する。 Unityのバージョンによってはパスが使えなくなるかもしれないので使用時は注意。
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
//Unity 4.1.5
public class UnityTextures : EditorWindow
{
@Farfarer
Farfarer / CubemapToEquirectangularWizard.cs
Last active July 2, 2024 06:54
Create dynamic equirectangular maps for Unity. These have the benefit that, as they're flat images, you can sample lower mips to get blurry reflections. The straight cubemap version (detailed here: http://www.farfarer.com/blog/2011/07/25/dynamic-ambient-lighting-in-unity/ ) will give you hard seams when you sample mips from the cubemap. Although…
// Wizard to convert a cubemap to an equirectangular cubemap.
// Put this into an /Editor folder
// Run it from Tools > Cubemap to Equirectangular Map
using UnityEditor;
using UnityEngine;
using System.IO;
class CubemapToEquirectangularWizard : ScriptableWizard {
@masa795
masa795 / DragAndDropTest.cs
Created May 15, 2013 03:09
Editor拡張でドラッグ&ドロップした時のファイルパスを取得する
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System.IO;
public class DragAndDropTest : EditorWindow
{
// Add menu item to the Window menu