Shader Specified Stencil Reference Value (Direct3D 12 ...
文章推薦指數: 80 %
This method sets the stencil reference value on a per-draw granularity. However, this value can be overwritten by the pixel shader. This D3D12 ( ... Skiptomaincontent Thisbrowserisnolongersupported. UpgradetoMicrosoftEdgetotakeadvantageofthelatestfeatures,securityupdates,andtechnicalsupport. DownloadMicrosoftEdge Moreinfo Tableofcontents Exitfocusmode ReadinEnglish Save Tableofcontents ReadinEnglish Save Edit Twitter LinkedIn Facebook Email Tableofcontents ShaderSpecifiedStencilReferenceValue(Direct3D12Graphics) Article 12/30/2021 2minutestoread 8contributors Isthispagehelpful? Yes No Anyadditionalfeedback? FeedbackwillbesenttoMicrosoft:Bypressingthesubmitbutton,yourfeedbackwillbeusedtoimproveMicrosoftproductsandservices.Privacypolicy. Submit Thankyou. Inthisarticle EnablingpixelshaderstooutputtheStencilReferenceValue,ratherthanusingtheAPI-specifiedone,enablesaveryfinegranularcontroloverstenciloperations. TheStencilReferenceValueisnormallyspecifiedbytheID3D12GraphicsCommandList::OMSetStencilRefmethod.Thismethodsetsthestencilreferencevalueonaper-drawgranularity.However,thisvaluecanbeoverwrittenbythepixelshader. ThisD3D12(andD3D11.3)featureenablesdeveloperstoreadandusetheStencilReferenceValue(SV_StencilRef)thatisoutputfromapixelshader,enablingaper-pixelorper-samplegranularity. TheshaderspecifiedvaluereplacestheAPI-specifiedreferencevalueforthatinvocation,whichmeansthechangeaffectsboththestenciltest,andwhenthestenciloperationD3D12_STENCIL_OP_REPLACE(onememberofD3D12_STENCIL_OP)isusedtowritethereferencevaluetothestencilbuffer. ThisfeatureisoptionalinbothD3D12andD3D11.3.Totestforitssupport,checkthePSSpecifiedStencilRefSupportedbooleanfieldofD3D12_FEATURE_DATA_D3D12_OPTIONSusingCheckFeatureSupport. HereisanexampleoftheuseofSV_StencilRefinapixelshader: uintmain2(float4c:COORD):SV_StencilRef { returnuint(c.x); } Relatedtopics Rendering ResourceBindinginHLSL ShaderModel5.1 SpecifyingRootSignaturesinHLSL Inthisarticle
延伸文章資訊
- 1Stencil Test - OpenGL Wiki
Fragment stencil value
- 2What is a stencil buffer? - Computer Graphics Stack Exchange
The stencil test is simply a per-pixel operation in which the current pixel stencil value is test...
- 3Set Custom Depth Stencil Value | Unreal Engine Documentation
Sets the CustomDepth stencil value (0 - 255) and marks the render state dirty. Target is Primitiv...
- 4Stencil testing - LearnOpenGL
A stencil buffer (usually) contains 8 bits per stencil value that amounts to a total of 256 diffe...
- 5OpenGL - depth and stencil buffers - YouTube