{"abstract":[{"text":"Configures the adjustments a render pass applies to depth values from fragment functions by a scaling factor and bias.","type":"text"}],"hierarchy":{"paths":[["doc:\/\/com.apple.documentation\/documentation\/technologies","doc:\/\/com.apple.metal\/documentation\/Metal","doc:\/\/com.apple.metal\/documentation\/Metal\/MTLRenderCommandEncoder"]]},"identifier":{"interfaceLanguage":"swift","url":"doc:\/\/com.apple.metal\/documentation\/Metal\/MTLRenderCommandEncoder\/setDepthBias(_:slopeScale:clamp:)"},"kind":"symbol","legalNotices":{"copyright":"Copyright &copy; 2026 Apple Inc. All rights reserved.","privacyPolicy":"https:\/\/www.apple.com\/privacy\/privacy-policy","termsOfUse":"https:\/\/www.apple.com\/legal\/internet-services\/terms\/site.html"},"metadata":{"availableLanguages":["de-DE","en-US","es-419","fr-FR","it-IT","ja-JP","ko-KR","pt-BR","zh-CN"],"externalID":"c:objc(pl)MTLRenderCommandEncoder(im)setDepthBias:slopeScale:clamp:","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"setDepthBias"},{"kind":"text","text":"("},{"kind":"typeIdentifier","preciseIdentifier":"s:Sf","text":"Float"},{"kind":"text","text":", "},{"kind":"externalParam","text":"slopeScale"},{"kind":"text","text":": "},{"kind":"typeIdentifier","preciseIdentifier":"s:Sf","text":"Float"},{"kind":"text","text":", "},{"kind":"externalParam","text":"clamp"},{"kind":"text","text":": "},{"kind":"typeIdentifier","preciseIdentifier":"s:Sf","text":"Float"},{"kind":"text","text":")"}],"modules":[{"name":"Metal"}],"navigatorTitle":[{"kind":"text","text":"- "},{"kind":"identifier","text":"setDepthBias:slopeScale:clamp:"}],"platforms":[{"introducedAt":"8.0","name":"iOS"},{"introducedAt":"8.0","name":"iPadOS"},{"introducedAt":"13.1","name":"Mac Catalyst"},{"introducedAt":"10.11","name":"macOS"},{"name":"tvOS"},{"introducedAt":"1.0","name":"visionOS"}],"required":true,"role":"symbol","roleHeading":"Instance Method","symbolKind":"method","title":"setDepthBias(_:slopeScale:clamp:)"},"primaryContentSections":[{"declarations":[{"languages":["swift"],"platforms":["iOS","iPadOS","Mac Catalyst","macOS","tvOS","visionOS"],"tokens":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"setDepthBias"},{"kind":"text","text":"("},{"kind":"externalParam","text":"_"},{"kind":"text","text":" "},{"kind":"internalParam","text":"depthBias"},{"kind":"text","text":": "},{"identifier":"doc:\/\/com.apple.documentation\/documentation\/Swift\/Float","kind":"typeIdentifier","preciseIdentifier":"s:Sf","text":"Float"},{"kind":"text","text":", "},{"kind":"externalParam","text":"slopeScale"},{"kind":"text","text":": "},{"identifier":"doc:\/\/com.apple.documentation\/documentation\/Swift\/Float","kind":"typeIdentifier","preciseIdentifier":"s:Sf","text":"Float"},{"kind":"text","text":", "},{"kind":"externalParam","text":"clamp"},{"kind":"text","text":": "},{"identifier":"doc:\/\/com.apple.documentation\/documentation\/Swift\/Float","kind":"typeIdentifier","preciseIdentifier":"s:Sf","text":"Float"},{"kind":"text","text":")"}]}],"kind":"declarations"},{"kind":"parameters","parameters":[{"content":[{"inlineContent":[{"text":"A constant bias the render pipeline applies to all fragments.","type":"text"}],"type":"paragraph"}],"name":"depthBias"},{"content":[{"inlineContent":[{"text":"A bias coefficient that scales with the depth of the primitive relative to the camera.","type":"text"}],"type":"paragraph"}],"name":"slopeScale"},{"content":[{"inlineContent":[{"text":"A value that limits the bias value the render pipeline can apply to a fragment. Pass a positive or negative value to limit the largest magnitude of a positive or negative bias, respectively.","type":"text"}],"type":"paragraph"},{"inlineContent":[{"text":"You can disable the bias clamping functionality by passing ","type":"text"},{"code":"0.0","type":"codeVoice"},{"text":".","type":"text"}],"type":"paragraph"}],"name":"clamp"}]},{"content":[{"anchor":"discussion","level":2,"text":"Discussion","type":"heading"},{"inlineContent":[{"text":"Call this method to have the render pipeline apply a bias to the rasterized depth after the clipping stage. The bias affects both depth testing and the values the render pipeline writes to the depth render target. If you don’t explicitly call this method, the pipeline doesn’t apply a scale or a bias to a depth value.","type":"text"}],"type":"paragraph"},{"inlineContent":[{"text":"Set a depth bias to improve the quality of techniques such as shadow mapping and avoid depth artifacts like shadow acne.","type":"text"}],"type":"paragraph"},{"content":[{"inlineContent":[{"text":"A depth bias only influences triangle primitives, but doesn’t apply to points or lines.","type":"text"}],"type":"paragraph"}],"name":"Note","style":"note","type":"aside"}],"kind":"content"}],"schemaVersion":{"major":0,"minor":3,"patch":0},"sections":[],"seeAlsoSections":[{"anchor":"Configuring-depth-and-stencil-behavior","generated":true,"identifiers":["doc:\/\/com.apple.metal\/documentation\/Metal\/MTLRenderCommandEncoder\/setDepthStencilState(_:)","doc:\/\/com.apple.metal\/documentation\/Metal\/MTLRenderCommandEncoder\/setDepthClipMode(_:)","doc:\/\/com.apple.metal\/documentation\/Metal\/MTLRenderCommandEncoder\/setDepthTestBounds(_:)","doc:\/\/com.apple.metal\/documentation\/Metal\/MTLRenderCommandEncoder\/setStencilReferenceValue(_:)","doc:\/\/com.apple.metal\/documentation\/Metal\/MTLRenderCommandEncoder\/setStencilReferenceValues(front:back:)"],"title":"Configuring depth and stencil behavior"}],"variants":[{"paths":["\/documentation\/metal\/mtlrendercommandencoder\/setdepthbias(_:slopescale:clamp:)"],"traits":[{"interfaceLanguage":"swift"}]},{"paths":["\/documentation\/metal\/mtlrendercommandencoder\/setdepthbias(_:slopescale:clamp:)"],"traits":[{"interfaceLanguage":"occ"}]}],"references":{"doc://com.apple.documentation/documentation/Swift/Float":{"abstract":[{"text":"A single-precision (32-bit), floating-point value type.","type":"text"}],"fragments":[{"kind":"keyword","text":"struct"},{"kind":"text","text":" "},{"kind":"identifier","text":"Float"}],"identifier":"doc:\/\/com.apple.documentation\/documentation\/Swift\/Float","kind":"symbol","navigatorTitle":[{"kind":"identifier","text":"Float"}],"role":"symbol","title":"Float","type":"topic","url":"\/documentation\/swift\/float"},"doc://com.apple.documentation/documentation/technologies":{"abstract":[],"identifier":"doc:\/\/com.apple.documentation\/documentation\/technologies","kind":"technologies","role":"overview","title":"Technologies","type":"topic","url":"\/documentation\/technologies"},"doc://com.apple.metal/documentation/Metal":{"abstract":[{"text":"Render advanced 3D graphics and compute data in parallel with graphics processors.","type":"text"}],"identifier":"doc:\/\/com.apple.metal\/documentation\/Metal","kind":"symbol","navigatorTitle":[{"kind":"text","text":"Metal"}],"role":"collection","title":"Metal","type":"topic","url":"\/documentation\/metal"},"doc://com.apple.metal/documentation/Metal/MTLRenderCommandEncoder":{"abstract":[{"text":"Encodes configuration and draw commands for a single render pass into a command buffer.","type":"text"}],"fragments":[{"kind":"keyword","text":"protocol"},{"kind":"text","text":" "},{"kind":"identifier","text":"MTLRenderCommandEncoder"}],"identifier":"doc:\/\/com.apple.metal\/documentation\/Metal\/MTLRenderCommandEncoder","kind":"symbol","navigatorTitle":[{"kind":"identifier","text":"MTLRenderCommandEncoder"}],"role":"symbol","title":"MTLRenderCommandEncoder","type":"topic","url":"\/documentation\/metal\/mtlrendercommandencoder"},"doc://com.apple.metal/documentation/Metal/MTLRenderCommandEncoder/setDepthBias(_:slopeScale:clamp:)":{"abstract":[{"text":"Configures the adjustments a render pass applies to depth values from fragment functions by a scaling factor and bias.","type":"text"}],"fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"setDepthBias"},{"kind":"text","text":"("},{"kind":"typeIdentifier","preciseIdentifier":"s:Sf","text":"Float"},{"kind":"text","text":", "},{"kind":"externalParam","text":"slopeScale"},{"kind":"text","text":": "},{"kind":"typeIdentifier","preciseIdentifier":"s:Sf","text":"Float"},{"kind":"text","text":", "},{"kind":"externalParam","text":"clamp"},{"kind":"text","text":": "},{"kind":"typeIdentifier","preciseIdentifier":"s:Sf","text":"Float"},{"kind":"text","text":")"}],"identifier":"doc:\/\/com.apple.metal\/documentation\/Metal\/MTLRenderCommandEncoder\/setDepthBias(_:slopeScale:clamp:)","kind":"symbol","navigatorTitle":[{"kind":"text","text":"- "},{"kind":"identifier","text":"setDepthBias:slopeScale:clamp:"}],"required":true,"role":"symbol","title":"setDepthBias(_:slopeScale:clamp:)","type":"topic","url":"\/documentation\/metal\/mtlrendercommandencoder\/setdepthbias(_:slopescale:clamp:)"},"doc://com.apple.metal/documentation/Metal/MTLRenderCommandEncoder/setDepthClipMode(_:)":{"abstract":[{"text":"Configures how the render pipeline handles fragments outside the near and far planes of the view frustum.","type":"text"}],"fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"setDepthClipMode"},{"kind":"text","text":"("},{"kind":"typeIdentifier","preciseIdentifier":"c:@E@MTLDepthClipMode","text":"MTLDepthClipMode"},{"kind":"text","text":")"}],"identifier":"doc:\/\/com.apple.metal\/documentation\/Metal\/MTLRenderCommandEncoder\/setDepthClipMode(_:)","kind":"symbol","navigatorTitle":[{"kind":"text","text":"- "},{"kind":"identifier","text":"setDepthClipMode:"}],"required":true,"role":"symbol","title":"setDepthClipMode(_:)","type":"topic","url":"\/documentation\/metal\/mtlrendercommandencoder\/setdepthclipmode(_:)"},"doc://com.apple.metal/documentation/Metal/MTLRenderCommandEncoder/setDepthStencilState(_:)":{"abstract":[{"text":"Configures the combined depth and stencil state.","type":"text"}],"fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"setDepthStencilState"},{"kind":"text","text":"((any "},{"kind":"typeIdentifier","preciseIdentifier":"c:objc(pl)MTLDepthStencilState","text":"MTLDepthStencilState"},{"kind":"text","text":")?)"}],"identifier":"doc:\/\/com.apple.metal\/documentation\/Metal\/MTLRenderCommandEncoder\/setDepthStencilState(_:)","kind":"symbol","navigatorTitle":[{"kind":"text","text":"- "},{"kind":"identifier","text":"setDepthStencilState:"}],"required":true,"role":"symbol","title":"setDepthStencilState(_:)","type":"topic","url":"\/documentation\/metal\/mtlrendercommandencoder\/setdepthstencilstate(_:)"},"doc://com.apple.metal/documentation/Metal/MTLRenderCommandEncoder/setDepthTestBounds(_:)":{"abstract":[{"text":"Configures the range for depth bounds testing.","type":"text"}],"fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"setDepthTestBounds"},{"kind":"text","text":"("},{"kind":"typeIdentifier","preciseIdentifier":"s:SN","text":"ClosedRange"},{"kind":"text","text":"<"},{"kind":"typeIdentifier","preciseIdentifier":"s:Sf","text":"Float"},{"kind":"text","text":">)"}],"identifier":"doc:\/\/com.apple.metal\/documentation\/Metal\/MTLRenderCommandEncoder\/setDepthTestBounds(_:)","kind":"symbol","role":"symbol","title":"setDepthTestBounds(_:)","type":"topic","url":"\/documentation\/metal\/mtlrendercommandencoder\/setdepthtestbounds(_:)"},"doc://com.apple.metal/documentation/Metal/MTLRenderCommandEncoder/setDepthTestMinBound:maxBound:":{"abstract":[{"text":"Configures the minimum and maximum bounds for depth bounds testing.","type":"text"}],"fragments":[{"kind":"text","text":"- "},{"kind":"identifier","text":"setDepthTestMinBound:maxBound:"}],"identifier":"doc:\/\/com.apple.metal\/documentation\/Metal\/MTLRenderCommandEncoder\/setDepthTestMinBound:maxBound:","kind":"symbol","role":"symbol","title":"setDepthTestMinBound:maxBound:","type":"topic","url":"\/documentation\/metal\/mtlrendercommandencoder\/setdepthtestminbound:maxbound:"},"doc://com.apple.metal/documentation/Metal/MTLRenderCommandEncoder/setStencilReferenceValue(_:)":{"abstract":[{"text":"Configures the same comparison value for front- and back-facing primitives.","type":"text"}],"fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"setStencilReferenceValue"},{"kind":"text","text":"("},{"kind":"typeIdentifier","preciseIdentifier":"s:s6UInt32V","text":"UInt32"},{"kind":"text","text":")"}],"identifier":"doc:\/\/com.apple.metal\/documentation\/Metal\/MTLRenderCommandEncoder\/setStencilReferenceValue(_:)","kind":"symbol","navigatorTitle":[{"kind":"text","text":"- "},{"kind":"identifier","text":"setStencilReferenceValue:"}],"required":true,"role":"symbol","title":"setStencilReferenceValue(_:)","type":"topic","url":"\/documentation\/metal\/mtlrendercommandencoder\/setstencilreferencevalue(_:)"},"doc://com.apple.metal/documentation/Metal/MTLRenderCommandEncoder/setStencilReferenceValues(front:back:)":{"abstract":[{"text":"Configures different comparison values for front- and back-facing primitives.","type":"text"}],"fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"setStencilReferenceValues"},{"kind":"text","text":"("},{"kind":"externalParam","text":"front"},{"kind":"text","text":": "},{"kind":"typeIdentifier","preciseIdentifier":"s:s6UInt32V","text":"UInt32"},{"kind":"text","text":", "},{"kind":"externalParam","text":"back"},{"kind":"text","text":": "},{"kind":"typeIdentifier","preciseIdentifier":"s:s6UInt32V","text":"UInt32"},{"kind":"text","text":")"}],"identifier":"doc:\/\/com.apple.metal\/documentation\/Metal\/MTLRenderCommandEncoder\/setStencilReferenceValues(front:back:)","kind":"symbol","navigatorTitle":[{"kind":"text","text":"- "},{"kind":"identifier","text":"setStencilFrontReferenceValue:backReferenceValue:"}],"required":true,"role":"symbol","title":"setStencilReferenceValues(front:back:)","type":"topic","url":"\/documentation\/metal\/mtlrendercommandencoder\/setstencilreferencevalues(front:back:)"}},"variantOverrides":[{"patch":[{"op":"replace","path":"\/identifier\/interfaceLanguage","value":"occ"},{"op":"replace","path":"\/metadata\/platforms","value":[{"introducedAt":"8.0","name":"iOS"},{"introducedAt":"8.0","name":"iPadOS"},{"introducedAt":"13.1","name":"Mac Catalyst"},{"introducedAt":"10.11","name":"macOS"},{"name":"tvOS"},{"introducedAt":"1.0","name":"visionOS"}]},{"op":"replace","path":"\/metadata\/roleHeading","value":"Instance Method"},{"op":"replace","path":"\/metadata\/title","value":"setDepthBias:slopeScale:clamp:"},{"op":"replace","path":"\/metadata\/symbolKind","value":"method"},{"op":"replace","path":"\/metadata\/fragments","value":[{"kind":"text","text":"- "},{"kind":"identifier","text":"setDepthBias:slopeScale:clamp:"}]},{"op":"replace","path":"\/hierarchy","value":{"paths":[["doc:\/\/com.apple.documentation\/documentation\/technologies","doc:\/\/com.apple.metal\/documentation\/Metal","doc:\/\/com.apple.metal\/documentation\/Metal\/MTLRenderCommandEncoder"]]}},{"op":"add","path":"\/topicSections","value":null},{"op":"add","path":"\/relationshipsSections","value":null},{"op":"replace","path":"\/seeAlsoSections","value":[{"anchor":"Configuring-depth-and-stencil-behavior","generated":true,"identifiers":["doc:\/\/com.apple.metal\/documentation\/Metal\/MTLRenderCommandEncoder\/setDepthStencilState(_:)","doc:\/\/com.apple.metal\/documentation\/Metal\/MTLRenderCommandEncoder\/setDepthClipMode(_:)","doc:\/\/com.apple.metal\/documentation\/Metal\/MTLRenderCommandEncoder\/setDepthTestMinBound:maxBound:","doc:\/\/com.apple.metal\/documentation\/Metal\/MTLRenderCommandEncoder\/setStencilReferenceValue(_:)","doc:\/\/com.apple.metal\/documentation\/Metal\/MTLRenderCommandEncoder\/setStencilReferenceValues(front:back:)"],"title":"Configuring depth and stencil behavior"}]},{"op":"replace","path":"\/primaryContentSections\/0","value":{"declarations":[{"languages":["occ"],"platforms":["iOS","iPadOS","Mac Catalyst","macOS","tvOS","visionOS"],"tokens":[{"kind":"text","text":"- ("},{"kind":"typeIdentifier","preciseIdentifier":"c:v","text":"void"},{"kind":"text","text":") "},{"kind":"identifier","text":"setDepthBias:"},{"kind":"text","text":"("},{"kind":"typeIdentifier","preciseIdentifier":"c:f","text":"float"},{"kind":"text","text":") "},{"kind":"internalParam","text":"depthBias"},{"kind":"text","text":" "},{"kind":"identifier","text":"slopeScale:"},{"kind":"text","text":"("},{"kind":"typeIdentifier","preciseIdentifier":"c:f","text":"float"},{"kind":"text","text":") "},{"kind":"internalParam","text":"slopeScale"},{"kind":"text","text":" "},{"kind":"identifier","text":"clamp:"},{"kind":"text","text":"("},{"kind":"typeIdentifier","preciseIdentifier":"c:f","text":"float"},{"kind":"text","text":") "},{"kind":"internalParam","text":"clamp"},{"kind":"text","text":";"}]}],"kind":"declarations"}},{"op":"replace","path":"\/primaryContentSections\/1","value":{"kind":"parameters","parameters":[{"content":[{"inlineContent":[{"text":"A constant bias the render pipeline applies to all fragments.","type":"text"}],"type":"paragraph"}],"name":"depthBias"},{"content":[{"inlineContent":[{"text":"A bias coefficient that scales with the depth of the primitive relative to the camera.","type":"text"}],"type":"paragraph"}],"name":"slopeScale"},{"content":[{"inlineContent":[{"text":"A value that limits the bias value the render pipeline can apply to a fragment. Pass a positive or negative value to limit the largest magnitude of a positive or negative bias, respectively.","type":"text"}],"type":"paragraph"},{"inlineContent":[{"text":"You can disable the bias clamping functionality by passing ","type":"text"},{"code":"0.0","type":"codeVoice"},{"text":".","type":"text"}],"type":"paragraph"}],"name":"clamp"}]}},{"op":"replace","path":"\/references\/doc:~1~1com.apple.metal~1documentation~1Metal~1MTLRenderCommandEncoder\/title","value":"MTLRenderCommandEncoder"},{"op":"replace","path":"\/references\/doc:~1~1com.apple.metal~1documentation~1Metal~1MTLRenderCommandEncoder\/fragments","value":[{"kind":"identifier","text":"MTLRenderCommandEncoder"}]},{"op":"replace","path":"\/references\/doc:~1~1com.apple.metal~1documentation~1Metal~1MTLRenderCommandEncoder\/navigatorTitle","value":[{"kind":"identifier","text":"MTLRenderCommandEncoder"}]},{"op":"replace","path":"\/references\/doc:~1~1com.apple.metal~1documentation~1Metal~1MTLRenderCommandEncoder~1setDepthBias(_:slopeScale:clamp:)\/title","value":"setDepthBias:slopeScale:clamp:"},{"op":"replace","path":"\/references\/doc:~1~1com.apple.metal~1documentation~1Metal~1MTLRenderCommandEncoder~1setDepthBias(_:slopeScale:clamp:)\/fragments","value":[{"kind":"text","text":"- "},{"kind":"identifier","text":"setDepthBias:slopeScale:clamp:"}]},{"op":"replace","path":"\/references\/doc:~1~1com.apple.metal~1documentation~1Metal~1MTLRenderCommandEncoder~1setDepthClipMode(_:)\/title","value":"setDepthClipMode:"},{"op":"replace","path":"\/references\/doc:~1~1com.apple.metal~1documentation~1Metal~1MTLRenderCommandEncoder~1setDepthClipMode(_:)\/fragments","value":[{"kind":"text","text":"- "},{"kind":"identifier","text":"setDepthClipMode:"}]},{"op":"replace","path":"\/references\/doc:~1~1com.apple.metal~1documentation~1Metal~1MTLRenderCommandEncoder~1setDepthStencilState(_:)\/title","value":"setDepthStencilState:"},{"op":"replace","path":"\/references\/doc:~1~1com.apple.metal~1documentation~1Metal~1MTLRenderCommandEncoder~1setDepthStencilState(_:)\/fragments","value":[{"kind":"text","text":"- "},{"kind":"identifier","text":"setDepthStencilState:"}]},{"op":"replace","path":"\/references\/doc:~1~1com.apple.metal~1documentation~1Metal~1MTLRenderCommandEncoder~1setStencilReferenceValue(_:)\/title","value":"setStencilReferenceValue:"},{"op":"replace","path":"\/references\/doc:~1~1com.apple.metal~1documentation~1Metal~1MTLRenderCommandEncoder~1setStencilReferenceValue(_:)\/fragments","value":[{"kind":"text","text":"- "},{"kind":"identifier","text":"setStencilReferenceValue:"}]},{"op":"replace","path":"\/references\/doc:~1~1com.apple.metal~1documentation~1Metal~1MTLRenderCommandEncoder~1setStencilReferenceValues(front:back:)\/title","value":"setStencilFrontReferenceValue:backReferenceValue:"},{"op":"replace","path":"\/references\/doc:~1~1com.apple.metal~1documentation~1Metal~1MTLRenderCommandEncoder~1setStencilReferenceValues(front:back:)\/fragments","value":[{"kind":"text","text":"- "},{"kind":"identifier","text":"setStencilFrontReferenceValue:backReferenceValue:"}]}],"traits":[{"interfaceLanguage":"occ"}]}]}