Skip to content

Instantly share code, notes, and snippets.

@jdupuy
jdupuy / SampleVndf_GGX.cpp
Last active September 24, 2024 15:22
Sampling Visible GGX Normals with Spherical Caps
// Helper function: sample the visible hemisphere from a spherical cap
vec3 SampleVndf_Hemisphere(vec2 u, vec3 wi)
{
// sample a spherical cap in (-wi.z, 1]
float phi = 2.0f * M_PI * u.x;
float z = fma((1.0f - u.y), (1.0f + wi.z), -wi.z);
float sinTheta = sqrt(clamp(1.0f - z * z, 0.0f, 1.0f));
float x = sinTheta * cos(phi);
float y = sinTheta * sin(phi);
vec3 c = vec3(x, y, z);
@cshenton
cshenton / block_allocator.odin
Last active March 25, 2024 00:45
Allocator based on Sebastian Aaltonen's Offset Allocator, for suballocating GPU heaps
package block_allocator
// Allocator based on Sebastian Aaltonen's Offset Allocator:
// https://github.com/sebbbi/OffsetAllocator/blob/main/offsetAllocator.cpp
import "core:fmt"
import "core:math/bits"
import "core:math/rand"
assert_allocator_layout_good :: proc(allocator: ^Block_Allocator) {
@Marc-B-Reynolds
Marc-B-Reynolds / output.md
Last active November 25, 2024 22:53
brute force testing of 1/sqrt functions
click for range breakdown

checking on [3f800000,40000000] [1.000000e+00,2.000000e+00]

func e max ULP CR FR 2 ULP > 2 ULP CR% FR% 2 ULP% > 2 ULP%
vrsqrte_f32 -- 4947968 103 225 216 8388065 0.001228 0.002682 0.002575 99.993515
FRSR_Mon0 -- 564177 3 8 6 8388592 0.000036 0.000095 0.000072 99.999797
FRSR_Deg0 -- 403258 0 0 0 8388609 0.000000 0.000000 0.000000 100.000000
FRSR_Mon1 -- 14751 230 464 466 8387449 0.002742 0.005531 0.005555 99.986172
@h3r2tic
h3r2tic / restir-meets-surfel-lighting-breakdown.md
Created November 23, 2021 02:15
A quick breakdown of lighting in the `restir-meets-surfel` branch of my renderer

A quick breakdown of lighting in the restir-meets-surfel branch of my renderer, where I revive some olde surfel experiments, and generously sprinkle ReSTIR on top.

General remarks

Please note that this is all based on work-in-progress experimental software, and represents a single snapshot in development history. Things will certainly change 😛

Due to how I'm capturing this, there's frame-to-frame variability, e.g. different rays being shot, TAA shimmering slightly. Some of the images come from a dedicated visualization pass, and are anti-aliased, and some show internal buffers which are not anti-aliased.

Final images

Suppose Alice and Bob need a protocol for agreeing to perform an action.
The communication delay is T seconds (which we assume to be symmetric).
A standard handshaking protocol is request/acknowledgement. Alice raises her hand
to signal a request. Bob sees the signal T seconds later. When Bob is ready to perform
the action, he raises his hand to signal acknowledgement. So, from when Alice sent the
request, it's at least 2T seconds before she sees Bob's acknowledgement and can perform
the action.
@SwooshyCueb
SwooshyCueb / SuperEagle.glsl
Created May 21, 2016 05:51
Temporary location for glsl stuff
#version 420 compatibility
// Will insert lines here so make sure version is at the very top.
// No includes.
/******************************************************************************/
/* GLSL Fragment Shader implementation of the SuperEagle 2x upscaler filter */
/******************************************************************************/
/* Copyright (C) 2016 Markus Kitsinger (SwooshyCueb) <root@swooshalicio.us> */
/* */
/* This implementation of the SuperEagle filter is subject to the terms of */
@bkaradzic
bkaradzic / orthodoxc++.md
Last active November 28, 2024 15:42
Orthodox C++

Orthodox C++

What is Orthodox C++?

Orthodox C++ (sometimes referred as C+) is minimal subset of C++ that improves C, but avoids all unnecessary things from so called Modern C++. It's exactly opposite of what Modern C++ suppose to be.

Why not Modern C++?

@adactio
adactio / basicServiceWorker.js
Last active March 27, 2023 09:30
A basic Service Worker, for use on, say, a blog.
'use strict';
// Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
// http://creativecommons.org/publicdomain/zero/1.0/
(function() {
// Update 'version' if you need to refresh the cache
var staticCacheName = 'static';
var version = 'v1::';