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

How to do it...

The first example that we are going to create is going to be some simple glass. As before, right-click in the appropriate subfolder of your Content Browser and create a new material. Here's how we go about it:

  1. Let's name it with a pertinent name, something like M_SampleGlass, as that's what we'll be creating!
  2. Open up the material editor, and focus on the Details panel. That's the first area we are going to operate on. Make sure you have the main material node selected—if you haven't created anything else, that's the only element that should exist on the main editor graph:
  1. Having the main node selected, you'll be able to see that the second editable attribute under the Material section of the Details panel is the Blend Mode. Let's change that from the default value of Opaque to the more appropriate Translucent one as follows:
  1. After this change has happened, you'll note that several options have been grayed out inside of the main material node. We'll come back to this shortly.
  2. Without leaving the Details panel, you can now scroll down to the Translucency section of the main material node. You should be able to find a drop-down menu named Lighting Mode, which we'll need to change from the default value of Volumetric NonDirectional to the one named Surface Translucency Volume, as shown in the following screenshot:

If you hover over each of the options inside of the Lighting Mode drop-down menu, you should be able to take a look at their description. You'll note that some of the options are meant to be used with particles, while others are meant for 3D models. That's the reason why some of the material attributes were previously grayed out— some options don't make sense to be used if we are going to be applying the material to a particle, for example, so these are left out.

  1. With that out of the way, let's now attach a Constant4Vector to the Base Color node and give it an interesting value. I'm going with a bluish tone, as we'll be creating a glass and they usually have that kind of tint.
Why a Constant4Vector and not a Constant3Vector, as we used last time? This new type that we are using includes a fourth parameter, which can be used as an alpha value, something very useful for glass-like materials as you'll see for yourself in a moment.
  1. Without leaving the Constant4Vector behind, set the alpha value to something like 0.5. Don't go all the way with this parameter! Setting it either as a 0 or a 1 would make our future material fully transparent or opaque, so choose something in between. Plug the value into the Base Color material node as follows:

  1. Now it's time to plug in the alpha value of our Constant4Vector into the Opacity slot of our material. Drag from the pin of the Constant4Vector into an empty space in the main graph and release the left mouse button. A contextual menu should now appear, and you want to type maskSelecting ComponentMask is what we want to be doing now!
  1. With the component mask selected, let's take a look at the details panel. In there you'll be able to select which of the four components from the Constant4Vector node you want to use. For our case, as we'll be driving the opacity through the alpha, let's just tick the last option.
  2. Finally, connect the mask to the Opacity pin. Click on the Apply button and save the material. The preview window may take a moment to update itself, but once it does we should be looking at a translucent material like the following:

Now that we have our material correctly set up, let's apply it to the model in our scene. If you've opened the level that I've set up for you, 01_ 04_ TranslucentMaterials_ Intro, you'll see that we have an object called SM_ Glass. If you are creating things on your own project, just create a model in which we can apply this newly created material. In any case, the scene should look something like this after you apply the new material:

Simple but effective! In the future, we'll be taking a look at how to properly set up a more complex translucent material, with reflections, refractions, and other interesting effects. But for now, we've taken one of the most important steps in that path—actually starting to walk!

主站蜘蛛池模板: 汝城县| 渑池县| 麦盖提县| 福清市| 临朐县| 中山市| 嘉祥县| 宜阳县| 英山县| 海丰县| 仙居县| 瑞金市| 手机| 越西县| 平阳县| 志丹县| 张家港市| 山阴县| 隆昌县| 阿坝| 南平市| 阿坝县| 广灵县| 长乐市| 分宜县| 全州县| 清原| 涞水县| 天长市| 广水市| 桂林市| 西藏| 莫力| 昌宁县| 富平县| 山阳县| 吴堡县| 全南县| 通江县| 阳江市| 土默特左旗|