Jump to content

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


Recommended Posts

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.

Edited by violgamba

Share this post


Link to post

Oh man thats a rough one, no lie. 

 

So this type of action should be able to get handled with a function Similar to A_AttachLight and the trigger just depends on what you want to trigger the Function during a specific  State of the actor entering or exiting. Best I can do is give you an example with no guarantee of it working.

 

1. Gldef  file

------Define Hardware Shader

Spoiler

HardwareShader [Type] <LumpName>
{
	Shader "<File>"
}
  
HardwareShader Sprite TROSA
  {
    Materials/Specualar/SpecualarImp.txt
  }

 

--- Make a separate actor or copy the graphic/lump you want to attach the shader to that uses a different lump name

    EX: TROOa and TROSA  where they are both the same actual graphic as TROOa (being Doom IMp frame A in this example)

 

--- Then you need to write the action frames of the Actor to get the effect you are wanting to achieve

 EX: In the this case the Shader Sprite would hopefully be called during the "Spawn" State loop and any other time it calls the TROSA frame.

Spoiler

Actor Dumymp : DoomImp replaces DoomImp
{
  States
  {
    Spawn:
        TROO A 2 A_look
	    TROS A 2 A_Look // THis frame being the applied shader frame
        Loop
}
}

 

 

Share this post


Link to post

Thanks for this suggestion, Kalensar.  It seems like the best way to go, given the current interface.  I can write a script to take a list of images that need to be highlighted, which duplicates each image (for the highlighted version) and generates a GLDEFS file for all images and their highlighted counterparts.

 

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, Kalensar, or anyone else is interested in giving feedback or just a thumbs up, please check it out.

Edited by violgamba

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...