Skip to content

Instantly share code, notes, and snippets.

View sortofsleepy's full-sized avatar

Joe sortofsleepy

View GitHub Profile
@sortofsleepy
sortofsleepy / spritesheet.glsl
Created September 10, 2024 21:51
glsl spritesheet helper
// A helper to sample a section of a texture. useful for things like spritesheets.
// texCoord - uvs of the surface you're rendering to
// imageSize - the size of the patch you want to sample
// fulLTextureSize - the full dimensions of the texture you're sampling from
// imageCoord - the x/y value of the section to sample from.
// Sourced from @Gabor on Disccord in the @creativecode server.
vec2 sample_section(
vec2 texCoord,
vec2 imageSize,
@sortofsleepy
sortofsleepy / refs.glsl
Last active August 20, 2024 13:27
Vulkan Buffer Reference basics
// ... version, etc
#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
struct SceneDataTable {
uint64_t vertices;
};
layout(buffer_reference, scalar) buffer Vertices { vec4 v[]; };
@sortofsleepy
sortofsleepy / grid_helper.glsl
Last active September 1, 2024 12:52
Grid position helper functions
// some general helpers on how to sample a 1D grid.
// returns the x/y coordinate of value inside of an 1D array/grid.
// pass in the desired index. size refers to the "width" of the grid.
// note that you may have to round/floor the value depending on your needs, ivec2 is only available in glsl.
ivec2 get_coord(int index, int size){
return ivec2(index % size, index / size);
}

Rollup / SSR / Phoenix LiveView notes

(IN PROGRESS)

Rollup can be configured to build the necessary parts to do SSR with JS frameworks. I've only tested w/ Solid but with some modifications, you can also adapt the following for things like Svelte and perhaps other frameworks.

This is actually based largely off of LiveSvelte but I wanted to use something more common these days like Rollup - this is however just

@sortofsleepy
sortofsleepy / .gitlab-ci.yml
Last active May 20, 2024 13:12
Gitlab CI deploy to cloudflare example
image: node:latest
cache:
paths:
- node_modules/
stages:
- build
compile:
@sortofsleepy
sortofsleepy / Unreal notes.md
Last active April 10, 2024 01:13
Web/OpenGL -> Unreal Engine

Some general observations about Unreal. Note that I am dumb and some mistakes / misinformation might be present.

Units

1 "unit" in unreal for setting something is approximately setting that object to 0.01 scale.

For example, for the default 100x100x100 cube, to make it 1x1x1, you set the scale of that to 0.01

I believe things are "technically" in cm, but don't quote me on that.

@sortofsleepy
sortofsleepy / .gitdepsignore
Last active March 19, 2024 16:14
Setup UE w/ some excluded dependencies
/Engine/Extras/VisualStudioDebugging/**
/Engine/Extras/VisualStudioSnippets/**
/Engine/Extras/Maya_AnimationRiggingTools/**
/Engine/Extras/MayaVelocityGridExporter/**
/Engine/Plugins/Online/**
@sortofsleepy
sortofsleepy / OdinWebAssemblyBasic.md
Last active August 15, 2024 04:11
Odin language simple WebAsembly setup

Have some free time on my hands so I thought I'd try out Odin, an interesting language I came across a few weeks ago. I haven't dived too far into it but so far from what I understand, it's another language in a similar vain of Rust and Zig(both also very good)

Since as far as I can tell, though Odin does support WebAssembly, how specifically to build for it is not well documented so I thought I should post a very basic setup for WebAssembly.

All the Odin app does is

  • export a function that called setup that calls an imported JS function getWindowWidth
  • In the JS, it calls setup and logs the result.

When building the Odin code, the command is roughly odin build -target="js_wasm32" -out=""

@sortofsleepy
sortofsleepy / +page.server.ts
Created July 2, 2023 14:31
SvelteKit File Upload Example
import {writeFileSync, existsSync, mkdirSync} from "fs"
// make sure tmp directory exists and create it if it doesn't
function checkTmp() {
if (!existsSync("static/tmp")) {
mkdirSync("static/tmp")
}
}
export const actions = {
// Example of how to find indices to values in a 2D array that are below a specified index.
/*
Take the following
[0,1,2,3
4,5,6,7
8,9,10,11]
This formula helps you figure out, for instance, what the index of 4 is if we're looking at index 0.