What is the fastest shadowing algorithm (CPU only)?

时光毁灭记忆、已成空白 提交于 2019-12-20 03:16:19

问题


Suppose I have a 3D model:

The model is given in the form of vertices, faces (all triangles) and normal vectors. The model may have holes and/or transparent parts.

For an arbitrarily placed light source at infinity, I have to determine:

  • [required] which triangles are (partially) shadowed by other triangles

Then, for the partially shadowed triangles:

  • [bonus] what fraction of the area of the triangle is shadowed
  • [superbonus] come up with a new mesh that describe the shape of the shadows exactly

My final application has to run on headless machines, that is, they have no GPU. Therefore, all the standard things from OpenGL, OpenCL, etc. might not be the best choice.

What is the most efficient algorithm to determine these things, considering this limitation?


回答1:


Do you have single mesh or more meshes ?

Meaning if the shadow is projected on single 'ground' surface or on more like room walls or even near objects. According to this info the solutions are very different

  1. for flat ground/wall surfaces

    is usually the best way a projected render to this surface

    camera direction is opposite to light normal and screen is the render to surface. Surface is not usually perpendicular to light so you need to use projection to compensate... You need 1 render pass for each target surface so it is not suitable if shadow is projected onto near mesh (just for ground/walls)

  2. for more complicated scenes

    You need to use more advanced approach. There are quite a number of them and each has its advantages and disadvantages. I would use Voxel map but if you are limited by space than some stencil/vector approach will be better. Of course all of these techniques are quite expensive and without GPU I would not even try to implement them.

    This is how Voxel map looks like:

    if you want just self shadowing then voxel map size can be only some boundig box around your mesh and in that case you do not incorporate whole mesh volume instead just projection of each pixel into light direction (ignore first voxel...) to avoid shadow on lighted surface



来源:https://stackoverflow.com/questions/22347296/what-is-the-fastest-shadowing-algorithm-cpu-only

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!