Skip to content

Instantly share code, notes, and snippets.

View noisecrime's full-sized avatar

NoiseCrime noisecrime

View GitHub Profile
@aras-p
aras-p / rgbm.c
Created September 7, 2011 04:50
Encoding to RGBM
// in our case,
const float kRGBMMaxRange = 8.0f;
const float kOneOverRGBMMaxRange = 1.0f / kRGBMMaxRange;
// encode to RGBM, c = ARGB colors in 0..1 floats
float r = c[1] * kOneOverRGBMMaxRange;
float g = c[2] * kOneOverRGBMMaxRange;
float b = c[3] * kOneOverRGBMMaxRange;
@darktable
darktable / DebugConsole.cs
Created December 1, 2011 00:25
Unity3D: Heavily modified version of Jeremy Hollingsworth's DebugConsole script.
#define DEBUG_CONSOLE
#define DEBUG_LEVEL_LOG
#define DEBUG_LEVEL_WARN
#define DEBUG_LEVEL_ERROR
#if (UNITY_EDITOR || DEVELOPMENT_BUILD)
#define DEBUG
#endif
#if (UNITY_IOS || UNITY_ANDROID)
@aras-p
aras-p / ImportMeshUtility.cpp
Created May 31, 2012 15:01
Unity tangent space calculation
// THIS IS ONLY A PORTION OF THE FILE
// WILL NOT COMPILE OUT OF THE BOX!
void OrthogonalizeTangent (TangentInfo& tangentInfo, Vector3f normalf, Vector4f& outputTangent)
{
TangentInfo::Vector3d normal = { normalf.x, normalf.y, normalf.z };
TangentInfo::Vector3d tangent = tangentInfo.tangent;
TangentInfo::Vector3d binormal = tangentInfo.binormal;
@AngryAnt
AngryAnt / EditorWindowExample.cs
Created June 15, 2012 08:30
EditorWindowExample from the Unity Asia Bootcamp 12 talk "Streamlining your Unity editor". A simple node based editor.
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
public class EditorWindowExample : EditorWindow
{
List<Node> nodes = new List<Node> ();
@aras-p
aras-p / hullshaderbug.md
Created August 2, 2012 12:30
d3dcompiler_43.dll hull shader optimization bug

Hull shader constant function, in triangle domain:

HSConstData HS_FlatConstant(InputPatch<InterpData, 3> I)
{
    float3 f;
    // factors computed per vertex
    f.x = I[0].fact;
    f.y = I[1].fact;
    f.z = I[2].fact;
@flarb
flarb / NaturalOrientation.cs
Created August 4, 2012 00:03
How to detect the "natural" orientation of an Android device in Unity3D. Also can use to detect tablet and phone.
using UnityEngine;
using System.Collections;
public class NaturalOrientation : MonoBehaviour {
public static int ORIENTATION_UNDEFINED = 0x00000000;
public static int ORIENTATION_PORTRAIT = 0x00000001;
public static int ORIENTATION_LANDSCAPE = 0x00000002;
public static int ROTATION_0 = 0x00000000;
@AngryAnt
AngryAnt / DualDisplay.cs
Last active January 24, 2024 08:26
Example use of the Unity 4.1 AirPlay API - gives a setup with the iOS device as controller of the remote display.
using UnityEngine;
using System.Collections;
/*
Runtime use:
To be available, AirPlay needs to be switched on for the device either via a native AirPlay UI component or
via the global AirPlay mirroring setting. Your options are:
A: Modify your Xcode project to layer a native AirPlay Cocoa control somewhere over your Unity content.
@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
@Farfarer
Farfarer / CubemapToEquirectangularWizard.cs
Last active March 6, 2023 05:45
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 / 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
{