Skip to content

Instantly share code, notes, and snippets.

@PopupAsylum
PopupAsylum / ShaderExposure.shader
Last active Jan 29, 2017
Applies the exposure of Exposure.cs
View ShaderExposure.shader
//Apply exposure
o.vColor.rgb *= _PA_Exposure;
//Uncharted 2 tonemapping curve http://filmicgames.com/archives/75
o.vColor.rgb =((o.vColor.rgb*(0.15*o.vColor.rgb + 0.10*0.50) + 0.20*0.02) / (o.vColor.rgb*(0.15*o.vColor.rgb + 0.50) + 0.20*0.30)) - 0.02 / 0.30;
@PopupAsylum
PopupAsylum / Exposure.cs
Created Jan 29, 2017
Sets a global exposure shader variable based on light probes
View Exposure.cs
using UnityEngine;
using System.Collections;
using UnityEngine.Rendering;
[ExecuteInEditMode]
public class Exposure : MonoBehaviour {
const float DEFAULT_EXPOSURE = 3f;
const string EXPOSURE_PROPERTY = "_PA_Exposure";
@PopupAsylum
PopupAsylum / CustomFramer.cs
Created Jan 24, 2017
Change how unity's 'F' framing is applied
View CustomFramer.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
public class CustomFramer : MonoBehaviour {
public float radius = 1f;
@PopupAsylum
PopupAsylum / PA_CubeRefraction
Last active Jan 6, 2017
Box Projected Refraction
View PA_CubeRefraction
//PA_CubeRefraction is an adaptation of the UnityGI_IndirectSpecular function from UnityGlobalIllumination.cginc
float3 PA_CubeRefraction(float3 vViewDirectionWs, float3 vPositionWs, float frosted) {
float3 result = 0;
float3 vRefractionDirWs0 = vViewDirectionWs.xyz;
#if ( UNITY_SPECCUBE_BOX_PROJECTION )
{
vRefractionDirWs0.xyz = BoxProjectedCubemapDirection(vViewDirectionWs.xyz, vPositionWs.xyz, unity_SpecCube0_ProbePosition, unity_SpecCube0_BoxMin, unity_SpecCube0_BoxMax);
}
@PopupAsylum
PopupAsylum / PointerCursor.cs
Last active Dec 20, 2016
PointerCursor.jslib goes in Assets/Plugins/WebGL, PointerCursor.cs goes in your scripts folder, call PointerCursor.SetPointer(true) to set the cursor as a pointer
View PointerCursor.cs
using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;
public class PointerCursor : MonoBehaviour {
[DllImport("__Internal")]
public static extern void SetPointer(bool arg);
}
@PopupAsylum
PopupAsylum / PointerCursor.cs
Created Dec 20, 2016
PointerCursor.jslib goes in Assets/Plugins/WebGL, PointerCursor.cs goes in your scripts folder, call SetPointer(true) to set the cursor as a pointer
View PointerCursor.cs
using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;
public class PointerCursor : MonoBehaviour {
[DllImport("__Internal")]
public static extern void SetPointer(bool arg);
}
@PopupAsylum
PopupAsylum / RefractedBounds.cs
Created Oct 29, 2016
Behaviour that modifies a renderers position during the render process to prevent it being culled
View RefractedBounds.cs
using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
[RequireComponent(typeof(MeshRenderer))]
public class RefractedBounds : MonoBehaviour {
MeshRenderer renderer;
void OnEnable() {
View Refract.cginc
float3 Refract(float3 position, float4 surface, float refractionIndex){
//ray origin is the camera position
float3 viewerPosition = _WorldSpaceCameraPos.xyz;
//ray end is the vertex's undistorted position
float3 vertexPosition = position;
//get the vector from the camera to the vertex
float3 worldRay = vertexPosition - viewerPosition;
@PopupAsylum
PopupAsylum / MeshBatcher.cs
Last active Oct 6, 2016
Combines multiple meshes based on materials and lightmap index
View MeshBatcher.cs
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class MeshBatcher : MonoBehaviour {
class MeshStrip
{
public List<int> strip = new List<int>();
@PopupAsylum
PopupAsylum / SymbolicProjectMenu.cs
Created Sep 23, 2016
Adds a menu option to create a copy of the current Unity project using symbolic links, Windows only, usually needs admin
View SymbolicProjectMenu.cs
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Runtime.InteropServices;
internal static class SymbolicLink {
#if UNITY_EDITOR_WIN
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool CreateSymbolicLink(string lpSymlinkFileName, string lpTargetFileName, SymLinkFlag dwFlags);
You can’t perform that action at this time.