Skip to content

Instantly share code, notes, and snippets.

View AGeorgy's full-sized avatar

George Ananchenko AGeorgy

View GitHub Profile
@aras-p
aras-p / iPad2Crash.shader
Created May 18, 2011 16:16
Shader crashes on iPad 2
/* Both vertex & fragment shaders (define VERTEX or FRAGMENT before loading each).
Looks like crash caused by indexing into uniform array. Crash goes away if:
1) replacing array indices [i] with actual constants (0 & 1) and removing index math, OR
2) removing unrelated ALU ops (' - viewpos'), OR
3) rewriting shader to not be unrolled; using for (int i = 0; i < 2; ++i) loop.
Shader by itself does not make any practical sense, I just simplified a more complex shader to smallest that still crashes.
Crashes inside PVR driver on iPad 2, iOS 4.3:
@aras-p
aras-p / ColoredNoise.shader
Created October 18, 2011 10:12
Colored Noise from AngryBots
Shader "Hidden/ColoredNoise" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_NoiseTex ("Noise (RGB)", 2D) = "white" {}
}
CGINCLUDE
#include "UnityCG.cginc"
@darktable
darktable / AutoSaveAssets.cs
Created November 16, 2011 00:12
Unity3D: Somewhat Hacky Method for Auto Saving Assets in Unity.
//#define VERBOSE
/* ***************************************************************************
Copyright 2011 Calvin Rien
(http://the.darktable.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@aras-p
aras-p / dirlm.shader
Created November 25, 2011 06:43
Directional Lightmap optimization try
Shader "Bumped Specular" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
_Shininess ("Shininess", Range (0.03, 1)) = 0.078125
_MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
_BumpMap ("Normalmap", 2D) = "bump" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
@asus4
asus4 / DownloadManager.cs
Created April 25, 2012 14:32
Unity DownloadManager
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
/**
DownloadManager
@author koki ibukuro
*/
public class DownloadManager : MonoBehaviour , System.IDisposable {
// using classes
@SeventySevian
SeventySevian / gist:3977847
Created October 30, 2012 01:49
Unity Pixelated shader
Shader "Seventy Sevian/Pixelated"
{
Properties
{
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Color ("Color", Color) = (1, 1, 1, 1)
_PixelCountU ("Pixel Count U", float) = 100
_PixelCountV ("Pixel Count V", float) = 100
}
@aras-p
aras-p / MobileIllumVertexLit.shader
Created November 30, 2012 13:23
Simple Illuminated VertexLit shader
Shader "Mobile/Illum VertexLit" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_Illum ("Illum (RGB)", 2D) = "black" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 80
Pass {
@drawcode
drawcode / WebWindow.cs
Created January 22, 2013 18:11
Unity WebWindow (browser within unity editor window, helpful for tools that require a web view or more beyond basic controls).
using UnityEngine;
using UnityEditor;
using System;
using System.Reflection;
public class WebWindow : EditorWindow {
static Rect windowRect = new Rect(100,100,800,600);
static BindingFlags fullBinding = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static;
static StringComparison ignoreCase = StringComparison.CurrentCultureIgnoreCase;
@coastwise
coastwise / gist:5951291
Created July 8, 2013 18:33
Compute horizontal field of view in Unity
float vFOVInRads = Camera.main.fieldOfView * Mathf.Deg2Rad;
float hFOVInRads = 2 * Mathf.Atan( Mathf.Tan(vFOVInRads / 2) * Camera.main.aspect);
float hFOV = hFOVInRads * Mathf.Rad2Deg;
@coastwise
coastwise / VertMinusCameraFOV.cs
Created July 8, 2013 20:16
VERT- Field of view scaling for Unity3D cameras.
using UnityEngine;
using System.Collections;
/**
* This class attempts to force VERT- Field of view scaling.
* By default, Unity uses the HOR+ technique.
*
* http://en.wikipedia.org/wiki/Field_of_view_in_video_games#Scaling_methods
*/