mmp / pbrt-v3

Source code for pbrt, the renderer described in the third edition of "Physically Based Rendering: From Theory To Implementation", by Matt Pharr, Wenzel Jakob, and Greg Humphreys.
http://pbrt.org
BSD 2-Clause "Simplified" License
4.86k stars 1.18k forks source link

Maybe there is a bug in RealisticCamera::GenerateRays? #289

Open leezyli opened 4 years ago

leezyli commented 4 years ago

I'v been read pbrt recently,as seen from RealisticCamera::GenerateRays: image pFilm2 is interpolated by s in [0,1),but pFilm.x == -pFilm2.x,why pFilm2.x is negatived here?Is there some coordinate system conversion here?

lyxyuren commented 4 years ago
  I'd like to try to answer this question. 
  I think the reason here may beacuse that the realistic lens system is considered. 
  The film is put behind the lens system, the aperture is inside the lens system, and the scene to be imaged is in front of the lens system. 
  The ray is traced to pass these elements in the aformentioned order. In this case, the x orientation is different from the case where no real lens is considered (refer to the uploded hand made figure). 

   When no real lens is considered, the film coordinate (or raster coordinate) can be assumed in front of the aperture, and the orientation of x axis in the film coordinate is the same as the x axis in the camera coordinate (refer to Figure 6.1 in Physically based rendering).

     By the way, are you using the pbrt in Visual Studio as a library just like how we include opencv or opengl? 

The case when realistic lens is considered

kanition commented 2 years ago

I have the same question. Inspired by lyxyuren's answer, I think that the view direction to the film here may be different from those for ProjectiveCamera. For RealisticCamera where the film is behind the lens, this direction is from the scene to the film. But for ProjectiveCamera where the film can be hypothetically in front of the lens, this direction is from the origin of the camera space to the scene. This change leads to this negative operation. However I still get confused as it seems a little strange and tricky. Maybe there is something unclear.