[No] Soft sprite clipping

Moderator: GZDoom Developers

Soft sprite clipping

Postby Nash » Thu Jun 01, 2017 7:24 am

Image
Image

This feature is sometimes called "soft particles" in other game engines. It softens the billboard's edges when intersecting with other geometry. Very beautiful for special effects like smoke, explosions and fire.

I propose an actor flag, perhaps +SoftClip, to enable this special rendering per-Actor.
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: Soft sprite clipping

Postby Major Cooke » Thu Jun 01, 2017 7:33 am

Does GZDoom even have this ability?

Obviously you know GZDoom doesn't have DirectX.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: Soft sprite clipping

Postby Rachael » Thu Jun 01, 2017 7:47 am

No, GZDoom does not have this ability - but the ability does exist in OpenGL.

It seems simple enough to add - but I am finding a stunning lack of documentation on this. Do you have any programming tutorials where this is actually implemented? Unless dpJudas or Graf already know how to do this, we do at least need that much.

We also need to know what feature set is required for it, because obviously not all systems will be able to support it.

(It seems to also be a good solution for some sprite clipping issues in general)
User avatar
Rachael
Webmaster
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Soft sprite clipping

Postby Nash » Thu Jun 01, 2017 7:48 am

It's not a DirectX-exlusive feature.

I nicked that screenshot from a Google image search (it's from Bioshock, which runs on Unreal Engine and therefore DirectX) but soft edge material techniques is a generic graphics technique, just like SSAO is not exclusive to either DX or GL.
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: Soft sprite clipping

Postby Nash » Thu Jun 01, 2017 7:51 am

Rachael - it's sometimes also called depth fading... I found this, not sure how helpful the tech stuff is in these, perhaps you can take a look?

http://developer.download.nvidia.com/SD ... les_hi.pdf
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: Soft sprite clipping

Postby dpJudas » Thu Jun 01, 2017 7:52 am

The screenshots are from DirectX, but the actual algorithm works with OpenGL too. Essentially it is based on sampling the depth buffer when drawing the sprite and if the fragment is closer than a certain distance it begins to fade to transparent. In plain GLSL, something along these lines:

Code: Select allExpand view
float linearDepth = texelFetch(DepthTexture, gl_ScreenPos.xy).r * DepthLinearScale + DepthLinearOffset;
FragColor.a *= clamp((linearDepth - gl_ScreenPos.z) * fadeStartDistance, 0.0, 1.0);

Now the catch is that this requires a depth texture. We already have one, as the SSAO pass uses it, but that means half the dinosaur cards won't be able to do this feature without a general frame rate loss.
dpJudas
 
 
 
Joined: 28 May 2016

Re: Soft sprite clipping

Postby Rachael » Thu Jun 01, 2017 7:53 am

Nash wrote:Rachael - it's sometimes also called depth fading... I found this, not sure how helpful the tech stuff is in these, perhaps you can take a look?

http://developer.download.nvidia.com/SD ... les_hi.pdf


The applicability potential for this is HUGE, so you can bet I want to put this in if I can. I am trying to find out how, right now. I'll take a look at it.

dpJudas wrote:Now the catch is that this requires a depth texture. We already have one, as the SSAO pass uses it, but that means half the dinosaur cards won't be able to do this feature without a general frame rate loss.

Which is why it should be enabled with a CVar. (Yeah, I know you hate those things. :P)
User avatar
Rachael
Webmaster
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Soft sprite clipping

Postby Nash » Thu Jun 01, 2017 7:55 am

Thank you both, dpJudas and Rachael for commenting. Hopefully it can be done without too much trouble. :D

And yeah I realize this won't be too friendly with dinosaur hardware, but GZDoom is already loaded with modern-only graphics enhancements... this would be just another one added to the modern feature-set...
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: Soft sprite clipping

Postby Rachael » Thu Jun 01, 2017 7:58 am

Nash wrote:And yeah I realize this won't be too friendly with dinosaur hardware, but GZDoom is already loaded with modern-only graphics enhancements... this would be just another one added to the modern feature-set...

Surprisingly enough, GZDoom still has its OpenGL 2.0 render path. Obviously, such things will not be supported on it, as there's no way we can backport a feature like this to it.

My big thing is - this has the potential to also allow us to push sprites into the floor to a reasonable depth. Maybe not the rocket explosions, per se, but at least having humanoid actors' feet not being pushed up out of the floor would be nice.
User avatar
Rachael
Webmaster
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Soft sprite clipping

Postby Nash » Thu Jun 01, 2017 8:02 am

I didn't think about using it on monsters (when I made the thread, I was purely thinking about smoke and fire and stuff like that) but you raise an interesting thought. I'm definitely curious now. :D

I've found some other links, although to be honest these all look like alien languages to me... perhaps it'd make more sense to you. I'm sure ONE of these might be useful!

https://nickthecoder.wordpress.com/2012 ... particles/
https://stackoverflow.com/questions/439 ... -in-opengl
http://faculty.ycp.edu/~dbabcock/PastCo ... lab14.html
http://www.informatik.uni-oldenburg.de/ ... page7.html
https://www.gamedev.net/topic/529947-co ... particles/
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: Soft sprite clipping

Postby Rachael » Thu Jun 01, 2017 8:19 am

Well - that's more complicated than I thought it would be. >_> As per usual, with OpenGL stuff. I'll look into it, but I can't make any promises on my part. :( I still have a long way to go with learning OpenGL programming...
User avatar
Rachael
Webmaster
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Soft sprite clipping

Postby Major Cooke » Thu Jun 01, 2017 9:16 am

I'm glad I was wrong. This would indeed be of great use!
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: Soft sprite clipping

Postby Graf Zahl » Thu Jun 01, 2017 10:11 am

This is the stuff which turns deprecation into unsupportedness... :mrgreen:
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Soft sprite clipping

Postby dpJudas » Fri Jun 02, 2017 11:32 am

After thinking a bit about Rachael's idea to sample from the depth buffer to handle sprite clipping I think I've come up with a way that might work:

Image

Hopefully I'm not missing some important detail here.
dpJudas
 
 
 
Joined: 28 May 2016

Re: Soft sprite clipping

Postby Major Cooke » Fri Jun 02, 2017 11:41 am

I just hope it's born in mind with the fact that it won't look good on everything, so a render flag to (dis)allow such a thing from happening is something I would expect...
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Next

Return to Closed Feature Suggestions

Who is online

Users browsing this forum: No registered users and 0 guests