Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • 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
1
Question by podborski · Oct 16, 2019 at 12:21 PM · rendertextureheadless

native texture pointer returns 0 in headless build

When I run the following code inside a Unity Editor, or if I build and run it (not in headless mode) GetNativeTexturePtr() returns a value >0 for the texture id, etc.

However, when building the app having a Server Build option enabled GetNativeTexturePtr() always returns 0. Even when IsCreated() returns true.

Any ideas what is happening here?

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class test : MonoBehaviour
 {
     private RenderTexture m_RenderTexture;
 
     // Start is called before the first frame update
     void Start()
     {
         m_RenderTexture = new RenderTexture(256, 256, 24, RenderTextureFormat.ARGB32);
         m_RenderTexture.Create();
         RenderTexture.active = m_RenderTexture;
         if (!m_RenderTexture.IsCreated())
         {
             Debug.LogError("RenderTexture could not be created");
         }
         Debug.Log("texture id = " + m_RenderTexture.GetNativeTexturePtr().ToString());
     }
 }
 
Comment
Add comment · Show 4
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 podborski · Oct 16, 2019 at 12:32 PM 0
Share

Is it even possible to use the RenderTexture inside a server build? I want to process that texture in my native plugin, and can not get it work inside a server build. Normal build works just fine. But as soon as the Renderer is a Null Device, I have this problem. I want to run my app on a server PC.

avatar image hexagonius podborski · Oct 17, 2019 at 08:46 AM 0
Share

What exactly would an app do with a texture that does not even render anything? Note, you can simply run the app as is on a server. Headless just means this: "The game does not display anything or accept user input."

avatar image podborski hexagonius · Oct 17, 2019 at 08:57 AM 0
Share

The app would render but not display. The rendered texture is then streamed over the network for example. As soon as I run the app over ssh / or remote desktop etc. I have issues :(

Show more comments

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Bunny83 · Oct 18, 2019 at 12:10 AM

Well, I'm not 100% sure but when you run Unity or a build in headless mode no graphics context is generated at all. In order to create a graphics context you need a window you can draw to (a device context). So in headless mode you don't actually require or use the GPU at all. So of course there would be no native texture pointer since the texture isn't uploaded to the GPU at all. Anything CPU based should still work.


The main issue is probably that almost all default drivers and APIs require a device context which is always bound to some kind of window. If you run in headless mode Unity is supposed to run even in CLI environments without any kind of window support. So it would be difficult to actually accomplish any kind of GPU based rendering.


See this SO question for some insight
This also might be related


If you generally search for GPU rendering in CLI mode you will find a lot blender related posts. However blender mainly uses CUDA or OpenCL for rendering and not the actual GPU rendering pipeline. So I don't think that this possible with Unity. Though I really don't know so this is just a wild guess. Maybe someone from the Unity team could shed some light on this (Maybe @Aras ?)

Comment
Add comment · 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 podborski · Nov 06, 2019 at 02:05 PM 0
Share

Thank you. I saw that UnityRenderStrea$$anonymous$$g has an open issue where someone mentioned a similar problem. I hope that Unity guys will give some insights on this.

avatar image
0

Answer by Lazuli · Oct 27, 2020 at 08:11 AM

I believe EGL was developed for just such a problem. Is there any way we could convince the Unity team to implement the ability to use an EGL context instead? (Or maybe someone could write a Native plugin..?)

Comment
Add comment · 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
0

Answer by avtarsohi · Apr 01 at 05:22 PM

You need to run X11 server for that. Here is the post which will help you: https://towardsdatascience.com/how-to-run-unity-on-amazon-cloud-or-without-monitor-3c10ce022639

Comment
Add comment · 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

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.

Follow this Question

Answers Answers and Comments

118 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Is it possible to Render Spectrum Data onto a UI Image? 0 Answers

How do I use a skybox and render texture? 3 Answers

Is RenderTexture simultaneous writing and sampling possible? 1 Answer

Texture2D to RenderTexture 1 Answer

Accessing rendertexture depthbuffer using shader 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