This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Javascript view builder to interpret raw ArrayBuffer data as structured data. | |
// Copyright 2024 (c) Élie Michel - MIT Licensed | |
// NB: This is loosly inspired by https://github.com/kainino0x/structured-accessor | |
const kTypedArrayConstructors = { | |
i8: Int8Array, | |
u8: Uint8Array, | |
i16: Int16Array, | |
u16: Uint16Array, | |
i32: Int32Array, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
An efficient numpy implementation of GLSL packHalf2x16 and unpackHalf2x16. | |
Author: Elie Michel <elie.michel@exppad.com> | |
License: MIT - 2023 | |
""" | |
def packHalf2x16(x, y): | |
""" | |
Pack two floats into a single uint32, like GLSL's packHalf2x16 function | |
(but vectorized for numpy arrays). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using https://github.com/eliemichel/WebGPU-Cpp | |
#include <webgpu/webgpu.hpp> | |
namespace raii { | |
class Buffer { | |
public: | |
// Whenever a RAII instance is created, we create an underlying resource | |
Buffer(wgpu::Device device, const wgpu::BufferDescriptor& bufferDesc) | |
: m_raw(device.createBuffer(bufferDesc)) | |
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stb_image_write.h" | |
#include <webgpu/webgpu.hpp> | |
#include <filesystem> | |
#include <string> | |
bool saveTexture(const std::filesystem::path path, wgpu::Device device, wgpu::Texture texture, int mipLevel) { | |
using namespace wgpu; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stb_image_write.h" | |
#include <webgpu/webgpu.hpp> | |
#include <filesystem>h | |
#include <string> | |
std::filesystem::path resolvePath(int frame) { | |
std::filesystem::path base = "render/frame" + std::to_string(frame) + ".png"; | |
create_directories(base.parent_path()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def local_import(module_name): | |
exec('\n'.join([l.body for l in bpy.data.texts[module_name].lines])) | |
for k, v in locals().items(): | |
globals()[k] = v | |
# Example | |
import bpy | |
import bmesh | |
import numpy as np | |
local_import('tiny_timer.py') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Credits 2020-2022 to Élie Michel <elie.michel@exppad.com> | |
# Released in Public Domain | |
# | |
# The Software is provided "as is", without warranty of any kind, express or | |
# implied, including but not limited to the warranties of merchantability, | |
# fitness for a particular purpose and non-infringement. In no event shall the | |
# authors or copyright holders be liable for any claim, damages or other | |
# liability, whether in an action of contract, tort or otherwise, arising | |
# from, out of or in connection with the software or the use or other dealings | |
# in the Software. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
def duplicate_node(n1, node_group=None, duplicate_links=False): | |
""" | |
Duplicate a node (without duplicating its links) | |
@param n1 The node to duplicate | |
@param node_group (optional) Group in which the node must be duplicated | |
@param duplicate_links Whether to keep input links or not | |
@return the new duplicate node | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// [...] | |
/** | |
* Create a new Mesh representing a simple pizza (really just a disc with | |
* a few quads on top of it). | |
* olive_count is the number of olives topping the pizza | |
* radius is the radius of the pizza | |
* base_polys is filled with the range of polygons belonging to the base | |
* olive_polys is filled with the range of polygons representing the olives | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is an automation of https://stackoverflow.com/questions/71783590/git-merge-strategy-option-theirs-for-individual-files | |
# Example: | |
# git_resolve.py --theirs path/to/some/file | |
import os | |
import argparse | |
from shutil import copyfile | |
import subprocess | |
parser = argparse.ArgumentParser(description='Resolve conflicted areas of a file during a git merge') |
NewerOlder