Pitch + Angle Based Sprite Masking
Moderator: GZDoom Developers
- Major Cooke
- Posts: 8206
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: GZBoomer Town
- Contact:
Pitch + Angle Based Sprite Masking
ZDoom
GZDoom
What ultimately was created to help combat the DONTFLIP issue with flat sprites turned into something a lot more useful VERY shortly after starting this, that can definitely help out with the zdoom community too.
Simply put, allows modders to define a mask range for angle and pitch, start and end. This offsets by the actor's angle and pitch but this can be made absolute (see the pull request for details).
If the player is outside that range, the actor won't draw at all.
GZDoom
What ultimately was created to help combat the DONTFLIP issue with flat sprites turned into something a lot more useful VERY shortly after starting this, that can definitely help out with the zdoom community too.
Simply put, allows modders to define a mask range for angle and pitch, start and end. This offsets by the actor's angle and pitch but this can be made absolute (see the pull request for details).
If the player is outside that range, the actor won't draw at all.
Last edited by Major Cooke on Fri Sep 23, 2016 6:30 pm, edited 5 times in total.
- Major Cooke
- Posts: 8206
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: GZBoomer Town
- Contact:
Re: Pitch + Angle Based Sprite Masking
Say... Graf, I don't need to do anything special for GZDoom, do I? Seeing as I had to for the SpriteAngle and SpriteRotation, I just wanted to check.
Re: Pitch + Angle Based Sprite Masking
I imagine it's used for some special effects but honestly I can't imagine those. Can you give some examples of use cases?
Also how is the angle part better than, say, providing angled sprites that are simply a 1x1 transparent pixel? For the pitch I could suppose something such as the ROTT GADs where you put different actors in the same place and depending on view pitch it's a different one that is seen. That makes it quite a clumsy workaround for a limitation of the engine but well, why not.
Also how is the angle part better than, say, providing angled sprites that are simply a 1x1 transparent pixel? For the pitch I could suppose something such as the ROTT GADs where you put different actors in the same place and depending on view pitch it's a different one that is seen. That makes it quite a clumsy workaround for a limitation of the engine but well, why not.
- Major Cooke
- Posts: 8206
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: GZBoomer Town
- Contact:
Re: Pitch + Angle Based Sprite Masking
The biggest compliment this serves is towards DONTFLIP flag for GZDoom, and the ability to basically turn off seeing the backside. Seeing blood splatters on the top of a lift and hanging over the edge also bugs the crap out of me. I can tolerate it when viewed from above but from below? Let's just say I'm not seeing decal support for floors/ceilings in GZDoom anytime soon.
As for it being better, I'm not meaning to outright replace it but one can set up a single 0-angled sprite and use that to have certain effects occurring on specific sides, possibly with the help of SpriteAngle.
I also have a multi-part actor that's actually pretty huge. Knowing big and small sprites, they can sometimes project over each other simply from the smallest of angle dependencies when the actor's facing to the side and the piece is warping right in front of the actor. The moment the main actor's facing more towards you than not (talking just a slight change of angle so you'd be in the front 180 FOV), bam. That piece immediately is drawn over the main actor. I HATE that.
The pitch thing: I hadn't actually thought of that. And, indeed, while it might be I see no real work-around for that either without introducing a whole new subsection of sprite naming and finding compatible ways to get that working, so this would be the next best thing (even though that wasn't exactly my original intention, thanks for that idea.)
As for it being better, I'm not meaning to outright replace it but one can set up a single 0-angled sprite and use that to have certain effects occurring on specific sides, possibly with the help of SpriteAngle.
I also have a multi-part actor that's actually pretty huge. Knowing big and small sprites, they can sometimes project over each other simply from the smallest of angle dependencies when the actor's facing to the side and the piece is warping right in front of the actor. The moment the main actor's facing more towards you than not (talking just a slight change of angle so you'd be in the front 180 FOV), bam. That piece immediately is drawn over the main actor. I HATE that.
The pitch thing: I hadn't actually thought of that. And, indeed, while it might be I see no real work-around for that either without introducing a whole new subsection of sprite naming and finding compatible ways to get that working, so this would be the next best thing (even though that wasn't exactly my original intention, thanks for that idea.)
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49223
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Pitch + Angle Based Sprite Masking
I'm not going to merge this without a second opinion of another developer.
- Major Cooke
- Posts: 8206
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: GZBoomer Town
- Contact:
Re: Pitch + Angle Based Sprite Masking
Alright. Does it look okay to you at least or is there something that can be done to improve it? If there's something I can do, I'd like to know so I can do so while waiting.
Re: [Needs Dev Reviewing]Pitch + Angle Based Sprite Masking
Not sure I really quality as another developer in this part of the codebase, but Cooke wanted me to take a look at this.
From what I can tell on the PR diff, the patch seems sane enough, except that using "players[consoleplayer].camera->player" in IsInsideVisibleAngles is not correct when called from R_ProjectSprite. This is because it might be rendering a canvas texture camera, where the view position is not the console camera.
I would add change it to AActor::IsInsideVisibleAngles(DVector3 cameraPos), and then change the call in R_ProjectSprite to say !thing->IsInsideVisibleAngles(ViewPos).
Edit: my suggested solution won't fully fix this as it also needs to know the direction the camera is facing, which it is grabbing from the console camera. I think the globals ViewAngle, ViewPitch, ViewRoll have this information, but I'm not sure. Either way, better test this with some camera textures.
From what I can tell on the PR diff, the patch seems sane enough, except that using "players[consoleplayer].camera->player" in IsInsideVisibleAngles is not correct when called from R_ProjectSprite. This is because it might be rendering a canvas texture camera, where the view position is not the console camera.
I would add change it to AActor::IsInsideVisibleAngles(DVector3 cameraPos), and then change the call in R_ProjectSprite to say !thing->IsInsideVisibleAngles(ViewPos).
Edit: my suggested solution won't fully fix this as it also needs to know the direction the camera is facing, which it is grabbing from the console camera. I think the globals ViewAngle, ViewPitch, ViewRoll have this information, but I'm not sure. Either way, better test this with some camera textures.

- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49223
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: [Needs Dev Reviewing]Pitch + Angle Based Sprite Masking
This does not need review for code quality but for appropriateness of the feature as such. I just want to hear another opinion before adding it.
Re: [Needs Dev Reviewing]Pitch + Angle Based Sprite Masking
I can see some logic in wanting to only show a sprite for certain angles where the graphics itself relies on an illusion that the sprite is more than it appears. The alternative solution suggested by Gez (use a 1x1 transparent image) seems a bit hacky, so if that's the only way of doing it today I think the patch makes sense. So I guess it comes down to whether there's a better way of doing this?
Re: [Needs Dev Reviewing]Pitch + Angle Based Sprite Masking
My point was the engine already has a system in place for showing different sprites depending on view angle, so if you don't want an actor to be visible from behind, you can give it a transparent "5" sprite.
On the other hand, there's no such feature for pitch and roll, so it's easier for me to understand the use case for pitch (I think the issue of a blood splat on the ground displayed with a flat sprite and viewed from below would still be a question of pitch, not angle, right?). And I suppose once you have this feature for pitch, then there's no reason not to have it for angle.
On the other hand, there's no such feature for pitch and roll, so it's easier for me to understand the use case for pitch (I think the issue of a blood splat on the ground displayed with a flat sprite and viewed from below would still be a question of pitch, not angle, right?). And I suppose once you have this feature for pitch, then there's no reason not to have it for angle.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49223
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: [Needs Dev Reviewing]Pitch + Angle Based Sprite Masking
dpJudas wrote:I can see some logic in wanting to only show a sprite for certain angles where the graphics itself relies on an illusion that the sprite is more than it appears. The alternative solution suggested by Gez (use a 1x1 transparent image) seems a bit hacky, so if that's the only way of doing it today I think the patch makes sense. So I guess it comes down to whether there's a better way of doing this?
Thanks. That's the kind of feedback I was asking for. To make it clear: I have no real problems with the feature as-is, but sometimes a second opinion is necessary before going on.
- Major Cooke
- Posts: 8206
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: GZBoomer Town
- Contact:
Re: [Needs Dev Reviewing]Pitch + Angle Based Sprite Masking
Ah, I see, you wanted opinion on the concept.Graf Zahl wrote:Thanks. That's the kind of feedback I was asking for. To make it clear: I have no real problems with the feature as-is, but sometimes a second opinion is necessary before going on.
You are correct.Gez wrote:On the other hand, there's no such feature for pitch and roll, so it's easier for me to understand the use case for pitch (I think the issue of a blood splat on the ground displayed with a flat sprite and viewed from below would still be a question of pitch, not angle, right?). And I suppose once you have this feature for pitch, then there's no reason not to have it for angle.
Code: Select all
VisibleStartPitch 0
VisibleEndPitch -90
I did not include roll because I don't think there's any such use for it at this time. I could try, but I'll make it a new PR for it after this is merged, if anyone can think of what it would be good for.
It would be nice to find a way for defining a sprite set to replace the images at certain pitch levels... but if that was done, then people might start asking for things like adjustable angle positions and it just might get into a snowball effect. Plus that doesn't exactly address if, say, the actor is capable of looking up at the target from below and it changes all around.dpJudas wrote:I can see some logic in wanting to only show a sprite for certain angles where the graphics itself relies on an illusion that the sprite is more than it appears. The alternative solution suggested by Gez (use a 1x1 transparent image) seems a bit hacky, so if that's the only way of doing it today I think the patch makes sense. So I guess it comes down to whether there's a better way of doing this?
Yeah that'll get really sticky.
- Major Cooke
- Posts: 8206
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: GZBoomer Town
- Contact:
Re: Pitch + Angle Based Sprite Masking
Added GZDoom PR.
Re: Pitch + Angle Based Sprite Masking
Code: Select all
VisibleStartPitch 0
VisibleEndPitch -90