Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible minor bug fix in using PBRT_FLOAT_AS_DOUBLE #151

Closed
neobis001 opened this issue Aug 30, 2017 · 1 comment
Closed

Possible minor bug fix in using PBRT_FLOAT_AS_DOUBLE #151

neobis001 opened this issue Aug 30, 2017 · 1 comment

Comments

@neobis001
Copy link

I used CMake to create a pbrt Visual Studio 2015 solution, with CMAKE_BUILD_TYPE "Release" and the solution build settings as Release - x64. From the Users Guide in the pbrt site, I uncommented "#define PBRT_FLOAT_AS_DOUBLE" in src/core/pbrt.h.

When I tried to build the solution, I got this error in the pbrt project, in the ptex.cpp file:

C2664: 'pbrt::RGBSpectrum pbrt::RGBSpectrum::FromRGB(const pbrt::Float [], pbrt::SpectrumType)': cannot convert argument 1 from 'float *' to 'const pbrt::Float[]'

The line is

return Spectrum::FromRGB(result);

where result is a 'float*' parameter in a function called "fromResult". Seems like defining PBRT_FLOAT_AS_DOUBLE makes 'Float' a double, and an implicit convesion from float* to double* isn't allowed. So I made an explicit cast like below, and the build worked:

return Spectrum::FromRGB((const pbrt::Float*)result);

Would this be considered a bug and a working bug fix? I've only built pbrt to try out a render, haven't seriously studied it yet. The ptex.cpp file looks relatively new, seems related to the March 5 texture cache feature you mention on your site. Don't see that file in my first pbrt build I made back in January.

mmp added a commit that referenced this issue Aug 30, 2017
@mmp
Copy link
Owner

mmp commented Aug 30, 2017

The intermediate value needs to be explicitly copied into a Float array; the ptex code always returns float values, but if Float is double, then we need to copy into a Float array to convert to doubles so that the cast is valid. Just pushed a fix to do just that.

Thanks for reporting this!

@mmp mmp closed this as completed Aug 30, 2017
LarsPh pushed a commit to LarsPh/deepscattering-pbrt that referenced this issue Apr 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants