Skip to content

Instantly share code, notes, and snippets.

@DGriffin91
DGriffin91 / main.rs
Created February 17, 2023 21:57
Generate log2 LUT stimulus vertical strip
// Generate log2 LUT stimulus
// [dependencies]
// image = "0.24"
// glam = "0.22"
use glam::{vec3, Vec3};
use image::{ImageBuffer, Rgb};
extern crate image;
@DGriffin91
DGriffin91 / main.rs
Last active February 17, 2023 21:47
Convert 32bit, 16bit, or RGB9E5 images to either 16bit or RGB9E5 KTX2 with ZSTD supercompression in 3D
// Convert 32bit, 16bit, or RGB9E5 images in 3D or vertical strip format
// to either 16bit or RGB9E5 KTX2 with ZSTD supercompression in 3D
// Example cargo run -- --inputs tony_mc_mapface.dds,blender_-11_12.exr,AgX-default_contrast.exr --outputs tony_mc_mapface.ktx2,blender_-11_12.ktx2,AgX-default_contrast.ktx2
// [dependencies]
// Should be able to use bevy 0.10 instead when it is release. Needed for exr support. (TODO rewrite without bevy)
// bevy = { git = "https://github.com/DGriffin91/bevy", branch = "tonemap_options", features = ["zstd", "ktx2", "exr", "dds"] }
// half = { version = "2.1" }
// ktx2 = { git = "https://github.com/BVE-Reborn/ktx2", rev = "4a7cc48ffa4deb3aa1ef5b453292220489908fa1" }
@DGriffin91
DGriffin91 / main.rs
Created February 17, 2023 21:35
AgX-default_contrast.lut.png to vertical exr
// for converting https://github.com/MrLixm/AgXc/blob/main/obs/obs-script/AgX-default_contrast.lut.png
// to a vertical exr
// [dependencies]
// image = "0.24"
// glam = "0.22"
use std::path::Path;
use image::{DynamicImage, GenericImage, GenericImageView, ImageBuffer, Rgb};
@DGriffin91
DGriffin91 / main.rs
Last active March 5, 2024 08:11
Bevy Combine Meshes with Transforms
// License: Apache-2.0 / MIT
// Combine multiple meshes in Bevy with Transforms
// Adapted from https://github.com/bevyengine/bevy/blob/main/examples/3d/3d_shapes.rs
use std::f32::consts::PI;
use bevy::{
math::Vec4Swizzles,
prelude::*,
render::{
@DGriffin91
DGriffin91 / bitcast error
Last active October 10, 2022 18:55
rkyv LLVM Invalid bitcast
Compiling invalid-bitcast v0.1.0
Invalid bitcast
%38 = bitcast <2 x i32> %37 to <2 x i24>
Invalid bitcast
%40 = bitcast <2 x i32> %39 to <2 x i24>
in function _ZN4rkyv5impls4core89_$LT$impl$u20$rkyv..DeserializeUnsized$LT$$u5b$U$u5d$$C$D$GT$$u20$for$u20$$u5b$T$u5d$$GT$19deserialize_unsized17h8bf3deadc9a4552bE
LLVM ERROR: Broken function found, compilation aborted!
error: could not compile `invalid-bitcast`
@DGriffin91
DGriffin91 / main.rs
Last active August 3, 2022 10:36
Mesh with many quads
// License: Apache-2.0 / MIT
//camera controller from https://github.com/DGriffin91/bevy_basic_camera
use bevy::{
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
prelude::*,
render::render_resource::PrimitiveTopology,
};
use bevy_basic_camera::{CameraController, CameraControllerPlugin};
@DGriffin91
DGriffin91 / main.rs
Last active July 21, 2022 07:45
Basic Bevy Mipmap Generation
// License: Apache-2.0 / MIT
use std::num::NonZeroU8;
use bevy::{
asset::HandleId,
prelude::*,
render::{
render_resource::{
Extent3d, TextureDescriptor, TextureDimension, TextureFormat, TextureUsages,
@DGriffin91
DGriffin91 / letterboxing.rs
Last active December 5, 2022 22:20 — forked from cart/letterboxing.rs
Basic Letterboxing
// License: Apache-2.0 / MIT
use bevy::{
core_pipeline::clear_color::ClearColorConfig,
prelude::*,
render::{camera::RenderTarget, render_resource::*, view::RenderLayers},
};
fn main() {
App::new()
@DGriffin91
DGriffin91 / main.rs
Last active July 21, 2022 07:45
Bevy game of life in fragment shader
// License: Apache-2.0 / MIT
use bevy::{
prelude::*,
reflect::TypeUuid,
render::{
camera::{Camera, RenderTarget},
render_resource::{
AsBindGroup, Extent3d, ShaderRef, TextureDescriptor, TextureDimension, TextureFormat,
TextureUsages,
@DGriffin91
DGriffin91 / main.rs
Last active July 21, 2022 07:46
Bevy Lambert Material Example
// License: Apache-2.0 / MIT
// lambert_material.wgsl:
/*
#import bevy_pbr::mesh_view_bindings
#import bevy_pbr::mesh_bindings
#import bevy_pbr::pbr_types
#import bevy_pbr::utils
#import bevy_pbr::clustered_forward