[ZSCRIPT]How to put an overlay on a camera view?
Moderator: GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
-
- Posts: 537
- Joined: Wed Dec 22, 2021 7:02 pm
- Graphics Processor: Intel (Modern GZDoom)
- Location: Medellin, Colombia
[ZSCRIPT]How to put an overlay on a camera view?
I've got a locked door but I let the player peek through the keyhole. I've got a camera on the other side and it works how I want it to. How do I put a keyhole silhouete over that camera view?
I found a post on how to do that in ACS using a HUD message, but how to do it with ZScript?
I found a post on how to do that in ACS using a HUD message, but how to do it with ZScript?
-
- Posts: 1318
- Joined: Tue Dec 06, 2016 11:25 am
Re: [ZSCRIPT]How to put an overlay on a camera view?
You use either a custom ZScript Statusbar or, probably more appropriate here, an EventHandler's RenderOverlay virtual.
-
- Posts: 537
- Joined: Wed Dec 22, 2021 7:02 pm
- Graphics Processor: Intel (Modern GZDoom)
- Location: Medellin, Colombia
Re: [ZSCRIPT]How to put an overlay on a camera view?
Wow, things aren't hard to do once you know where to find them. Thanks!
An example for anyone else trying to do this:
And a screenie to see what it could look like
An example for anyone else trying to do this:
Code: Select all
class MWR_Silhouette_Handler : EventHandler
{
TextureId tKeyhole;
override void OnRegister()
{
tKeyhole = texman.CheckForTexture("Keyhole");
}
override void RenderUnderlay (RenderEvent e)
{
if (!(e.camera is "MWR_PeekCamera")) return;
Screen.DrawTexture(tKeyhole, false, 0, 0, DTA_FullScreen, 1);
}
}
Spoiler:
-
- Posts: 877
- Joined: Tue May 07, 2019 12:24 pm
- Graphics Processor: nVidia with Vulkan support
-
- Posts: 537
- Joined: Wed Dec 22, 2021 7:02 pm
- Graphics Processor: Intel (Modern GZDoom)
- Location: Medellin, Colombia
Re: [ZSCRIPT]How to put an overlay on a camera view?
I'm trying out a few different things to see what looks goodDan_The_Noob wrote: ↑Sun Oct 08, 2023 12:35 am IDEA - make overlay the shape of the pixels the keyhole is made off on the door texture
The textures I'm using are pretty low res (I'm revamping a game from 1990), the door is 32x52, the lock is about 5x7 and the keyhole is 3x4. So blowing that up to fullscreen would be like minecraft level chunkiness.
See it here:
Spoiler:So far I love it but I'm still playing with ideas. Like there is a random chance that looking tough the keyhole will just see a big eye looking back and play some jump-scare music
-
- Posts: 877
- Joined: Tue May 07, 2019 12:24 pm
- Graphics Processor: nVidia with Vulkan support
Re: [ZSCRIPT]How to put an overlay on a camera view?
Ya see, make the hole cross-shaped to match right?
attention to detail is a big thing for some people
-
- Posts: 537
- Joined: Wed Dec 22, 2021 7:02 pm
- Graphics Processor: Intel (Modern GZDoom)
- Location: Medellin, Colombia
Re: [ZSCRIPT]How to put an overlay on a camera view?
Yeah, I see what you're saying. But in game design there is a balance between realism and playability. My first try I made it a more realistic looking keyhole slot, a circle with a slit below it like you'd expect an old skeleton key to look. It looked cool but you can't hardley see anything through it because it's so narrow. Anything I want the player to see has got to be right in line with it. So I made the overlay hole more stretched out and exaderated looking. Yes, less realistic, but much more functional.Dan_The_Noob wrote: ↑Sun Oct 08, 2023 10:44 pm Ya see, make the hole cross-shaped to match right?
attention to detail is a big thing for some people
But whatever, the code is posted. On your levels you can make the keyhole look however you want
I also have other parts of the levels where you look into a crystal ball to peek at other parts of the level. I just realized I could make some cool overlays for those too.
-
- Posts: 537
- Joined: Wed Dec 22, 2021 7:02 pm
- Graphics Processor: Intel (Modern GZDoom)
- Location: Medellin, Colombia
Re: [ZSCRIPT]How to put an overlay on a camera view?
I just realized this will draw over the automap. If you don't want that, throw this line in the RenderOverlay:
Code: Select all
override void RenderUnderlay (RenderEvent e)
{
if (automapActive) return;
if (!(e.camera is "MWR_PeekCamera")) return;
Screen.DrawTexture(tKeyhole, false, 0, 0, DTA_FullScreen, 1);
}
-
- Posts: 537
- Joined: Wed Dec 22, 2021 7:02 pm
- Graphics Processor: Intel (Modern GZDoom)
- Location: Medellin, Colombia
-
- Posts: 877
- Joined: Tue May 07, 2019 12:24 pm
- Graphics Processor: nVidia with Vulkan support
Re: [ZSCRIPT]How to put an overlay on a camera view?
maybe just add a binding to shrink it X amount on the key for shrink/grow screen
-
-
- Posts: 1805
- Joined: Sun Jul 21, 2019 8:54 am
Re: [ZSCRIPT]How to put an overlay on a camera view?
There is no need to mess with bindings, you can just check the screenblocks CVar of the player.
-
- Posts: 877
- Joined: Tue May 07, 2019 12:24 pm
- Graphics Processor: nVidia with Vulkan support
-
- Posts: 537
- Joined: Wed Dec 22, 2021 7:02 pm
- Graphics Processor: Intel (Modern GZDoom)
- Location: Medellin, Colombia
Re: [ZSCRIPT]How to put an overlay on a camera view?
so is the CVARs the way to go? Is there no function in screen or somewhere that is aware of the frame?
Also, where can I draw the overlay so that it is under the frame?
Also, where can I draw the overlay so that it is under the frame?
-
- Posts: 537
- Joined: Wed Dec 22, 2021 7:02 pm
- Graphics Processor: Intel (Modern GZDoom)
- Location: Medellin, Colombia