Skip to content

Instantly share code, notes, and snippets.

View jamornsriwasansak's full-sized avatar

Jamorn Sriwasansak jamornsriwasansak

View GitHub Profile
#include <iostream>
#include <vector>
#include <cassert>
#include <string>
void print_tab(int t)
{
for (int i = 0; i < t; i++)
{
std::cout << "\t";
#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)
{
#pragma once
#include <cassert>
#include <memory>
enum class Op
{
cnst,
var,
add,
#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 June 21, 2021 10:01
Virtual Ray Light integrator plugin for PBRT-v3
#include <iostream>
#include <memory>
#include "vrl.h"
#include "ir.h"
#include "parallel.h"
#include "scene.h"
#include "imageio.h"
#include "spectrum.h"
@jamornsriwasansak
jamornsriwasansak / qbvh.cpp
Created June 20, 2021 20:28
SIMD quad bvh
#pragma once
#include <iostream>
#include <vector>
#include "common\reflectcuts.h"
#include "common\accel.h"
// require linearbvhnode
#include "accels\linearbvh.h"
// 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),
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:
#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 September 19, 2017 20:27
CUDA and OpenGL texture interop. Quite painful to find a working solution.
//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"