Skip to content

Instantly share code, notes, and snippets.

View aras-p's full-sized avatar

Aras Pranckevičius aras-p

View GitHub Profile
@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"
@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" }
@aras-p
aras-p / keywords.cpp
Created December 19, 2011 09:21
light keywords
void Light::SetLightKeyword()
{
// OK, "2 at 1"
printf_console ("LightMasks: %x at 1\n", (UInt32)(kLightKeywordMasks[1]&0xFFFFFFFF));
// BAD, 0
printf_console ("LightMasks: %x at m_KeywordMode (%i)\n", (UInt32)(kLightKeywordMasks[m_KeywordMode]&0xFFFFFFFF), m_KeywordMode);
// BAD, 0
printf_console ("LightMasks: %x at (int)m_KeywordMode (%i)\n", (UInt32)(kLightKeywordMasks[(int)m_KeywordMode]&0xFFFFFFFF), m_KeywordMode);
int idx = m_KeywordMode;
// BAD, 0
@aras-p
aras-p / classornot.js
Created December 20, 2011 05:38
is this a class or not
var myFloat = 1337.0;
var myColor = Color (1,0.5,0.3,1);
var myTextureRef : Texture;
vbPtr[ 0].vert.Set( x0, y0, 0.0f ); vbPtr[ 0].color = color; vbPtr[ 0].uv.Set( tx0, ty0 );
vbPtr[ 1].vert.Set( x1, y0, 0.0f ); vbPtr[ 1].color = color; vbPtr[ 1].uv.Set( tx1, ty0 );
vbPtr[ 2].vert.Set( x2, y0, 0.0f ); vbPtr[ 2].color = color; vbPtr[ 2].uv.Set( tx2, ty0 );
vbPtr[ 3].vert.Set( x3, y0, 0.0f ); vbPtr[ 3].color = color; vbPtr[ 3].uv.Set( tx3, ty0 );
vbPtr[ 4].vert.Set( x0, y1, 0.0f ); vbPtr[ 4].color = color; vbPtr[ 4].uv.Set( tx0, ty1 );
vbPtr[ 5].vert.Set( x1, y1, 0.0f ); vbPtr[ 5].color = color; vbPtr[ 5].uv.Set( tx1, ty1 );
vbPtr[ 6].vert.Set( x2, y1, 0.0f ); vbPtr[ 6].color = color; vbPtr[ 6].uv.Set( tx2, ty1 );
vbPtr[ 7].vert.Set( x3, y1, 0.0f ); vbPtr[ 7].color = color; vbPtr[ 7].uv.Set( tx3, ty1 );
vbPtr[ 8].vert.Set( x0, y2, 0.0f ); vbPtr[ 8].color = color; vbPtr[ 8].uv.Set( tx0, ty2 );
vbPtr[ 9].vert.Set( x1, y2, 0.0f ); vbPtr[ 9].color = color; vbPtr[ 9].uv.Set( tx1, ty2 );
@aras-p
aras-p / cache.cs
Created February 14, 2012 20:09
cache instead
static public void SetRenderActiveFlagMode( ref GameObject parent, bool mode )
{
var pr = parent.renderer; // query the component just once!
if( pr != null )
{
pr.enabled = mode;
}
var pt = parent.transform; // query the component just once!
int childCount = pt.GetChildCount();
@aras-p
aras-p / neon.s
Created March 31, 2012 20:02
Xcode do not like
@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
@ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
@ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
@ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
@ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
#define HANDLE_LIST(texList, FormatFunc, AtlasFunc) \
do { \
const unsigned count = texList.size(); \
Texture2D** tex = count ? &texList[0] : 0; \
\
TextureFormat format; \
unsigned page, pad; \
TextureFilterMode filter; \
\
FormatFunc(tex, count, &format); \
@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;
@aras-p
aras-p / tempregs.txt
Created June 5, 2012 12:18
bump spec temp regs
// ----------------------------------------------------------------------------------
// OpenGL
SubProgram "opengl " {
Keywords { "DIRECTIONAL" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "SHADOWS_OFF" "VERTEXLIGHT_ON" }
Bind "vertex" Vertex
Bind "tangent" ATTR14
Bind "normal" Normal
Bind "texcoord" TexCoord0