Skip to content

Instantly share code, notes, and snippets.

@reinsteam
reinsteam / approx_exp2.c
Last active February 18, 2017 10:27
Coefficients of minimax polynomial approximation of exp2(x) using the Remez Exchange Algorithm in range (0.0, 1.0]
// maximum relative error : 2.38418579e-07
const float exp2_c0 = 0.999999930f;
const float exp2_c1 = 0.693153100f;
const float exp2_c2 = 0.240153617f;
const float exp2_c3 = 0.055826318f;
const float exp2_c4 = 0.008989340f;
const float exp2_c5 = 0.0018775767f;
inline float exp2_zero_one_range(float x)
{
@reinsteam
reinsteam / atmosphere_clouds_rendering.md
Last active March 1, 2024 14:43
A collection of links to various materials on atmosphere / clouds rendering

Atmosphere / Clouds Rendering

Research papers

Atmosphere

  • A fast, simple method to render sky color using gradients maps [[Abad06]]
  • A Framework for the Experimental Comparison of Solar and Skydome Illumination [[Kider14]]
  • A Method for Modeling Clouds based on Atmospheric Fluid Dynamics [[Miyazaki01]]
  • A Physically-Based Night Sky Model [[Jensen01]]
@reinsteam
reinsteam / pcomp.md
Created November 20, 2016 12:04
Links to materials about perceptual image comparison metric

Perceptual Image Differencing

  • [1983. Peter Burt and Edward Adelson. The Laplacian Pyramid as a Compact Image Code][1]
  • [1993. Scott Daly. The visible differences predictor: an algorithm for the assessment of image fidelity][2]
  • [1995. Andrew S. Glassner. In Principles of digital image synthesis, pages 59-66][3]
  • [1997. Gregory Ward-Larson, Holly Rushmeier, and Christine Piatko. A visibility matching tone reproduction operator for high dynamic range scenes][4]
  • [1999. Mahesh Ramasubramanian, Sumant N. Pattnaik, Donald P. Greenberg. A perceptually based physical error metric for realistic image synthesis][5]
  • [2004. Yangli Hector Yee, Anna Newman. A perceptual metric for production Testing][6]
  • [2004. HECTOR YEE, SUMANTA PATTANAIK and DONALD P. GREENBERG. Spatiotemporal Sensitivity and Visual Attention for Efficient Rendering of Dynamic Environments][7]
  • [2004. Hector Yee. *A Perceptual Metric for Production Testing (Submitted and Accepted in Journal of
@reinsteam
reinsteam / PrefixSum64.hlsl
Created October 29, 2016 13:18
An HLSL for computing prefix sum of 64 values using LDS
uint ReadSlotId(uint LaneId, uint mask0, uint mask1)
{
return LaneId & (0x20 | mask0) | mask1;
}
void LdsBarrier() {}
groupshared float Scratch[64];
float PrefixSum64(uint LaneId, float x)
@reinsteam
reinsteam / Sample4x4MinMaxZ.hlsl
Last active October 22, 2016 09:02
An HLSL function for sampling a depth texture and computing min and max of 4x4 grid of texels using 4 fetches
float Min3(float a, float b, float c)
{
return min(a, min(b, c));
}
float Max3(float a, float b, float c)
{
return max(a, max(b, c));
}
@reinsteam
reinsteam / tundra_msvc_config.lua
Created June 19, 2016 04:07
Configs for tundra build system
local msvc_config =
{
Env = {
CCOPTS = {
"/Wall", "/WL", "/GR-", "/EHs-c-", "/analyze", '/FA', '/TC',
"/Zl", "/Za",
{ "/O2", "/GL", "/GS-", "/Gw"; Config = "*-vs*-release" },
{ "/Od", "/GL-", "/GS", "/RTCcsu"; Config = "*-vs*-debug" },
},
LIBS = {
uint BitReverse(uint x)
{
x = ((x & 0x55555555) << 1) | ((x & 0xaaaaaaaa) >> 1);
x = ((x & 0x33333333) << 2) | ((x & 0xcccccccc) >> 2);
x = ((x & 0x0f0f0f0f) << 4) | ((x & 0xf0f0f0f0) >> 4);
x = ((x & 0x00ff00ff) << 8) | ((x & 0xff00ff00) >> 8);
x = ((x & 0x0000ffff) << 16) | ((x & 0xffff0000) >> 16);
return x;
}
@reinsteam
reinsteam / compress_ETC1_split_alpha_nomips.bat
Created October 19, 2015 11:29
Combination of flags for etcpack tool to compress PNG to KTX
etcpack test.png test -s slow -e perceptual -as -c etc -f RGB -ext PNG -ktx -v -progress
@reinsteam
reinsteam / PreviewTexture2D.cs
Created September 2, 2015 13:12
Simple previewer for texture properties in Unity
using UnityEngine;
public class PreviewTexture2D : PropertyAttribute
{
public PreviewTexture2D()
{ }
}
@reinsteam
reinsteam / enum_volume.c
Created August 28, 2015 23:17
Sample code of volumes enumeration to get physical and logical sector alignment
#pragma warning (push)
/* 4820: '<struct-name>' : 'n' bytes padding added after data member '<member-name>'*/
# pragma warning (disable : 4820)
# pragma warning (disable : 4255 4668)
# include <windows.h>
# include <stdio.h>
#pragma warning (pop)
typedef unsigned u32;