Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syphon plugin interaction with certain skydomes blacks out the skytexture #23

Open
kristofgavrielides opened this issue May 3, 2016 · 10 comments

Comments

@kristofgavrielides
Copy link

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?

@vade
Copy link
Member

vade commented May 3, 2016

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

@kristofgavrielides
Copy link
Author

where do i set these values?

@vade
Copy link
Member

vade commented May 3, 2016

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 :)

@kristofgavrielides
Copy link
Author

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

@vade
Copy link
Member

vade commented May 4, 2016

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
Copy link
Member

vade commented May 4, 2016

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.

@brianchasalow
Copy link
Member

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
#23 (comment)

@kristofgavrielides
Copy link
Author

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

@preamptive
Copy link

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

@kristofgavrielides
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants