A way to control an actor/sprite shader, to turn it on & off?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

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!)
Post Reply
violgamba
Posts: 41
Joined: Wed Apr 10, 2024 4:53 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10

A way to control an actor/sprite shader, to turn it on & off?

Post by violgamba »

I need to be able to modify parameters for a shader on a particular actor and/or sprite. Minimally, I need to enable/disable a shader at runtime, but if I can control it else-ways then I can simply have the shader bypass its effect when "disabled". The only information I've found regarding shader control has focused on post-processing shaders. What I've got is a "HardwareShader Sprite" gldef entry, which attaches the shader to a particular sprite.

FYI, what I'm trying to do is to implement a hover-highlight effect on certain kinds of Actors. At worst, I can just add a "HardwareShader Sprite" gldefs entry for every sprite used by these Actors, but really I need to be able to toggle the shaders for this to work. I've tried highlighting the hovered Actor by pulsing its alpha, but while this works it really doesn't look good.

Anybody know of a way to toggle a sprite shader? FYI, I am comfortable with ZScript.
User avatar
Cherno
Posts: 1337
Joined: Tue Dec 06, 2016 11:25 am

Re: A way to control an actor/sprite shader, to turn it on & off?

Post by Cherno »

Not possible.
The ony options are
a) Post-Processing with masking (changing the actor's RenderStye to Stencil, for example). Breaks down with AA and transparency.
b) Changing the actor's sprite to a graphic lump that has the shader you want(or back). Cumbersome to implement for all sprite possiblities.
violgamba
Posts: 41
Joined: Wed Apr 10, 2024 4:53 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10

Re: A way to control an actor/sprite shader, to turn it on & off?

Post by violgamba »

Thanks for replying so quickly, though sad news.

Regarding your suggestion A: if I understand you right, are you suggesting the Renderstyle where an actor is rendered as a single solid color? I did try that: blinking RenderStyle-Stencil on and off while hovered (trying both white and black shade). However, it was harsh on the eyes and using Renderstyle-Translucent and strobing the alpha looks better IMO. Not great, but better.

Also, what do you mean by "breaks down with AA and transparency"?
User avatar
Cherno
Posts: 1337
Joined: Tue Dec 06, 2016 11:25 am

Re: A way to control an actor/sprite shader, to turn it on & off?

Post by Cherno »

If a post-processing shader checks each screen pixel for the mask color, there will be problems once a a masked sprite has it's edge pixels on screen smoothed by AA or has transparency and has stuff behind it. Both affect the pixel color and thereby the reliability of the post-processing shader mask color detection.
violgamba
Posts: 41
Joined: Wed Apr 10, 2024 4:53 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10

Re: A way to control an actor/sprite shader, to turn it on & off?

Post by violgamba »

Hmm. Thanks for explaining this, Cherno. It sounds like having a "normal" and a "highlighted" version of each highlight-able image is the best solution at the moment. I think a script that takes an image list and duplicates each image and generates a GLDEFS file would make this reasonable.

FYI, I've coded a feature for GZDoom that addresses my issue and am hoping for feedback before I post a pull-request for it. I've added it to the ZDoom forums here. If you, or anyone else is interested in giving feedback or just a thumbs up, please check it out.
Post Reply

Return to “Scripting”