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 / Extensions.cs
Created March 7, 2016 17:02
設定をプレイ中に変更したり、jsonに書き込んだり、読み込んだり
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.IO;
static class Extensions
{
public static void LoadJsonFile<T> (T overwriteTarget, string filePath = "appData.json")
@sugi-cho
sugi-cho / ColorCollect.cginc
Created January 21, 2016 10:59
色補正に使う!
#ifndef COLOR_COLLECT
#define COLOR_COLLECT
float3 rgb2hsv(float3 c)
{
float4 K = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
float4 p = lerp(float4(c.bg, K.wz), float4(c.gb, K.xy), step(c.b, c.g));
float4 q = lerp(float4(p.xyw, c.r), float4(c.r, p.yzx), step(p.x, c.r));
float d = q.x - min(q.w, q.y);
float2 d = _MainTex_TexelSize.xy;
fixed4 c = tex2D(_MainTex, uv);//元のテクスチャ
fixed4 o = tex2D(_Overlay, uv/(d*256));//feltのテクスチャが入る。uvが伸びないように調整してる
//HSLを調整したかったら使ってもいいけど無視してもいい!
float4 hslDelta = lerp(_HSL1, _HSL2, uv2.y);
float3 hsl = RGBToHSL(c.rgb);
hsl = saturate(hsl + hslDelta);
half3 c2 = HSLToRGB(hsl.rgb);
@sugi-cho
sugi-cho / drag.cs
Created December 25, 2015 08:08
DeltaTimeの値に依存しない、drag値の求め方!
var drag = Mathf.Exp(-_drag * deltaTime);
Shader "Hidden/ShikakuKirakira"
{
Properties
{
_Speed ("speed", Float) = 2
_Scale ("scale", Float) = 10
_Size ("size", Float) = 0.5
}
CGINCLUDE
#include "UnityCG.cginc"
@sugi-cho
sugi-cho / SaveData.cs
Last active February 15, 2016 11:28
クラスのデータをJsonにして、StreamingAssetフォルダに保存するやつ
using UnityEngine;
using System.IO;
using System.Collections;
public class SaveData : MonoBehaviour
{
public int data1;
public float data2;
public string data3;
using UnityEngine;
using UnityEngine.Rendering;
using System.Collections;
public class MassMeshes : MonoBehaviour
{
public Mesh origin;
public int numMeshes;
public Material drawMat;
public bool castShadow = true;
@sugi-cho
sugi-cho / Billboard-CastShadow.shader
Created November 26, 2015 14:27
ビルボードで、影を落とす、受ける、球。
Shader "Unlit/Billboard-CastShadow"
{
Properties
{
_DC ("diffuse", Color) = (0.5,0.5,0.5,1)
_SC ("Specular color (RGB), roughness (A)", Color) = (0.5,0.5,0.5,0.5)
_Size ("size", Float) = 1
}
CGINCLUDE
#define UNITY_PASS_SHADOWCASTER
@sugi-cho
sugi-cho / ShadowCaster.shader
Last active November 26, 2015 14:38
Shaderの影を投影する部分。
Shader "Custom/ShadowCaster" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
// ---- shadow caster pass:
@sugi-cho
sugi-cho / gist:011ef8eccdaf43cdab52
Created November 26, 2015 02:02
名前の付け方、考え中
lPos / local position / v.vertex
wPos / world position / mul(_Object2World, v.vertex)
vPos / view position / mul(UNITY_MATRIX_MV, v.vertex)
cPos / clip Position / mul(UNITY_MATRIX_MVP, v.vertex)