Render video in plane use shaderModifiers , but the color is too light

I use ARKIT to load a plane, and the plane modifies the SCNShaderModifierEntryPointFragment to display the decoded video. However, the rendered video image is too light and lighter than the video rendered using metalLayer. Why is this happening? I also tried to modify SCNShaderModifierEntryPointSurface, set the _surface.diffuse. And I also try use rgb instead of yuv. But still the same.


texture2d textureY;
texture2d textureUV;
float3x3 coversionMatrix;

float3 yuv;
yuv.x = textureY.sample(textureSampler, _surface.diffuseTexcoord).r;
yuv.yz = textureUV.sample(textureSampler, _surface.diffuseTexcoord).rg;

float3 rgb = coversionMatrix * (yuv - offset);
_output.color = float4(rgb, 1.0);


set the shaderModifiers

myMaterial.shaderModifiers = @{ SCNShaderModifierEntryPointFragment : shader};


render in ar :https://photos.app.goo.gl/sqUkW9hzZTaPog7Z6


render in metalLayer: https://photos.app.goo.gl/9dP49om7WSkeQYt56

Replies

Because Metal and Scene have different color space?