Solved

Not able to get stencil to work

Posted on 2010-09-16
2
635 Views
Last Modified: 2013-12-08
Was trying to get Stencil to work in my app. I use Sprites to render content on to the Device. Content could be movies, pictures or text.

Can I set the stencil buffer using these Sprites, which can be used in later passes to stencil out other Sprites being rendered?

I'm even not able to stencil out any of the Sprites by setting StencilFunction = Compare.Never! Anything wrong that I might be doing?

Bit more searching got me to a technique wherein we draw silhouette of the shapes to be added to the stencil buffer. Is this really required in my case? I just want to use the Sprites, and add them to stencil buffer to stencil out other Sprites.
0
Comment
Question by:Mohit_Kaushal
  • 2
2 Comments
 

Author Comment

by:Mohit_Kaushal
ID: 33699140
OK.. So I figured out how to get it done. Referred to this post - http://www.gamedev.net/community/forums/viewreply.asp?ID=1999276

But now the sprite is ignoring alpha values and rendering sprites opaque. Similar to the effect we get when alpha blending is set to false. Any ideas?
0
 

Accepted Solution

by:
Mohit_Kaushal earned 0 total points
ID: 33700491
So, I finally figured it out. It's all related to Sprites and its Begin() method.

Sprite.Begin() will modify the RenderState and disable stencil. We can prevent it by setting SpriteFlags.DoNotModifyRenderState flag, but then the alpha blending is not supported when sprites are drawn.

What I did now was simply call Sprite.Begin() without SpriteFlags.DoNotModifyRenderState flag set. And before the call to Sprite.Draw(), enabled stencil on the device.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
candy crush 4 435
Help me install PYgame on Python 3.3.3 IDLE 6 558
Java3D Add Line to existing scene 1 210
scoresAverage challenge 8 125
What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question