Skip to content

Instantly share code, notes, and snippets.

@Codezigineer
Codezigineer / ssrshader.js
Last active July 31, 2024 22:13
Realistic fork of Screen Space Reflections implementation from Threejs Examples
import {
Matrix4,
Vector2,
AddEquation,
Color,
NormalBlending,
DepthTexture,
SrcAlphaFactor,
OneMinusSrcAlphaFactor,
MeshNormalMaterial,
@Codezigineer
Codezigineer / doc.md
Last active July 26, 2024 03:30
# Screen space AO technique that is faster than HBAO and just as accurate

Planar Screen Space Ambient Occlusion

PSSAO works off of SSAO, but also includes how much a depth difference matters in the end result. Let's say a is our depth/distance value. This distance is: (in pseudocode) a = (dot(centerPixelNormal, neighboringPixel3DPos) - dot(centerPixelNormal, centerPixel3DPos)) / distance( neighboringPixelPos * cameraDimensions, centerPixelPos * cameraDimensions)

Now put it in this formula:

@Codezigineer
Codezigineer / vocab.txt
Created December 11, 2023 19:10
A fast tokenizer
This file has been truncated, but you can view the full file.
the


.
,
of
and
to
@Codezigineer
Codezigineer / PSocket.php
Last active March 25, 2023 21:05
Simpler HTTP Socket server in PHP (Apache, no modules)
<?php
declare(strict_types=1);
$input = fopen("php://input");
class HTTPSocketServer {
public ?callable $onData = null;
private bool $serverStarted = false;
@Codezigineer
Codezigineer / webcomp.sh
Last active February 21, 2023 01:52
webcomp: Very simple WebAssembly compiler based on LLVM 8+
#!/bin/bash
if [[ "$(curl https://gist.github.com/Codezigineer/501c09f8a3114ce7bb32c7d27301650b/raw/webcomp.sh)" != "$(cat $0)" ]]; then
cd "$(dirname $0)"
curl https://gist.github.com/Codezigineer/501c09f8a3114ce7bb32c7d27301650b/raw/webcomp.sh -o webcomp
fi
usage() {
echo "Usage: webcomp [ -f infile ] [ -o outfile ] [ -O0 ] [ -O1 ] [ -O2 ] [ -O3 ] [ -t target {default is wasm32} ] [ -O ]"
}
@Codezigineer
Codezigineer / iSH-emscripten.sh
Last active February 18, 2023 04:09
Emscripten for iSH
apk update
apk add curl git bash zip clang gcc nodejs python3
curl https://codeload.github.com/emscripten-core/emsdk/zip/refs/heads/main -o main.zip
unzip main.zip -d emsdk
cd emsdk
cd emsdk-main
chmod +x emsdk
./emsdk install latest
./emsdk activate latest
@Codezigineer
Codezigineer / Cryptorand.c
Last active February 5, 2023 03:19
Cryptorand.c
#include <stdlib.h>
unsigned char clz32(unsigned int x)
{
return __builtin_clz(x);
};
unsigned char *randomData(unsigned length)
{
unsigned char *array = (unsigned char *)malloc(length);
@Codezigineer
Codezigineer / index.html
Created November 27, 2022 06:54
Tearable Cloth
<canvas id="c"></canvas>
<div id="info">
<div id="top">
<a id="close" href="">&times;</a>
</div>
<p>
<br>- Tear the cloth with your mouse
<br>
<br>- Right click and drag to cut