prefrontalcortex / UnityGLTF

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

Stereo instancing shader issue #71

Closed Jerem-35 closed 1 year ago

Jerem-35 commented 1 year ago

Hello,

I am currently facing an issue with the gltf shaders with the stereo instancing mode (tested on Quest PC and Hololens). The object associated with the PbrMetallicRoughness material is only visible for one eye (left).

I get the following error :

Shader error in 'GLTF/PbrMetallicRoughness': variable 'vi' used without having been completely initialized

I am using Unity 2021.3 LTS with the Oculus SDK.

Best

Edit : I did found a solution. It seems that the instance id of the VertexInput variable in "VertexColor.cginc" is not initialized. I just transfered this id from the appdata_full `structure.

WrappedVertexOutput vert_vcol(appdata_full v)
{
    // Save the color information
    WrappedVertexOutput o;
    o.color = v.color;

    // Forward this call to the default vertBase
    VertexInput vi;
    UNITY_TRANSFER_INSTANCE_ID(v, vi);
    vi.vertex = v.vertex;
    vi.normal = v.normal;
    vi.uv0 = v.texcoord;
    vi.uv1 = v.texcoord1;
#if defined(DYNAMICLIGHTMAP_ON) || defined(UNITY_PASS_META)
    vi.uv2 = v.tetcoord2;
#endif
#ifdef _TANGENT_TO_WORLD
    vi.tangent = v.tangent;
#endif
    o.innerValue = vertBase(vi);

    return o;
}

Tested on Hololens and Quest and it works

hybridherbst commented 1 year ago

Thanks, that looks good!