Search Unity

Spout [Syphon on Windows] Unity Plugin

Discussion in 'Scripting' started by Ben-Kuper, Jun 4, 2014.

  1. Ben-Kuper

    Ben-Kuper

    Joined:
    Aug 31, 2012
    Posts:
    16
    Hi,
    i'm glad to announce the upcoming release of the Spout Unity Plugin.

    Spout is the successor of Wyphon, and is a plugin that let users share textures across softwares.
    More info about spout here : http://spout.zeal.co/

    Here are 2 videos showing both receiving textures from Resolume, Processing and a demo app, and sending to Resolume and a demo app.

    Enjoy !




     
  2. jrs

    jrs

    Joined:
    Jun 5, 2014
    Posts:
    1
    Hey,

    Nice work on the plugin - any timeframe for the release of this? would you be happy to let me test it?

    Regards - James
     
  3. Ben-Kuper

    Ben-Kuper

    Joined:
    Aug 31, 2012
    Posts:
    16
    Hi,
    Spout is working on a major update to integrate in the next stable release dx11 support (which is needed for the Unity plugin to work).
    One the spout team releases a stable version, i will clean it up and release it.
    I can't give you a date, but we're working everyday with Lynn to get this version working, and make sure that each decisions are relevant in the long run.

    You can find the sources here : https://github.com/benkuper/Unity-Plugins/tree/master/SpoutPlugin
    it might work out of the box, although i doubt it, it's been compiled with a modified version of the SpoutSDK and you won't be able to share texture from Unity if receivers are DX9.

    i'll keep you updated,
    Ben
     
  4. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
    Great, great news! Really looking forward what cool things will be possible with this plugin.
     
  5. Ben-Kuper

    Ben-Kuper

    Joined:
    Aug 31, 2012
    Posts:
    16
    Hey there,
    for those who want Flash content running smoothly in Unity as textures, here it is ! Spout AS3 Plugin that can send content to Unity, Resolume, etc.
    Now you can have live AS3 applications providing animations for Unity !

     
  6. lesvandales

    lesvandales

    Joined:
    May 5, 2014
    Posts:
    1
    After 24 hours of try, i m searching for help.

    The unityspoutdemo/export exemple don't work. The send and render don't comunicate.

    Fort the spout test when i play scene i have error "dllnotfoudexception ......Nativespoutplugin.dll"

    Capture.JPG


    Can you help me ?

    (sorry for my english)
     
  7. Ben-Kuper

    Ben-Kuper

    Joined:
    Aug 31, 2012
    Posts:
    16
    Hi lesvandales,
    i'm sorry you struggled with the plugin. As I said, the plugin was compiled with modified version of the Spout SDK, so it might simply not work on other computers...
    Spout is currently being refactored and updated, i will clean the sources and pack everything when Spout is officially updated.
    If you really want this to work (and it will only work as receiver, because unity sender will send DX11 textures and no current official plugins are DX11 compatible), you can try to find which DLL NativeSpoutPlugin.dll is depending on with a software called dependencyWalker (download the 32 bit version).
    I can already tell you that the plugin has been compiled with VS2012 so it might be dependant of the msvcr110.dll and msvcp110.dll (or msvcr110d.dll and msvcp110d.dll), and is also depending on pthreadVC2.dll (for multithreading)
    You can find those dlls online (dll-files.com for example)

    - Are you french ?

    Ben
     
  8. Ren072

    Ren072

    Joined:
    Aug 3, 2012
    Posts:
    5
    Hi Ben,

    Any news on the development?
     
  9. Ben-Kuper

    Ben-Kuper

    Joined:
    Aug 31, 2012
    Posts:
    16
    Hi,
    spout has not released its update yet, i hope it won't be too long.
    In the meantime, you can already check the sources and try the existing demos
     
  10. skullthug

    skullthug

    Joined:
    Oct 16, 2011
    Posts:
    202
    (I posted this originally on the YouTube video, but found this thread and it seems more appropriate to have it here)

    Thank you, so so much, for making this. Seriously, I'm overjoyed I can mess around with this concept without having to switch to a Mac now.

    However, I've been having trouble getting the Unity Spout plugin to receive or send anything it seems. Resolume finds its Sender, but I only end up getting a black screen. I checked the RenderTexture and it is indeed being updated, and the debug console makes it sound like it should be wokring. I'm sort of stumped how to debug this. Unity doesn't manage to get anything from the Spout test sender either. Any ideas?
     
  11. Ben-Kuper

    Ben-Kuper

    Joined:
    Aug 31, 2012
    Posts:
    16
    Hi skullthug,
    sorry i didn't answer on the youtube comments, somebody wrote me an email with the exact same problem and i thought it was you who didn't read my answer by email yet.

    I would need more informations about your setup in order to be able to tell you what's going on.
    - Which OS are you on (i assume Win8)
    - What hardware are you using (laptop, graphic card : Nvidia or ATI, if Nvidia, do you have optimus)
    - Did you get the official spout demos working ?
    - Can you test Unity <> VVVV ?

    There are posts in the official spout forum that explain in details those issues, but just so you know :
    - Spout requires Nvidia to be able to transform textures between OpenGL and directX. That means that if you don't have an Nvidia card, you will only be able to share textures between "DX-only" plugins (for the moment, Unity and VVVV are the only ones that are not using the Nvidia driver's GLDX interop functionnality).
    - Optimus enabled Nvidia cards are currently not supported, Nvidia has announced a driver update which should fix this problem and allow spout to run on optimus cards.

    Hope that helped,
    Ben
     
  12. skullthug

    skullthug

    Joined:
    Oct 16, 2011
    Posts:
    202
    Thanks kindly for replying Ben.

    I'm running Win7
    I am running a ATI/AMD video card (Radeon HD 7700)
    The official spout demos work fine with Resolume via memoryshare. I didn't realize a Nvidia card was a possible factor, so I guess my question now is can the Unity Spout plugin work via memoryshare? I'm new to this level of graphic technicality, so I'm afraid I don't quite understand your statement about Unity & VVVV not using GLDX interop functionality.
    I'm not at all familiar with VVVV, so I don't really know how to test it communicating with Unity easily either, yet.


    UPDATE:
    Apparently AMD Radeon cards can now support that certain functionality with the newest drivers (I haven't updated in ages for reasons I won't go into).
    After updating the Unity Spout scenes worked instantly. So, cool :) Thanks for your reply, I probably would not have figured that out otherwise.
     
    Last edited: Sep 16, 2014
  13. skullthug

    skullthug

    Joined:
    Oct 16, 2011
    Posts:
    202
    I have one last question, is there any way to get the Spout Plugin to utilize MemoryShare mode? The hardware I'd like to be running this setup on unfortunately does not have a video card with the right DX support.
     
  14. masi

    masi

    Joined:
    Dec 12, 2013
    Posts:
    4
    Hi Ben
    If I run the demo unity application you compiled, then it is possible to send from this application and receive it in the standard Spout2 demo receiver (both 64bit and DirectX 11). So everything works fine there.
    However, if I compile your Unity project myself in Unity and run this, it does not work. The sender can not be initialized.

    With some debugging I found out that getNativeTexturePtr() always returns 0 for a RenderTexture. In your script you use this to pass the native pointer to the plugin. And thus of course the initialization with a null pointer fails.

    I have an NVIDIA graphics card with the newest driver .. but I assume this is not the problem, since your compiled version runs fine. Also it does not make a difference if I compile the dll myself or take your compiled dll. The problem occurs in both, Unity 4.5 and Unity 5beta

    Do I have to set anything special in the Unity project to make this run?

    Thanks in advance for any help!
     
  15. Pawscal

    Pawscal

    Joined:
    Mar 26, 2013
    Posts:
    11
    Same problem here with the TexturePointer Error. Have an idea of how to fix this?

    Thanx !
     
  16. Pawscal

    Pawscal

    Joined:
    Mar 26, 2013
    Posts:
    11
    Hey there. I found some kind of fix for the TexturePointer Error.
    in Spout2Sender.cs, replace this :
    Code (CSharp):
    1. void Start()
    2.     {
    3.         if(texture != null) senderIsCreated = Spout2.CreateSender(sharingName,texture);
    4.     }
    by this:
    Code (CSharp):
    1. void Start()
    2.     {
    3.         Invoke ("CreateSender", 0.5f);
    4.     }
    and add this method:
    Code (CSharp):
    1. void CreateSender()
    2.     {
    3.         if(texture != null) senderIsCreated = Spout2.CreateSender(sharingName,texture);
    4.     }
    Worked for me :)
     
  17. masi

    masi

    Joined:
    Dec 12, 2013
    Posts:
    4
    Found a similar solution. It looks like the texture is just not ready at the call in start(). Also, I think the sending should be moved into OnPostRender() to make sure the rendering has finished. In there we also know that the texture is ready. So my solution is this:

    Code (CSharp):
    1.  
    2.     void Start()
    3.     {
    4.     }
    5.  
    6.     void Update()
    7.     {
    8.     }
    9.  
    10.     void OnPostRender()
    11.     {
    12.         if (texture != null) {
    13.             if (!senderIsCreated) {
    14.                 senderIsCreated = Spout2.CreateSender(sharingName, texture);
    15.             } else {
    16.                 Spout2.UpdateSender(sharingName, texture);
    17.             }
    18.         }
    19.     }
    20.  
     
  18. picpic

    picpic

    Joined:
    Nov 20, 2014
    Posts:
    1
    Hello,
    I'm just started to use spout and try somes test with it, i could manage to run it and build a really simple app with it.
    I have a question about it, i actuallty saw that it support resolume, i wan't to build a frame of my app in Arkaos Media master Pro 4. Is it support by it yet. and how to manage it.

    Thanks
     
  19. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
    Hi,
    i played with the latest version and realized that the texture from Unity comes flipped on the y-axis into the Spout receiver. Don't know exactly if this is a common problem with Unity RenderTextures.(It confuses me that nodody complained about that till now) . There is a quick workaround for that:
    Just use this script from Unity to change the Camera.projectionMatrix and add it to the Spout sender camera:
    http://docs.unity3d.com/ScriptReference/Camera.OnPreCull.html
     
  20. Ben-Kuper

    Ben-Kuper

    Joined:
    Aug 31, 2012
    Posts:
    16
    Hello sloopidoopi,
    indeed the texture is flipped, that's a common conversion problem between directx and opengl. I also have the problem with the AfterFX plugin, but as most of the time it ends in Resolume, this not really a problem since i just have to
     
  21. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
    Just for your interest: I opened a new repository to have a more official place for the Unity Spout efforts:
    https://github.com/sloopidoopi/Spout4Unity
    It is mainly based on the code from Ben but i made it more flexible in terms of enabling/disabling and it works now in editor&play mode.
     
  22. Ben-Kuper

    Ben-Kuper

    Joined:
    Aug 31, 2012
    Posts:
    16
    To everybody interested in further Spout development, i removed the code from my repository, and Spout4Unity is now the one and only place to get the latest SpoutPlugin. my repo will still be there for a bit with a link to Spout4Unity so people will know where to look when being redirected to my repo from other websites.
     
  23. L05

    L05

    Joined:
    May 18, 2014
    Posts:
    3
    I'm really excited to learn about Spout development for Unity, and thanks Ben and Sloopi for working on this! Sloopi, is there any way you can put up a video or some documentation on how to get the Unity Spout plugin working?

    **edit**
    Has anyone gotten Spout to work with Unity 5, or is it only supported for Unity 4?
     
    Last edited: Mar 31, 2015
  24. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
    Sorry for the late reply! Today I committed a new version on Github that should work with Unity 5.
    Hopefully i get the time to write a little HowTo in the next weeks :rolleyes:
     
  25. czuczr

    czuczr

    Joined:
    Jan 23, 2014
    Posts:
    7
    Great plugin! ;-) Have some problem with a scene that has multiple cameras with different depths and cullingmasks.. And to make some more fun I have a Canvas for UI stuffs. Please could you tell me how to achieve this? I would like to see everything on the receiver side what is visible on Unity screen. Thank you!
     
  26. czuczr

    czuczr

    Joined:
    Jan 23, 2014
    Posts:
    7
  27. VJzoo

    VJzoo

    Joined:
    Jul 22, 2013
    Posts:
    2
    Awesome work with Spout4Unity :)

    Im trying to get the plugin to work and I seems to be doing some strange things http://imgur.com/VXhJwPt as you can see it seems to see through geometry :/ Is there a fix for this at all? or am I just missing something? This happens with the demo scenes as well for me both live in the editor or when I make a build.
     
  28. Ben-Kuper

    Ben-Kuper

    Joined:
    Aug 31, 2012
    Posts:
    16
    Hello,
    when using Spout, you'll see stuff that Unity's handling differently, especially with the alpha channel.
    So when you face behaviors like that, try to tweak the material and shaders of your objects (force them to a non transparent shader for instance), and also be sure your camera has an opaque background color as well (most of the time in U4, the camera has a 0-alpha background but Unity's showing the backround color without alpha anyway)
     
  29. VJzoo

    VJzoo

    Joined:
    Jul 22, 2013
    Posts:
    2
    Thanks for taking the time to help :)

    I tried a few things with Alpha and textures and it didn't change anything but I just changed the rendering path option in the camera to "deferred" insted of "use player settings" and it has fixed the issue.

    Now time to get the Kinect working :D
     
  30. fernantastic

    fernantastic

    Joined:
    Jan 26, 2014
    Posts:
    4
    Great work!
    I had one big issue though: My game has lots of different cameras that render in sequence in multiple scenes (background/foreground/post fx/ui) so I can't just get one camera's targetTexture to output to Spout.
    I notice that the Syphon Unity plugin taps into the rendering pipeline through a native plugin on OnRenderImage() and just gets the camera's result without having to get it from camera.targetTexture (so if you just add a camera with culling mask to Nothing and depth 99 you get the same result as the screen).
    For now I'm doing a hack to make certain cameras blend rendertextures together to make it output to Spout, but maybe there's a way to get an implementation similar to Syphon's to make it easier to ouput everything with zero effort?
     
  31. ajk48n

    ajk48n

    Joined:
    Mar 27, 2014
    Posts:
    5
    I'm having some trouble getting the plugin to work on certain software/hardware configurations.

    Everything works fine on a desktop PC with an NVIDIA Quadro k2000. I'm running Unity 5.1.0f3

    However when I move the same project over to my laptop I have some problems.
    The laptop has an NVIDIA 940 M and I'm running Unity 5.3.4f1.

    When running on the laptop I am not able to receive any textures. It looks like the ResourceView that is created is null, and all width and height information for the texture is 0. Strangely enough, the name of the Spout sender is correct so Unity is obviously seeing some data come across.

    I can run the Spout demo sending and receiving just fine, and I can pipe things with a different Spout sender. So Spout seems to be working fine which makes me think that it's something related to the Unity version possibly.

    Anyone have any ideas?
     
  32. ajk48n

    ajk48n

    Joined:
    Mar 27, 2014
    Posts:
    5
    Just as a followup, I have downgraded the laptop to 5.1.0f3 and I’m still having the same issue.
     
  33. ajk48n

    ajk48n

    Joined:
    Mar 27, 2014
    Posts:
    5
    And as another followup, I managed to fix this. The laptop had hybrid integrated graphics with the NVIDIA card. It was defaulting to using the integrated graphics which didn't work with the Unity spout plugin. So I went into NVIDIA settings and made a specific program setting for Unity which told it to always use the NVIDIA card for graphics. Works perfectly now.
     
  34. patchworkx

    patchworkx

    Joined:
    Nov 8, 2014
    Posts:
    20
    hello --
    someone tryed to use spout on unity 5.5 with resolume-- just gettin systembreakedown-- and errornotice...--_ is it possible to downloade direct from asset store?
     
  35. SpaceMaharaj

    SpaceMaharaj

    Joined:
    Apr 17, 2017
    Posts:
    1
    hello community, I am trying Unity 5.6 with Spout SDK2 to spout to Resolume 5.1.*. While running the demo example, i get an error - unable to create OpenGL/DirectX interop ? Am on Windows 10, 64Bit, DirectX12. Please help. Highly Appreciate your quick feedback/observation.
     
  36. pachermann

    pachermann

    Joined:
    Dec 18, 2013
    Posts:
    133
  37. moonlock

    moonlock

    Joined:
    Feb 28, 2022
    Posts:
    10