Skip to content

Instantly share code, notes, and snippets.

Avatar

Jamorn Sriwasansak jamornsriwasansak

View GitHub Profile
View 2048_playground.cpp
#include <iostream>
#include <vector>
#include <cassert>
#include <string>
void print_tab(int t)
{
for (int i = 0; i < t; i++)
{
std::cout << "\t";
View compiletime-autodiff.hpp
#pragma once
#define F_INLINE __forceinline constexpr
template <int VarIndex>
struct Var
{
template<int OtherVarIndex>
static F_INLINE float eval(const Var<OtherVarIndex> & var, const float v)
{
View runtime-autodiff.hpp
#pragma once
#include <cassert>
#include <memory>
enum class Op
{
cnst,
var,
add,
View lightcuts.cpp
#include "lightcuts.hpp"
template <class PointLightType, class PointLightNodeType>
class PointLightTree
{
public:
Spectrum samplePosition(Vec3 * wi, bool * isVisible, const Intersection & isect, const Scene & scene, const Sampler & sampler) const { assert(false && "unimplemented"); return Spectrum(0.0); };
Spectrum sampleDirection(Vec3 * wi, Vec3 * position, const Sampler & sampler) const { assert(false && "unimplemented"); return Spectrum(0.0); }
@jamornsriwasansak
jamornsriwasansak / vrl.cpp
Last active Jun 21, 2021
Virtual Ray Light integrator plugin for PBRT-v3
View vrl.cpp
#include <iostream>
#include <memory>
#include "vrl.h"
#include "ir.h"
#include "parallel.h"
#include "scene.h"
#include "imageio.h"
#include "spectrum.h"
View qbvh.cpp
#pragma once
#include <iostream>
#include <vector>
#include "common\reflectcuts.h"
#include "common\accel.h"
// require linearbvhnode
#include "accels\linearbvh.h"
View blackbody_approx.cpp
// https://portsmouth.github.io/Trinity/
// Approximate map from temperature in Kelvin to blackbody emission color.
// Valid from 1000 to 40000 K (and additionally 0 for pure full white)
vec3 colorTemperatureToRGB(const in float temperature)
{
mat3 m = (temperature <= 6500.0) ? mat3(vec3(0.0, -2902.1955373783176, -8257.7997278925690),
vec3(0.0, 1669.5803561666639, 2575.2827530017594),
vec3(1.0, 1.3302673723350029, 1.8993753891711275)) :
mat3(vec3(1745.0425298314172, 1216.6168361476490, -8257.7997278925690),
View pfm.py
import numpy as np
import re
import sys
import matplotlib.pyplot as plt
def flip(m, axis):
if not hasattr(m, 'ndim'):
m = np.asarray(m)
indexer = [slice(None)] * m.ndim
try:
View mybvh.cpp
#include <algorithm>
#include <cassert>
#include <vector>
#include "common\intersection.h"
#include "common\reflectcuts.h"
#include "common\accel.h"
#include "math\ray.h"
#include "math\math.h"
@jamornsriwasansak
jamornsriwasansak / cuda-gltexture-interop.cu
Created Sep 19, 2017
CUDA and OpenGL texture interop. Quite painful to find a working solution.
View cuda-gltexture-interop.cu
//This software contains source code provided by NVIDIA Corporation.
#include "cuda_runtime.h"
#include "cuda_surface_types.h"
#include "surface_functions.h"
// must include in this order :(
#include "GL\glew.h"
#include "cuda_gl_interop.h"
#include "GLFW\glfw3.h"