Skip to content

Commit

Permalink
a12 added SyphonClientTextureProjector script, and made it so that Sy…
Browse files Browse the repository at this point in the history
…phonClientTexture adds the mainTexture on all materials on a gameObject, not just the first
  • Loading branch information
briangibson committed Nov 4, 2013
1 parent 33842fa commit 3377442
Show file tree
Hide file tree
Showing 22 changed files with 280 additions and 48 deletions.
44 changes: 34 additions & 10 deletions Syphon Implementations/Unity3D/Unity3D-3_5/Read Me.rtf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
\f0\fs36 \cf0 Syphon for Unity Pro 4.0 \
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural

\fs20 \cf0 1.0 Public Beta 2 a11
\fs20 \cf0 1.0 Public Beta 2 a12
\fs36 \
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural

Expand All @@ -30,19 +30,41 @@ Open the .unitypackage to import to an existing project, or simply create a new
\
Add a Syphon.cs to your main camera. this will act as your Syphon manager.\
\
Syphon Server: \
You have two options.\

\b (*For new users*) \
----------------------
\b0 \

\b Syphon Server:
\b0 \
1) if you want to simply output the existing Unity scene camera as a syphon server, add a SyphonServerTexture to any camera in your scene. For basic setups, use this.\
\
2) (*For advanced users*) if you want to output a custom resolution video texture (i.e., 3072x768 for a triplehead, etc) add a SyphonServerTextureCustomResolution to the main camera in your scene. If you want a quick way to use Unity as a control surface, where its GUI is only visible inside the Unity app itself, additionally take a look at the code in ControlSurfaceExample. See the unity scene SyphonServerCustomResolution.unity for a demo.\
\
\
Syphon Client: \

\b Syphon Client:
\b0 \
Add a SyphonClientTexture to any object in your scene.\
On the SyphonClientTexture, in the public inspector fields, add the name and appName of the client you just added.\

\b ----------------------\
\b0 \
\
Take a look at the code in SyphonClientTexture.cs's ApplyTexture() method to see how to add additional functionality- adding the texture to projectors, bump maps, etc.\

\b (*For advanced users*)\
----------------------\
Syphon Server:
\b0 \
if you want to output a custom resolution video texture (i.e., 3072x768 for a triplehead, etc) add a SyphonServerTextureCustomResolution to the main camera in your scene. If you want a quick way to use Unity as a control surface, where its GUI is only visible inside the Unity app itself, additionally take a look at the code in ControlSurfaceExample. See the unity scene SyphonServerCustomResolution.unity for a demo.\
\

\b SyphonClient:
\b0 \
if you want to use a Projector as a Syphon client, add the SyphonClientTextureProjector script to a gameObject that has a Projector on it, and then in its public inspector fields, add the name and appName of the client.\

\b ----------------------\
\b0 \
Take a look at the code in SyphonClientTexture.cs's ApplyTexture() method to see how to add additional functionality- adding the texture to projectors, bump maps, etc.\
\
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ri-2496\pardirnatural\qj
\cf0 Syphon for Unity is published under a BSD license. See the included License.txt file.\
Expand All @@ -54,8 +76,10 @@ Syphon for Unity3D - Brian Chasalow (Unity 3D integration and scripting), Tom Bu
\
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ri-2496\pardirnatural\qj

\b \cf0 Release Notes:
\b0 \
\b \cf0 Release Notes:\
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ri-2496\pardirnatural\qj
\b0 \cf0 a12: added SyphonClientTextureProjector script, and made it so that SyphonClientTexture adds the mainTexture on all materials on a gameObject, not just the first\
a11: added a custom resolution syphon example, and fixed a rare threading issue on syphon exit or creation. \
a10: fixed a bug with OnRetireServer crashing with OpenFrameworks servers exiting.\
a9: fixed some Unity 4.2 texture creation and 64 bit issues. uses custom Syphon framework with multithreading changes.\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<None Include="Assets\Resources\SyphonShaders\AlphaTest-Glossy01.shader" />
<None Include="Assets\Resources\SyphonShaders\Particle MultiplyDouble.shader" />
<None Include="Assets\Resources\SyphonShaders\Particle AddMultiply.shader" />
<None Include="Assets\Resources\SyphonShaders\SyphonProjector.shader" />
<None Include="Assets\Resources\SyphonShaders\Particle Alpha BlendDepthtestOff.shader" />
<None Include="Assets\Resources\SyphonShaders\SyphonSkybox.shader" />
<None Include="Assets\Resources\SyphonShaders\Particle Alpha BlendFront.shader" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<None Include="Assets\Resources\SyphonShaders\AlphaTest-Glossy01.shader" />
<None Include="Assets\Resources\SyphonShaders\Particle MultiplyDouble.shader" />
<None Include="Assets\Resources\SyphonShaders\Particle AddMultiply.shader" />
<None Include="Assets\Resources\SyphonShaders\SyphonProjector.shader" />
<None Include="Assets\Resources\SyphonShaders\Particle Alpha BlendDepthtestOff.shader" />
<None Include="Assets\Resources\SyphonShaders\SyphonSkybox.shader" />
<None Include="Assets\Resources\SyphonShaders\Particle Alpha BlendFront.shader" />
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<Compile Include="Assets\Plugins\SyphonObject\SyphonClientObject.cs" />
<Compile Include="Assets\Plugins\SyphonObject\SyphonServerObject.cs" />
<Compile Include="Assets\Plugins\SyphonTexture-AdvancedUsers\ControlSurfaceExample.cs" />
<Compile Include="Assets\Plugins\SyphonTexture-AdvancedUsers\SyphonClientTextureProjector.cs" />
<Compile Include="Assets\Plugins\SyphonTexture-AdvancedUsers\SyphonServerTextureCustomResolution.cs" />
<Compile Include="Assets\Plugins\SyphonTexture\SyphonClientTexture.cs" />
<Compile Include="Assets\Plugins\SyphonTexture\SyphonServerTexture.cs" />
Expand All @@ -62,6 +63,7 @@
<None Include="Assets\Resources\SyphonShaders\AlphaTest-Glossy01.shader" />
<None Include="Assets\Resources\SyphonShaders\Particle MultiplyDouble.shader" />
<None Include="Assets\Resources\SyphonShaders\Particle AddMultiply.shader" />
<None Include="Assets\Resources\SyphonShaders\SyphonProjector.shader" />
<None Include="Assets\Resources\SyphonShaders\Particle Alpha BlendDepthtestOff.shader" />
<None Include="Assets\Resources\SyphonShaders\SyphonSkybox.shader" />
<None Include="Assets\Resources\SyphonShaders\Particle Alpha BlendFront.shader" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<Compile Include="Assets\Plugins\SyphonObject\SyphonClientObject.cs" />
<Compile Include="Assets\Plugins\SyphonObject\SyphonServerObject.cs" />
<Compile Include="Assets\Plugins\SyphonTexture-AdvancedUsers\ControlSurfaceExample.cs" />
<Compile Include="Assets\Plugins\SyphonTexture-AdvancedUsers\SyphonClientTextureProjector.cs" />
<Compile Include="Assets\Plugins\SyphonTexture-AdvancedUsers\SyphonServerTextureCustomResolution.cs" />
<Compile Include="Assets\Plugins\SyphonTexture\SyphonClientTexture.cs" />
<Compile Include="Assets\Plugins\SyphonTexture\SyphonServerTexture.cs" />
Expand All @@ -62,6 +63,7 @@
<None Include="Assets\Resources\SyphonShaders\AlphaTest-Glossy01.shader" />
<None Include="Assets\Resources\SyphonShaders\Particle MultiplyDouble.shader" />
<None Include="Assets\Resources\SyphonShaders\Particle AddMultiply.shader" />
<None Include="Assets\Resources\SyphonShaders\SyphonProjector.shader" />
<None Include="Assets\Resources\SyphonShaders\Particle Alpha BlendDepthtestOff.shader" />
<None Include="Assets\Resources\SyphonShaders\SyphonSkybox.shader" />
<None Include="Assets\Resources\SyphonShaders\Particle Alpha BlendFront.shader" />
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<None Include="Assets\Resources\SyphonShaders\AlphaTest-Glossy01.shader" />
<None Include="Assets\Resources\SyphonShaders\Particle MultiplyDouble.shader" />
<None Include="Assets\Resources\SyphonShaders\Particle AddMultiply.shader" />
<None Include="Assets\Resources\SyphonShaders\SyphonProjector.shader" />
<None Include="Assets\Resources\SyphonShaders\Particle Alpha BlendDepthtestOff.shader" />
<None Include="Assets\Resources\SyphonShaders\SyphonSkybox.shader" />
<None Include="Assets\Resources\SyphonShaders\Particle Alpha BlendFront.shader" />
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<None Include="Assets\Resources\SyphonShaders\AlphaTest-Glossy01.shader" />
<None Include="Assets\Resources\SyphonShaders\Particle MultiplyDouble.shader" />
<None Include="Assets\Resources\SyphonShaders\Particle AddMultiply.shader" />
<None Include="Assets\Resources\SyphonShaders\SyphonProjector.shader" />
<None Include="Assets\Resources\SyphonShaders\Particle Alpha BlendDepthtestOff.shader" />
<None Include="Assets\Resources\SyphonShaders\SyphonSkybox.shader" />
<None Include="Assets\Resources\SyphonShaders\Particle Alpha BlendFront.shader" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ static AutorunSyphon()
{
//only cache the assembly/update the instance/etc if the syphon instance already exists in the scene
//but, using registered syphon clients/server scripts instead of 'finding' them in the scene. this is faster.
// if(UnityEngine.Object.FindObjectOfType(typeof(SyphonServerTexture)) != null ||
// UnityEngine.Object.FindObjectOfType(typeof(SyphonClientTexture)) != null){
if(Syphon.syphonScriptCount > 0){
if(UnityEngine.Object.FindObjectOfType(typeof(SyphonServerTexture)) != null ||
UnityEngine.Object.FindObjectOfType(typeof(SyphonClientTexture)) != null){
// if(Syphon.syphonScriptCount > 0){
if(!Syphon.assemblyIsUpdated())
Syphon.cacheAssembly();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (c) 2010-2012 Brian Chasalow, bangnoise (Tom Butterworth) & vade (Anton Marini).
/*
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/


//This script should be applied to any object in the scene, and lets you attach a syphon client texture to any Unity object.
//You may modify the ApplyTexture() method as necessary, to handle projectors, bump maps, etc.
using UnityEngine;
using System.Collections;

public class SyphonClientTextureProjector : SyphonClientTexture {
// Use this for initialization
[SerializeField]
private Material projectorMaterial;

public override void ApplyTexture(){
if(clientObject != null && clientObject.Initialized){
Projector proj = GetComponent<Projector>();
if(proj != null && projectorMaterial != null){
proj.material = projectorMaterial;
proj.material.SetTexture ("_ShadowTex", clientObject.AttachedTexture);
clientObject.AttachedTexture.wrapMode = TextureWrapMode.Clamp;
}

}
}

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
//You may modify the ApplyTexture() method as necessary, to handle projectors, bump maps, etc.
using UnityEngine;
using System.Collections;
#pragma warning disable 0219

public class SyphonClientTexture : MonoBehaviour {
// Use this for initialization
public string clientAppName = "Test Server";
public string clientName = "";
private SyphonClientObject clientObject;
protected SyphonClientObject clientObject;
void Start () {
//this next line creates a syphon instance if it doesn't already exist
Syphon instance = Syphon.Instance;
Expand All @@ -46,12 +47,13 @@ void OnDestroy(){
}

#if UNITY_EDITOR
public SyphonClientTexture(){
Syphon.syphonScriptCount++;
}
~SyphonClientTexture(){
Syphon.syphonScriptCount--;
}
//i don't trust that this doesn't crash unity. need more testing.
// public SyphonClientTexture(){
// Syphon.syphonScriptCount++;
// }
// ~SyphonClientTexture(){
// Syphon.syphonScriptCount--;
// }
#endif

void setupTexture(){
Expand All @@ -74,9 +76,12 @@ public void AnnounceServer(string appName, string name){
}

//handle applying the client texture to your object whichever way you please.
public void ApplyTexture(){
public virtual void ApplyTexture(){
if(clientObject != null && clientObject.Initialized){
renderer.sharedMaterial.mainTexture = clientObject.AttachedTexture;
Material[] matArray = renderer.sharedMaterials;
for(int i = 0; i < matArray.Length; i++){
matArray[i].mainTexture = clientObject.AttachedTexture;
}
renderer.sharedMaterial.mainTexture.wrapMode = TextureWrapMode.Repeat;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
using System.IO;
using System.Runtime.InteropServices;
using System.Collections.Generic;
#pragma warning disable 0219

public class SyphonServerTexture : MonoBehaviour {

Expand All @@ -47,12 +48,13 @@ public class SyphonServerTexture : MonoBehaviour {


#if UNITY_EDITOR
public SyphonServerTexture(){
Syphon.syphonScriptCount++;
}
~SyphonServerTexture(){
Syphon.syphonScriptCount--;
}
//i don't trust that this doesn't crash unity. need more testing.
// public SyphonServerTexture(){
// Syphon.syphonScriptCount++;
// }
// ~SyphonServerTexture(){
// Syphon.syphonScriptCount--;
// }
#endif

public virtual void Start() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
\f0\fs36 \cf0 Syphon for Unity Pro 4.0 \
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural

\fs20 \cf0 1.0 Public Beta 2 a11
\fs20 \cf0 1.0 Public Beta 2 a12
\fs36 \
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural

Expand All @@ -30,19 +30,41 @@ Open the .unitypackage to import to an existing project, or simply create a new
\
Add a Syphon.cs to your main camera. this will act as your Syphon manager.\
\
Syphon Server: \
You have two options.\

\b (*For new users*) \
----------------------
\b0 \

\b Syphon Server:
\b0 \
1) if you want to simply output the existing Unity scene camera as a syphon server, add a SyphonServerTexture to any camera in your scene. For basic setups, use this.\
\
2) (*For advanced users*) if you want to output a custom resolution video texture (i.e., 3072x768 for a triplehead, etc) add a SyphonServerTextureCustomResolution to the main camera in your scene. If you want a quick way to use Unity as a control surface, where its GUI is only visible inside the Unity app itself, additionally take a look at the code in ControlSurfaceExample. See the unity scene SyphonServerCustomResolution.unity for a demo.\
\
\
Syphon Client: \

\b Syphon Client:
\b0 \
Add a SyphonClientTexture to any object in your scene.\
On the SyphonClientTexture, in the public inspector fields, add the name and appName of the client you just added.\

\b ----------------------\
\b0 \
\
Take a look at the code in SyphonClientTexture.cs's ApplyTexture() method to see how to add additional functionality- adding the texture to projectors, bump maps, etc.\

\b (*For advanced users*)\
----------------------\
Syphon Server:
\b0 \
if you want to output a custom resolution video texture (i.e., 3072x768 for a triplehead, etc) add a SyphonServerTextureCustomResolution to the main camera in your scene. If you want a quick way to use Unity as a control surface, where its GUI is only visible inside the Unity app itself, additionally take a look at the code in ControlSurfaceExample. See the unity scene SyphonServerCustomResolution.unity for a demo.\
\

\b SyphonClient:
\b0 \
if you want to use a Projector as a Syphon client, add the SyphonClientTextureProjector script to a gameObject that has a Projector on it, and then in its public inspector fields, add the name and appName of the client.\

\b ----------------------\
\b0 \
Take a look at the code in SyphonClientTexture.cs's ApplyTexture() method to see how to add additional functionality- adding the texture to projectors, bump maps, etc.\
\
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ri-2496\pardirnatural\qj
\cf0 Syphon for Unity is published under a BSD license. See the included License.txt file.\
Expand All @@ -54,8 +76,10 @@ Syphon for Unity3D - Brian Chasalow (Unity 3D integration and scripting), Tom Bu
\
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ri-2496\pardirnatural\qj

\b \cf0 Release Notes:
\b0 \
\b \cf0 Release Notes:\
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ri-2496\pardirnatural\qj
\b0 \cf0 a12: added SyphonClientTextureProjector script, and made it so that SyphonClientTexture adds the mainTexture on all materials on a gameObject, not just the first\
a11: added a custom resolution syphon example, and fixed a rare threading issue on syphon exit or creation. \
a10: fixed a bug with OnRetireServer crashing with OpenFrameworks servers exiting.\
a9: fixed some Unity 4.2 texture creation and 64 bit issues. uses custom Syphon framework with multithreading changes.\
Expand Down
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3377442

Please sign in to comment.