Skip to content

Instantly share code, notes, and snippets.

View kugimasa's full-sized avatar
👾
Just Enjoy👍

kugi kugimasa

👾
Just Enjoy👍
View GitHub Profile
@kugimasa
kugimasa / CircularMotionXY.cs
Created February 23, 2023 13:24
Unity MonoBehaviour code for XY/YZ planer circular movement of an object.
using UnityEngine;
public class CircularMotionXY: MonoBehaviour
{
[SerializeField, Range(0, 1000)] private float _Speed;
[SerializeField, Range(1, 100)] private float _Radius;
[SerializeField] private Transform _Center;
private float _theta = 0.0f;
void Update()
@kugimasa
kugimasa / RaymarchingSample.shader
Last active September 23, 2021 12:30
Raymarching Sample in Unity
Shader "Custom/RaymarchingSample"
{
Properties
{
[KeywordEnum(WORLD, OBJECT)] _Coordinate ("Coordinate", int) = 0
[KeywordEnum(SPHERE, TORUS)] _Object ("Object", int) = 0
_MainTex ("Texture", 2D) = "white" {}
_MaxStep ("Max Step" , int) = 100
_MaxDist ("Max Ray Distance", int) = 1000
_SurfDist ("Surface Distance", float) = 0.01
@kugimasa
kugimasa / uniform_hemisphere.py
Last active May 26, 2020 04:35
Sampling a direction on hemisphere uniformly
import numpy as np
def uniform_hemisphere():
# Sampling 2 random numbers
u_1 = np.random.rand()
u_2 = np.random.rand()
# Angles
phi = 2 * np.pi * u_1
theta = np.pi / 2 * u_2
@kugimasa
kugimasa / cosine_lobe.py
Last active May 26, 2020 04:35
Sampling a direction on hemisphere using Cosine Lobe
import numpy as np
def cosine_lobe(N):
# Sampling 2 random numbers
u_1 = np.random.rand()
u_2 = 1.0 - np.random.rand()
# angles
phi = 2 * np.pi * u_1
theta = np.arccos(np.power(u_2, 1/(N+1)))