Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Build Unity Game using UnityGLTF (Shaders problem)? #206

Closed
Vytek opened this issue Jul 20, 2018 · 13 comments
Closed

How to Build Unity Game using UnityGLTF (Shaders problem)? #206

Vytek opened this issue Jul 20, 2018 · 13 comments

Comments

@Vytek
Copy link
Contributor

Vytek commented Jul 20, 2018

This is my Unity config:

Versions
Unity: 2017.3.1f1 (fc1d3344e6ea)
VRTK: 3.3.0 (may not be correct if source is GitHub)
SteamVR: 1.2.3
VR Settings
Standalone: None, OpenVR
Scripting Define Symbols
Standalone: VRTK_DEFINE_SDK_STEAMVR;VRTK_DEFINE_STEAMVR_PLUGIN_1_2_1_OR_NEWER;VRTK_DEFINE_STEAMVR_PLUGIN_1_2_2_OR_NEWER
WSA: VRTK_DEFINE_SDK_WINDOWSMR
WSA: VRTK_DEFINE_SDK_WINDOWSMR

I am workin on:
Version system: macOS 10.13.6 (17G65)
Version kernel: Darwin 17.7.0

In Editor all works fine. But when I am trying to build my demo I have in log:

07-20_08-56-30: Console Log (Exception): ShaderNotFoundException: GLTF/PbrMetallicRoughness not found. Did you forget to add it to the build?
UnityGLTF.StandardMap..ctor (System.String shaderName, System.Int32 MaxLOD) (at <6e2e72fb449c4779bd7a6f55349ab1e6>:0)
UnityGLTF.MetalRough2StandardMap..ctor (System.String shaderName, System.Int32 MaxLOD) (at <6e2e72fb449c4779bd7a6f55349ab1e6>:0)
UnityGLTF.MetalRoughMap..ctor (System.Int32 MaxLOD) (at <6e2e72fb449c4779bd7a6f55349ab1e6>:0)
UnityGLTF.GLTFSceneImporter.ConstructMaterial (GLTF.Schema.Material def, System.Int32 materialIndex) (at <6e2e72fb449c4779bd7a6f55349ab1e6>:0)
UnityGLTF.GLTFSceneImporter+c__Iterator11.MoveNext () (at <6e2e72fb449c4779bd7a6f55349ab1e6>:0)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <4b58939e897a4c34942efe344ae250a9>:0)

So I am trying to include shader in "Graphics" settings as file:

schermata 2018-07-20 alle 09 25 37

But the build doesn't works. Unity freeze on creating globalgamemanagers.assets:
https://answers.unity.com/questions/918996/unity-5-freezes-while-building.html

Now I include GLTF/PbrMetallicRoughness.shader in Assets/Resources dir, but I have seen that PBR Materials doesn't work fine :_(

How to fix the issue? I would like to write a little guide of how create a perfect build with UnityGLTF.

Thanks you!

@Vytek Vytek changed the title How to Build Unity using UnityGLTF? How to Build Unity Game using UnityGLTF? Jul 20, 2018
@Vytek Vytek changed the title How to Build Unity Game using UnityGLTF? How to Build Unity Game using UnityGLTF (Shaders problem)? Jul 20, 2018
@Vytek
Copy link
Contributor Author

Vytek commented Jul 20, 2018

Including GLTF/PbrMetallicRoughness.shader delete error message but something not work fine.

This is in player:

mayaverseclient_2018-07-20_22-21-26

sharex_2018-07-20_22-21-09

THIS THE CORRECT VISUALIZATION IN EDITOR:

unity_2018-07-20_22-25-25

unity_2018-07-20_22-25-43

This test is done with:

Versions
Unity: 2017.4.5f1 (89d1db9cb682)
VRTK: 3.3.0 (may not be correct if source is GitHub)
SteamVR: 1.2.3
VR Settings
Standalone: None, OpenVR
Scripting Define Symbols
Standalone: VRTK_DEFINE_SDK_STEAMVR;VRTK_DEFINE_STEAMVR_PLUGIN_1_2_1_OR_NEWER;VRTK_DEFINE_STEAMVR_PLUGIN_1_2_2_OR_NEWER
WSA: VRTK_DEFINE_SDK_WINDOWSMR
WSA: VRTK_DEFINE_SDK_WINDOWSMR

@Vytek
Copy link
Contributor Author

Vytek commented Jul 21, 2018

@Vytek
Copy link
Contributor Author

Vytek commented Jul 21, 2018

Perhaps I found how to fix the issue.

This works with (but I suppose also for other Unity versions):

unity_2018-07-21_16-05-42

  1. NOT USE: NOT include GLTF/PbrMetallicRoughness.shader in (Edit -> Project Settings -> Graphics) This configuration freeze Unity building in "globalgamemanagers.assets". You had to kill the process and restart Unity Editore.

  2. NOT USE: copy GLTF/PbrMetallicRoughness.shader in Assets/Resources directory fix the log error, but the Unity Player not renderer PBR or alpha texture correctly (see previous images on other posts).

  3. CORRECT: Create a ShaderVariants (Edit -> Project Settings -> Graphics) Save to Asset and load your shadervariants. Check in Editor Inspector if your shadervariants contains GLTF/PbrMetallicRoughness.shader , if not add it ;-)

unity_2018-07-21_16-03-19

unity_2018-07-21_16-02-26

NOW ALL WORKS!

Please confirm if my fix is corret and I will close the issue here.

@blgrossMS
Copy link

blgrossMS commented Jul 21, 2018

Sounds good. It would be great if you could send out a PR

@alt-ctrl-dev
Copy link

This works on 2018.2. Managed to build the app for android!

@Vytek
Copy link
Contributor Author

Vytek commented Jul 30, 2018

As request by @blgrossMS:

#213

@riccardogiorato
Copy link

schermata 2018-07-30 alle 16 10 21

I get black model with no textures after testing your steps @Vytek what am I doing wrong? The console/log doesn't give any error on mac or android.

@Vytek
Copy link
Contributor Author

Vytek commented Jul 30, 2018

Which version of Unity? Check shader Variant perhaps it use also other shader? If not add it and retry!
Check my PR: #213
If you have problem contact me on Telegram: https://web.telegram.org/#/im?p=@Vytek

@riccardogiorato
Copy link

riccardogiorato commented Jul 31, 2018

I have just fixed my problem with the black textures on Android and Mac. I had to keep the shaders loaded in the build settings.

schermata 2018-07-31 alle 10 49 46

This flag should be required? By enabling it and fixing the load of the shaders will create any problem?

This issue is related to this other issue too, users might get black textures even after following the previous steps due to GLTF embedded model: #214

@Vytek
Copy link
Contributor Author

Vytek commented Aug 2, 2018

I think so ;-)

@riccardogiorato
Copy link

Think what?

@marcspraragen
Copy link

Noting that if you do use the saved shadervariants asset approach, the file needs to be refreshed if any new variants are introduced in GLTF files (MASK and BLEND alpha modes, in my case). Otherwise Unity might not include the new variants when building to Android.

@pfcDorn
Copy link
Contributor

pfcDorn commented Feb 9, 2024

Please update to the latest version and open a new issue if the problem persists. Thanks!

@pfcDorn pfcDorn closed this as completed Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants