Skip to content

Commit

Permalink
Update CHANGELOG, fix web-demo
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeeter committed Feb 17, 2025
1 parent cc749be commit 8e66b51
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
- Fix inconsistency between JIT and VM evaluator when performing interval
evaluation of `not([NAN, NAN])`.
- Propagate `NAN` values through `and` and `or` operations on intervals.
- Add a new `Image<P>` generic image type (wrapping a `Vec<P>`, `width`, and
`height`).
- Define `DepthImage`, `NormalImage`, and `ColorImage` specializations
- Use these types in 2D and 3D rendering
- Remove `Grad::to_rgb` in favor of handling it at the image level

# 0.3.4
Expand Down
7 changes: 0 additions & 7 deletions demos/web-editor/crate/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions demos/web-editor/crate/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use fidget::{
context::{Context, Tree},
render::{
BitRenderMode, CancelToken, ImageRenderConfig, ImageSize, RotateHandle,
ThreadPool, TileSizes, TranslateHandle, View2, View3,
VoxelRenderConfig, VoxelSize,
BitRenderMode, CancelToken, DepthImage, ImageRenderConfig, ImageSize,
NormalImage, RotateHandle, ThreadPool, TileSizes, TranslateHandle,
View2, View3, VoxelRenderConfig, VoxelSize,
},
var::Var,
vm::{VmData, VmShape},
Expand Down Expand Up @@ -120,6 +120,7 @@ pub fn render_normals(

// Convert into an image
Ok(norm
.to_color()
.into_iter()
.flat_map(|[r, g, b]| [r, g, b, 255])
.collect())
Expand All @@ -130,7 +131,7 @@ fn render_3d_inner(
image_size: usize,
view: View3,
cancel: CancelToken,
) -> Option<(Vec<u32>, Vec<[u8; 3]>)> {
) -> Option<(DepthImage, NormalImage)> {
let cfg = VoxelRenderConfig {
image_size: VoxelSize::from(image_size as u32),
threads: Some(ThreadPool::Global),
Expand Down
12 changes: 12 additions & 0 deletions fidget/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,18 @@ pub(crate) trait RenderWorker<'a, F: Function> {
}

/// Generic image type
///
/// The image is laid out in row-major order, and can be indexed either by a
/// `usize` index or a `(row, column)` tuple.
///
/// ```text
/// 0 ------------> width (columns)
/// | |
/// | |
/// | |
/// V--------------
/// height (rows)
/// ```
pub struct Image<P> {
data: Vec<P>,
width: usize, // XXX use ImageSize instead?
Expand Down
2 changes: 1 addition & 1 deletion models/sponge.rhai
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ let rescale = manhattan / radius;
let blend = 1.0; // adjust the sphere-ness of the sponge
let r = (rescale * blend) + (1.0 - blend);

draw(intersection(sponge, x + y + z - 2))
draw(sponge.remap_xyz(x / r, y / r, z / r));

0 comments on commit 8e66b51

Please sign in to comment.