RenderHeads / UnityPlugin-AVProVideo

AVPro Video is a multi-platform Unity plugin for advanced video playback
https://www.renderheads.com/products/avpro-video/
224 stars 27 forks source link

[3.0.0] Unable scale the Sphere Mesh with OES shader #1839

Open DevJamaly opened 2 months ago

DevJamaly commented 2 months ago

Describe the issue When I apply the OES shader to the sphere mesh. The sphere mesh scales down in scale and translates off to the side. This happens for both OES and OES transparent shader.

Your Setup (please complete the following information):

To Reproduce

  1. Change texture format in Android Platform settings to "Y Cb Cr 420_OES"
  2. Apply OES material to sphere and scale it to 10 in all dimensions
  3. Use "Apply to Mesh" to play video onto sphere mesh
  4. Build to device. The video sphere is offset and scaled down.
TJ-Sentient commented 2 months ago

Any updates on this ? Facing the same issue !

Chris-RH commented 2 months ago

So this works fine with the non-OES shaders? Can I confirm you are using OpenGLES, not Vulkan?

DevJamaly commented 2 months ago

So this works fine with the non-OES shaders?

Yes, it works fine with non-OES shaders provided by AVPro

Can I confirm you are using OpenGLES, not Vulkan?

Yes i am using OpenGLES3 as the graphics API

Last8Exile commented 2 months ago

@DevJamaly @TJ-Sentient Hello. When I tried to use OES shaders I encounter similar issue. Somehow I unable to control position, rotation or scale of renered video. It seems always rendered with default transform at world origin. I never go deeper and swithed back to using BGRA texture (does not have time to properly investigate).

Can you, please, check if you are able to affect transform of Mesh with OES shader in any way? If not - it seems there is problem with OES shader and transformation matrices.

DevJamaly commented 2 months ago

@Last8Exile this is exactly the issue i am facing. Thank you for describing it eloquently. As you mentioned due to it rendering at origin and ignoring transforms i have currently switched to non-OES shader. However, i hope we can fix this issue as soon as possible.

DevJamaly commented 2 months ago

@Chris-RH any updates on this issue? Were you guys able to recreate the error on your end. Please let me know if there are any updates. I am using AVPro for a current project demo, which is due soon, and i would like to use OES.

Ste-RH commented 3 weeks ago

I think this might be a Unity issue. We were seeing something similar a year or two ago and the issue was the object transform was always coming through to the shader as identity. I wonder if this is the same issue.

colinhallett commented 3 weeks ago

I'm also seeing issues with the OES shader - including the one described above. I found a basic fix for this in the main vertex method in the OES shader -

#if defined(STEREO_MULTIVIEW_ON)
    int eyeIndex = SetupStereoEyeIndex();
    mat4 vpMatrix = GetStereoMatrixVP(eyeIndex);
    gl_Position = vpMatrix * _CustomObjectToWorld * gl_Vertex; // replace unity_ObjectToWorld with a custom matrix that is set with a shader property
#else
     gl_Position = XFormObjectToClip(_CustomObjectToWorld * gl_Vertex); // add in the property here
#endif

However, certain videos play upside down (though remain correctly scaled and positioned) and I can't find any reason why some do and some don't. I've reverted to using the non-OES shader, which isn't ideal, but seems a lot more reliable.

Ste-RH commented 2 weeks ago

Could you maybe try replacing unity_ObjectToWorld with UNITY_MATRIX_M ?

Ste-RH commented 2 weeks ago

Also, just to check. Is anything here dynamically/statically batched (meshes)? As these are are generated in world space and so that martix will always be identity. I don't think that would be the case here, but just wanting to check.

colinhallett commented 2 weeks ago

Could you maybe try replacing unity_ObjectToWorld with UNITY_MATRIX_M ?

That didn't have any affect. Tried a few others just to see listed here - https://docs.unity3d.com/Manual/SL-UnityShaderVariables.html) but it's always the identity matrix.

Also, just to check. Is anything here dynamically/statically batched (meshes)? As these are are generated in world space and so that martix will always be identity. I don't think that would be the case here, but just wanting to check.

Nope