Blending for the MTLPixelFormat.r8Unorm texture

Is it possible to have correct blending with MTLPixelFormat.r8Unorm texture?

Here is what I use now but it works wrong:
Code Block
private func createBrushDescriptor(library: MTLLibrary) -> MTLRenderPipelineDescriptor {
let vertexDescriptor = MTLVertexDescriptor()
vertexDescriptor.attributes[0].format = .float2
vertexDescriptor.attributes[0].offset = 0
vertexDescriptor.attributes[0].bufferIndex = 0
vertexDescriptor.layouts[0].stride = 2 * MemoryLayout<simd_float1>.size
vertexDescriptor.layouts[0].stepFunction = .perVertex
vertexDescriptor.layouts[0].stepRate = 1
let descriptor = MTLRenderPipelineDescriptor()
descriptor.vertexFunction = library.makeFunction(name: "brush_vertex_function")
descriptor.vertexDescriptor = vertexDescriptor
descriptor.fragmentFunction = library.makeFunction(name: "brush_fragment_function")
descriptor.colorAttachments[0].pixelFormat = .r8Unorm
descriptor.colorAttachments[0].isBlendingEnabled = true
descriptor.colorAttachments[0].rgbBlendOperation = .add
descriptor.colorAttachments[0].sourceRGBBlendFactor = .one
descriptor.colorAttachments[0].destinationRGBBlendFactor = .one
descriptor.depthAttachmentPixelFormat = .invalid
return descriptor
}


But it works wrong.
Answered by Ivan85 in 623723022
In my case this configuration helped:

Code Block
descriptor.colorAttachments[0].isBlendingEnabled = true
descriptor.colorAttachments[0].rgbBlendOperation = .max
descriptor.colorAttachments[0].sourceRGBBlendFactor = .one
descriptor.colorAttachments[0].destinationRGBBlendFactor = .one


Accepted Answer
In my case this configuration helped:

Code Block
descriptor.colorAttachments[0].isBlendingEnabled = true
descriptor.colorAttachments[0].rgbBlendOperation = .max
descriptor.colorAttachments[0].sourceRGBBlendFactor = .one
descriptor.colorAttachments[0].destinationRGBBlendFactor = .one


Blending for the MTLPixelFormat.r8Unorm texture
 
 
Q