计算机图形学实验,实现ray tracing算法并与opengl渲染效果对比。
原文及code参见:我的Github
Ray Tracing
In this assignment,I implemented the Ray-Tracing algorithm in c++.I didn’t use any library but the CImg library,only use to read and display pixel values.
Creating the scene:
The scene is defined in an xml file.The entire scene encompassed by the label:
<scene>...</scene>
Lights:
The lights are defined in label <lights>...</lights>
.In my code,lights are all point sources and all that need specification is their position and color.
<light>
<position x="0" y="9" z="-15.0"/>
<color r="1.0" g="1.0" b="1.0"/>
</light>
Planes:
We need three elements to define a plane:a point in the plane、the plane’s normal vector and its color.Of course,we need to define its material.
<plane>
<point x="0.0" y="-10.0" z="0.0"/>
<normal x="0.0" y="10.0" z="0.0"/>
<color r="1.0" g="1.0" b="1.0" />
<specs ref="0"