Any object in a ray tracing scenario can be rendered only by the intersection algorithm and the normal algorithm.
Virtual int intersect (const ray & ray, float & distance) = 0;
Virtual vector3 getnormal (vector3 & Pos) = 0;
To adapt to the rendering of the triangle band, the data structure of the triangle is defined:
Vector3 vertex [3];
Vector3 normal [3];
Because pasters are not yet supported, the ray tracing plug-in only processes vertex data (0x4110) and surface data (0x4120) when reading the 3DS file ). At present, the normal is calculated based on the surface of the triangle, and the influence of the adjacent triangle is not considered. Therefore, the rendered image looks very stiff. The next step is to re-calculate the normal data of the three vertices and optimize the speed.
This article is originally created by span Zhang (Zhang youbang). For more information, see the source.
The first stop of Chinese original Fragment Art and Chinese original fragment Software