From 4f4ca9e60a88caa3cd1733ab7611ce4deadb2b51 Mon Sep 17 00:00:00 2001 From: Xiaochun Tong Date: Sun, 14 Apr 2024 21:14:50 -0400 Subject: [PATCH] added luisa::lerp(x,y,t) --- luisa_compute/src/lang/ops/spread.rs | 9 +++++++++ luisa_compute/src/lib.rs | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/luisa_compute/src/lang/ops/spread.rs b/luisa_compute/src/lang/ops/spread.rs index 78e9b67..53b1aab 100644 --- a/luisa_compute/src/lang/ops/spread.rs +++ b/luisa_compute/src/lang/ops/spread.rs @@ -245,6 +245,15 @@ where x.max_(y) } +/// lerp(x, y, t) = x*(1-t) + y*t +/// the parameter order is the same as in GLSL/HLSL +pub fn lerp(x: A, y: B, t: T) -> >::Output +where + A: FloatLerpExpr, +{ + x.lerp(y, t) +} + impl ClampExpr for Expr where S: SpreadOps, Join = T>, diff --git a/luisa_compute/src/lib.rs b/luisa_compute/src/lib.rs index b640e66..a9b3583 100644 --- a/luisa_compute/src/lib.rs +++ b/luisa_compute/src/lib.rs @@ -14,7 +14,7 @@ pub mod resource; pub mod rtx; pub mod runtime; -pub use crate::lang::ops::{max, min}; +pub use crate::lang::ops::{lerp, max, min}; pub mod prelude { pub use half::f16;