Skip to content

Instantly share code, notes, and snippets.

View kodai100's full-sized avatar

Kodai Takao kodai100

View GitHub Profile
@kodai100
kodai100 / Unity_SimpleColor.shader
Last active December 7, 2016 03:50
Simple Color Shader.
Shader "Custom/SimpleColor" {
Properties{
_Color("Color", Color) = (1,1,1,1)
}
SubShader{
Pass{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
Shader "Custom/Billboard" {
Properties{
_MainTex("Texture", 2D) = "white" {}
_Size("Size", Range(0, 0.1)) = 1
}
SubShader{
Tags{ "RenderType" = "Transparent" }
Shader "Custom/SimpleTexture" {
Properties{
_MainTex("Base(RGB)", 2D) = "white" {}
}
SubShader{
LOD 200
CGINCLUDE
void OnGUI() {
int w = Screen.width / 2;
int h = Screen.height / 2;
int s = 512;
GUI.DrawTexture(new Rect(w - s / 2, h - s / 2, s, s), tex);
}
@kodai100
kodai100 / SingularValueDecomposition.cs
Created June 6, 2017 07:48
Calculates Singular Value Decomposition
public static void SVD(Matrix2x2 A, out Matrix2x2 U, out Vector2 S, out Matrix2x2 V) {
if (Mathf.Abs(A.m01 - A.m10) < MATRIX_EPSILON && Mathf.Abs(A.m01) < MATRIX_EPSILON){
V = new Matrix2x2(A.m00 < 0 ? -1 : 1, 0, 0, A.m11 < 0 ? -1 : 1);
S = new Vector2(Mathf.Abs(A.m00), Mathf.Abs(A.m11));
U = Identity();
} else{
float j = A.m00 * A.m00 + A.m01 * A.m01;
float k = A.m10 * A.m10 + A.m11 * A.m11;
float v_c = A.m00 * A.m10 + A.m01 * A.m11;
using Vector = MathNet.Numerics.LinearAlgebra.Vector<float>;
using Matrix = MathNet.Numerics.LinearAlgebra.Matrix<float>;
using UnityEngine;
public class ConfigureNumerics : MonoBehaviour {
public Vector3 v1;
public Vector3 v2;
public Vector3 v3;
@kodai100
kodai100 / GraphPlotter.shader
Created August 1, 2017 08:13
Graph Plotting Shader for Unity ShaderLab
Shader "Custom/GraphPlotter" {
Properties{
_Division("Size", Range(10, 300)) = 0
_Radius("Radius", Range(0, 1)) = 1
_Color("Color", Color) = (0, 0, 0, 0)
}
SubShader{
Tags{ "Queue" = "Transparent" "RenderType" = "Transparent" }
@kodai100
kodai100 / README.md
Last active August 5, 2017 15:53
MyUnityReadme

Title

thumbnail movie

Title is a xxxxxxxx. See also [some link][Link].

Unity Packages

@kodai100
kodai100 / Toggle.shader
Created August 8, 2017 03:01
Unity Shader Bool Property Example
Shader "Custom/ToggleTest" {
Properties{
_BackgroundTex("Background Texture", 2D) = "white"{}
[Toggle(USE_TEXTURE)] _UseTexture("Use Texture", Float) = 0
}
SubShader{
Tags{ "Queue" = "Transparent" "RenderType" = "Transparent" }
@kodai100
kodai100 / .gitignore
Created August 8, 2017 03:07
Unity My ,gitignore
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/Assets/AssetStoreTools*
# Visual Studio 2015 cache directory
/.vs/