0

Does anyone know of a good source for writing positional light code in OpenGL ES2?

All the tutorials I have seen expect your model to be at the world center (0,0,0), and the light is affecting that.

Although this might be useful in many cases, how about lights that can exist anywhere in the world? That is a lot more useful to me. :)

I am more looking for the shader code to implement this, but the current target platform is iOS with C++.

4

1 回答 1

0

我用谷歌搜索了“片段着色器聚光灯”并得到了第一页。它没有反射效果,但它确实有位置和方向(你可以使用或扔掉任何东西)。

尽管我建议您根据自己的特定需求编写自己的着色器,并在网络上搜索您想要的效果,因为互联网上到处都是。

您还写道,模型位于中心,然后应用灯光位于中心。无论如何,要获得光线在其他地方的效果,只需使用带有光线位置的均匀,然后从像素位置中减去该向量(在光线位置坐标中描述对象位置),然后将结果与与光线相关的着色器部分一起使用。

于 2013-05-27T11:45:56.437 回答