Single-pass instanced rendering
Describe the bug Importing models from a C# MonoBehavior results in models that are with solid pink (no shading, like a silhouette) with each eye seeing the model at a different offset. Models appear fine in Windows Player, but not in Android build running on Meta Quest.
Left eye sees it in its correct location. The right eye sees it offset to the right and it moves around based on head movement.
I'm not doing anywhere in my app that renders differently per eye and I don't manipulate the instantiated model.
Files This happens with every model I've tried to load, but here's an example.
glTF Validator shows a few warnings that don't seem relevant, but no errors.
To Reproduce C# Code:
public async void LoadModelFile(string modelFilename)
{
try
{
GLTFast.GltfImport gltf = new ();
var success = await gltf.LoadFile(modelFilename);
if (success)
{
GameObject go = new();
success = await gltf.InstantiateMainSceneAsync(go.transform);
if (success)
{
return;
}
else
{
Debug.LogError(">> Error adding to scene", this);
UnityEngine.Object.Destroy(go);
go = null;
}
}
else
{
Debug.LogError(">> Load failed", this);
}
Debug.LogError(">> Success", this);
}
catch (Exception e)
{
Debug.LogError(e.Message, this);
}
}
Expected behavior I expect it to load with correct shape, textures, and stereo view.
Screenshots
If you can do cross-view 3D (cross your eyes) you can align the grid and see how each eye has the model shifted a bit.
Desktop (please complete the following information):
- glTFast version: 6.4.0
- Unity Editor version: 2022.3.27f1
- Render Pipeline and version: Universal Render Pipeline 14.0
- Platform: Windows 11
additionally (if significant for the bug):
- Device: Meta Quest 3 / Android 12.0 (12L, API Level 32)
Additional context n/a
I'm also seeing this, adding my specs here too in case it helps
- glTFast version 6.9.0
- Unity Editor 2022.3.28f1
- Render Pipeline: Built-in Render Pipeline
- Platform: Windows 11
- Device: Meta Quest 3
- Target OS: Android API Level 34
Hi,
Have you had a look at how to setup your project's materials and shader variants? Likely some are missing.
GltfImport, by default, does not log eventual problems unless instructed to do so. Initialize it like so and try it again:
GLTFast.GltfImport gltf = new (logger:new ConsoleLogger());
Now it should log errors/warnings to the console.
Let me know if you need further assistance.
Hi @atteneder , thanks for the logger tip. Got an error saying to include the glTFPbrMetallicRoughness shader, great for later projects!
I did just need an unlit shader though, so I modified the glTFUnlit shader. Had to add a couple lines of shader code to make it work: https://docs.unity3d.com/2022.2/Documentation/Manual/SinglePassInstancing.html
Hello @snaik27, just want to know exactly what you modified in that shader because I got the same issue on my side. Thanks in advance
Have you had a look at how to setup your project's materials and shader variants? Likely some are missing.
I've read this, but I'm not sure it applies. I'm trying to load user models at runtime. There's nothing to setup in advance. What's the best way to approach this?
Creating a shader variant collection and include it in preloaded shaders doesn't work for me, but, I solved this by adding the shaders that are missing in 'Always Include Shaders' section, I'm loading models at runtime as well.
@snaik27 Thanks a lot for finding the culprit and pointing me towards the solution!
Is there a way to verify the solution works without having the Quest at hand (like, is it reproducible in the Meta XR Simulator)?
Would you be willing to make a pull request?