Unity3D icon indicating copy to clipboard operation
Unity3D copied to clipboard

syphon plugin interaction with certain skydomes blacks out the skytexture

Open kristofgavrielides opened this issue 9 years ago • 10 comments

screen shot 2016-05-03 at 20 40 26 screen shot 2016-05-03 at 20 40 47

the images speak for themselves. as soon as SyphonServerTextureCustomResolution script is activated the textured skydome gets lost and is blacked out in the syphon output. does anybody know how to fix that?

kristofgavrielides avatar May 03 '16 18:05 kristofgavrielides

This could be a premultiplied vs un premultiplied alpha issue? I'd experiment with that.

vade avatar May 03 '16 18:05 vade

where do i set these values?

kristofgavrielides avatar May 03 '16 19:05 kristofgavrielides

This has to do with the blending in Unity and the construction of the image you send to it via Syphon. I have no idea, you're in control :)

vade avatar May 03 '16 19:05 vade

So I checked all blend-modes in the skyshaders without having luck. I then looked at the Syphon Server Custom Resolution script and changed from ARGB32 to RGB565 in this line:

customRenderTexture = new RenderTexture(renderWidth, renderHeight, 0, RenderTextureFormat.RGB565);

Now the alphachannels are fine, but the color resolution is bad. Do you have a workaround for that?

screen shot 2016-05-04 at 19 55 07

kristofgavrielides avatar May 04 '16 18:05 kristofgavrielides

Thats likely not going to fix it.

Your issue is either your client is expecting color in the form of premultiplied:

vec4 RGB = vec4(color.r * color.a, color.b * color.a, color.g * color.a, color.a)

or straight / unpremultiplied

vec4 RGB = vec4 (color.r, color.g, color.b, color.a)

Note the difference in color channels.

I forget what unity skyboxes expect do behind the scenes because I don't do a lot of Unity dev (cc @brianchasalow ?) but the you might be able to fix this on the Syphon server client side by unpremultiplying , or pre-multiplying depending on the blending in your Syphon client.

vade avatar May 04 '16 18:05 vade

you can force unpremultiplied from a premultiplied by dividing each color component by the alpha btw. Typically you want to have a pipeline that chooses one approach. Syphon does not and never will adjust the alpha / color channels, its agnostic to premultiplied or unpremultiplied. This is good, but can cause confusion when you mix approaches like above.

vade avatar May 04 '16 18:05 vade

Can't you just stick a SyphonServerAlphaOne*.cs *image effect on the camera you're trying to render the syphon server with? It'll write 1 to the alpha channel- if the image looks correct in Unity but looks wrong in the app that's receiving the Syphon texture, this is usually the correct answer, unless you want to actually use the alpha channel in some meaningful way in the app you're sharing the texture with, in which case you have to carefully manage what is getting written to the alpha channel within Unity. Brian

On Wed, May 4, 2016 at 11:10 AM, vade [email protected] wrote:

you can force unpremultiplied from a premultiplied by dividing each color component by the alpha btw. Typically you want to have a pipeline that chooses one approach. Syphon does not and never will adjust the alpha / color channels, its agnostic to premultiplied or unpremultiplied. This is good, but can cause confusion when you mix approaches like above.

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/Syphon/Unity3D/issues/23#issuecomment-216952459

brianchasalow avatar May 04 '16 23:05 brianchasalow

Yeah, sticking a SyphonServerAlphaOne*.cs *image effect on the camera helped! Thanks brianchasalow and vade!

kristofgavrielides avatar May 05 '16 11:05 kristofgavrielides

There is a great Unity implementation of Syphon here... https://github.com/keijiro/Funnel fully compatible with the new OpenGL backend (OpenGL Core) Unity 5.3 or later

preamptive avatar May 05 '16 11:05 preamptive

Yes, it's nice, but only syphon-server, no client yet.

kristofgavrielides avatar May 05 '16 12:05 kristofgavrielides