Skip to content

Instantly share code, notes, and snippets.

View sortofsleepy's full-sized avatar

Joe sortofsleepy

View GitHub Profile
@sortofsleepy
sortofsleepy / CMakeLists.txt
Created June 8, 2023 23:07
Building Google Dawn w/ CMake
cmake_minimum_required(VERSION 3.25)
project(dawn_compile)
set(CMAKE_CXX_STANDARD 17)
add_executable(dawn_compile main.cpp)
include_directories(dawn_compile ${CMAKE_CURRENT_SOURCE_DIR}/libraries/dawn/include)
include_directories(dawn_compile ${CMAKE_CURRENT_SOURCE_DIR}/libraries/dawn/gen/include)
@sortofsleepy
sortofsleepy / ParticleSystem.ts
Last active May 27, 2023 16:13
BabylonJS MultiRenderTarget particle system example
import {
Constants,
Color4,
Mesh,
Scene,
RenderTargetTexture,
Engine,
Vector3,
UniversalCamera,
RawTexture,
@sortofsleepy
sortofsleepy / setup.jsx
Last active May 19, 2023 16:40
example of how to build an instanced sphere while adding additional attributes to the mesh
// Builds instanced data for the packing
const objdata = useMemo(() => {
let sphere = new SphereGeometry(1, widthSegments, heightSegments);
// build colors
let palette = colors({
numberOfValues: 20
})
const settings = {
@sortofsleepy
sortofsleepy / r3fInstancedBufferGeometry.js
Last active April 20, 2023 16:32
This is a basic example of using InstancedBufferGeometry in react-three-fiber as of 8.12.1. Uses the pack-spheres npm module to generate the shapes.
import React, {useMemo} from "react";
import pack from "pack-spheres"
import {SphereGeometry, GLSL3, InstancedBufferAttribute} from "three"
export default function (props) {
const {
numInstances = 1000,
dimensions = 3,
packAttempts = 500,
@sortofsleepy
sortofsleepy / build.zig
Created January 24, 2023 23:51
Zig build script - passing command line value example
const Builder = @import("std").build.Builder;
const std = @import("std");
pub const OptionsStep = @import("std").build.OptionsStep;
pub fn build(b: *Builder) void {
var option = b.option(bool,"Desktop", "Set to true to build desktop focused library");
if(option == true){
std.log.info("TODO",.{});
@sortofsleepy
sortofsleepy / fullscreentriangle.tsx
Last active May 18, 2023 13:32
a-big-triangle React / react-three-fiber
import * as React from "react"
import {useEffect, useMemo,} from "react"
import {Sphere, Vector2, GLSL3} from "three";
import {useThree} from "@react-three/fiber";
/**
* A port of a-big-triangle to react-three-fiber.
*
* https://github.com/mikolalysenko/a-big-triangle
*
@sortofsleepy
sortofsleepy / houdini_json_geo_export.py
Created June 13, 2021 17:38
Basic way to export props of a geo node in Houdini into Json.
import json, os
# adapted from here with minor tweaks
# https://github.com/sideeffects/GameDevelopmentToolset/blob/Development/otls/rop_csv_exporter.hda/gamedev_8_8Driver_1rop__csv__exporter/PythonModule#L43
# needs a bit more work to make it better but works well enough for now.
node = hou.pwd()
geo = node.geometry()
filename = "./tester.json"
import * as vscode from 'vscode';
import {existsSync,promises,readFileSync} from "fs"
import {resolve, posix, normalize} from "path"
let getFiles = async(dir) =>{
const dirents = await promises.readdir(dir,{
withFileTypes:true
@sortofsleepy
sortofsleepy / shaderrcsample.cpp
Created June 8, 2020 03:13
sample of how to use shaderc to compile shaders
void Shader::compile(VkDevice * device,const std::string source_name, shaderc_shader_kind kind, const std::string source,
bool optimize) {
shaderc::Compiler compiler;
shaderc::CompileOptions options;
if(optimize){
options.SetOptimizationLevel(shaderc_optimization_level_size);
}
@sortofsleepy
sortofsleepy / example.cpp
Created May 30, 2020 15:07
Example of how to deal with HTML elements and callbacks entirely in Emscripten/C++.
/*
I know I pieced this together largely from another person's idea and their goal of trying to deal with
XMLHTTPRequests. I unfortunately can't find the original source, if you happen to be that person and this looks
familiar, link me to your post(s) and I'll credit you properly
*/
// Somewhere in your .cpp file "EmscriptenCallback" and "Callback" can be whatever you want, it just has to be a unique name
// for the argument to the std::function, that can be whatever you want too but for the purposes of this i think it makes sense to
// leave it as a val since you're expecting an event object back.