Sending Texture from Unity3d to openFrameworks -- noise

Hey,
I am trying to send a texture (small 32x32 RGB24) from Unity3d to openFrameworks via Tcp. I am trying to recive the texture using bit modified ClientServer example http://www.openframeworks.cc/files/rawBytesClientServer-Xcode00573.zip. I attached image so you can see how it looks like. Any toughts?

Here’s unity source code

  
using UnityEngine;  
using System;  
using System.Collections;  
using System.Net;  
using System.Net.Sockets;  
using System.IO;  
using System.Threading;  
  
public class rtTOtcp : MonoBehaviour  
{  
	  
	public RenderTexture rTexture;  
	public Texture2D sTexture;  
	public Texture2D retTexture;  
	//IPEndPoint ipEnd =   
	TcpListener listener = new TcpListener(new IPEndPoint (IPAddress.Parse ("127.0.0.1"), 9050));  
	TcpClient client;  
	public bool isConnected=false;  
	//sendImage2DMain = new Texture2D(sendRenderTextureMain.width, sendRenderTextureMain.height, TextureFormat.RGB24, false);  
	int dataSent = 0;  
  
	void Start ()  
	{  
		sTexture = new Texture2D (rTexture.width, rTexture.height, TextureFormat.RGB24,false);  
		retTexture = new Texture2D(rTexture.width,rTexture.height, TextureFormat.RGB24,false);  
		try {  
		listener.Start();	  
		} catch (SocketException ex) {  
			Debug.Log (ex.Message);	  
		}  
  
	}  
	  
	void Update()  
	{  
	if(!isConnected)  
		{  
		if(listener.Pending())  
			{  
			client = listener.AcceptTcpClient();  
				isConnected=true;  
			}  
		}  
	}  
		  
	// Update is called once per frame  
	void OnPostRender ()  
	{  
		RenderTexture.active = rTexture;  
		sTexture.ReadPixels(new Rect (0, 0, rTexture.width, rTexture.height), 0, 0);  
		sTexture.Apply ();  
		  
		if(isConnected)  
		dataSent = SendVarData (client, sTexture.EncodeToPNG());	  
	}  
		  
	  
	  
	private static int SendVarData (TcpClient c, byte[] data)  
	{  
		  
		int total = 0;  
		int size = data.Length;  
		int dataleft = size;  
		int sent;  
		  
		  
   
		byte[] datasize = new byte[0];  
		datasize = BitConverter.GetBytes (size);  
		//sent = c.Client.Send (datasize);  
		try {  
			while (total < size) {  
			  
				sent = c.Client.Send (data, total, dataleft, SocketFlags.None);  
				total += sent;  
				dataleft -= sent;  
				Debug.Log(dataleft);  
			}  
		} catch (Exception ex) {  
			Debug.Log (ex.Message);	  
		}  
		return total;  
	}     
}  
  

And where oF magic happens

  
  
void testApp::setup(){  
	ofBackground(60,60,70);  
	tex.allocate(32, 32,GL_RGB);  
	pixelsLoaded = false;  
}  
  
//--------------------------------------------------------------  
void testApp::update(){  
  
	client.update(32*32*3);  
  
	if( client.getState() == COMPLETE ){  
		tex.loadData(client.pixels, 32, 32, GL_RGB);  
		pixelsLoaded = true;  
  
        client.reset();  
	}  
}  
  

Thanks!

i don’t know unity enough to answer your question, but have you considered syphon https://github.com/Syphon/ofxSyphon or the older UDP tile streamer https://github.com/benMcChesney/ofxUDPTileStreamer

syphon worked fine for me the other way around, I wouldn’t imagine there would be any problems using it from Unity to oF.

I’m on windows. The texture isn’t that big it is 32x32 rgb24, so sending it via tcp should’t be a problem. I tried usig rgba32 format but also with no success