Spout4Unity icon indicating copy to clipboard operation
Spout4Unity copied to clipboard

Unity 5

Open dirkvanwelden opened this issue 10 years ago • 18 comments

Thanks for this wonderful plugin. I've been trying to make it work in Unity5, but it seems that the texture type has changed in Unity5. I've made it work by recompiling the dll with a different DXGI format. (I used R32G32B32A32_FLOAT, since that worked fine with Unity5). Since you can now change the texture format of the rendertexture in Unity5, you'll probably need another parameter.

Cheers! Dirk - I-Illusions

dirkvanwelden avatar Feb 17 '15 13:02 dirkvanwelden

Thanks for the info!

sloopidoopi avatar Feb 17 '15 15:02 sloopidoopi

Hey that's interesting. I tried this with the Spout demo sender and it works. So do these formats -

DXGI_FORMAT_R16G16B16A16_FLOAT DXGI_FORMAT_R16G16B16A16_SNORM DXGI_FORMAT_R10G10B10A2_UNORM

None of these are compatible with a DirectX 9 receiver, but I have to think about this a little.

Lynn Jarvis

leadedge avatar Feb 18 '15 00:02 leadedge

I was sending out a RenderTexture from within Unity to Resolume, and that gave errors, no matter which format I selected for the RenderTexture in Unity. Using the debug method (thanks for that) I was able to trace the problem. CreatedSharedDX11Texture always returned false because of the DXGI_FORMAT. Unity5 uses ARGB32 as the default RT format.

dirkvanwelden avatar Feb 18 '15 08:02 dirkvanwelden

I am not familiar with Unity, so I am not sure of why using DXGI_FORMAT_R32G32B32A32_FLOAT solved the problem.

But I was hoping there might be a solution using R32G32B32A32_FLOAT textures to share with DirectX 9, so I looked again at sharing with different formats, but unfortunately again I find that DXGI_FORMAT_B8G8R8A8_UNORM is required.

It does not affect a DirectX 11 receiver though.

leadedge avatar Feb 18 '15 12:02 leadedge

"Since you can now change the texture format of the rendertexture in Unity5, you'll probably need another parameter." Instead of using a global, in createSender() you should be able to just use desc.Format and provide the format straight from unity. Although this says it succeeds for me, (creates a texture and sender is registered) I'm still yet to get this to work... (and choosing certain formats in unity causes a crash in the spout plugin, although for some reason it's not being trapped when I attach the debugger)

SoylentGraham avatar Mar 12 '15 12:03 SoylentGraham

It occurs to me that the format should in fact be specified for CreateSender and Dirk must have one so. I am not sure why it is working without it and will need to trace that through. Also UpdateSender will assume that the format does not change.

What texture formats are you having trouble with? Does DXGI_FORMAT_R32G32B32A32_FLOAT as noted above not work for you?

leadedge avatar Mar 12 '15 23:03 leadedge

In the setup I have, (win 8.1 parallels vm on OS X) no formats are working at all. The demo receiver recognises the senders but claims all formats are incompatible. RGBA4444 (iirc) actually crashes unity (filed a bug for that.)

On my ACTUAL windows machine... It seems to fail to register the sender names to the shared memory. Need to debug that more.

So far I've not got it working at all.

On Thursday, March 12, 2015, leadedge [email protected] wrote:

It occurs to me that the format should in fact be specified for CreateSender and Dirk must have one so. I am not sure why it is working without it and will need to trace that through. Also UpdateSender will assume that the format does not change.

What texture formats are you having trouble with? Does DXGI_FORMAT_R32G32B32A32_FLOAT as noted above not work for you?

— Reply to this email directly or view it on GitHub https://github.com/sloopidoopi/Spout4Unity/issues/1#issuecomment-78701157 .

  • Graham Reeves
  • http://www.grahamreeves.com/

SoylentGraham avatar Mar 13 '15 00:03 SoylentGraham

On the Spout forum there have been several reports of problems with Windows 8 and Bootcamp, as well as Windows 8 with Optimus graphics.

With the latest Spout release, if Intel graphics is detected as the render adapter, Spout reverts to DirectX 9. The demo receiver will show whether it is using DirectX 11 or DirectX 9 in the caption as well as "Help->System Capabilities". If it is using DirectX 9 it will not receive from Unity.

Your actual Windows machine might not have compatible graphics for the GL/DX extensions. If that is the case, the demo programs will start in memoryshare mode and this does not use multiple named senders. Again "Help->System Capabilities" will show what graphics is detected and the sharing mode.

I am not sure what you mean by (win 8.1 parallels vm on OS X). Does this mean "Parallels Desktop". I have not heard from anybody using that. If vm means a virtual machine, the graphics drivers will not support GL/DX extensions. I found that recently. The graphics driver is virtual too it seems.

So I would look at the basics first and if the demo Sender and Receiver start with DirectX 11 and work OK together, the problem is not with the hardware and the Unity plugin should work. We can then examine the format's more closely.

There is something going on I am not sure about in the posts above because if DXGI_FORMAT_R32G32B32A32_FLOAT works, so should DXGI_FORMAT_R8G8B8A8_UNORM.

leadedge avatar Mar 13 '15 06:03 leadedge

can anyone provide instructions on setting up spout4unity (ie. where do i put the files, etc) am unfortunately very lost :(

demondias avatar Mar 15 '15 16:03 demondias

I'm a bit of a visual studio novice and I'm having trouble getting it to compile - lots of missing library links and pthead stuff. I understand what needs to be done but I don't feel like spending a few days of my life figuring out how to get VS set up correctly for this project.

Any chance someone would be willing to post the built asset with the updated variable type so I can drop it in Unity 5?

Thanks!

matthewwachter avatar Mar 20 '15 17:03 matthewwachter

For anyone still wanting to use Unity 5 with Spout, I created a download with two plugins with different DXGI formats: one that worked on a computer with an NVidia graphics card (R32G32B32A32_FLOAT) and one that worked with an older AMD graphics card (R10G10B10A2_UNORM). You can download them here: https://www.dropbox.com/s/30kk31k0wcpzhdk/Spout5UnityPlugins.zip?dl=0

After you rename them and replace the old .dll, you will need to change the color formats for your render texture assets within Unity. For the NVidia card I used ARGB HALF and for the AMD card I used ARGB2101010.

I’m not too sure of why either of these work for their respected graphics card, so if you want to change the format within the plugin but don’t know where to start here are some instructions for those not too familiar with C++ or visual studio.

  1. Open the .sln for the Native Spout4Unity plugin in Visual Studio.
  2. In the solution explorer under source files, delete anything that isn’t NativeSpoutPlugin.cpp. Then replace them from the SPOUTSDK/Source folder from wherever you installed Spout (If you don’t have the source folder, download the Master version from the Spout 2 Github Page: https://github.com/leadedge/Spout2 ). This fixes it’s inability to find the associated files.
  3. In the solutions explorer, right click NativeSpoutPlugin, click properties and go to the configurations manager. Set the active solution platform to be x64.
  4. Still under properties under ConfigurationProperties->C/C++ change the additional include directories to your SPOUTSDK\Source folder.
  5. Under ConfigurationProperties->BuildEvents->Post-Build Evens you may need to either modify or remove the post build events (where visual studio tries to copy your plugin into your demo).
  6. After this you should be able to build a new .dll with any of the DXGI formats mentioned in this thread or elsewhere.

Although I’m really only tuned in on the Unity side of things don’t hesitate to send me a message if you are still having trouble getting this to work and I’ll see what I can do to help.

Tabski avatar Apr 27 '15 15:04 Tabski

Sweet! You rock.

On Mon, Apr 27, 2015 at 8:09 AM, Tabski [email protected] wrote:

For anyone still wanting to use Unity 5 with Spout, I created a download with two plugins with different DXGI formats: one that worked on a computer with an NVidia graphics card (R32G32B32A32_FLOAT) and one that worked with an older AMD graphics card (R10G10B10A2_UNORM). You can download them here: https://www.dropbox.com/s/30kk31k0wcpzhdk/Spout5UnityPlugins.zip?dl=0

After you rename them and replace the old .dll, you will need to change the color formats for your render texture assets within Unity. For the NVidia card I used ARGB HALF and for the AMD card I used ARGB2101010.

I’m not too sure of why either of these work for their respected graphics card, so if you want to change the format within the plugin but don’t know where to start here are some instructions for those not too familiar with C++ or visual studio.

  1. Open the .sln for the Native Spout4Unity plugin in Visual Studio.
  2. In the solution explorer under source files, delete anything that isn’t NativeSpoutPlugin.cpp. Then replace them from the SPOUTSDK/Source folder from wherever you installed Spout (If you don’t have the source folder, download the Master version from the Spout 2 Github Page: https://github.com/leadedge/Spout2 ). This fixes it’s inability to find the associated files.
  3. In the solutions explorer, right click NativeSpoutPlugin, click properties and go to the configurations manager. Set the active solution platform to be x64.
  4. Still under properties under ConfigurationProperties->C/C++ change the additional include directories to your SPOUTSDK\Source folder.
  5. Under ConfigurationProperties->BuildEvents->Post-Build Evens you may need to either modify or remove the post build events (where visual studio tries to copy your plugin into your demo to work as the path to copy to might be set differently for your computer)
  6. After this you should be able to build a new .dll with any of the DXGI formats mentioned in this thread or elsewhere.

Although I’m really only tuned in on the Unity side of things don’t hesitate to send me a message if you are still having trouble getting this to work and I’ll see what I can do to help.

— Reply to this email directly or view it on GitHub https://github.com/sloopidoopi/Spout4Unity/issues/1#issuecomment-96694912 .

matthewwachter avatar Apr 27 '15 16:04 matthewwachter

Hi all, i fixed all the Unity 5 issues (hopefully ;-) ). There where some problems with 32/64 bit dlls and an error in the native plugin where the wrong textureformat was used. I changed everything so on my system (Windows 8.1 64 bit with ATI card it now works in 32/64 bit mode) On the Unity side i added a property to the SpoutSender where you can choose the textureformat the plugin should use. For me it worked with DXGI_FORMAT_R8G8B8A8_UNORM and the RenderTexture has colorFormat ARGB32. (I compiled the native plugin with VS 2010 ) Let me know if it works for you.

sloopidoopi avatar May 22 '15 20:05 sloopidoopi

This is great ! Tested and it works, at least in Editor mode The remaining issue is that with this texture format, DX9 is not supported. We came to the conclusion that the only DX11-DX9 compatible format for using with Spout is DXGI_FORMAT_B8G8R8A8_UNORM which translates to D3DFMT_A8R8G8B8 in DX9.

benkuper avatar May 23 '15 11:05 benkuper

I just test it and it work now for me.

thanks you

picpic1979 avatar May 25 '15 07:05 picpic1979

Hi all,

regarding DirectX 9, I have been looking at this.

It seems that Intel graphics can work OK as long as it is DirectX 9, so the current Spout SDK looks for Intel graphics as the render device and switches to DirectX 9 if so. But this has led to trouble with Windows 8 / Optimus graphics, so that approach has not worked out very well.

What I intend to release next is an installer that allows the user to select DirectX 9 as an option, otherwise the default will be DirectX 11.

For DirectX 11 I can can list the following formats :

DXGI_FORMAT_R32G32B32A32_FLOAT
DXGI_FORMAT_R16G16B16A16_FLOAT
DXGI_FORMAT_R16G16B16A16_SNORM
DXGI_FORMAT_R10G10B10A2_UNORM
DXGI_FORMAT_R8G8B8A8_UNORM
DXGI_FORMAT_B8G8R8A8_UNORM
DXGI_FORMAT_B8G8R8AX_UNORM (untested)

As Ben has indicated, for a DirectX 9 receiver, the only format that is compatible is DXGI_FORMAT_B8G8R8A8_UNORM.

I hope this information is useful.

Cheers to all,

Lynn

leadedge avatar May 25 '15 07:05 leadedge

In the latest version i re-added the DXGI_FORMAT_B8G8R8A8_UNORM format in the native plugin and as option in the Unity SpoutSender.

sloopidoopi avatar May 28 '15 16:05 sloopidoopi

Hi! I am working on a computer with Intel graphics and really hoping to get this working despite that. When I use the DXGI_FORMAT_B8G8R8A8_UNORM format in a sender in Unity, spout receivers (whether in Unity via this plugin or in VPT using sprout source) show up as a black screen. If I use any other formats, I get the expected "cannot create directx/opengl interop" error, since as described in this thread, spout is using Dx9 because of the Intel graphics. With the other formats, I am able to see the texture with a receiver in Unity. I am able to send and receive Dx9 textures via the Spout demo programs. It seems so close to working, I am really hoping there is a fix. Any suggestions would be massively appreciated!

calebfoss avatar Aug 23 '18 16:08 calebfoss