Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Did anyone get TexturePlugin demo to work on Windows?

Discussion in 'Editor & General Support' started by slipstream, May 8, 2008.

  1. slipstream

    slipstream

    Joined:
    May 4, 2008
    Posts:
    21
    I guess the title says it all. We built a custom plugin on an OSX side but the thing failed to work on Windows when the project was built for Windows platform. Upon further investigation we found out that the original TexturePlugin demo available from the Unity3d.com does not work on Windows either (it has the Windows dll included and when the project is built for Windows, it fails to make any texture whatsoever leaving cube black).

    Any ideas?
     
  2. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    The plugin is OpenGL specific. On Windows Direct3D is used by default, so OpenGL specific plugin won't work there. If you pass a "-force-opengl" command line parameter to the windows game, it should use OpenGL.
     
  3. slipstream

    slipstream

    Joined:
    May 4, 2008
    Posts:
    21
    Thanks for the info. However, OpenGL seems quite inefficient on XP side. Hence, I was hoping to harness D3D for this purpose (now that I know I need to use it to get good performance). That being said, unlike GetInstanceID() which returns int value of the current texture within Unity and can be passed into a plugin, for D3D, I was unable to locate a method that would expose underlying D3D plugin to the referenced texture. Am I missing something or does the current version of Unity lack such method? Or, (since I am not very experienced with D3D) am I missing some kind of a D3D method that would allow me to use resulting GetInstanceID() int value to reference the texture?

    For what it's worth, having a working D3D implementation of the Texture Plugin demo would be most helpful.
     
  4. Johannes5

    Johannes5

    Joined:
    May 28, 2008
    Posts:
    11
    Hi,
    I also found out that the texture or quicktime plugin is indeed not working under Windows / Directx Environment. I would write a directx implementation, but there is no documentation at all regarding directx/plugins. Is it actually possible to write a plugin which supports d3d ? can I use the textureID supplied from opengl? glBindTexture is supposed to replaced with g_d3d_device->SetTexture(0,g_texture);
    Where do I get the d3ddevice? Can someone from Unity (Aras?) make up a small hint how to change the texture plugin to work with directx ?
    regards
    Johannes
     
  5. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    We're going to update the plugin and the documentation page for upcoming Unity 2.1.

    In the meantime, here's an example project with the plugin, updated to be graphics API independent. I am basically passing array of colors for the plugin to fill, and then using SetPixels() on a texture.
     

    Attached Files:

  6. Johannes5

    Johannes5

    Joined:
    May 28, 2008
    Posts:
    11
    Hi Aras,
    thanks a lot for your help. I will try and get the quicktime plugin to work under windows. But is it possible to write a plugin which uses directx / d3d calls? Is the conversion from opengl to directx done in realtime or while compiling? Can you tell us more about the upcoming Unity 2.1 ?
    regards
    Johannes
     
  7. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    The "problem" with Direct3D is that there is a notion of "d3d device". Whereas in OpenGL everything happens in the "currently set context", in D3D you have to pass in a device pointer to get something done. And right now there's no way to get the device pointer out of Unity. The real question is, what are you actually trying to do? :)

    The decision which one to use is made at runtime. The logic is this: first try Direct3D 9.0c. If it's not installed, is disabled or there are no hardware accelerated drivers, then use OpenGL. For standalone Windows players, you can also pass "-force-opengl" command line parameter to make it use OpenGL.

    It is going to be out "someday soon" :) We're in testing mode right now.
     
  8. Johannes5

    Johannes5

    Joined:
    May 28, 2008
    Posts:
    11
    One thing I wanted to achieve is render the current scene to a broadcast device like a decklink board or write an AVI File. With your method, could I get access to the renderbuffer as well ?
    regards
    Johannes
     
  9. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
  10. Johannes5

    Johannes5

    Joined:
    May 28, 2008
    Posts:
    11
    Hi Aras,
    I made the quicktime plugin work both platforms and with alpha channel, but since I have to convert from bytes to floats its very slow (ARGB 1024x512 around 5 fps). Do you hav an idea how to speedup the whole process ? Can I access opengl textures while running under windows in directx ?
    regards
    Johannes
     
  11. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Are you sure it's the conversion process that is slow? I did some profiling myself (on the TexturePlugin sample), and the conversion time was very minor.

    No, because OpenGL textures don't exist when using Direct3D. You can run via OpenGL on Windows if that's really the problem (via "-force-opengl" command line parameter).
     
  12. Johannes5

    Johannes5

    Joined:
    May 28, 2008
    Posts:
    11
    Hi Aras,

    it seems that it was a problem with the codec. We tried png, but it is decoding too slow, like jpeg2000. We tried the Animation codec, but its almost uncompressed and runs only smooth off a raid array. Can you suggest a quicktime codec which compresses and has alpha as well ?
    regards
    Johannes
     
  13. fhmiv

    fhmiv

    Joined:
    Jan 31, 2007
    Posts:
    38
    We recently ran in to this cross-platform problem with the quicktime plugin. We don't want to force opengl mode on Windows for performance reasons.

    Is it possible to get your code for this? Maybe the quicktime plugin page on the wiki http://www.unifycommunity.com/wiki/index.php?title=QTPlayback
    would be a good place to put it.
     
  14. ShaunKime

    ShaunKime

    Joined:
    Apr 19, 2011
    Posts:
    7
    I took a quick look at the API and it looks like GetNativeTextureID is still only valid for OpenGL. Is there still no way to access the underlying GPU data?

    I have a client that needs a 1080P live video stream (1920×1080 pixels) displayed in Unity. I'm going to try the approach outlined above for working generically with textures, but this seems really inefficient.

    Do you have any other suggestions that might work better?