I've implemented a new feature for GZDoom, but I'd like feedback on its interface before submitting a pull request. The feature is "Named Hardware Shaders". The basic idea is that, rather than assigning a shader
to an image at design time, you can, instead, setup a "named" shader, that can be assigned
to an actor at runtime, via ZScript. Being assigned to the actor, the shader will be used when rendering whatever sprite the actor currently displays.
The interface for this feature (explained below) is where I'd like feedback. I
think it's a pretty good interface, but I'm only one novice GZDoom user. Any comments or critiques are more than welcome. Also, if you like the feature as-is, posting to express this will (hopefully) help it be accepted into GZDoom more quickly.
Here's the interface:
1) In the GLDEFS file/lump, where you usually write "HardwareShader" definitions, you can write "NamedHardwareShader" definitions. The syntax is similar, except that there's no type, and the lumpname is replaced with a shader-name to be referenced in ZScript.
Example:
Code: Select all
NamedHardwareShader highlight1
{
Shader "shaders/hilight1.fp"
}
2) In ZScript you call `TexMan.GetNamedShader(name)` to get the numerical id of the named shader defined in GLDEFS, then you set the new actor field "Shader" to it. This makes the actor render with the shader. Two special Shader ids are -1 (to use the default shader of the rendered image) and 0 (to enforce NO shader). For example:
Code: Select all
myActor.Shader = TexMan.GetNamedShader("highlight1"); // The actor will render with the "highlight" shader
myActor.Shader = -1; // The actor will render with whatever shaders are attached to its images in GLDEFS (or no shaders, if none are attached)
myActor.Shader = 0; // The actor will render with NO shaders, even if its images have shaders attached
So, my implementation works fine for the basic examples I've tried it with. I am new to GZDoom source code, so I wouldn't be surprised if there's a gotcha or two the main dev's will point out. The speed parameter might need some work, for example. However, I think that it's a viable solution. If you are curious,
here's a link to the commit that adds this feature.
Thanks for any feedback you can provide!