Skip to content

Instantly share code, notes, and snippets.

View sugi-cho's full-sized avatar
😪
zzz

Hironori Sugino sugi-cho

😪
zzz
View GitHub Profile
@sugi-cho
sugi-cho / Example
Created June 8, 2015 12:18
event Action に アクションを足していく
public event System.Action<int> OnJoin;
void Init(){
this.OnJoin += JoinAction;
}
void JoinAction(int id){
list.Add(id);
}
using UnityEngine;
using UnityEditor;
using System.Collections;
public class BakeTransformToMesh
{
[MenuItem("sugi.cho/Mesh/Bake Transform")]
public static void BakeTransform ()
{
using UnityEngine;
using UnityEditor;
using System.Collections;
public class CreateTex3D : EditorWindow
{
[MenuItem("sugi.cho/Window/CreatePerlin3DTexture")]
public static void Init ()
{
EditorWindow window = EditorWindow.GetWindow (typeof(CreateTex3D));
Shader "Custom/QuaternionTest" {
Properties {
_AX("axis", Vector) = (0,0,0,0)
_TH("theta", Float) = 0
}
CGINCLUDE
#include "UnityCG.cginc"
#define PI 3.1416
@sugi-cho
sugi-cho / qmul
Created January 26, 2015 04:54
memo! Quaternion
// Quaternion multiplication.
// http://mathworld.wolfram.com/Quaternion.html
float4 qmul(float4 q1, float4 q2)
{
return float4(
q2.xyz * q1.w + q1.xyz * q2.w + cross(q1.xyz, q2.xyz),
q1.w * q2.w - dot(q1.xyz, q2.xyz)
);
}
@sugi-cho
sugi-cho / Actionの使い方
Created January 19, 2015 08:27
System.Action、デリゲート
using System;
void Test(string t){
Debug.Log(t);
}
void Main(){
Action<string> a = Test;
a("test");
}
@sugi-cho
sugi-cho / vertWorldPos.shader
Last active August 29, 2015 14:12
world position to frag matrix example
v2f vert(Input v) {
float4 posWorld = mul(_Object2World, v.vertex);
posWorld.xyz += _POS;
v2f o;
o.vertex = mul(UNITY_MATRIX_P, mul(UNITY_MATRIX_V, posWorld));
o.uv = v.uv;
return o;
}
@sugi-cho
sugi-cho / FragmentLit.shader
Last active August 29, 2015 14:06
v2f shader with lighting in unity simple
Shader "Custom/FragmentLit" {
CGINCLUDE
#include "UnityCG.cginc"
sampler2D _MainTex;
fixed4 _Color;
struct v2f {
float4 pos : SV_POSITION;
fixed4 color : COLOR;
@sugi-cho
sugi-cho / SetCamRect.cs
Created August 18, 2014 10:03
カメラのcamera.rectを設定することができる。カメラの後ろに、黒でクリアするカメラかなにかを置いた方が良い。
using UnityEngine;
using System.Collections;
public class SetCamRect : MonoBehaviour
{
public Camera[] cams;
string
propRectMinX = "RectMinX",
propRectMinY = "RectMinY",
propRectMaxX = "RectMaxX",
@sugi-cho
sugi-cho / getBulurTex.cs
Created August 13, 2014 10:38
generate blur renderTexture
public void GetBlurTex(RenderTexture targetTexture, int iteration, int ds){
RenderTexture rt = targetTexture;
float
widthMod = 1f / (1f * (1 << ds));
int
rtW = rt.width,
rtH = rt.height;
for(int i = 0; i < iteration; i++){
float iterationOffs = (float)i;