Search code examples
javagraphics3drenderingraytracing

In raytracing, where is the image-plane?


I am starting a basic raytracing engine in Java.

I understand the basics of how it works, but I am not sure where the image-plane should be placed in the world, exactly. In all the diagrams I see, it just shows the image-plane somewhere between the camera and the scene.

Currently I have my camera at (0, 0, -5) and my image plane centered at (0, 0, -4). I don't know where it should be placed that would be "normal" or "make sense".

Thank you.


Solution

  • I may be wrong but I don't think you need any image-plane concept here. It's just a matter of mapping pixel positions to rays.

    You can assume you have some image-plane and you do your math this way, but imagine you want a fish-eye or 360deg rendering - now you can't represent it by image-plane but it's still possible to render.

    What you need, basically is a way to convert pixel position (x,y) into a ray (start, direction) but the way you do this is up to you. You may imagine a plane, divide it into pixels and compute rays going from a camera to specific pixel. You may also assume some angular delta between one pixel and the next one, then get your camera direction and rotate it for every pixel. In fact the second approach should be better because it avoids distortions you get in typical 3D rendering with big Fov. With this second approach it's also possible to do rendering with fovs near or bigger than 180 deg.

    This is also one of the best things in ray tracing, you don't have all those assumptions about clipping planes, rasterization and entire GPU pipeline. You just write a code that will compute some value, how you do it is up to you.

    If you decide to stick with image-plane however, then you probably know that when you make this plane twice as big and move it twice as far away, it should give you the same result. So your main problem here are numerical errors. It's hard to give any specific numbers as it always 'depends' but I think that a distance of 1, regardless of the units you use is a good start.