This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// オイラー角(ラジアン)を回転行列に変換 | |
float4x4 eulerAnglesToRotationMatrix(float3 angles) | |
{ | |
float ch = cos(angles.y); float sh = sin(angles.y); // heading | |
float ca = cos(angles.z); float sa = sin(angles.z); // attitude | |
float cb = cos(angles.x); float sb = sin(angles.x); // bank | |
// Ry-Rx-Rz (Yaw Pitch Roll) | |
return float4x4( | |
ch * ca + sh * sb * sa, -ch * sa + sh * sb * ca, sh * cb, 0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Quaternion slerp | |
// https://en.wikipedia.org/wiki/Slerp | |
float4 slerp(float4 q0, float4 q1, float t) | |
{ | |
q0 = normalize(q0); | |
q1 = normalize(q1); | |
float dot_q0q1 = dot(q0, q1); | |
bool dotIsNegative = dot_q0q1 < 0.0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generate random number | |
float rand(float2 co) | |
{ | |
return frac(sin(dot(co.xy, float2(12.9898, 78.233))) * 43758.5453); | |
} | |
// 半径1の球体の内部のランダムな点 | |
float3 randomInsideUnitSphere(float co) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Wang Hash Random | |
#define WANG_HASH_SEED_MAX 4294967295 | |
#define INV_WANG_HASH_DIV 2.3283064e-10 | |
float wang_hash(uint seed) | |
{ | |
seed = (seed ^ 61) ^ (seed >> 16); | |
seed *= 9; | |
seed = seed ^ (seed >> 4); | |
seed *= 0x27d4eb2d; | |
seed = seed ^ (seed >> 15); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Quaterion to Rotation Matrix4x4 | |
float4x4 quaternion_to_rotation_matrix(float4 q) | |
{ | |
float n = 1.0 / sqrt(q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w); | |
q.x *= n; | |
q.y *= n; | |
q.z *= n; | |
q.w *= n; | |
return float4x4( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Quaterion to Rotation Matrix4x4 | |
float4x4 quaternion_to_rotation_matrix(float4 q) | |
{ | |
float n = 1.0 / sqrt(q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w); | |
q.x *= n; | |
q.y *= n; | |
q.z *= n; | |
q.w *= n; | |
return float4x4( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
/// <summary> | |
/// 二重起動を防止する | |
/// </summary> | |
public class AvoidDoubleLaunch : MonoBehaviour | |
{ | |
void Start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class AsyncMailSender : MonoBehaviour { | |
public string MailFromAddress = "from@gmail.com"; | |
public string MailHost = "smtp.gmail.com"; | |
public int MailPort = 587; | |
public string MailPassword = "frompassword"; | |
public string MailToAddress = "to@gmail.com"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class AsyncMailSender : MonoBehaviour { | |
public string MailFromAddress = "from@gmail.com"; | |
public string MailHost = "smtp.gmail.com"; | |
public int MailPort = 587; | |
public string MailPassword = "frompassword"; | |
public string MailToAddress = "to@gmail.com"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 2D Vector Field Flow Debug Arrow Render | |
* | |
* This code is a porting of | |
* https://www.shadertoy.com/view/4s23DG | |
*/ | |
Shader "Debug/VectorFieldFlowArrowRender" | |
{ | |
Properties |
NewerOlder