Page 1 of 1
A way to control an actor/sprite shader, to turn it on & off?
Posted: Fri May 24, 2024 3:29 am
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.
Re: A way to control an actor/sprite shader, to turn it on & off?
Posted: Fri May 24, 2024 4:04 am
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.
Re: A way to control an actor/sprite shader, to turn it on & off?
Posted: Fri May 24, 2024 11:39 am
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"?
Re: A way to control an actor/sprite shader, to turn it on & off?
Posted: Sat May 25, 2024 12:19 am
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.
Re: A way to control an actor/sprite shader, to turn it on & off?
Posted: Tue May 28, 2024 6:35 am
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.