Skip to content

Instantly share code, notes, and snippets.

View Ushio's full-sized avatar

Ushio Ushio

  • to be continued...
  • japan
View GitHub Profile
@Ushio
Ushio / main.cpp
Created November 3, 2019 15:34
TexturedTriangle
/*******************************************************************************************
*
* raylib [core] example - Initialize 3d camera mode
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
@Ushio
Ushio / material.hpp
Created December 30, 2018 05:41
material
class MicrocylinderClothMaterial : public IMaterial {
public:
glm::dvec3 tangentu;
glm::dvec3 tangentv;
glm::dvec3 bxdf(const glm::dvec3 &wo, const glm::dvec3 &wi) const override {
if (glm::dot(Ng, wi) < 0.0 || glm::dot(Ng, wo) < 0.0) {
return glm::dvec3(0.0);
}
@Ushio
Ushio / material.hpp
Created December 30, 2018 05:41
material
class MicrocylinderClothMaterial : public IMaterial {
public:
glm::dvec3 tangentu;
glm::dvec3 tangentv;
glm::dvec3 bxdf(const glm::dvec3 &wo, const glm::dvec3 &wi) const override {
if (glm::dot(Ng, wi) < 0.0 || glm::dot(Ng, wo) < 0.0) {
return glm::dvec3(0.0);
}
@Ushio
Ushio / microcylindercloth.hpp
Created December 30, 2018 05:39
microcylindercloth
#pragma once
#include <glm/glm.hpp>
#include <glm/ext.hpp>
namespace rt {
#define MICROCYLINDER_ASSERT_ENABLE 1
#if MICROCYLINDER_ASSERT_ENABLE
@Ushio
Ushio / vex
Created December 29, 2018 03:39
tracking refraction
vector rd = normalize(set(-1, ch("dirY"), 0));
vector ro = @P;
int prim = addprim(0, "polyline");
addvertex(geoself(), prim, @ptnum);
float ior = ch("ior");
for(int i = 0 ; i < 20; ++i) {
vector p;
@Ushio
Ushio / cylinder_reflectance.hpp
Created December 24, 2018 14:11
cylinder_reflectance
inline double normalized_gaussian(double beta, double theta) {
return std::exp(-theta * theta / (2.0 * beta * beta)) / (std::sqrt(glm::two_pi<double>()) * beta);
}
inline double Nr(double phi_d) {
return 0.25 * std::cos(phi_d * 0.5);
}
inline double Mr(double theta_h, double gamma_s) {
return normalized_gaussian(gamma_s, theta_h);
}
inline double bsdf(glm::vec3 u, glm::vec3 wi, glm::vec3 wo, double beta, double *cosThetaI) {
@Ushio
Ushio / bsdf.hpp
Created December 17, 2018 14:39
thread BSDF
#if NDEBUG
#define RT_ASSERT(expect_true) ;
#else
#define RT_ASSERT(expect_true) if((expect_true) == 0) { __debugbreak(); }
#endif
inline double normalized_gaussian(double beta, double theta) {
return std::exp(-theta * theta / (2.0 * beta * beta)) / (std::sqrt(glm::two_pi<double>() * beta * beta));
}
@Ushio
Ushio / FixedMenu
Created November 5, 2018 03:28
FixedMenu
public class FixedMenu : IMenu
{
struct Item
{
public string Key;
public string Label;
public string LabelShortCut;
public List<IMenu> Children;
}
Item _item;
#pragma once
#include <algorithm>
#include <glm/glm.hpp>
#include <glm/ext.hpp>
namespace rt {
class SphericalTriangleSampler {
public:
/*
a, b, c はポリゴンの頂点
@Ushio
Ushio / Polygon2DRenderer.cs
Created October 5, 2018 06:23
Polygon2DRenderer
using UnityEngine;
using System.Collections.Generic;
using UnityEngine.UI;
public class Polygon2DRenderer : Graphic
{
public Transform _Mesh;
protected override void OnPopulateMesh(VertexHelper vh)
{