Chapter 6:Rectangles and Lights
今天,我们来学习长方形区域光照
先看效果
light
首先我们需要设计一个发光的材质
/// light.hpp // ----------------------------------------------------- // [author] lv // [begin ] 2019.1 // [brief ] the areaLight-class for the ray-tracing project // from the 《ray tracing the next week》 // ----------------------------------------------------- #pragma once namespace rt { //the statement of areaLight class class areaLight :public material { public: areaLight() { } areaLight(texture* mat) :_emit(mat) { } virtual bool scatter(const ray& InRay, const hitInfo& info, rtvec& attenuation, ray& scattered)const { return false; } virtual rtvec emitted(rtvar u, rtvar v, const rtvec& p)const { return _emit->value(u, v, p); } private: texture* _emit; }; } // rt namespace