- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有内核函数,它必须将从 pixelBuffer(ARFrame.capturedImage) 创建的 Y 和 CbCr 纹理转换为 RGB 纹理,就像在苹果指南中一样 https://developer.apple.com/documentation/arkit/displaying_an_ar_experience_with_metal但我克服了发光的纹理
kernel void renderTexture(texture2d<float, access::sample> capturedImageTextureY [[ texture(0) ]],
texture2d<float, access::sample> capturedImageTextureCbCr [[ texture(1) ]],
texture2d<float, access::read_write> outTextue [[texture(2)]],
uint2 size [[threads_per_grid]],
uint2 pid [[thread_position_in_grid]]){
constexpr sampler colorSampler(mip_filter::linear,
mag_filter::linear,
min_filter::linear);
const float4x4 ycbcrToRGBTransform = float4x4(
float4(+1.0000f, +1.0000f, +1.0000f, +0.0000f),
float4(+0.0000f, -0.3441f, +1.7720f, +0.0000f),
float4(+1.4020f, -0.7141f, +0.0000f, +0.0000f),
float4(-0.7010f, +0.5291f, -0.8860f, +1.0000f)
);
float2 texCoord;
texCoord.x = float(pid.x) / size.x;
texCoord.y = float(pid.y) / size.y;
// Sample Y and CbCr textures to get the YCbCr color at the given texture coordinate
float4 ycbcr = float4(capturedImageTextureY.sample(colorSampler, texCoord).r,
capturedImageTextureCbCr.sample(colorSampler, texCoord).rg, 1.0);
float4 color = ycbcrToRGBTransform * ycbcr;
outTextue.write(color, pid);
我用这段代码创建 CGImage:
var cgImage: CGImage?
VTCreateCGImageFromCVPixelBuffer(pixelBuffer, options: nil, imageOut: &cgImage)
cgImage有正常的闪电
当我尝试使用 MTKTextureLoader 从 cgImage 创建纹理时,我也忽略了光照纹理
如何像在cgImage中一样用普通光获得MTLTexture
cgImage:(预期结果)
内核函数:
用这段代码创建纹理:
let descriptor = MTLTextureDescriptor()
descriptor.width = Int(Self.maxTextureSize.width)
descriptor.height = Int(Self.maxTextureSize.height)
descriptor.usage = [.shaderWrite, .shaderRead]
let texture = MTLCreateSystemDefaultDevice()?.makeTexture(descriptor: descriptor)
并用内核函数写入像素。
已经尝试过 MTLTextureDescriptor 的不同像素格式
纹理加载器:
let textureLoader = MTKTextureLoader(device: MTLCreateSystemDefaultDevice()!)
let texturee = try! textureLoader.newTexture(cgImage: cgImage!, options: [.SRGB : (false as NSNumber)])
已经尝试过不同的 MTKTextureLoader.Options
GitHub 项目演示问题: PixelBufferToMTLTexture
最佳答案
问题已解决,感谢 0xBFE1A8,通过添加 Gamma 校正
通过替换
outTextue.write(color, pid);
与:
outTextue.write(float4(pow(color.rgb, float3(2,2,2)), color.a), pid);
关于swift - 生成的 MTLTexture 比 CGImage 更轻,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62478638/
我的页面包含一个带有 5 个选项卡的 tabcontainer。每个选项卡都包含多个 RadGrid,因为 RadGrid 比 ASP.NET gridview 重。我的页面滞后,即运行速度非常慢。我
我有一个 extjs >4 应用程序,它使用选项卡面板作为菜单。每个选项卡下都有内容(包括容器等的 View )。 我注意到 extjs 可以正确处理 DOM,并且不会渲染我的应用程序拥有的所有内容。
这个问题在这里已经有了答案: PyCharm running way slow (10 个答案) 关闭去年。 我非常喜欢 PyCharm 的想法并且很乐意使用它。但是,它容易消耗计算机的处理能力和滞
我有内核函数,它必须将从 pixelBuffer(ARFrame.capturedImage) 创建的 Y 和 CbCr 纹理转换为 RGB 纹理,就像在苹果指南中一样 https://develop
我问这个问题是因为我和我的同事对编码风格有争议,因为他更喜欢箭头函数声明: const sum = (a, b) => a + b; 我更喜欢旧式的独立函数声明: function sum(a, b)
有没有一种方法可以“更轻量”地使用 globalCompositeOperation,同时使用 source-atop? (又名打火机,但仅限于已经绘制了一些东西的地方。) 最佳答案 一次只能设置一项
我正在为企业网站寻找轻型文本富编辑器,比 tinymce 更轻,带有用于评论表单的基本按钮。重要的是编辑器也可以在 IE6 中工作。直到现在我都在尝试 cleditor 15KB,但是当按“输入”键时
我问这个问题是因为我和我的同事在编码风格上存在争议,因为他更喜欢箭头函数声明: const sum = (a, b) => a + b; 而且我更喜欢老式的独立函数声明: function sum(a
我想知道该代码是否: select(fd,..., NULL); 比那个消耗更少的CPU: struct timeval tv; tv.tv_sec = X; tv_tv_usec = Y; sele
我是一名优秀的程序员,十分优秀!