我试图尽可能逼真的渲染一个场景,在该场景中,点光源击中一个对象,并以与脸部法线相同的角度反弹(入射角=反射角),并在其他地方照亮该场景。
现在,我知道CubeCamera
按照我在网上找到的示例,在threejs中通常使用-material处理反射,但是它不适用于我的情况,因为我可能从无法观察的角度观察场景。观察物体在另一个物体的镜状表面上的反射。
考虑一下我正在研究的这个示例原型:如果从场景中的墙壁突出的盒子具有镜面材料(用完成CubeCamera
),那么我将无法在底面上看到绿色立方体的反射。除非相机位于特定位置;但是,在现实生活中,如果一个光源照亮的物体在另一个物体附近通过,它将部分照亮,就好像它本身就是一个光源一样(当然,这取决于物体的反射率),并且从任何角度都应该可以看到现象,从中可以看到接收间接照明的对象。
因此,我想到了将a添加PointLight
到多维数据集的想法,但这当然会对周围环境产生不良影响。
我将尝试按以下顺序说明我的目标:
1)在这里,我以后将其称为阳台的远端正确地是黑暗的,而标有红色“ x”的区域是立方体具有一个PointLight
向各个方向发光的孩子的结果。
2)在这里,阳台的远处的脸仍然是黑暗的,而当立方体经过时,底部的远处接收的光线甚至更多,这是可取的,但是立方体后面的墙壁实际上应该是黑暗的(我还没有添加阴影,我首先要获得正确的照明),以及其下方的地面和灯柱。
3) Finally, when the cube has passed the balcony, it's just plain wrong for the balcony's side and bottom face to be illuminated, for we all now that a reflected ray does not bounce back the way it came from. Same applies to the lamp post.
Now I realize that all the mistakes that occur are due to the fact that the cube emits light itself, what I'm hoping you can help me with is determining a way to produce physically accurate reflected rays.
I would like to avoid using ambient light or other hacks to simulate real-life scenarios and stick to physics as much as possible; I suspect what I want to achieve is very computationally heavy to render, let alone animate in a real-time use case, but that's not an issue for I'm merely trying to develop a proof-of-concept, not something that should necessarily perform fast.
From what I gather, I should probably be writing custom vertex and fragment shaders for the materials receiving indirect illumination, right? Unfortunately I wouldn't know where to begin, can anyone point me in the right direction? Cheers.
If you do not want to go to the Volumetric rendering then you have 3 options (I know of)
ray-tracing
you have to use ray-trace rendering (back ray-trace) to achieve this. This will also cover shadows,transparent materials,reflected illumination and much more if coded properly. Unless you want to do also precise atmospheric scattering then this is the way.
If the casted ray hits any obstacle then its color is changed (due to obstacle property) and new ray is casted as reflected light ray. If material is transparent then also refracted ray is casted ... Each hit or refraction affect light intensity so you stop when intensity is lower then some treshold or on some layer of recursion (limit max number of refractions per ray) to avoid infinite loops and you can manipulate performance/quality ...
standard polygon rendering
With this approach (I think you are using it right now) you have to improvise. The reflection and illumination effects can be done similar to shadowing techniques. For each surface you have to render the scene in reflected direction. The same can be done with shadows but then you just rendering to the light direction or use shadow map instead. If you have insane number of reflective surfaces then this approach is not the way also to achieve reflection of refraction you have to render recursively making it multiple rendering pass per polygon which is also insane.
cubemap
您可以对每个对象使用多维数据集映射。它与项目符号2相似,但是在生成立方体贴图时而不是在每帧中仅执行一次疯狂操作。如果对象太多,那么这也是不可行的。您只能将立方体贴图用于具有反射曲面的对象,以使其易于管理。另外,如果对象正在移动,则必须不时地重新生成立方体贴图。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句