قالب وردپرس درنا توس
Home / IOS Development / ios – Just a Metal frag shader makes a transparent color?

ios – Just a Metal frag shader makes a transparent color?



I have a simple pipeline description

   let p = MTLRenderPipelineDescriptor ()
...
p.colorAttachments [0] .pixelFormat = .bgra8Unorm

The background is plain blue

   la bg = MTLClearColor (red: 0, green: 0, blue: 1, alpha: 1)

leave pass = MTLRenderPassDescriptor ()
pass.colorAttachments [0] .loadAction = .clear
pass.colorAttachments [0] .clearColor = bg

I just draw a poly on it, says a red one: [fragment] half4 fattie_fragment () {
return half 4 (1,0,0, 1);
}

Or green …

  fragment half4 fattie_fragment () {
return half 4 (0,1,0, 1);
}

What to do in Metal if you want the triangle to be transparent? Fragment half4bag_fragment () {
return half 4 (0.1

.0, 0.275);
}

(Note – TBC I do not want the overall view to be transparent. Just the shader, the drawn triangle.)


Source link