Fat*_*ler 1 graphics raytracing
我想知道有光线追踪经验的人是否可以帮助我找出我的程序中的一些问题,但是我不能发布很多代码,因为这个程序是学校作业.我只是想知道我是否能得到一些有助于引导我朝正确方向前进的技巧.所以提前谢谢!
首先)如您所见,我的光线追踪图像中有大量噪音.场景由悬停在平面上的单个三角形组成.还存在单个点光源.
第二)当我计算阴影射线时不会发生噪声,但它会为阴影计算错误的颜色.
我的光线追踪算法:
for each pixel,
color c;
for each shape in the scene
send a ray through each pixel and see if it collides with a shape
if it does
color = calculate color of ray
else, color = background color
return color
To calculate color of ray...
color c = 0,0,0 // rgb
for each light source in the scene
make a new ray (shad_ray) that starts at where the original ray hit the shape...
... and ends at the light source
see if the shadow ray hits a shape on its way to the light
if it does,
calculate ambient color using ambient color of shape material and...
... ambient light intensity
if not,
calculate shading with sum of ambient/diffuse/specular components
Run Code Online (Sandbox Code Playgroud)
我知道这是一个非常宽松的算法描述.但如果需要,我可以提供更多信息.
