Skip to content

Instantly share code, notes, and snippets.

@pyalot
pyalot / gist:5171175
Last active September 25, 2019 22:27
Minecraft mca/nbt parser
from struct import unpack
from zlib import decompress
class BufferStream:
def __init__(self, data):
self.pos = 0
self.data = data
def get(self, amount):
result = self.data[self.pos:self.pos+amount]
@pyalot
pyalot / octahedral.shader
Last active December 17, 2023 19:51
octahedral mapping
#define sectorize(value) step(0.0, (value))*2.0-1.0
#define sum(value) dot(clamp((value), 1.0, 1.0), (value))
#define PI 3.141592653589793
vec2 normalToUvRectOct(vec3 normal){
normal /= sum(abs(normal));
if(normal.y > 0.0){
return normal.xz*0.5+0.5;
}
else{