Soft sprite clipping

Moderator: GZDoom Developers

User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Soft sprite clipping

Post by Nash »

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
Major Cooke
Posts: 8176
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: Soft sprite clipping

Post by Major Cooke »

Does GZDoom even have this ability?

Obviously you know GZDoom doesn't have DirectX.
User avatar
Rachael
Posts: 13575
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Soft sprite clipping

Post by Rachael »

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
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Soft sprite clipping

Post by Nash »

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
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Soft sprite clipping

Post by Nash »

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
dpJudas
 
 
Posts: 3044
Joined: Sat May 28, 2016 1:01 pm

Re: Soft sprite clipping

Post by dpJudas »

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 all

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.
User avatar
Rachael
Posts: 13575
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Soft sprite clipping

Post by Rachael »

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
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Soft sprite clipping

Post by Nash »

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
Rachael
Posts: 13575
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Soft sprite clipping

Post by Rachael »

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
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Soft sprite clipping

Post by Nash »

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
Rachael
Posts: 13575
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Soft sprite clipping

Post by Rachael »

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
Major Cooke
Posts: 8176
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: Soft sprite clipping

Post by Major Cooke »

I'm glad I was wrong. This would indeed be of great use!
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49073
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Soft sprite clipping

Post by Graf Zahl »

This is the stuff which turns deprecation into unsupportedness... :mrgreen:
dpJudas
 
 
Posts: 3044
Joined: Sat May 28, 2016 1:01 pm

Re: Soft sprite clipping

Post by dpJudas »

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.
User avatar
Major Cooke
Posts: 8176
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: Soft sprite clipping

Post by Major Cooke »

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...
Locked

Return to “Closed Feature Suggestions [GZDoom]”