Shader Specified Stencil Reference Value (Direct3D 12 ...

文章推薦指數: 80 %
投票人數:10人

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



請為這篇文章評分?