pbrt-v4
pbrt-v4 copied to clipboard
Scaled UVs and non power of 2 textures
Hello,
I found a problem when using large scaled UVs and textures that are neither 2D nor power of 2. In the following image, the texture (768x768) is getting resized to 1024x1024 pixels. However, it seems that the scaling operation doesn't interpolate pixels within the texture but only expand with black pixels.
While rendering, that effect introduces a checker pattern with a margin equal to the difference between the closest power of 2 (above) and the size of the image (not displayed in the Blender screenshot).

After several tests, it doesn't seems to be related to the clamping method. If my guess is correct, it might be coming from the FloatResizeUp method... Is this intentional ?
Thank you for your amazing work.
Is it possible to provide a simple .pbrt scene file (and texture) that exhibits the issue?
Sure !
Sampler "random"
"integer pixelsamples" [1]
Integrator "path"
"integer maxdepth" [2]
Film "rgb"
"integer xresolution" [400]
"integer yresolution" [400]
"string filename" ["output.exr"]
LookAt 16.624420166015625 -4.477263927459717 10.265084266662598
15.794795036315918 -4.240492343902588 9.759454727172852
-0.48223456740379333 0.15252532064914703 0.8626620769500732
Camera "perspective"
"float fov" [22.895194130645738]
WorldBegin
LightSource "infinite"
"string filename" "textures/sky.exr" "float scale" 8
Texture "texture" "float" "imagemap"
"string filename" ["textures/texture.png"]
AttributeBegin
Material "matte"
"float sigma" [0.0]
"texture reflectance" ["texture"]
Scale [5.0 5.0 5.0]
Shape "plymesh"
"string filename" [""]
AttributeEnd
And the scene elements : pbrt.zip
Hm, that scene doesn't work with pbrt-v4 (or pbrt-v3 for that matter); The Scale is borked, there's no filename for the "plymesh", etc.
I briefly looked at this and don't think FloatResizeUp() is the problem. Here is what it generates for your texture; the borders look ok:

For a harsher test, below is a 768x768 white image resized by that function to 1024x1024. All the pixels are exactly one, even at the borders, as desired. (And so it comes out as a big white space!)
Anyway, if you can send a working repro case, that'd be great.

I checked here and seems that the behavior is correct. scaled_texture.zip If you want to play with a different texture scales, you only need to change the values in the UV coordinates code:
Texture "ImageMap_128721171554" "spectrum" "imagemap"
"string filename" "textures/texture.png"
"float maxanisotropy" [ 8.0 ]
"string encoding" "gamma 2.2"
"string wrap" "repeat"
"string filter" "bilinear"
"bool invert" false
"string mapping" [ "uv" ]
"float uscale" [ 3.5 ]
"float vscale" [ 3.5 ]
"float udelta" [ 0.0 ]
"float vdelta" [ 0.0 ]
Cheers..
Thank you very much for your kind replies, After rebuilding the whole project, it seems to be working fine. My mistake, I was probably working with an older commit.