# Why is the z coordinate simply set to 1 for setting up direction of a ray in ray marching

I’ve recently gotten into shader art , using sites like shadertoy and various tutorials for getting started.

One thing I noticed is that a typical setup involves ray marching whereby:

1. We set a hypothetical camera / eye, typically somewhere on the negative Z axis looking forward at the direction of XY plane
2. Our (2D) image plane is typically the XY plane
3. We then project out rays from the origin which is our eye / camera, and for each pixel (x, y) on our image we set the direction of the corresponding ray emanating from the eye and passing through this pixel to be (x, y, 1)

My question is specifically about this ray direction - why is z simply set to 1 irrespective of the actual camera position on the z axis? Is this just a hack that doesn’t matter eg because of some subsequent normalization , does this represent some actual parameter of the camera (focal length etc) or otherwise? Most tutorials gloss over this without explanation so curious where this comes from.

• For NeRFs, however, you should not tweak the z value and always leave it to 1 or -1 (when generate the ray directions from pixel coords). Since with near, far and number of samples per ray, you can obtain the starting point, end point and other samples on the ray with simple multiplication. For example: near * ray_dir + camera_pos is usually the starting point. Changing z values of rays will change the meaning of near and far (depth). Commented Apr 1 at 1:42