透明遮光物体

发布于 2025-01-14 00:46:23 字数 957 浏览 2 评论 0原文

我想渲染一个地板+屋顶向一侧开放的房间。房间包含一个点光源,它的“外部”由环境光(太阳)照亮。还有一项附加要求:用户应该能够查看房间内部以了解发生了什么。但我不能简单地拆掉屋顶,因为这样房间就会被环境光完全照亮。

我认为我的问题可以通过让透明的 3D 物体仍然阻挡光线来解决。

为了让您了解我当前的场景,它是这样的:

Scene

灰色的东西是我房间的墙。黑色的东西是房间的地板。绿色的东西是场景的地面。该房间包含一个点光源。

我目前正在使用两个场景(请参阅从定向/环境照明中排除区域)因为我希望房间内部不受环境光的影响。但现在我的灯光只能影响房间内部(点光源)或外部(环境光),但不能同时影响两者。

我的场景的可运行示例可以在这里找到:

https: //codesandbox.io/s/confident-worker-64kg7m?file=/src/index.js

再说一次:我认为我的问题可以通过使用仍然阻挡光线的透明物体来解决。如果我有的话,我会简单地在我的房间顶部(作为屋顶)放置一个 3d 平面并使其透明......它会阻挡房间内部的光线(但如果房间是开放的,仍然让它进入外面) )并且它还会阻挡环境光(部分 - 如果房间是开放的)......

也许还有另一种我没有看到的解决方案。

I want to render a room with a floor + roof that is open to one side. The room contains a point light and the "outside" it lit by an ambient light (the sun). There is one additional requirement: The user should be able to look inside the room to see whats going on. But I cannot simply remove the roof because then the room is fully lit by the ambient light.

I think my problem could be solved by having 3d objects that are transparent by still are blocking the light.

To give you an idea about my current scene, this is how it looks like:

Scene

The grey thing is the wall of my room. The black thing is the floor of the room. The green thing is the ground of the scene. The room contains a point light.

I am currently using two scenes (see Exclude Area from Directional/Ambient Lighting) because I wanted the inside of the room to be unaffected by the ambient light. But now my lights can only affect either the inside of my room (the point light) OR the outside (the ambient light) but not both.

A runnable sample of my scene can be found here:

https://codesandbox.io/s/confident-worker-64kg7m?file=/src/index.js

Again: I think that my problem could be solved by having transparent objects that still block the light. If I had that I would simply have a 3d plane on top of my room (as the roof) and make it transparent... It would block the light that is inside of the (but still let it go outside if the room is open) and it would also block the ambient light (partially - if the room is open)...

Maybe there is also another solution that I am not seeing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

怪我鬧 2025-01-21 00:46:23

只需使用一个场景而不是两个场景,然后在相关网格上启用阴影,这样光线就不会从内部穿过到外部。一旦您仅使用一个场景,演示中要采取的步骤是:

  1. 禁用 AmbientLight,并仅使用 DirectionalLight,因为 AmbientLight 会不加区别地照亮所有内容,而这不是您想要的。
  2. 将定向光放置在建筑物上方,使其从上到下发光。
  3. 在墙壁上启用阴影投射
  4. 添加天花板网格,并将材质的侧面设置为 side: THREE.BackSide。这只会渲染网格的背面,这意味着从上方看不到它,但它仍然会投射阴影。
  const roomCeilMat = new MeshStandardMaterial({
    side: BackSide
  });
  const roomCeiling = new Mesh(roomFloorGeo, roomCeilMat);
  roomCeiling.position.set(0, 0, 1);
  roomCeiling.castShadow = true;
  scene1.add(roomCeiling);

请参阅此处获取演示的工作副本:
https://codesandbox.io/s/stupefied-williams -qd7jmi?file=/src/index.js

在此处输入图像描述

Just use one scene instead of two, then enable shadows across the relevant meshes so a light doesn't cross from inside to outside. Once you're using only one scene, the steps to take in your demo are:

  1. Disable AmbientLight, and use DirectionalLight only, since AmbientLight illuminates everything indiscriminately, and that's not what you want.
  2. Place the directional light above your structure, so it shines from the top-down.
  3. Enable shadow-casting on the walls
  4. Add a ceiling mesh with the material's side set to side: THREE.BackSide. This will only render the back side of the Mesh, which means it won't be visible from above, but it will still cast shadows.
  const roomCeilMat = new MeshStandardMaterial({
    side: BackSide
  });
  const roomCeiling = new Mesh(roomFloorGeo, roomCeilMat);
  roomCeiling.position.set(0, 0, 1);
  roomCeiling.castShadow = true;
  scene1.add(roomCeiling);

See here for a working copy of your demo:
https://codesandbox.io/s/stupefied-williams-qd7jmi?file=/src/index.js

enter image description here

生生不灭 2025-01-21 00:46:23

我会为房间分配一个平坦的发射材料。或者深度梯度(如果它变成地形)。由于 环境光 不会投射阴影。它节省了光线和额外的几何图形或组。再加上网络模型查看器可能会渲染得更好。如果您要进行显示过渡,请使用剪辑平面或纹理 alpha 蒙版。

这取决于表示形式与输出格式。它还取决于最终平面图的复杂程度。如果您的过程很简单,它将在 Raspberry Voxel 上运行 Sims Lite。

I would assign a flat, emissive material to the room. Or a depth gradient if it becomes terrain. Since ambient light doesn't cast shadow. It saves a light and extra geometry or groups. Plus web model viewer(s) would probably render it better. If you're doing a reveal transition, use a clip plane or texture alpha mask.

It depends on the presentation versus the output format. Also it depends on the complexity of the final floorplan. If your process is simple it will run Sims Lite on a Raspberry Voxel.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文