官术网_书友最值得收藏!

How to do it...

We will start this recipe by placing a reflective object in our default scene and looking at how certain aspects of the environment can be seen reflected in its surface. Take the following steps:

  1. Open the map named 01_05_HDRi Lighting, and take a look at the reflective sphere in the middle of the level:

You can see that I've applied a material to the model, named M_Chrome. This is a copy of the material we created in our third recipe, named M_PBR_Metal, where we've modified the base color and the roughness value to make it more chrome-looking. Thanks to its reflective properties, we can see the environment clearly. This is happening thanks to the HDRi image we are using. We are now going to replicate this effect without using the blueprint that was already set up for us, and we will instead create our own.

One of the things that we want to move away from in the setup we are going to create is having the environment image visible at all times. You could be thinking that the metal ball is reflecting the image you see in the preceding screenshot and not the actual light—and that would be only natural as you are seeing that image in the background. This is, however, just a visual cue that the blueprint uses to better visualize from where the environment lighting is hitting an object. Having said so, let's start working with the basic building blocks and not with pre-made tools to better understand how things work.

  1. Delete the BP_LightStudio and the SphereReflectionCapture and click on the Build icon—we should now be looking at a completely dark scene.
  2. From the Modes panel, navigate to the Place tab and to the Lights section within it. You should be able to find a Skylight, the type of light that we can use to illuminate with HDRi textures. Drag and drop it into the scene as follows:
  1. With the newly created skylight selected, navigate to the Details panel and look at the options under the Light section. The first option on the drop-down menu says SLS Captured Scene, which uses the already existing scene to create a light. We want to change that value to the other available option, SLS Specified Cubemap. Once that's done, select a Cubemap from the next drop-down menu—let's go with the one we've used in the past, HDRI_AlexsAptas follows:
  1. After selecting the texture, you will be able to check for yourself that nothing has changed; we are still looking at a black screen. This is because the default type that was spawned was one of the Static type and skylights of that type need to get built before we can see them. Click on the Build icon again and see what happens:
  1. We are now lighting our scene with the HDRi! However, we are still using a static light, which has its inconveniences regarding reflections (as you can see, there are none!). Let's change between static, stationary, and dynamic to see how the scene varies:

As you can see, going from a static type of light to a dynamic one gets us the reflections back. This is due to the fact that static lights only exist during the light baking process—that is, when we click on the Build button. In order to use HDRis to their full extent, we should be aiming for a dynamic or stationary type of light.

Let's focus once again on the metallic ball under this new dynamic skylight that we now have. There might be a bit of a problem, if we look closely:

You can see that there's a black edge going on across the surface of the ball, which is happening because the skylight is by default only using half of a sphere to project the selected texture. This is happening because objects are usually not lit from underneath, and we might be fine with that sometimes. However we can solve that by selecting the next option:

  1. As you saw in the previous picture, select the Skylight and expand the Light section on the Details panel. In there you will be able to see that the set Lower Hemisphere Is Solid setting is ticked by default—unticking it will make the light use a full sphere to project the HDRi.
You might be inclined to fill your scene with geometry so as to obscure the emptiness that is being reflected in the chrome ball. However, Unreal doesn't render the objects that the camera can't see—so the reflections that should be happening thanks to the objects that would be behind it won't show at all. This is one of the sacrifices that real-time rendering has to make in order to be so efficient, so keep that in mind! We can solve that by placing a reflection capture, as we'll see next.

However useful having a full spherical HDRi skylight lighting our scene might be, it can also introduce some undesired effects that we don't want to see. For instance, we might want to use the actual geometry of our level to affect the lower part of the chrome ball and not the HDRi. If that's the case, tick again the Lower Hemisphere Is Solid setting and let's try something different.

  1. Place some planes around the level, in a similar fashion to what I'm doing in the next screenshot. This is just to mimic a scenario where we would have more geometry throughout the level, which could be used for reflections, so we don't have that black band across the reflective ball we saw before. Assign those planes a different material—I'm using M_Basic_Wall from the Starter Content pack:
  1. Place the camera somewhere close to the reflective ball so we can see it clearly. We are still seeing the previous reflections, and not the current ones:
  1. In order to fix this, go to the drop-down menu to the right of the Build icon and select the option Build Reflection Captures:

With that done, you should now be looking at your recently created planes in the reflections of the chrome ball as follows:

主站蜘蛛池模板: 台中市| 镇康县| 右玉县| 两当县| 洞头县| 乐昌市| 宁陕县| 伊宁市| 南和县| 建宁县| 修武县| 边坝县| 油尖旺区| 通州市| 焦作市| 贵溪市| 固镇县| 靖安县| 南昌市| 万荣县| 河津市| 罗城| 鸡泽县| 册亨县| 霍山县| 汉沽区| 阿克苏市| 衡水市| 如皋市| 崇文区| 荣昌县| 金沙县| 锡林郭勒盟| 曲周县| 海安县| 武冈市| 汉中市| 阳城县| 明溪县| 万宁市| 伊宁县|