Skip to content

Instantly share code, notes, and snippets.

👁‍🗨
Yes

mattatz mattatz

View GitHub Profile
@mattatz
mattatz / Matrix.hlsl
Last active Mar 15, 2019
Matrix operations for HLSL
View Matrix.hlsl
#ifndef __MATRIX_INCLUDED__
#define __MATRIX_INCLUDED__
#define IDENTITY_MATRIX float4x4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
float4x4 inverse(float4x4 m) {
float n11 = m[0][0], n12 = m[1][0], n13 = m[2][0], n14 = m[3][0];
float n21 = m[0][1], n22 = m[1][1], n23 = m[2][1], n24 = m[3][1];
float n31 = m[0][2], n32 = m[1][2], n33 = m[2][2], n34 = m[3][2];
float n41 = m[0][3], n42 = m[1][3], n43 = m[2][3], n44 = m[3][3];
@mattatz
mattatz / Quaternion.hlsl
Last active Dec 9, 2018
Quaternion structure for HLSL
View Quaternion.hlsl
#ifndef __QUATERNION_INCLUDED__
#define __QUATERNION_INCLUDED__
#define QUATERNION_IDENTITY float4(0, 0, 0, 1)
#ifndef PI
#define PI 3.14159265359f
#endif
// Quaternion multiplication
@mattatz
mattatz / Easing.hlsl
Created Jan 19, 2018
Easing functions for HLSL.
View Easing.hlsl
#ifndef _EASING_INCLUDED_
#define _EASING_INCLUDED_
float ease_linear(float x) {
return x;
}
float ease_in_quad(float x) {
float t = x; float b = 0; float c = 1; float d = 1;
return c*(t/=d)*t + b;
@mattatz
mattatz / mat4.h
Last active Jan 9, 2018
Column major 4x4 matrix struct for CUDA.
View mat4.h
// Column major 4x4 matrix for CUDA.
// Sources:
// - https://github.com/JAGJ10/Snow/blob/master/Snow/matrix.h
// - https://github.com/mrdoob/three.js/blob/master/src/math/Matrix4.js
#pragma once
#include "cuda_runtime.h"
struct mat4 {
@mattatz
mattatz / ComponentUtil.cs
Last active Jan 7, 2019
CopyComponent by Script for Unity
View ComponentUtil.cs
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
namespace Utils
{
@mattatz
mattatz / Rand.cs
Created Jan 11, 2017
Random class for Unity.
View Rand.cs
using Random = System.Random;
using UnityEngine;
namespace mattatz {
public class Rand {
Random rnd;
@mattatz
mattatz / GradientTexGen
Created Nov 28, 2016
Gradient Texture2D Generator for Unity.
View GradientTexGen
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
using System.IO;
using System.Collections;
namespace mattatz.Utils {
@mattatz
mattatz / FBXRotationHelper.cs
Created Jun 22, 2016
FBXモデルのrootにhelperオブジェクトが置いてある場合に発生する回転のバグを修正するやつ.
View FBXRotationHelper.cs
using UnityEngine;
using System.Collections;
namespace mattatz.Utils {
/*
* FBXモデルのrootにhelperオブジェクトが置いてある場合に発生する回転のバグを修正するやつ.
* rootオブジェクトをx軸に-90度回転させ,親オブジェクトを追加する.
* http://answers.unity3d.com/questions/13988/asset-import-from-3dsmax-rotation-issue.html
*/
@mattatz
mattatz / LookAtMatrix.cginc
Last active Sep 25, 2018
Build a 4x4 look at matrix in cginc
View LookAtMatrix.cginc
#ifndef _LOOK_AT_MATRIX_
#define _LOOK_AT_MATRIX_
float4x4 look_at_matrix(float3 at, float3 eye, float3 up) {
float3 zaxis = normalize(at - eye);
float3 xaxis = normalize(cross(up, zaxis));
float3 yaxis = cross(zaxis, xaxis);
return float4x4(
xaxis.x, yaxis.x, zaxis.x, 0,
xaxis.y, yaxis.y, zaxis.y, 0,
@mattatz
mattatz / WindowControl.cs
Last active Jul 3, 2018
Unityの画面の位置や解像度の指定、タイトルバーの消去などを行うユーティリティ
View WindowControl.cs
using UnityEngine;
using System.Collections;
using System;
using System.Runtime.InteropServices;
namespace Utils {
// ここからコードを拝借させてもらいました!
// http://answers.unity3d.com/questions/13523/is-there-a-way-to-set-the-position-of-a-standalone.html
You can’t perform that action at this time.