忽略了三个的光源。

时间:2022-04-24 04:45:53

I'm trying to make a 3D hex grid and I want to implement a fog of war.

我正在尝试制作一个三维的十六进制网格,我想要实现一个战争的迷雾。

Here's a sample of what the grid looks like at the moment:

下面是一个关于网格的例子:

忽略了三个的光源。

I have lighting set up as follows:

我的照明设置如下:

// hemisphere light
var hemisphereLight = new THREE.HemisphereLight(0xffffff, 0.3);
scene.add(hemisphereLight);

// point light
var pointLight = new THREE.PointLight(0xffffff, 0.7);
pointLight.position = camera.position;
pointLight.rotation.y = Math.PI/2;
scene.add(pointLight);

What I'm trying to do is to make tiles that are in the fog of war not respond to the pointLight, that way they only have the low intensity hemisphereLight. I can't seem to find a way to do this. I can't change the tiles to use MeshBasicMaterial, which doesn't respond to any lights, because I DO want the "fog of war" tiles to have the lighting from hemisphereLight.

我想要做的是让那些在战争迷雾中的瓷砖不会对点光产生反应,那样它们只会有低强度的半球光。我似乎找不到一种方法来做这件事。我不能改变瓷砖使用的网格材料,它对任何光线都没有反应,因为我想要“战争的迷雾”瓷砖有来自半球光的照明。

I'm open to suggestions to implement fog of war differently as well.

我也愿意以不同的方式来实施战争的迷雾。

UPDATE:

更新:

I was able to get it to work using a custom shader.

我能让它使用自定义着色器。

忽略了三个的光源。

1 个解决方案

#1


3  

Nice concept, IMHO.

好的概念,恕我直言。

Really, your only choice is to create your own ShaderMaterial for the "fog of war" tiles. In your shader, you would ignore all lights that are not HemisphereLights.

真的,你唯一的选择是为“战争之雾”瓷砖创造你自己的材质。在你的着色器里,你会忽略所有不是半球形的灯。

Remember, if you are going to use ShaderMaterial, and you want to be able to access the scene lights, you need to set the material parameter lights: true. There are many three.js examples of this.

记住,如果你要使用材质,你想要能够访问场景灯,你需要设置材质参数灯:真的。有很多三人。js的例子。

three.js r.58

三。js r.58

#1


3  

Nice concept, IMHO.

好的概念,恕我直言。

Really, your only choice is to create your own ShaderMaterial for the "fog of war" tiles. In your shader, you would ignore all lights that are not HemisphereLights.

真的,你唯一的选择是为“战争之雾”瓷砖创造你自己的材质。在你的着色器里,你会忽略所有不是半球形的灯。

Remember, if you are going to use ShaderMaterial, and you want to be able to access the scene lights, you need to set the material parameter lights: true. There are many three.js examples of this.

记住,如果你要使用材质,你想要能够访问场景灯,你需要设置材质参数灯:真的。有很多三人。js的例子。

three.js r.58

三。js r.58