use std::rc::Rc;
use super::{
binary, block, call, constant, float, join, math, rotate, shader_fn, to_const, to_var,
};
use super::{
camera_position, camera_projection_matrix, camera_view_matrix, model_world_matrix,
position_geometry, position_world, uniform,
};
use crate::math::{Color, Matrix2, Matrix3, Matrix4};
use crate::nodes::node::{FnDef, Lazy, Node, NodeRef, Type, UniformGroup, UniformSource};
fn input_type(args: &[&NodeRef]) -> Type {
let len = |n: Option<&&NodeRef>| match n {
Some(n) if !n.ty().is_matrix() => n.ty().components(),
_ => 0,
};
let (a, b, c) = (args.first(), args.get(1), args.get(2));
let (la, lb, lc) = (len(a), len(b), len(c));
if la > lb && la > lc {
a.unwrap().ty()
} else if lb > lc {
b.unwrap().ty()
} else if lc > la {
c.unwrap().ty()
} else {
a.unwrap().ty()
}
}
fn integer_type(ty: Type) -> Type {
match ty.component_type() {
Type::I32 | Type::U32 => ty,
_ => Type::vector_of(Type::I32, ty.components()),
}
}
fn unary(name: &'static str, x: NodeRef) -> NodeRef {
let ty = x.ty();
math(name, vec![x], ty)
}
fn convert_type(ty: Type, params: Vec<NodeRef>) -> NodeRef {
let n = ty.components();
if params.is_empty() {
return constant(ty, vec![0.0; n]);
}
let all_const = params
.iter()
.all(|p| matches!(p.node(), Node::Const { .. }));
if all_const {
let mut values: Vec<f64> = params
.iter()
.flat_map(|p| match p.node() {
Node::Const { values, .. } => values.clone(),
_ => unreachable!(),
})
.collect();
if values.len() == 1 {
values = vec![values[0]; n];
}
values.resize(n, 0.0);
return constant(ty, values);
}
if params.len() == 1 {
return params[0].to(ty);
}
join(ty, params)
}
pub fn color(hex: u32) -> NodeRef {
Color::from_hex(hex).into()
}
pub fn color_rgb(r: f64, g: f64, b: f64) -> NodeRef {
constant(Type::Vec3, vec![r, g, b])
}
pub fn bool(x: impl Into<NodeRef>) -> NodeRef {
convert_type(Type::Bool, vec![x.into()])
}
macro_rules! vector_ctor {
($(#[$m:meta])* $name:ident, $ty:expr, $($arg:ident),+) => {
$(#[$m])*
pub fn $name($($arg: impl Into<NodeRef>),+) -> NodeRef {
convert_type($ty, vec![$($arg.into()),+])
}
};
}
vector_ctor!(
uvec2, Type::UVec2, x, y
);
vector_ctor!(
uvec3, Type::UVec3, x, y, z
);
vector_ctor!(
uvec4, Type::UVec4, x, y, z, w
);
vector_ctor!(
ivec3, Type::IVec3, x, y, z
);
vector_ctor!(
ivec4, Type::IVec4, x, y, z, w
);
vector_ctor!(
bvec2, Type::BVec2, x, y
);
vector_ctor!(
bvec3, Type::BVec3, x, y, z
);
vector_ctor!(
bvec4, Type::BVec4, x, y, z, w
);
pub fn mat2(m: Matrix2) -> NodeRef {
constant(Type::Mat2, m.elements.to_vec())
}
pub fn mat3(m: Matrix3) -> NodeRef {
constant(Type::Mat3, m.elements.to_vec())
}
pub fn mat4(m: Matrix4) -> NodeRef {
constant(Type::Mat4, m.elements.to_vec())
}
pub fn mat2_join(args: Vec<NodeRef>) -> NodeRef {
convert_type(Type::Mat2, args)
}
pub fn mat3_join(args: Vec<NodeRef>) -> NodeRef {
convert_type(Type::Mat3, args)
}
pub fn mat4_join(args: Vec<NodeRef>) -> NodeRef {
convert_type(Type::Mat4, args)
}
pub fn pi() -> NodeRef {
float(std::f64::consts::PI)
}
pub fn pi2() -> NodeRef {
float(std::f64::consts::TAU)
}
pub fn half_pi() -> NodeRef {
float(std::f64::consts::FRAC_PI_2)
}
pub fn epsilon() -> NodeRef {
float(1e-6)
}
pub fn infinity() -> NodeRef {
float(1e6)
}
macro_rules! unary_math {
($(#[$m:meta])* $name:ident, $wgsl:literal) => {
$(#[$m])*
pub fn $name(x: impl Into<NodeRef>) -> NodeRef {
unary($wgsl, x.into())
}
};
}
unary_math!(
atan, "atan"
);
unary_math!(
acos, "acos"
);
unary_math!(
asin, "asin"
);
unary_math!(
tan, "tan"
);
unary_math!(
sinh, "sinh"
);
unary_math!(
cosh, "cosh"
);
unary_math!(
tanh, "tanh"
);
unary_math!(
asinh, "asinh"
);
unary_math!(
acosh, "acosh"
);
unary_math!(
atanh, "atanh"
);
unary_math!(
round, "round"
);
unary_math!(
trunc, "trunc"
);
unary_math!(
degrees, "degrees"
);
unary_math!(
radians, "radians"
);
unary_math!(
transpose, "transpose"
);
unary_math!(
count_one_bits, "countOneBits"
);
unary_math!(
count_trailing_zeros, "countTrailingZeros"
);
unary_math!(
count_leading_zeros, "countLeadingZeros"
);
pub fn determinant(m: impl Into<NodeRef>) -> NodeRef {
math("determinant", vec![m.into()], Type::F32)
}
pub fn inverse(m: impl Into<NodeRef>) -> NodeRef {
let m = m.into();
let name = match m.ty() {
Type::Mat2 => "tsl_inverse_mat2",
Type::Mat3 => "tsl_inverse_mat3",
Type::Mat4 => "tsl_inverse_mat4",
other => panic!("three-rs: inverse() of a {other:?}"),
};
unary(name, m)
}
fn pow_of(a: NodeRef, b: NodeRef) -> NodeRef {
let ty = input_type(&[&a, &b]);
math("pow", vec![a, b], ty)
}
pub fn pow2(x: impl Into<NodeRef>) -> NodeRef {
let x = x.into();
x.mul(x.clone())
}
pub fn pow3(x: impl Into<NodeRef>) -> NodeRef {
x.into().pow3()
}
pub fn pow4(x: impl Into<NodeRef>) -> NodeRef {
let x = x.into();
x.mul(x.clone()).mul(x.clone()).mul(x)
}
pub fn difference(a: impl Into<NodeRef>, b: impl Into<NodeRef>) -> NodeRef {
let d = a.into().sub(b);
unary("abs", d)
}
pub fn cbrt(a: impl Into<NodeRef>) -> NodeRef {
let a = a.into();
unary("sign", a.clone()).mul(pow_of(unary("abs", a), float(1.0 / 3.0)))
}
pub fn length_sq(a: impl Into<NodeRef>) -> NodeRef {
let a = a.into();
super::dot(a.clone(), a)
}
pub fn face_forward(
n: impl Into<NodeRef>,
i: impl Into<NodeRef>,
nref: impl Into<NodeRef>,
) -> NodeRef {
let (n, i, nref) = (n.into(), i.into(), nref.into());
let ty = input_type(&[&n, &i, &nref]);
math("faceForward", vec![n, i, nref], ty)
}
pub fn parabola(x: impl Into<NodeRef>, k: impl Into<NodeRef>) -> NodeRef {
let x = x.into();
pow_of(float(4.0).mul(x.mul(float(1.0).sub(x.clone()))), k.into())
}
pub fn gain(x: impl Into<NodeRef>, k: impl Into<NodeRef>) -> NodeRef {
let (x, k) = (x.into(), k.into());
let low = pow_of(float(2.0).mul(x.clone()), k.clone()).mul(0.5);
let high = float(1.0).sub(pow_of(float(2.0).mul(float(1.0).sub(x.clone())), k).mul(0.5));
x.less_than(0.5).select(low, high)
}
pub fn pcurve(x: impl Into<NodeRef>, a: impl Into<NodeRef>, b: impl Into<NodeRef>) -> NodeRef {
let (x, a, b) = (x.into(), a.into(), b.into());
let num = pow_of(x.clone(), a.clone());
let den = pow_of(x.clone(), a.clone()).add(pow_of(float(1.0).sub(x), b));
pow_of(num.div(den), float(1.0).div(a))
}
pub fn sinc(x: impl Into<NodeRef>, k: impl Into<NodeRef>) -> NodeRef {
let (x, k) = (x.into(), k.into());
let arg = unary("abs", pi().mul(k.mul(x).sub(1.0))).max(1e-6);
let arg = to_const(None, arg);
arg.sin().div(arg)
}
pub fn xor(a: impl Into<NodeRef>, b: impl Into<NodeRef>) -> NodeRef {
math("tsl_xor", vec![a.into(), b.into()], Type::Bool)
}
pub fn bit_not(a: impl Into<NodeRef>) -> NodeRef {
let node = a.into();
let ty = integer_type(node.ty());
NodeRef::new(Node::BitNot { node, ty })
}
fn bitcast(x: NodeRef, component: Type) -> NodeRef {
let ty = Type::vector_of(component, x.ty().components());
let name = match ty {
Type::F32 => "bitcast<f32>",
Type::I32 => "bitcast<i32>",
Type::U32 => "bitcast<u32>",
Type::Vec2 => "bitcast<vec2<f32>>",
Type::Vec3 => "bitcast<vec3<f32>>",
Type::Vec4 => "bitcast<vec4<f32>>",
Type::IVec2 => "bitcast<vec2<i32>>",
Type::IVec3 => "bitcast<vec3<i32>>",
Type::IVec4 => "bitcast<vec4<i32>>",
Type::UVec2 => "bitcast<vec2<u32>>",
Type::UVec3 => "bitcast<vec3<u32>>",
Type::UVec4 => "bitcast<vec4<u32>>",
other => panic!("three-rs: bitcast to {other:?}"),
};
math(name, vec![x], ty)
}
pub fn float_bits_to_int(x: impl Into<NodeRef>) -> NodeRef {
bitcast(x.into(), Type::I32)
}
pub fn float_bits_to_uint(x: impl Into<NodeRef>) -> NodeRef {
bitcast(x.into(), Type::U32)
}
pub fn int_bits_to_float(x: impl Into<NodeRef>) -> NodeRef {
bitcast(x.into(), Type::F32)
}
pub fn uint_bits_to_float(x: impl Into<NodeRef>) -> NodeRef {
bitcast(x.into(), Type::F32)
}
pub fn increment(a: &NodeRef) -> NodeRef {
let temp = to_const(None, a.to(Type::I32));
block(vec![temp.clone(), a.add_assign(1)], temp)
}
pub fn decrement(a: &NodeRef) -> NodeRef {
let temp = to_const(None, a.to(Type::I32));
block(vec![temp.clone(), a.sub_assign(1)], temp)
}
pub fn increment_before(a: &NodeRef) -> NodeRef {
block(vec![a.add_assign(1)], a.clone())
}
pub fn decrement_before(a: &NodeRef) -> NodeRef {
block(vec![a.sub_assign(1)], a.clone())
}
pub fn mod_(a: impl Into<NodeRef>, b: impl Into<NodeRef>) -> NodeRef {
let (a, b) = (a.into(), b.into());
let ty = input_type(&[&a, &b]);
if matches!(ty.component_type(), Type::I32 | Type::U32) {
return binary("%", a, b);
}
let name = match ty {
Type::F32 => "tsl_mod_float",
Type::Vec2 => "tsl_mod_vec2",
Type::Vec3 => "tsl_mod_vec3",
Type::Vec4 => "tsl_mod_vec4",
other => panic!("three-rs: mod() of a {other:?}"),
};
math(name, vec![a, b], ty)
}
pub fn hash(seed: impl Into<NodeRef>) -> NodeRef {
let state = seed.into().to_uint().mul(747796405u32).add(2891336453u32);
let word = state
.shift_right(state.shift_right(28u32).add(4u32))
.bit_xor(state.clone())
.mul(277803737u32);
word.shift_right(22u32)
.bit_xor(word)
.to_float()
.mul(1.0 / 4294967296.0)
}
pub fn rand(uv: impl Into<NodeRef>) -> NodeRef {
let uv = uv.into();
let uv = if uv.ty() == Type::Vec2 { uv } else { uv.xy() };
let dt = super::dot(uv, constant(Type::Vec2, vec![12.9898, 78.233]));
let sn = mod_(dt, pi());
unary("fract", sn.sin().mul(43758.5453))
}
fn tri_def() -> Rc<FnDef> {
thread_local! { static CELL: Lazy<Rc<FnDef>> = const { Lazy::new() }; }
CELL.with(|c| {
c.get(|| {
shader_fn(Some("tri"), vec![("x", Type::F32)], Type::F32, |args| {
args[0].fract().sub(0.5).abs()
})
})
})
}
fn tri(x: NodeRef) -> NodeRef {
call(&tri_def(), vec![x])
}
fn tri3(p: NodeRef) -> NodeRef {
thread_local! { static CELL: Lazy<Rc<FnDef>> = const { Lazy::new() }; }
let def = CELL.with(|c| {
c.get(|| {
shader_fn(Some("tri3"), vec![("p", Type::Vec3)], Type::Vec3, |args| {
let p = &args[0];
join(
Type::Vec3,
vec![
tri(p.z().add(tri(p.y().mul(1.0)))),
tri(p.z().add(tri(p.x().mul(1.0)))),
tri(p.y().add(tri(p.x().mul(1.0)))),
],
)
})
})
});
call(&def, vec![p])
}
pub fn tri_noise_3d(
position: impl Into<NodeRef>,
speed: impl Into<NodeRef>,
time: impl Into<NodeRef>,
) -> NodeRef {
thread_local! { static CELL: Lazy<Rc<FnDef>> = const { Lazy::new() }; }
let def = CELL.with(|c| {
c.get(|| {
shader_fn(
Some("triNoise3D"),
vec![
("position", Type::Vec3),
("speed", Type::F32),
("time", Type::F32),
],
Type::F32,
|args| {
let (position, speed, time) = (&args[0], &args[1], &args[2]);
let p = to_var(None, position.clone());
let z = to_var(None, float(1.4));
let rz = to_var(None, float(0.0));
let bp = to_var(None, p.clone());
let index = NodeRef::new(Node::Param {
name: "i",
ty: Type::F32,
});
let dg = to_var(None, tri3(bp.mul(2.0)));
let t = to_var(None, tri(p.z().add(tri(p.x().add(tri(p.y()))))));
let body = vec![
dg.clone(),
p.add_assign(dg.add(time.mul(float(0.1).mul(speed.clone())))),
bp.mul_assign(1.8),
z.mul_assign(1.5),
p.mul_assign(1.2),
t.clone(),
rz.add_assign(t.div(z.clone())),
bp.add_assign(0.14),
];
let looped = NodeRef::new(Node::Loop {
start: Some(float(0.0)),
count: float(3.0),
index,
condition: "<=",
update: None,
body,
});
block(vec![p, z, rz.clone(), bp, looped], rz)
},
)
})
});
call(
&def,
vec![position.into().to(Type::Vec3), speed.into(), time.into()],
)
}
pub fn osc_triangle(t: impl Into<NodeRef>) -> NodeRef {
t.into().add(0.5).fract().mul(2.0).sub(1.0).abs()
}
pub fn osc_square(t: impl Into<NodeRef>) -> NodeRef {
unary("round", t.into().fract())
}
pub fn osc_sawtooth(t: impl Into<NodeRef>) -> NodeRef {
t.into().fract()
}
pub fn rotate_uv(uv: impl Into<NodeRef>, rotation: impl Into<NodeRef>) -> NodeRef {
rotate_uv_about(uv, rotation, constant(Type::Vec2, vec![0.5, 0.5]))
}
pub fn rotate_uv_about(
uv: impl Into<NodeRef>,
rotation: impl Into<NodeRef>,
center: impl Into<NodeRef>,
) -> NodeRef {
let center = center.into();
rotate(uv.into().sub(center.clone()), rotation).add(center)
}
pub fn spherize_uv(uv: impl Into<NodeRef>, strength: impl Into<NodeRef>) -> NodeRef {
spherize_uv_about(uv, strength, constant(Type::Vec2, vec![0.5, 0.5]))
}
pub fn spherize_uv_about(
uv: impl Into<NodeRef>,
strength: impl Into<NodeRef>,
center: impl Into<NodeRef>,
) -> NodeRef {
let uv = uv.into();
let delta = uv.sub(center);
let delta2 = delta.dot(delta.clone());
let delta4 = delta2.mul(delta2.clone());
let offset = delta4.mul(strength);
uv.add(delta.mul(offset))
}
pub fn remap(
node: impl Into<NodeRef>,
in_low: impl Into<NodeRef>,
in_high: impl Into<NodeRef>,
out_low: impl Into<NodeRef>,
out_high: impl Into<NodeRef>,
) -> NodeRef {
remap_impl(
node.into(),
in_low.into(),
in_high.into(),
out_low.into(),
out_high.into(),
false,
)
}
pub fn remap_clamp(
node: impl Into<NodeRef>,
in_low: impl Into<NodeRef>,
in_high: impl Into<NodeRef>,
out_low: impl Into<NodeRef>,
out_high: impl Into<NodeRef>,
) -> NodeRef {
remap_impl(
node.into(),
in_low.into(),
in_high.into(),
out_low.into(),
out_high.into(),
true,
)
}
fn remap_impl(
node: NodeRef,
in_low: NodeRef,
in_high: NodeRef,
out_low: NodeRef,
out_high: NodeRef,
clamp: bool,
) -> NodeRef {
let mut t = node.sub(in_low.clone()).div(in_high.sub(in_low));
if clamp {
t = t.clamp(0.0, 1.0);
}
t.mul(out_high.sub(out_low.clone())).add(out_low)
}
pub fn delta_time() -> NodeRef {
thread_local! { static CELL: Lazy<NodeRef> = const { Lazy::new() }; }
CELL.with(|c| {
c.get(|| {
uniform(
UniformSource::DeltaTime,
Type::F32,
UniformGroup::Render,
None,
)
})
})
}
pub fn frame_id() -> NodeRef {
thread_local! { static CELL: Lazy<NodeRef> = const { Lazy::new() }; }
CELL.with(|c| {
c.get(|| {
uniform(
UniformSource::FrameId,
Type::U32,
UniformGroup::Render,
None,
)
})
})
}
#[derive(Clone, Debug)]
#[non_exhaustive]
pub struct Billboarding {
pub position: Option<NodeRef>,
pub horizontal: bool,
pub vertical: bool,
pub horizontal_rotation: bool,
}
impl Default for Billboarding {
fn default() -> Self {
Self {
position: None,
horizontal: true,
vertical: false,
horizontal_rotation: false,
}
}
}
pub fn billboarding(options: Billboarding) -> NodeRef {
let mw = model_world_matrix();
let center = match options.position {
Some(p) => p,
None => position_world().sub(
mw.mul(join(Type::Vec4, vec![position_geometry(), float(0.0)]))
.xyz(),
),
};
let mut statements = Vec::new();
let world = to_var(None, mw.clone());
let column = |m: &NodeRef, c: usize, v: &NodeRef, out: &mut Vec<NodeRef>| {
out.push(m.element(c).element(0).assign(v.x()));
out.push(m.element(c).element(1).assign(v.y()));
out.push(m.element(c).element(2).assign(v.z()));
};
column(&world, 3, ¢er, &mut statements);
let model_view = to_var(None, camera_view_matrix().mul(world.clone()));
let scale_x = mw.element(0).length();
let scale_y = mw.element(1).length();
let scale_z = mw.element(2).length();
let (right, up, forward);
if options.horizontal_rotation {
let look = camera_position().sub(world.element(3).xyz());
let look_xz = join(Type::Vec3, vec![look.x(), float(0.0), look.z()]).normalize();
let right_w = join(
Type::Vec3,
vec![look_xz.z(), float(0.0), look_xz.x().negate()],
);
right = Some(
camera_view_matrix()
.mul(join(Type::Vec4, vec![right_w, float(0.0)]))
.xyz()
.mul(scale_x),
);
up = Some(camera_view_matrix().element(1).xyz().mul(scale_y));
forward = camera_view_matrix()
.mul(join(Type::Vec4, vec![look_xz, float(0.0)]))
.xyz()
.mul(scale_z);
} else {
right = options
.horizontal
.then(|| join(Type::Vec3, vec![scale_x, float(0.0), float(0.0)]));
up = options
.vertical
.then(|| join(Type::Vec3, vec![float(0.0), scale_y, float(0.0)]));
forward = constant(Type::Vec3, vec![0.0, 0.0, 1.0]);
}
if let Some(right) = right {
column(&model_view, 0, &right, &mut statements);
}
if let Some(up) = up {
column(&model_view, 1, &up, &mut statements);
}
column(&model_view, 2, &forward, &mut statements);
let result = camera_projection_matrix()
.mul(model_view)
.mul(position_geometry());
block(statements, result)
}
impl NodeRef {
pub fn to_float(&self) -> NodeRef {
self.to(Type::vector_of(Type::F32, 1))
}
pub fn to_int(&self) -> NodeRef {
self.to(Type::I32)
}
pub fn to_uint(&self) -> NodeRef {
self.to(Type::U32)
}
pub fn to_bool(&self) -> NodeRef {
self.to(Type::Bool)
}
pub fn to_vec2(&self) -> NodeRef {
self.to(Type::Vec2)
}
pub fn to_vec3(&self) -> NodeRef {
self.to(Type::Vec3)
}
pub fn to_vec4(&self) -> NodeRef {
self.to(Type::Vec4)
}
pub fn to_color(&self) -> NodeRef {
self.to(Type::Vec3)
}
pub fn to_ivec2(&self) -> NodeRef {
self.to(Type::IVec2)
}
pub fn to_ivec3(&self) -> NodeRef {
self.to(Type::IVec3)
}
pub fn to_ivec4(&self) -> NodeRef {
self.to(Type::IVec4)
}
pub fn to_uvec2(&self) -> NodeRef {
self.to(Type::UVec2)
}
pub fn to_uvec3(&self) -> NodeRef {
self.to(Type::UVec3)
}
pub fn to_uvec4(&self) -> NodeRef {
self.to(Type::UVec4)
}
pub fn to_bvec2(&self) -> NodeRef {
self.to(Type::BVec2)
}
pub fn to_bvec3(&self) -> NodeRef {
self.to(Type::BVec3)
}
pub fn to_bvec4(&self) -> NodeRef {
self.to(Type::BVec4)
}
pub fn to_mat2(&self) -> NodeRef {
self.to(Type::Mat2)
}
pub fn to_mat3(&self) -> NodeRef {
self.to(Type::Mat3)
}
pub fn to_mat4(&self) -> NodeRef {
self.to(Type::Mat4)
}
pub fn atan(&self) -> NodeRef {
atan(self)
}
pub fn acos(&self) -> NodeRef {
acos(self)
}
pub fn tan(&self) -> NodeRef {
tan(self)
}
pub fn sinh(&self) -> NodeRef {
sinh(self)
}
pub fn cosh(&self) -> NodeRef {
cosh(self)
}
pub fn tanh(&self) -> NodeRef {
tanh(self)
}
pub fn asinh(&self) -> NodeRef {
asinh(self)
}
pub fn acosh(&self) -> NodeRef {
acosh(self)
}
pub fn atanh(&self) -> NodeRef {
atanh(self)
}
pub fn round(&self) -> NodeRef {
round(self)
}
pub fn trunc(&self) -> NodeRef {
trunc(self)
}
pub fn degrees(&self) -> NodeRef {
degrees(self)
}
pub fn radians(&self) -> NodeRef {
radians(self)
}
pub fn determinant(&self) -> NodeRef {
determinant(self)
}
pub fn inverse(&self) -> NodeRef {
inverse(self)
}
pub fn transpose(&self) -> NodeRef {
transpose(self)
}
pub fn pow2(&self) -> NodeRef {
pow2(self)
}
pub fn pow4(&self) -> NodeRef {
pow4(self)
}
pub fn difference(&self, b: impl Into<NodeRef>) -> NodeRef {
difference(self, b)
}
pub fn cbrt(&self) -> NodeRef {
cbrt(self)
}
pub fn length_sq(&self) -> NodeRef {
length_sq(self)
}
pub fn length(&self) -> NodeRef {
super::length(self)
}
pub fn face_forward(&self, i: impl Into<NodeRef>, nref: impl Into<NodeRef>) -> NodeRef {
face_forward(self, i, nref)
}
pub fn xor(&self, b: impl Into<NodeRef>) -> NodeRef {
xor(self, b)
}
pub fn bit_not(&self) -> NodeRef {
bit_not(self)
}
pub fn count_one_bits(&self) -> NodeRef {
count_one_bits(self)
}
pub fn count_trailing_zeros(&self) -> NodeRef {
count_trailing_zeros(self)
}
pub fn count_leading_zeros(&self) -> NodeRef {
count_leading_zeros(self)
}
pub fn mod_(&self, b: impl Into<NodeRef>) -> NodeRef {
mod_(self, b)
}
pub fn hash(&self) -> NodeRef {
hash(self)
}
pub fn remap(
&self,
in_low: impl Into<NodeRef>,
in_high: impl Into<NodeRef>,
out_low: impl Into<NodeRef>,
out_high: impl Into<NodeRef>,
) -> NodeRef {
remap(self, in_low, in_high, out_low, out_high)
}
pub fn remap_clamp(
&self,
in_low: impl Into<NodeRef>,
in_high: impl Into<NodeRef>,
out_low: impl Into<NodeRef>,
out_high: impl Into<NodeRef>,
) -> NodeRef {
remap_clamp(self, in_low, in_high, out_low, out_high)
}
pub fn smoothstep(&self, low: impl Into<NodeRef>, high: impl Into<NodeRef>) -> NodeRef {
super::smoothstep(low, high, self)
}
pub fn step(&self, edge: impl Into<NodeRef>) -> NodeRef {
super::step(edge, self)
}
}
pub(super) fn math_input_type(args: &[&NodeRef]) -> Type {
input_type(args)
}