Facepunch / sbox-issues

176 stars 12 forks source link

Stencil Rendering support for Graphics.RenderToTexture() #2571

Closed Adesii closed 1 year ago

Adesii commented 1 year ago

For?

S&Box

What can't you do?

Unable to render only a section of the screen and save that to a texture. Currently it will always render the whole scene when using the function even if 90% will be discarded.

I've seen a GDC Talk about how it works in Portal 2 and tried to recreate it but from what Sam said Stencil Rendering isn't support for non vr usage. https://discord.com/channels/833983068468936704/893738580885782538/1027496696537677874

If it is supported it should be documented somewhere.

How would you like it to work?

Since im not sure how it would work internally i got no clue. maybe through passing in a Texture into a Attribute or Rendering into a Graphics.Stencil attribute.

What have you tried?

i got it working for the most part for use in Recursion Rendering without allocating lots of rendering textures. but there isn't much benefit for it rightnow as shown here: https://discord.com/channels/833983068468936704/893738580885782538/1026646214999023616

It works for the most part just that it isn't saving any performance because it is just re-rendering the whole scene everytime fully. I might just be doing something stupid but i tried my best :(

Additional context

No response

samzanemesis commented 1 year ago

I will evaluate it, we had disabled stencils outside of VR because our depth precision was getting too small for large maps, but I have done some recent changes that mitigated that, and should be possible to have stencils again

PixelQubed commented 1 year ago

Is there an ETA on this? Just asking.

samzanemesis commented 1 year ago

I'm working with a glow outline rework that adds some stencil manipulation functions

PixelQubed commented 1 year ago

I'm working with a glow outline rework that adds some stencil manipulation functions

Thanks for the update. I saw that post in the discord. It looks great. I can't wait for proper stencil support.