HDRP, Lit Shader Mask Map, how to create this mask?

I’m working on a ScriptedImporter that allows you to repack texture channels however you want. Also allows you to automatically make materials and terrain layers out of a folder of texture maps. Thinking of open sourcing it. If anyone is working on a similar thing, maybe we can collaborate?

2 Likes

sound useful

I’ve pushed an initial version of my tool, Swizzler (forked from unity-texture-packer). Please try it and let me know if you have any issues or feature requests! Opening issues or discussions on GitHub is the easiest way. GitHub - wilg/swizzler: 🔨 Unity utility to easily create mask maps.

3 Likes

Gold - pure gold.

2 Likes

Hi master =) I just tried to get your swizzler running in latest 2022.x LTS HDRP, sadly nothing pops up when I click one of the two options in tools/

I would badly need your tool running! Shame on unity, because your tool should be standard in unity!

Is this tool still the best method for creating the mask out of photoshop?

Do you mean just load the maps in any incorrect slots and then run the wizard? How do you run the wizard on a specific material like this? I’m a little confused I have not used the hdrp wizard very much besides setting up the project.

The HDRP wizard in Unity has a tool option that helps to convert materials from the Standard lit shader to the HDRP lit shader. When you run the wizard, it automatically packs the necessary maps and adjusts them to work properly HDRP, this process generates the linear mask map.

window > Rendering > HDRP Wizard > Convert All/Selected Built-in [Lit] Materials to HDRP [Lit]
or
Edit Rendering > Materials > Convert All/Selected Built-in [Lit] Materials to HDRP [Lit]
Both do the same thing.

Basic Standard to HDRP lit Mask generating process Basic Standard to HDRP lit Mask generate

9077287--1256251--upload_2023-6-13_13-6-0.png

both the wizard and edit manu have the upgrade materials option.

In the Standard shader, certain maps are packed in specific channels of the texture:

  • Albedo texture: The alpha channel can contain smoothness information.
  • Metallic texture: The alpha channel can also contain smoothness information.
  • Normal Map texture: This should be in OpenGL format with Y+ and the swizzle function can be used to correct it if needed.
  • Height texture
  • Occlusion texture
  • Detail mask texture

Smoothness can be represented as either a gloss map or an inverted roughness map, depending on the workflow and the source material. It is packed into either the Albedo A channel or the Metallic A channel, swizzel can also be used here if incorrect.

In the HDRP shader, the packing and channels are different:

  • BaseColor texture

  • Mask texture (in linear colour space)

  • R channel represents Metallic

  • G channel represents Ambient Occlusion (AO)

  • B channel represents Detail Mask or Height, depending on the material

  • A channel represents smoothness

The Normal Map should still be in the OpenGL format.

Linear Mask map generated in action
Linear Mask map generated in action Linear Mask map generated in action

9077287--1256254--upload_2023-6-13_13-9-21.gif

This feature is particularly useful if you primarily work with Unity and don’t have access to texture-packing tools commonly used by artists ( DCC). It simplifies the process of upgrading materials to HDRP.

However, if you are using custom third-party assets that have their own texture packing conventions, you may need to find a solution that works best for your specific case.

If you don’t have access to industry-standard tools like Substance, Maya, or ArtEngine, Quixel Mixer can serve as a robust alternative to Photoshop for texture packing, especially considering how Photoshop handles alpha as transparency in specific formats.

For artists, you can pack textures following the Unity Standard packing convention, as it only requires packing one alpha channel. Later, you can use the HDRP wizard to convert the materials, this could be useful if you need to have the full library compatible with HDRP. This approach can speed up material generation and batching within Unity or your digital content creation (DCC) software.
otherwise, you can just pack according to the pipeline.

If you’re building or using a content delivery network (CDN), I’d advise keeping the textures unpacked and create a custom packing setup during the exporting process. This way, you can cater to individual artist workflows and avoid unnecessary repacking steps.

end result and this entire process can be done within HDRP
9077287--1256269--upload_2023-6-13_13-33-29.png

1 Like

Thank you for the detailed response, let me give this a go and I’ll post back!

1 Like

If anyone should come here looking at this plugin for Unity I can vouch that it still works with versions up to 2023.1.13f1. It might seem a bit cumbersome, but it is very easy to use. I have also been using it with the beta version of Muse with HDRP and Raytracing. I can no longer live a happy life without it.

Also, I use the Channel Packer instead of the HDRP wizard because the latter doesn’t always work for me.

If I have Standard material containing only Albedo Map and Normal Map and convert it through Unity Wizard to HDRP Lit material, will generated Mask Map be any good?
Or it is necessary to create AO or other textures somewhere else before converting material? Or possibly is there some Unity asset capable to generate needed textures for Mask Map from Albedo and Normal Map?

If the source standard material doesn’t have any map used for metallic/smoothness/AO, then no mask map is needed and should (iirc) not be created.

Or, in the worst case, it will be a white map and the material with be controller by the sliders.

Thank you.
My concern is about DAZ characters I use, where visual quality really matters. I have Albedo, Normal Map and Specular Map (all you can get from DAZ studio). And I wonder if I can do more to improve visual quality of character faces. I also use Screen Space Global Illumination and Screen Space Ambient Occlusion (it helps a lot). As a shader I use “Better Lit Shader” as it has layers (using it for makeup and tattoos), Wetness and Dissolve effects. And it also has dedicated Specular Map slot.

9559366--1351567--Mica - Character Customization.jpg

Yet another tutorial here: TerraFormer - Advanced Terrain Shader (HDRP/URP) - Community Showcases - Unity Discussions

To be honest this is one of the biggest shame of HDRP to me. Creating, editing and managing maps is one of the most frequent task in the artistic pipeline, especially when projects grow to scale. This little “optimization” makes it a real hassle and is one of the many reasons why HDRP has such a bad reputation.

This is a typical evil optimization. This idea of packing four one-channel textures into one four channel texture is indeed good for the sampling time and memory usage on the GPU. But these benefits will only have an observable impact on few projects, where GPU memory is a issue (which is mostly the case for URP mobile apps). If you have GPU memory issues on a HDRP project, you are most likely doing something wrong and if not, then you are among the rare dev teams that will simply consider making their own shader to pack textures to optimize things.

They could have proposed this optimized Lit shader in addition to a simpler one.

They could have implemented a simple right click => “pack to lit mask”, “pack to detail mask”…(which is done in the conversion wizards)

They could have wrote a script and tutorial for Gimp, Photoshop and such to help artists.

They could have worked on this fundamental feature at least once in the last 5 years.

Unity took this bad design decision to annoy 100% HDRP devs for an optimization useless in 99.5% scenarios. I hate it.

1 Like

Typically, you can script these things and the wizard/Renderer exists for standard to HDRP packing. You can also create this with shader graph with render textures, substance as well, both common tech artist and artist workflows. Since packing is very project specific, designers need a way to be flexible with this, mostly meaning it’s easier to use one of these methods or external to your editor.

As for having designer specific workflows, this is the “newest” implementation for unity since it’s been mostly programmer centric and not design or UX primarily, though it has essences fof both, you almost get a see and feel of it being programmer centric. Similarly Unreal is the opposite since C++ has a higher entry level than C#.

Regarding HDRP, in my personal experience, I wouldn’t have been able to use Unity unless it existed because of my difference in skill sets resonate with HDRP much better than the other pipelines, so I was able to skill up and adopt it much faster than most who were trying to transition to it.

I think what has slowed Unity down significantly has been the chaos with company global goals and rapid shifts and pivots in leadership directions, the “oo piece of candy” scenario. This left the company in a situation where most endeavours have been left unfinished or unrealised especially when it comes to the non service/free parts, you’ll notice that services and web services are fully fleshed, agnostic and constantly at the forefront by comparison.

When it’ll review and shift focus to UX and designer workflows specifically as a game engine is anyone’s guess, but also since designers generally work with several software softwares with many workflows in and out of them, Unity is typically the last or the one they spend least time in (depending on role). You’ve got lots of options though you just gotta work out the approach that works best for you. I didn’t even think UE could pack native to file directly.

And “Smoothness” instead of Roughness. I have never seen a texture pack include a smoothness map, meaning it has to be reversed -1 every time.

HDRP should use Roughness.

I previously [quote=“Stardog, post:57, topic: 702225, username:Stardog”]
And “Smoothness” instead of Roughness. I have never seen a texture pack include a smoothness map, meaning it has to be reversed -1 every time.

HDRP should use Roughness.
[/quote]

Smoothness is just a glossiness map workflow

In PBR There are two distinctive workflows for this:

Metal rough
Metal gloss

Unity just uses the latter, other Renderers and industry may prefer one or the other or be agnostic.

This is a a similar situation to Open GL or Direct x or coordinate systems.

If a texture pack being sold for unity isn’t including smoothness packs then it’s likely building for Multi stores and multi engine platforms and not regarding the specific.

With design workflows, these are simply chosen ahead of time for x project and the designer will just follow the workflow.

For Substance and Quixel design work, all maps and workflows can be set up and generated the packing you wish. Similarly as mentioned above too.

A potentially valuable option to eliminate all this drama would be to implement Texture Sets, which I have posted about here Texture sets could be a valuable addition to the Unity engine