- Home /
Question by
Katerpilet · Jun 02, 2017 at 09:12 AM ·
androidopenglgles
How to render OES Texture in Unity
I am trying to render an OES texture in Unity. I create the texture on Java side and then interop that to Unity. Here is my Unity code:
m_currentTexture = Texture2D.CreateExternalTexture(1080, 1920, TextureFormat.RGB24, false, false, new System.IntPtr(webviewTextureReference));
bool hasMainTexProp = GetComponent<Renderer>().material.HasProperty("_MainTex");
print("texture hasproperty: " + hasMainTexProp);
GetComponent<Renderer>().material.EnableKeyword("_MainTex");
GetComponent<Renderer>().material.SetTexture("_MainTex", m_currentTexture);
And my fragment shader:
#ifdef FRAGMENT
#extension GL_OES_EGL_image_external : require
uniform samplerExternalOES _MainTex;
varying vec2 TextureCoordinate;
void main()
{
gl_FragColor = textureExternal(_MainTex, TextureCoordinate);
}
#endif
Any ideas? Only black renders.
Comment