Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9122013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:59:33+00:00 2026-06-17T05:59:33+00:00

I have a function that renders a triangle of desired color. I am trying

  • 0

I have a function that renders a triangle of desired color. I am trying to render a yellow triangle and then a red triangle over it with stencil test enable. I am using a circle as my stencil window. What should be my stencil test equations and operations to get the below output. All rendering in DirectX09 only.
Desired output
Kindly guide to few good and simple examples for below APIs….

SetRenderState(D3DRS_STENCILFUNC,
SetRenderState(D3DRS_STENCILREF,
SetRenderState(D3DRS_STENCILMASK,
SetRenderState(D3DRS_STENCILWRITEMASK,
SetRenderState(D3DRS_STENCILZFAIL,
SetRenderState(D3DRS_STENCILFAIL,
SetRenderState(D3DRS_STENCILPASS,

How do we use Stencil operation in DirectX09 shaders effect file (vs_3_0 and ps_3_0) ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:59:35+00:00Added an answer on June 17, 2026 at 5:59 am

    The documentation of the renderstates should answer most of your related questions.

    For creating the stencilmask, you need the methods

    SetRenderState(D3DRS_STENCILZFAIL,D3DSTENCILOP_KEEP)
    SetRenderState(D3DRS_STENCILFAIL,D3DSTENCILOP_INCRSAT)
    SetRenderState(D3DRS_STENCILPASS,D3DSTENCILOP_INCRSAT)
    SetRenderState(D3DRS_STENCILFUNC,D3DCMP_ALWAYS)
    

    because they increment the stencilbuffer, while rendering your circle. Then youre drawing your yellow triangle without using the stencilbuffer. After that youre drawing the red triangle with

    SetRenderState(D3DRS_STENCILZFAIL,D3DSTENCILOP_KEEP)
    SetRenderState(D3DRS_STENCILFAIL,D3DSTENCILOP_KEEP)
    SetRenderState(D3DRS_STENCILPASS,D3DSTENCILOP_KEEP)
    SetRenderState(D3DRS_STENCILFUNC,D3DCMP_LESS)    
    SetRenderState(D3DRS_STENCILREF,0)
    

    so your that your stenciltest returns only true, where youre circle had been drawn before (there should be the stencilvalue greater 0). If after that there is nothing drawn properly, you should try to deactivate the Z-Test maybe, the order of your triangles isn’t right.

    How do we use Stencil operation in DirectX09 shaders effect file (vs_3_0 and ps_3_0) ?

    Stencil operations are only used from your main program code. Shaders cannot have any effect on the stenciltests.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function that renders RGB video frames to a window. This works
I've a problem with celery's logger. I have a function that renders frames. I
I have a function in a view that renders the xml in the browser,
I have a function that takes an input string and then runs the string
I have this code that renders a map. function initialize() { var myOptions =
Inside my Controller i have function that runs after user clicks on item, which
So I have function that formats a date to coerce to given enum DateType{CURRENT,
In my Java code I have function that gets file from the client in
I have function Start() that is fired on ready. When I click on .ExampleClick
I have a function that returns two values in a list. Both values need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.