【发布时间】:2019-12-08 15:00:35
【问题描述】:
我使用ARKIT加载一个平面,平面修改SCNShaderModifierEntryPointFragment来显示解码后的视频。但是,渲染的视频图像比使用 metalLayer 渲染的视频太轻和更轻。为什么会这样?我也试过修改SCNShaderModifierEntryPointSurface,设置_surface.diffuse。我也尝试使用 rgb 代替 yuv。但还是一样。
这也不应该是因为光线。我尝试使用diffuse.content = image,没错。
我尝试使用 SCNProgram、shaderModifiers 渲染 MTLTexture。渲染 YUV 或 RGB 结果,颜色更浅
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};
【问题讨论】:
-
当我将 MTLTexture 发送到着色器显示时,颜色错误。
-
如果我设置“material.diffuse.contents = AVPlayer;”,那就对了。但我不想使用 AVPlayer