atteneder / glTFast

Efficient glTF 3D import / export package for Unity
Other
1.24k stars 251 forks source link

Standard SpeedTree static export/import support #343

Open bitinn opened 2 years ago

bitinn commented 2 years ago

Is your feature request related to a problem? Please describe.

Currently the support for SpeedTree are problematic in 3 ways:

I don't use SpeedTree assets in real-time due to their performance cost, and I generally convert them to static meshes for my Blender / Unity workflow. So having a semi-automated workflow via glTF would be great.

Describe the solution you'd like

Describe alternatives you've considered

Doing all of these manually.

Additional context

Unity has recently released free SpeedTree assets and scenes, in case you want to investigate this issue. It contains both TIFF normal map and usage of SpeedTree (Nature) shaders. I tested with the HDRP demo.

https://assetstore.unity.com/packages/3d/environments/unity-terrain-hdrp-demo-scene-213198 https://assetstore.unity.com/packages/3d/environments/unity-terrain-urp-demo-scene-213197

atteneder commented 2 years ago

Hi @bitinn ,

Thanks for this detailed report. Much appreciated!

* `Nature/*` class shaders are special and require reading from a different set of texture ids, currently glTFast ignore all textures on such materials.

Right, I haven't tested those shaders, but it makes a lot of sense

* Large trees often need to be visible from a long distance, so have LODGroup on them, glTFast currently doesn't recognize Unity's LOD import convention. So on a round trip export/import, the LODGroup component is lost. (Obviously even a FBX round trip will lose the LODGroup settings, but Unity is able to set a sensible default LOD cascade on import.)

I presume glTFast exports the current LOD, which depends on the camera's position/perspective, right? I just created a dedicated issue in #345

* I also ran into an issue exporting TIFF (`.tif`) normal maps, glTFast doesn't appear to recognize them as linear map, so the exported texture looks much bluer than the original, PNG normal map doesn't suffer from this issue.

Opened #346

I don't use SpeedTree assets in real-time due to their performance cost, and I generally convert them to static meshes for my Blender / Unity workflow. So having a semi-automated workflow via glTF would be great.

I totally agreee. That's a great use-case.

* Reconsider texture import strategy, currently the glTF spec's ORM texture is not compatible with default Lit in Unity, this makes round trip more time consuming (potential solution includes 1. texture import post processor, 2. glb importer allowing texture channel repack).

The channel mappings are given, so copying channels around cannot be avoided, unless we implement export of glTF shaders as well. Since you use the SpeedTree shaders, I asume this is not that what you mean, right?

* LOD solution can be solved via [Level of detail support #20](https://github.com/atteneder/glTFast/issues/20) , should be mostly compatible with Unity's LODGroup, barring the cross fade settings.

Re-framed #20 to be about import and #345 about export.

* Reopen [Normal map should be loaded as linear not sRGB #67](https://github.com/atteneder/glTFast/issues/67) as it appears only partially resolved.

Said issue is about import, so new issue #346 instead.

Thanks

hybridherbst commented 2 years ago

In general I think the way to support "each and every weird custom thing" (trees, TMPro, Canvas, whatever you want to export/import) is to build custom callbacks, at least that's the plan for UnityGltf. Some of those could of course be built in at some point (trees make sense) but others would be very workflow and project specific.

bitinn commented 2 years ago

I definitely agree, though the problem is on import we cannot easily distinguish them (between a tree glb and a car glb), so it would seem like we need some import settings to allow users to select an import template, to remap material and textures correctly.

Sent from my iPhone

On Mar 21, 2022, at 18:56, hybridherbst @.***> wrote:

 In general I think the way to support "each and every weird custom thing" (trees, TMPro, Canvas, whatever you want to export) is to build custom callbacks, at least that's the plan for UnityGltf. Some of those could of course be built in at some point (trees make sense) but others would be very workflow and project specific.

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.

hybridherbst commented 2 years ago

Yes, if you want to fully recreate the tree you might need to emit additional userData or a simple extension (possible through callbacks) with everything that can't properly be transferred via glTF itself.

bitinn commented 2 years ago

Just to limit the scope a bit: for now, I am happy if I can get the basic PBR maps out and in again. Main problem currently is texture channel packing differences and import material assignments.

Sent from my iPhone

On Mar 21, 2022, at 20:01, hybridherbst @.***> wrote:

 Yes, if you want to fully recreate the tree you might need to emit additional userData or a simple extension (possible through callbacks) with everything that can't properly be transferred via glTF itself.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.