Closed paul-bonnel-fr closed 4 years ago
Hello!
You should be able to adjust your shader to use our conversion methods (or you could copy them into your own).
You need to add the following toggle to the properties of your shader:
[Toggle(USE_YPCBCR)] _UseYpCbCr("Use YpCbCr", Float) = 0
Include "AVProVideo.cginc".
#include "UnityCG.cginc"
#include "AVProVideo.cginc"
You need to add these two items to your uniforms:
#if USE_YPCBCR
uniform sampler2D _ChromaTex;
uniform float4x4 _YpCbCrTransform;
#endif
Then in your fragment shader call the following to get the actual colour out:
#if USE_YPCBCR
col = SampleYpCbCr(_MainTex, _ChromaTex, i.uv.xy, _YpCbCrTransform);
#else
// whatever code you use to sample the texture
#endif
Use MediaPlayer.TextureProducer.GetTexture(0)
for getting _MainTex and MediaPlayer.TextureProducer.GetTexture(1)
for getting _ChromaTex.
MediaPlayer.TextureProducer.GetYpCbCrTransform()
returns the matrix you need to set _YpCbCrTransform.
And you can use the ApplyToMaterial/ApplyToMesh components to apply the video parameters (texture, YCbCr option etc) to the material.
Thank you guys !
Hi everyone !
Our videos need chroma key removal. We have a shader that takes care of chroma key removal, but it seems that we can not use it with the YCbCr option on iOS, as activating this option switches to one of your shaders.
Question: can we use the YCbC option and remove a chroma color at the same time (with one of your shaders or one of ours)?
Stay safe guys :)