Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411507 Posts in 69374 Topics- by 58429 Members - Latest Member: Alternalo

April 25, 2024, 11:03:20 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Set global stencil test regardless of shader (command buffers?)
Pages: [1]
Print
Author Topic: Set global stencil test regardless of shader (command buffers?)  (Read 599 times)
oahda
Level 10
*****



View Profile
« on: June 12, 2018, 07:58:28 AM »

I have a question about something that could've been so easy if I were working directly with a graphics API like OpenGL but might just be impossible without a custom rendering pipeline in Unity because the functionality doesn't seem to be exposed through the C# API anywhere, but I'm not willing to give my hopes up without asking a few more people so here goes…

I've detailed it on Unity Answers:

https://answers.unity.com/questions/1517375/set-global-stencil-test-regardless-of-shader-comma.html
Logged

bateleur
Level 10
*****



View Profile
« Reply #1 on: June 19, 2018, 01:48:20 AM »

I think you're probably right that it can't be done, but one possible hack I don't see mentioned in the UnityAnswers post is to set up multiple cameras and then use an OnRenderImage for each Camera which does no work at all on the actual RenderTextures passed to it but instead modifies your stencil texture as a side effect.

(I don't know if this works - even if it is applicable to your setup - since I haven't tested it.)
Logged

oahda
Level 10
*****



View Profile
« Reply #2 on: June 19, 2018, 01:54:51 AM »

Yeah, I ended up concluding that a custom pipeline is the only way, which isn't an option for me, so I ended up solving my task in a completely different way, without using the stencil buffer at all. Works, but probably less efficient. /:

Writing to the buffer was never an issue, so unfortunately that doesn't really help—the issue was making every draw call read it to get clipped—but thanks anyway! c:
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic