Hey all,
I am trying to render a GL_TEXTURE_EXTERNAL_OES in Unity. The shader is compiling properly, but all I get is a black screen on device. I create the texture and hook it up properly on the Java side, send that over to Unity and do:
m_currentTexture = Texture2D.CreateExternalTexture(1080, 1920, TextureFormat.RGB24, true, true, new System.IntPtr(webviewTextureReference));
GetComponent<Renderer>().material.SetTexture("_MainTex", m_currentTexture);
My shader looks like:
Shader "Unlit/ViewTextureShader"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType" = "Opaque" }
LOD 100
Pass
{
GLSLPROGRAM
#ifdef VERTEX
out vec2 textureCoordinates;
void main()
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
textureCoordinates = gl_MultiTexCoord0.xy;
}
#endif
#ifdef FRAGMENT
#extension GL_OES_EGL_image_external_essl3 : require
uniform samplerExternalOES _MainTex;
in vec2 textureCoordinates;
void main()
{
gl_FragColor = texture2D(_MainTex, textureCoordinates);
}
#endif
ENDGLSL
}
}
}