Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

R3F20: TintPlugin registered by its path (raea-render stays within its 2,000 lines); tint's colour buffer padded in a loop, not a closure dupes matched

shinyobjectzfc3bba9b1a10
diff --git a/engine/render/src/engine.rs b/engine/render/src/engine.rs
index 7554fd23..8f7f6706 100644
--- a/engine/render/src/engine.rs
+++ b/engine/render/src/engine.rs
@@ -80,8 +80,6 @@ use raea_sys_volume as volume;
// meshes that cast shadows without being drawn (<Mesh shadow="only">)
use raea_sys_material::shadow_only;
use raea_sys_material::shadow_catch;
-// a colour a copy over an <Instances>' surface (three's instanceColor)
-use raea_sys_material::tint;
// baked simulations played back by the frame (<MeshSequence>, <Goo>) and glitches on any part (physics.tsx)
use raea_sys_meshseq as meshseq;
// toon (cel) surfaces and their ink outlines (<MeshToonMaterial>)
diff --git a/engine/render/src/engine/raea_plugins.rs b/engine/render/src/engine/raea_plugins.rs
index 980601d4..a1abd68e 100644
--- a/engine/render/src/engine/raea_plugins.rs
+++ b/engine/render/src/engine/raea_plugins.rs
@@ -64,7 +64,7 @@ raea_plugin! {
GrassPlugin: raea_sys_grass::install, "Fields of grass, made in tiles as detailed as the camera's distance asks (systems/grass).";
ShadowOnlyPlugin: super::shadow_only::install, "Meshes in the shadow maps only (shadow_only.rs).";
ShadowCatchPlugin: super::shadow_catch::install, "Surfaces that show only the shadows falling on them (shadow_catch.rs).";
- TintPlugin: super::tint::install, "A colour a copy over an <Instances>' surface, three's instanceColor (tint.rs).";
+ TintPlugin: raea_sys_material::tint::install, "A colour a copy over an <Instances>' surface, three's instanceColor (tint.rs).";
ToonPlugin: super::toon::install, "The toon surface and its ink outline's materials (toon.rs).";
ShaderExtPlugin: super::shader_ext::install, "Shaders written in TypeScript over the lit standard surface (raea-sys-shader).";
ThreeShaderPlugin: raea_sys_three_shader::install, "three.js's shaders: a ShaderMaterial's GLSL (naga) and a node material's WGSL, with three's built-ins (raea-sys-three-shader).";
diff --git a/systems/material/src/tint.rs b/systems/material/src/tint.rs
index f0f81615..c16381bd 100644
--- a/systems/material/src/tint.rs
+++ b/systems/material/src/tint.rs
@@ -35,7 +35,10 @@ impl MaterialExtension for Tint {
/// The copies' colours as the buffer holds them: linear rgba, alpha 1. A buffer of the same size is written in place
/// on the GPU (GpuShaderBuffer reuses it), so the material's bind group stands.
pub fn colour_buffer(rgb: &[[f32; 3]]) -> ShaderBuffer {
- let words: Vec<[f32; 4]> = rgb.iter().map(|c| [c[0], c[1], c[2], 1.0]).collect();
+ let mut words: Vec<[f32; 4]> = Vec::with_capacity(rgb.len());
+ for &[r, g, b] in rgb {
+ words.push([r, g, b, 1.0]);
+ }
ShaderBuffer::new(words, bevy::asset::RenderAssetUsages::default())
}