Skip to content

Instantly share code, notes, and snippets.

import numpy as np
# [ 32, 32 ]
# GGX_E[32-roughness][32-cos_theta]
GGX_E = np.array([
[0.9635857939720154, 0.995747983455658, 0.9983890056610107, 0.9992253184318542, 0.9995855093002319, 0.9996441006660461, 0.9998587369918823, 0.99983811378479, 0.9998855590820312, 0.9998201727867126, 0.9998736381530762, 0.9998807311058044, 0.9998859763145447, 0.9998285174369812, 0.9999691247940063, 0.9998969435691833, 0.9999278783798218, 0.9999445676803589, 0.999960720539093, 0.9999779462814331, 0.9999331831932068, 0.9999798536300659, 0.999980628490448, 0.9999813437461853, 0.9999666213989258, 0.9999518990516663, 0.999967634677887, 0.9999833106994629, 0.9999531507492065, 0.9999687671661377, 0.9999690651893616, 0.9999998807907104],
[0.9624530076980591, 0.9955804944038391, 0.9987631440162659, 0.9992542862892151, 0.9995307326316833, 0.9997747540473938, 0.9998279809951782, 0.999792218208313, 0.999916136264801, 0.9996671080589294, 0.9998441338539124, 0.9997889399528503, 0.9998522996902466, 0.9998584389686584, 0.9999077916145325, 0
import {g, tm} from './util';
import {ColorTransform, TransferFunction} from './colorspace';
let ready = false;
let setup = () => ti.addToKernelScope({
tm,
ColorTransform, TransferFunction,
ToneMapping,
tone_map,
tone_map_hable, _hable_partial,
import {g, tm} from './util';
let ready = false;
let setup = () => ti.addToKernelScope({
g, tm,
ColorTransform, TransferFunction,
convert_to_xyz, convert_from_xyz, convert_color_space
});
export class ColorTransform {
import random
import torch
import numpy as np
import typing
from typing import Union
from combomethod import combomethod
from tinycio import fsio
@classmethod
def normals_to_height(cls,
normal_map:torch.Tensor,
self_tiling:bool=False,
rescaled:bool=False,
eps:float=torch.finfo(torch.float32).eps) -> (torch.Tensor, torch.Tensor):
"""
Compute height from normals. Frankot-Chellappa algorithm.
:param normal_map: Normal map tensor sized [N, C=3, H, W] or [C=3, H, W]
import time
import math
import torch
import taichi as ti
import taichi.math as tm
import tinytex as ttex
from tinycio import fsio
@Sam-Izdat
Sam-Izdat / interp.py
Created February 18, 2024 05:15
taichi interpolation
@ti.func
def _bilateral_interp_coeffs(self,
uv_grid:tm.vec2,
probe_elevation:float,
grid_height:int,
grid_width:int,
probe_height:int,
probe_width:int,
cascade:int) -> (tm.ivec4, tm.vec4):
"""Returns pixel indices and weights for interpolation"""
@Sam-Izdat
Sam-Izdat / bind-blacklist-memory
Created November 10, 2015 18:23
Memory usage with BIND blacklist
KiB Mem: 1012384 total, 974288 used, 38096 free, 128872 buffers
KiB Swap: 3068924 total, 372 used, 3068552 free. 356848 cached Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
6395 bind 20 0 312536 231284 2476 S 0.0 22.8 0:55.11 /usr/sbin/named -u bin
@Sam-Izdat
Sam-Izdat / blockeddomains.db
Created November 10, 2015 17:32
BIND dummy blockeddomains.db
$TTL 24h
@ IN SOA ads.example.com. hostmaster.example.com. (
2003052800 86400 300 604800 3600 )
@ IN NS server.example.com.
@ IN A 127.0.0.1
* IN A 127.0.0.1
@Sam-Izdat
Sam-Izdat / zones.blacklist.conf
Created November 10, 2015 17:18
BIND 9 blacklist for ads, malware and spyware
This file has been truncated, but you can view the full file.
// MICROSOFT SPYWARE
zone "telemetry.microsoft.com" { type master; file "/etc/bind/blockeddomains.db"; };
zone "a-0001.a-msedge.net" { type master; file "/etc/bind/blockeddomains.db"; };
zone "choice.microsoft.com" { type master; file "/etc/bind/blockeddomains.db"; };
zone "choice.microsoft.com.nsatc.net" { type master; file "/etc/bind/blockeddomains.db"; };
zone "compatexchange.cloudapp.net" { type master; file "/etc/bind/blockeddomains.db"; };
zone "corp.sts.microsoft.com" { type master; file "/etc/bind/blockeddomains.db"; };
zone "corpext.msitadfs.glbdns2.microsoft.com" { type master; file "/etc/bind/blockeddomains.db"; };
zone "cs1.wpc.v0cdn.net" { type master; file "/etc/bind/blockeddomains.db"; };
zone "df.telemetry.microsoft.com" { type master; file "/etc/bind/blockeddomains.db"; };