danielepanozzo / cg-old

44 stars 16 forks source link

1.1 and General Position / Lambertian Shading Clarification #78

Closed psfonseka closed 6 years ago

psfonseka commented 6 years ago

Hello,

I've been struggling to completely understand what is expected of me for task 1.1. Is it saying that I need to just make the code able to put in multiple sphere in multiple places with the same lighting (parallel light sources)? Or do I also have to have the lighting changed for each one(single original perspective based light source)? My confusion is from the fact that orthographic view involves keeping the light source ray in one direction, which currently makes it parallel to the z axis or else if I did change it so that the direction would change based off of the origin, I believe it would be a perspective projection, asked to be completed in 1.3. At the same time, my current understanding of the difference between the two could be wrong, which is why I want to clarify.

I guess to make it simple - if I have a sphere that is the same radius but in a different position from the origin, should the sphere look exactly the same as the sphere in the origin or should it look different in terms of shading/lighting?

Thanks

danielepanozzo commented 6 years ago

The sphere should look (slightly) different if its center is not in the origin.

The type of projection does not affect the shading. The type of projection changes how the rays are generated. The shading only happens after the intersection between the per-pixel ray and the object is found. After you know where the intersection is, you need to compute the shading (slide Diffuse Shading in https://cs.nyu.edu/%7Epanozzo/cg18/Slides/02%20-%20Ray%20Tracing,%20C++.pdf) which does depend on the relative position of the intersection point and the light (the vector is called l). If you move the sphere, the shading will change.

Note that Diffuse Shading does not depend on the viewer position: for parallel projection, if you move the viewer you should see a translation of the sphere on screen, but no changes in shading. Differently, Specular Shading does depend on the viewer position.

LihengGong commented 6 years ago

Hi,

Edit: Just found prof's answer. Please refer to Prof's answer.

My understanding is that you can use this formula to generate the ray from your camera for orthographic view:

u = l + (r − l)i/nx, v = b + (t − b)j/ny,

ray.direction←−w ray.origin← e + u u + v v

In orthographic view, all the ray's directions are the same, it is the origin of the rays that varies. Actually, the example program provided by prof shows exactly how the ray of orthographic view is generated.

psfonseka commented 6 years ago

Thanks!