如何使用Threejs实现逼真的反射

安德里亚·阿洛伊(Andrea Aloi)

我试图尽可能逼真的渲染一个场景,在该场景中,点光源击中一个对象,并以与脸部法线相同的角度反弹(入射角=反射角),并在其他地方照亮该场景。

现在,我知道CubeCamera按照我在网上找到的示例,在threejs中通常使用-material处理反射,但是它不适用于我的情况,因为我可能从无法观察的角度观察场景。观察物体在另一个物体的镜状表面上的反射。

考虑一下我正在研究的这个示例原型:如果从场景中的墙壁突出的盒子具有镜面材料(用完成CubeCamera),那么我将无法在底面上看到绿色立方体的反射。除非相机位于特定位置;但是,在现实生活中,如果一个光源照亮的物体在另一个物体附近通过,它将部分照亮,就好像它本身就是一个光源一样(当然,这取决于物体的反射率),并且从任何角度都应该可以看到现象,从中可以看到接收间接照明的对象。

因此,我想到了将a添加PointLight到多维数据集的想法,但这当然会对周围环境产生不良影响。

我将尝试按以下顺序说明我的目标:

步骤1

1)在这里,我以后将其称为阳台的远端正确地是黑暗的,而标有红色“ x”的区域是立方体具有一个PointLight向各个方向发光的孩子的结果。

第2步

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.

Spektre

If you do not want to go to the Volumetric rendering then you have 3 options (I know of)

  1. 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.

    • back raytracing is one (or 3) ray(s) per each screen pixel. It is much faster but not that precise.. (still precise enough)
    • raytracing is one ray per each 3D angular unit (steradian) of space per each light source. It is slow but precise (if ray density is high enough).

    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 ...

  2. 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.

  3. cubemap

    您可以对每个对象使用多维数据集映射。它与项目符号2相似,但是在生成立方体贴图时而不是在每帧中仅执行一次疯狂操作。如果对象太多,那么这也是不可行的。您只能将立方体贴图用于具有反射曲面的对象,以使其易于管理。另外,如果对象正在移动,则必须不时地重新生成立方体贴图。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何使用Pure CSS3绘制逼真的平滑缝阴影?

来自分类Dev

更逼真的照明

来自分类Dev

如何制作逼真的轮盘赌球旋转动画

来自分类Dev

如何制作逼真的轮盘赌球旋转动画

来自分类Dev

如何在 CSS/SVG 中创建逼真的光泽效果?

来自分类Dev

使用SVG制作逼真的(正弦)标记动画/抖动

来自分类Dev

如何使用反射实现回调?

来自分类Dev

更逼真的透视算法

来自分类Dev

Rust如何实现反射?

来自分类Dev

如何组合多个连续图像来模拟逼真的运动模糊?

来自分类Dev

javascript中逼真的鼠标移动坐标?

来自分类Dev

Unity 中逼真的阀轮旋转

来自分类Dev

Three.js:如何将映射添加到OBJ对象以获得逼真的金属材质?

来自分类Dev

如何在Java中实现反射?

来自分类Dev

使用反射实现this.class的正确方法

来自分类Dev

使用反射实现this.class的正确方法

来自分类Dev

平滑Java中随机生成的地形以获得逼真的效果

来自分类Dev

用逼真的重力使物体跳一次

来自分类Dev

平滑Java中随机生成的地形以获得逼真的效果

来自分类Dev

Matlab:逼真的动画弹跳球(模拟地球条件)

来自分类Dev

如何在运行时使用反射更改方法的实现?

来自分类Dev

如何使用反射将 DI 接口的所有实现配置为 IOptions<>?

来自分类Dev

如何使用反射设置数组

来自分类Dev

如何使用反射创建按钮?

来自分类Dev

如何在 A-Frame 中渲染逼真

来自分类Dev

如何在 A-Frame 中实现动态反射

来自分类Dev

在Java中使用泛型和反射实现接口方法

来自分类Dev

C#:使用反射动态调用显式实现的方法

来自分类Dev

使用反射检查是否已实现部分方法

Related 相关文章

热门标签

归档