3 篇文章 0 订阅
3 篇文章 0 订阅

# Assignment 4: Shadows, Reflection & Refraction

main 函数中除了调用raytracer外，其余不变：

信息隐藏


·   Expand your Material classes to store the reflective & transparent multipliers and the index of refraction, which are necessary for recursive ray tracing. The prototype for the PhongMaterial constructor should be:

·           PhongMaterial::PhongMaterial(const Vec3f &diffuseColor,

·                                        const Vec3f &specularColor,

·                                        float exponent,

·                                        const Vec3f &reflectiveColor,

·                                        const Vec3f &transparentColor,

·                                        float indexOfRefraction);

You should also implement appropriate accessor functions for these fields.

信息隐藏

PHONG明暗处理

...........

信息隐藏

Add support for the new command line arguments: -shadows, which indicates that shadow rays are to be cast, and-bounces and-weight, which control the depth of recursion in your ray tracer.

The main method of this class is traceRay that, given a ray, computes the color seen from the origin along the direction. This computation is recursive for reflected or transparent materials. We therefore need a stopping criterion to prevent infinite recursion. traceRay takes as additional parameters the current number of bounces (recursion depth) and a ray weight that indicates the percent contribution of this ray to the final pixel color. The corresponding maximum recursion depth and the cutoff ray weight are fields of RayTracer, which are passed as command line arguments to the program. Note that weight is a scalar that corresponds to the magnitude of the color vector.

  Vec3f traceRay(Ray &ray, float tmin, int bounces, float weight,
float indexOfRefraction, Hit &hit) const;


hit2.getT()==distanceTolight （光源无遮挡）

信息隐藏


信息隐藏

ray.getDirection().Dot3(_hit.getNormal())的乘积结果为正或者负，判断

信息隐藏

• 1
点赞
• 0
收藏
• 打赏
• 0
评论
11-27 776
07-01 444
08-12 700
04-15 76

### “相关推荐”对你有帮助么？

• 非常没帮助
• 没帮助
• 一般
• 有帮助
• 非常有帮助

cug_Luker

¥2 ¥4 ¥6 ¥10 ¥20

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、C币套餐、付费专栏及课程。