Fix bugs for pbrt bilinear patch

This commit is contained in:
hal8174 2025-08-27 19:06:47 +02:00
parent bb2089477e
commit 0480e041cd
Signed by: hal8174
SSH key fingerprint: SHA256:NN98ZYwnrreQLSOV/g+amY7C3yL/mS1heD7bi5t6PPw
6 changed files with 85 additions and 33 deletions

View file

@ -49,16 +49,7 @@ pub(super) struct SpectrumCheckerboardTexture2d {
impl Pbrt2dSpectrumTexture for SpectrumCheckerboardTexture2d {
fn get(&self, u: Float, v: Float) -> Color {
let (u, v) = self.mapping.map(u, v);
let even = if u >= 0.0 {
u.fract() >= 0.5
} else {
u.fract() >= -0.5
} ^ if v >= 0.0 {
v.fract() >= 0.5
} else {
v.fract() >= -0.5
};
let even = (u.floor() as i64 + v.floor() as i64) % 2 == 0;
match &self.tex[even as usize] {
Either::A(v) => *v,