Casey Primozic’s Notes

Misc. notes, code, and other content I want to post publicly that don’t warrant a full blog post

By Casey Primozic

Subscribe to RSS

Fixing rust-analyzer to work with uuid_unstable for v7 UUIDs

Recently, one of my coworkers added code that uses v7 UUIDs. v7 UUIDs are a new type of UUID that contains a timestamp along with randomness, making them useful for DB primary keys and similar things. However, that code broke my rust-analyzer install for local development. I already was running rust nightly locally, so there was some other issue. It said that Uuid::new_v7() wasn’t a function even though the v7 feature was enabled for the uuid crate and it was at the latest version.
Read more →

Fixing HSA_STATUS_ERROR_OUT_OF_RESOURCES Error with Stable Diffusion

I’ve been using Stable Diffusion XL via the Automatic1111 web UI to generate PBR textures for use in my Three.JS projects, as I’ve written about previously. Everything was going great until at random, the generation started crashing at 100% and I got this error in my console: :0:rocdevice.cpp :2786: 58285575154 us: 154003: [tid:0x7f59ee1216c0] Callback: Queue 0x7f583ec00000 Aborting with error : HSA_STATUS_ERROR_OUT_OF_RESOURCES: The runtime failed to allocate the necessary resources. This error may also occur when the core runtime library needs to spawn threads or create internal OS-specific events.
Read more →

Investigating Hill Noise for Terrain Generation

I’ve been working on some procedural terrain generation for my 3D work in Three.JS lately. I wanted to try out a fresh noise function for generating terrain; everyone has used Perlin noise or some variant of it for decades. I came across a blog post by Bruce Hill describing a noise function he designed himself - called Hill Noise. It works by combining a bunch of sine waves together with different offsets and rotations.
Read more →

Some Notes and Docs on the Rust Blackjack Procedural Geometry Tool

I’ve been trying out a tool written in Rust called Blackjack for procedural, node-based 3D modelling. It’s a lot like Blender’s geometry nodes. There aren’t a lot in terms of docs, and it looks like the project isn’t being actively developed right now. Nonetheless, I think it’s an extremely cool project, and the code is very high quality. So, I’ve been spending a bit of time getting familiar with it and trying it out.
Read more →

Fixing WebGL/Three.JS GL_INVALID_ENUM : glDrawElements: type was GL_FLOAT error

The Problem I was working on some procedural dynamic LOD terrain in Three.JS. As part of this, I was manually constructing indexed BufferGeometry instances. Things were working alright, but when I added in a depth pre-pass I started getting errors like this in the console and the terrain failed to render: GL ERROR :GL_INVALID_ENUM : glDrawElements: type was GL_FLOAT The code I had looked something like this: const vertices = new Float32Array((segments + 1) * (segments + 1) * 3); const indices = new Float32Array(segments * segments * 6); // .
Read more →

Debugging WebGL GLSL Shader Behavior Differences Between M1 Mac and AMD GPU

The Problem I’ve been working on a shader in GLSL for implementing volumetric fog via raytracing. I did the majority of the work for it it on my M1 Macbook laptop while traveling, but I was eager to try it out on my powerful 7900 XTX when I got home to see how it performed. To my surprise, the results looked extremely different! The lighting was very low-detail on my desktop with the AMD GPU compared to how it looked on my Macbook.
Read more →

Fixing “Could Not Load Openssl” Mastodon Build Error

While trying to update my Mastodon server to the latest v4.2.0 release, I kept running into build failures when running docker-compose build. I got errors like this in the logs: #20 27.04 Bundler 2.4.10 is running, but your lockfile was generated with 2.4.13. Installing Bundler 2.4.13 and restarting using that version. #20 27.21 There was an error installing the locked bundler version (2.4.13), rerun with the `--verbose` flag for more details.
Read more →

Fixing pmndrs Postprocessing Recursive Depth Texture Binding

I’ve been working on building 3D scenes and environments in the browser using Three.JS. As part of those, I make pretty heavy use of the pmndrs postprocessing library for post-processing and effects. I’ve also implemented a custom godrays effect that works with postprocesing called three-good-godrays. It creates a custom pass that is added to the postprocessing EffectComposer which renders volumetric screen-space godrays by reading the depth buffer and shadow map for a light.
Read more →

Fixing “performance is not defined” Issue with Svelte/SvelteKit

The Issue When building my SvelteKit project, I get lots of errors like this in my console: ERROR in ./src/graphEditor/nodes/CustomAudio/MIDIToFrequency/MIDIToFrequencySmallView.svelte Module build failed (from ./node_modules/svelte-loader/index.js): ReferenceError: performance is not defined at now (/home/casey/web-synth/node_modules/svelte/compiler.cjs:7:31) at new Stats (/home/casey/web-synth/node_modules/svelte/compiler.cjs:47:21) at compile (/home/casey/web-synth/node_modules/svelte/compiler.cjs:45535:16) at injectVarsToCode (/home/casey/web-synth/node_modules/svelte-preprocess/dist/transformers/typescript.js:85:45) at mixedImportsTranspiler (/home/casey/web-synth/node_modules/svelte-preprocess/dist/transformers/typescript.js:257:26) at transformer (/home/casey/web-synth/node_modules/svelte-preprocess/dist/transformers/typescript.js:336:11) at transform (/home/casey/web-synth/node_modules/svelte-preprocess/dist/autoProcess.js:46:12) at async /home/casey/web-synth/node_modules/svelte-preprocess/dist/autoProcess.js:117:29 at async script (/home/casey/web-synth/node_modules/svelte-preprocess/dist/autoProcess.js:147:33) at async process_single_tag (/home/casey/web-synth/node_modules/svelte/compiler.cjs:45984:21) at async Promise.all (index 0) at async replace_in_code (/home/casey/web-synth/node_modules/svelte/compiler.
Read more →

Fixing “can’t resolve ‘svelte/internal’” Error After Upgrading svelte

I bumped several of the dependencies for one of my projects. It uses Svelte and Webpack, and makes use of svelte-loader to facilitate importing .svelte files. I upgraded Svelte from v3.57.0 to v4.2.0, and bumped svelte-loader, svelte-preprocess, prettier-plugin-svelte, and many other libraries to their latest versions as well. After the upgrade, my Webpack dev server started up but failed to load with many errors like these displayed in the console:
Read more →