• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by thefallengamesstudio · Nov 14, 2016 at 07:37 PM · androidrenderingshadersshader programmingopengl es 2.0

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)

alt text

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"
 }

screenshot-2016-11-14-19-51-17.png (294.9 kB)
Comment
dustinkerstein
gaolei_nls

People who like this

2 Show 0
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image

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?

Comment
gaolei_nls

People who like this

1 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image thefallengamesstudio · Sep 21, 2018 at 09:59 AM 0
Share

Nope. We abandoned this approach

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Material with custom shader black on Android (Lightweight Render Pipeline) 0 Answers

Scene Color Node in Shader Graph not working with Unity's 2D Renderer and URP 5 Answers

How to write an additive HDRP shader without glow 0 Answers

Manual shaders in URP/HDRP 1 Answer

How can I add volume/depth to shadows? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges