- Home /
Any news about how to make use of GL_OES_EGL_image_external?
Hi.
I want to render a texture that's constantly updated outside unity by a video player contained in an Android plugin. The update is done in an arbitrary thread (should this be UnityMain?). I know how to hook the texture (using Texture2D.CreateExternalTexture after getting the handle from the plugin).
I managed to create a shader that uses "#extension GL_OES_EGLimage_external : require" and I see no errors in logcat about compilation, but the texture shown is black. Also, if I use the built-in unlit texture shader, the texture shown is plain purple(the smaller cube).
In the bottom-right is a GLSurfaceView from Android side (I added it as a child of UnityPlayer's root view for debugging)
Shader:
Shader "Fast" {
Properties {
_MainTex("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "Queue" = "Geometry" }
Pass
{
GLSLPROGRAM
#ifdef VERTEX
varying vec2 TextureCoordinate;
void main()
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
TextureCoordinate = gl_MultiTexCoord0.xy;
}
#endif
#ifdef FRAGMENT
// require GL_OES_EGL_image_external so we can access the external texture data on android's GPU
#extension GL_OES_EGL_image_external : require
//precision mediump float; // added
varying vec2 TextureCoordinate;
//uniform sampler2D _MainTex;
uniform samplerExternalOES _MainTex; // replaced above line with this in order to use GL_OES_EGL_image_external
void main()
{
gl_FragColor = texture2D(_MainTex, TextureCoordinate);
}
#endif
ENDGLSL
}
}
FallBack "Diffuse"
}
Answer by not_a_valid_username · Sep 21, 2018 at 07:20 AM
@thefallengamesstudio You might want to change texture2D with textureExternal as mentioned here. That being said, I'm having the exact same problem even with that change. Did you ever find a fix for this?
Your answer
Follow this Question
Related Questions
Material with custom shader black on Android (Lightweight Render Pipeline) 0 Answers
Problems with Depth Normals and variable CullMode 0 Answers
[Deferred Decals] Add simple specular channel to deffered decals 0 Answers
Rendering volumetric objects and maintaining correct depth 1 Answer
Weird rendering on Android: some materials become black, some sprites are replaced 1 Answer