Pages

Wednesday, June 3, 2020

Enscape custom assets - how to make leaves

Today's post comes compliments of industry expert Pieter Schiettecatte from A+I in New York CityClick here to see all this posts on this blog, include the very popular recent post: Tutorial: how to create custom Enscape assets.

Many of you have reached out on how to create custom Enscape assets with cutout maps. A typical example of this is vegetation: because the polycount must be kept low, each leaf cannot be modeled in full detail. Instead the shape of the leaf is approximated with just a few polygons and then extra definition is added by using a transparent .png image for the leaf’s color texture.

In this tutorial we will use an ivy plant as an example. You can download the Blender file here.

Ivy model rendered with Blender 2.9 

Ivy model with wireframe, notice the leaves are only roughly modeled with 6 polygons each

keep reading to learn more...

The material shader applied to the leaves. Notice that a transparent .png is used. For transparency to work in Blender, the alpha output socket of the image has to be connected to the alpha input node of the Principled BSDF shader.

Step 1) Export the ivy object to gltf+bin+textures and the white placeholder as an .obj file. For detailed information click here. Alternatively, download the exports from Blender files here.

Step 2) Create a custom asset using the asset creator tool and load it into your library. Render the asset in Enscape. Notice that the transparent edges of the leaves are rendering black. 



This is because Enscape assets do not support the transparency layer of .png files. Instead, we will need to manually add a black & white cutout map in the .gltf file.

Step 3) make a copy of the .png leaf texture maps and convert them to a black & white .png. Black for transparent areas, white for opaque areas. Save the cutout maps in your asset folder


Step 4) open the .gltf file in a code editor. If you don’t have a code editor installed, I recommend the free and open source Visual Studio Code (54mb)

Step 5) First it is necessary to declare that two additional image maps will be used for this gltf file.

Navigate to the “image” section of the .gltf and add a new entry for each cutout map (indicated in red). The names are arbitrary but the “uri” needs to match the filename exactly (including the file extension). Remember that Enscape assets do not support spaces in texture maps.

Each entry needs to be separated with a comma (indicated in blue).


Step 6) Next, the image maps need to be loaded into a texture slot. Navigate to the “textures” section of the .gtlf and add a new source for each cutout map (indicated in red). Again, each entry needs to be separated by a comma (indicated in blue)

The number for the source is referencing an entry in the image list. The numbering starts at 0, so for the 3rd image in the image list, the source is 2.


Step 7) Add the Enscape extensions to the .gltf file. Navigate to the top of the .gtlf file and just underneath the “asset” section add the extension information as indicated in the red box in the image below. This will make sure the materials can have a cutout map added to them (this is not an option in default gltf)



Step 8) Add the Enscape extensions (ENS_material) to the leaf materials. The extension provides for more than a dozen options, but in this case only two are necessary:

  • “materialType”: 3, this will trigger Enscape to render the material with the “foliage” shader. Enscape will use some optimizations like a modified shadow calculation, subsurface scattering and no outline generation.
  • Masktexture: this is the cutout map, the index refers to the number in the list of the textures (so index 2 is the third entry in the texture list (count starts at 0)

Step 9) Save the .gtlf and launch Enscape. The black edges should now render transparent. If you had trouble following the steps, you can download the finished asset here.




For BIM Chapters updates, follow @DanStine_MN on Twitter or connect on LinkedIn

Check out my video-based  courses on ArchSmarter.

I also write blog posts for Enscape - a new paradigm in rendering, animation and VR for AEC.