Skip to content

Instantly share code, notes, and snippets.

@futureengine2
futureengine2 / gi.c
Last active June 23, 2024 08:10
Radiance Cascades 2d GI implementation
static void gi_on_gpu(u8* in_bitmap, int w, int h) {
#define num_cascades 7
static bool initialized;
static gpu_bindgroup_t texture_bindgroup[2];
static gpu_bindgroup_t cascade_uniform_bindgroup[num_cascades];
static gpu_bindgroup_t render_uniform_bindgroup;
static gpu_buffer_t vertex_buffer;
static gpu_buffer_t uniform_buffer;
static gpu_pipeline_t pipeline;
@ecurtiss
ecurtiss / DrawBeamCircle.lua
Last active June 18, 2022 18:13
Circular Beams in Roblox
--[[
Creates a circle out of Beams.
You can let it use a default Beam object, but you probably want to pass it
your own via the BeamObject parameter.
local BeamCircle, Attachments, Beams = DrawBeamCircle({
[REQUIRED]
CFrame = CFrame of center of circle,
Radius = Radius of circle,
@mmozeiko
mmozeiko / shader.hlsl
Last active February 4, 2024 17:53
compute shader for rendering monospaced glyphs in grid
//
struct TerminalCell
{
// cell index into GlyphTexture, should be two 16-bit (x,y) values packed: "x | (y << 16)"
uint GlyphIndex;
// 0xAABBGGRR encoded colors, nonzero alpha for Foreground indicates to render colored-glyph
// which means use RGB values from GlyphTexture directly as output, not as ClearType blending weights
uint Foreground;
@andraantariksa
andraantariksa / SDL Audio.cpp
Created January 13, 2020 16:07
SDL simple record and playback
#include <SDL.h>
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <ctime>
const int MAX_RECORDING_DEVICES = 10;
@Fraktality
Fraktality / LerpCIELUV.lua
Last active February 14, 2024 02:09
Perceptually uniform color interpolation
local LerpCIELUV do
-- Combines two colors in CIELUV space.
-- function<function<Color3 result>(float t)>(Color3 fromColor, Color3 toColor)
-- https://www.w3.org/Graphics/Color/srgb
local clamp = math.clamp
local C3 = Color3.new
local black = C3(0, 0, 0)
@bkaradzic
bkaradzic / orthodoxc++.md
Last active July 29, 2024 04:50
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++?

@castano
castano / hemicube.cpp
Created June 20, 2014 09:46
Hemicube Integrator
#include "hemicube.h"
#define PACK_HEMICUBES 1
static void get_hemicube_face_normal(int index, Vector3 *forward, Vector3 *left, Vector3 *up) {
// Unwrapped hemicube with positive-Z in the middle.
switch (index) {
case 0: *forward = Vector3(+1, 0, 0); *left = Vector3( 0, 1, 0); break;