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 / memo.cs
Created May 30, 2014 06:04
メモ的なC#スクリプトを書く
draw = GetComponent (typeof(IDrawable)) as IDrawable;
@sugi-cho
sugi-cho / SpawnFromTriangle.cs
Last active August 29, 2015 14:01
三角頂点を扱う&トライアングルから、平均的に何かを出す!スクリプト
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class SpawnFromTriangle : MonoBehaviour
{
public Transform[] hanas;
public Triangle[] triangles;
public int numSpawn = 10;
public float emission = 10f;
//http://gamedev.stackexchange.com/questions/59797/glsl-shader-change-hue-saturation-brightness
vec3 rgb2hsv(vec3 c)
{
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
using UnityEngine;
using System.Collections;
public class AfterEffects : MonoBehaviour {
public Material[] effectMats;
void OnRenderImage(RenderTexture s, RenderTexture d){
RenderTexture rt = RenderTexture.GetTemporary(s.width, s.height);
Graphics.Blit(s, rt);
@sugi-cho
sugi-cho / template.html
Last active August 29, 2015 13:56
tumblr template 投稿用テンプレート
<div class="bigStage">
<div>
</div>
</div>
<p>
<a class="unityPlayer" href="UnityWeb.unity3d" target="_blank">
<img alt="image" src="tumbnailUrl" width="width"/>
</a>
</p>
@sugi-cho
sugi-cho / RandomOnMesh.cs
Created December 17, 2013 01:38
get random points on mesh
using UnityEngine;
using System.Collections;
public class RandomOnMesh : MonoBehaviour {
void OnDrawGizmos(){
Gizmos.color = Color.red;
for (int i = 0; i < 100; i++) {
Gizmos.DrawSphere(
GetRandomPointOnMesh(GetComponent<MeshFilter>().sharedMesh),
0.1f
@sugi-cho
sugi-cho / ImageParticleEffect.shader
Created December 5, 2013 17:55
テクスチャをばらまく系のイメージエフェクト
Shader "Custom/ImageParticleEffect" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_SampTex ("sampler tex", 2D) = "white" {}
_WebTex ("webcam tex", 2D) = "black" {}
_Scale ("sq scale", Float) = 10
_Size ("sq size", Float) = 1
}
CGINCLUDE
#include "UnityCG.cginc"
using UnityEngine;
using UnityEditor;
using System.Collections;
public class CreateMesh {
//16250枚Quadが入ったMeshを作る。
[MenuItem("Custom/Create/16250meshes")]
public static void CreateParticleMesh(){
Mesh mesh = new Mesh();
int vertexCount = 65000;
@sugi-cho
sugi-cho / suikomi.cs
Created September 13, 2013 05:43
てきとう。エラー出るはず!
Mesh mesh = GetComponent<MeshFilter>().mesh;
Vector3 targetPoint;
Vector3[] vertices = mesh.vertices;
float power; //吸い込まれ力
for(int i = 0; i < vertices.Length; i++){
//ここら変の計算を変えて、吸い込まれ方を調整
float d = (vertices[i] - targetPoint).sqrMagnitude;
vertices[i] += (vertices[i] - targetPoint)*Time.deltaTime*d*power;
}
@sugi-cho
sugi-cho / alphablend.shader
Created September 9, 2013 10:19
v2f、shader、参考にする書き方
Shader "AngryBots/Particle/AlphaBlend" {
Properties {
_MainTex ("Base", 2D) = "white" {}
_TintColor ("TintColor", Color) = (1.0, 1.0, 1.0, 1.0)
}
CGINCLUDE
#include "UnityCG.cginc"