prefrontalcortex / UnityGLTF

Runtime GLTF Loader for Unity3D
MIT License
163 stars 41 forks source link

Support SRP (URP/HDRP) Material mapping on Asset Import #38

Open bitinn opened 2 years ago

bitinn commented 2 years ago

This is more of a feature request than a bug, but currently UnityGLTF import materials with BIRP shader, so they do not work under URP or HDRP.

Screen Shot 2022-03-14 at 18 07 57

(glb file imported with glTFast, GLTFUtility, UnityGLTF)

2 ways to address this issue:

  1. Map materials to URP and HDRP Lit shaders when they are active, or provide some compatible shader graph.
  2. Expose material replacement in the import settings.3.

Personally I prefer option (2), as it matches what Unity model importer does; but it can't hurt to also have (1).

Screen Shot 2022-03-14 at 18 02 27

Currently both glTFast and GLTFUtility offers (1) using a custom shader graph, and GLTFUtility in addition support (2).

(Hope this doesn't create too much competition between plugins, but I also don't want to switch between 3 GLTF plugins just to get work done :) )

Thx!

hybridherbst commented 2 years ago

Thanks for the request, it's been a long-standing one :) For our projects we have actually switched to a workflow that does use multiple packages:

because that's where both of these have their strengths, at least right now.

The issue with (2) above is that it will not properly capture material properties as in the GLB file (there are simply features that do not map to any shader shipping with Unity/URP/HDRP); I agree that it would still be useful to have.

Two more options:

  1. using the ShaderGraphs shipping with glTFast for UnityGltf import if both packages are in the same project
  2. making new ShaderGraphs but only for 2021.2+ so that there's one graph for all (BiRP/URP/HDRP)

instead of the current approach of having divergent features across multiple shaders.

bitinn commented 2 years ago

Yeah personally I think (4) might be the better option, though I think it's important for a glTF plugin to be able to repack texture channel according to SRP Lit shader's preference, so that users can switch to Lit when needed.

One common roundtrip problem:

(For example, how do we export a Tree? https://github.com/atteneder/glTFast/issues/343 I end up first replacing Unity's SpeedTree shader with Lit, then on import, using a custom shader to support ORM map.)

hybridherbst commented 1 year ago

Option (4) above is implemented for a while (cross-pipeline Shader Graphs); there are a number of other issues listed here (e.g. remapping shaders on import) remaining.