Page 1 of 1

Native Scene Warping

PostPosted: Wed Aug 22, 2018 7:17 pm
by Pixel Eater
By this I mean Predator effects not only for Spectres, Invisiplayers and HUD weapons but also custom effects like steam leaks, heat/shock waves and warped glass or water surfaces.

I can't begin to describe how terrible an explainer I am :wink: So I'll portray my thoughts through song images using the Spectre as an example:

In this scene there are three Spectres and a Lost Soul named Goldilocks. However for this case to work the Spectres aren't being rendered to the main scene but a sample texture accessible to a post-processing shader.

Example sample texture:

It's important that all other items including level geometry be rendered black, both in front and behind of the Spectre (or other chosen sprites/textures). This basically gives the post-processing shader "hot spots" it can use to manipulate the main scene.

Photoshop re-enactment:


More advanced stuff can be done by colour encoding replacement sprites and tweaking the shader further.

This sprite sheet allows the shader to smoothly bend the sprites' edges to connect to the scene (Blue channel), give body contours to the warping (Green channel) and also center the effect on each sprite individually, giving the impression of multiple shader passes (Red channel). And with this method it opens up the possiblity for a translucent Lost Goldilocks to be able to affect the warping amount depending on it's own alpha value.

Some thoughts:
I propose that there be an option to still render the sprite into the main scene so that glass can have a texture and not just be warping air.
It would be good to have a couple destination sample textures so that modders can combine a few custom effects like warped glass and steam in one level (ooh steamed glass!).

I'm sure I've glossed over some things here but hopefully it sort of made sense :P

Re: Native Scene Warping

PostPosted: Thu Aug 23, 2018 4:21 am
by Marisa Kirisame
I'm betting this would require major changes to the renderer.

Re: Native Scene Warping

PostPosted: Thu Aug 23, 2018 5:47 am
by Graf Zahl
You are betting correctly.

Re: Native Scene Warping

PostPosted: Thu Aug 23, 2018 7:01 am
by Pixel Eater
I knew it would be a tall order but I had to ask ():)

Just curious- what kind of changes?

Re: Native Scene Warping

PostPosted: Thu Aug 23, 2018 7:13 am
by dpJudas
This requires creating custom gbuffers that the material shaders can output to. Currently there's one such in the system already: the normal vector gbuffer used by the SSAO pass.

Re: Native Scene Warping

PostPosted: Thu Aug 23, 2018 7:17 am
by Graf Zahl
And let's not forget that on lower end hardware, even if this can be done, will cause some performance issues.

Re: Native Scene Warping

PostPosted: Thu Aug 23, 2018 7:29 am
by dpJudas
I'm actually not that worried about the performance implications as all games using deferred lighting, even really old games like Battlefield Bad Company 2, often have 3-4 gbuffers while we only have one or two. The additional shader variants to be managed by the shader manager on the other hand..

Re: Native Scene Warping

PostPosted: Thu Aug 23, 2018 7:55 am
by Pixel Eater
Ah, G buffers again. It seems they are my enemy.

Re: Native Scene Warping

PostPosted: Thu Aug 23, 2018 9:37 am
by Graf Zahl
dpJudas wrote:I'm actually not that worried about the performance implications as all games using deferred lighting, even really old games like Battlefield Bad Company 2, often have 3-4 gbuffers while we only have one or two. The additional shader variants to be managed by the shader manager on the other hand..



You are clearly not thinking "old enough". ;)
When I last checked our users' hardware specs it's still roughly 40% on hardware that will start having problems - being more than 10 years old or real low end stuff that was never designed for gaming.

Re: Native Scene Warping

PostPosted: Fri Aug 24, 2018 3:22 am
by Nash
This would have allowed that displaced water effect Enjay loves so much from that one legacy map... ;)

Re: Native Scene Warping

PostPosted: Fri Aug 24, 2018 9:10 pm
by Pixel Eater
Nash wrote:This would have allowed that displaced water effect Enjay loves so much from that one legacy map... ;)
Managed to dig up the thread you're referencing: Over here

That'd be super cool. And being done by a sample texture accessible to all modders, anyone could customise it to their own taste 8-)