问题描述
我是金属着色语言的新手,所以您的友好指导会非常有帮助.我只是使用金属重复纹理,如下图所示(图像序列).但是它似乎不平滑.我如何使其像下面的金属点链接一样显示为平滑线.()
I am new to metal shading language.So your kind guidance would be so helpful.I just repeated texture using metal as shown on below image(Image sequence).But it seems not smoothy.How can I make it to be appeared as smoothy line as done in following link for metal points.(overlapping Metal Point primitives and blending)
此刻,我要做的是在手势的每个触摸点为顶点缓冲区(MTLBuffer)分配内存.
At the moment what I do is allocating memory for vertex buffer (MTLBuffer) at each touch point in my gesture.
代码:
func allocateMemoryForVetexBuffer(vertices: Array<Vertex>){
var vertexData = Array<Float>()
for vertex in vertices{
vertexData += vertex.floatBuffer()
}
let dataSize = vertexData.count * MemoryLayout.size(ofValue: vertexData[0])
print("dataSize:\(dataSize)")
vertexBuffer = device.makeBuffer(bytes: vertexData, length: dataSize, options: [])
vertexCount = vertices.count
}
我在平移手势识别器中调用此方法,但这会导致FPS下降.所以我的问题是不知道在金属层的单个平移上会添加多少个纹理,如何为帧缓冲区分配内存.
I am calling this method in my pan gesture recognizer.But it causes to drop FPS.So my problem is without knowing how many textures will add on single pan on metal layer, how may I allocate memory for Frame Buffer.
推荐答案
您不必要使用实例化.
更改此:
renderEncoder.drawPrimitives(type: .triangle, vertexStart: 0, vertexCount: vertexCount,
instanceCount: vertexCount / 3)
对此:
renderEncoder.drawPrimitives(type: .triangle, vertexStart: 0, vertexCount: vertexCount)
这篇关于金属阴影语言中平移手势上纹理的重新排列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!