x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Stencil Buffer

I'm trying to implement Alex Vlachos very clever technique of using a stencil mesh to write in the stencil buffer to save precious GPU cycles in my VR game. I've already done a lot of optimization to try and optimize fillrate for my game but this seems like the ideal solution to save a huge amount.

Here is the link of the technique for more info:

http://alex.vlachos.com/graphics/Alex_Vlachos_Advanced_VR_Rendering_GDC2015.pdf

The whole thing is interesting but the technique I'm talking about is on slide 59.

However, I'm at a loss on how to write in the stencil buffer in UE4. I've been searching RHI commands and found some related to the stencil buffer but I don't know exactly where to start to try and implement that.

If anyone can give me an hand that would be greatly appreciated.

Thanks!

Mick

Product Version: Not Selected
Tags:
more ▼

asked Mar 11 '15 at 03:54 PM in Rendering

avatar image

MickD777
2.1k 70 37 259

avatar image MickD777 Mar 11 '15 at 07:05 PM

Also, would that still be coherent with Time Warping ? Maybe not using a perfect-fit stencil mesh would work better?

avatar image MickD777 Mar 17 '15 at 06:19 PM

Bump? Anyone? Epic?

avatar image MickD777 May 07 '15 at 12:56 PM

I dare bump again :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

To use stencil you have to bind a depthstencil target with something like this SetRenderTarget(RHICmdList, FTextureRHIRef(), GetCubeShadowDepthZSurface(ShadowResolution));

Then clear RHICmdList.ClearMRT(bClearColor, NumClearColors, Colors, bClearDepth, Depth, bClearStencil, Stencil, FIntRect());

Then render some geometry to setup the stencil mask, with something like this

// Set stencil to one. RHICmdList.SetDepthStencilState(TStaticDepthStencilState< false,CF_DepthNearOrEqual, true,CF_Always,SO_Keep,SO_Keep,SO_Replace, false,CF_Always,SO_Keep,SO_Keep,SO_Keep, 0xff,0xff >::GetRHI(), 1);

In order to get fill rate savings during the base pass, you need to set up that stencil mask before the base pass, then setup stencil state to test against 1 with SetDepthStencilState.

more ▼

answered May 08 '15 at 01:33 AM

avatar image

DanielW STAFF
1.9k 31 11 72

avatar image MickD777 May 08 '15 at 10:08 PM

Thanks, I'll give this a try next week and let you know how it went!

avatar image George Li May 11 '15 at 06:30 PM

Hi Daniel:

I need to render character vision bubbles on screen, and the bubbles may be partially displayed. Can you provide more details about using Stencil buffer with C++?

The following information would do big help: - What class should I inherit while adding code to the project - A block of code sample

Thanks

George

avatar image George Li Nov 03 '15 at 01:12 AM

Just talked with Zak. Unfortunately, Unreal doesn't support he feature I expected now. Will wait and see.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question