Define uniforms in non-postprocess shaders

Remember, just because you request it, that doesn't mean you'll get it.

Moderator: GZDoom Developers

Posts: 1
Joined: Wed Jul 03, 2019 12:05 am

Define uniforms in non-postprocess shaders

Post by emprosthotonos »

Hello all, this is my first post here.

I'm trying to procedurally render an actor's sprite (color would depend on the player's actions), and I tried to define a Sprite shader and define a uniform so I can set the value in my actor's code every tick, but I noticed it wasn't working and the API was a little weird for that. I thought I had to define one shader per frame of my sprite so I could use the shader's name depending on the current actor's frame, but obviously that didn't work so I took a look at the source code and noticed that uniforms only get parsed when it's a PostProcess shader.

I know a little bit about graphics programming and know that there's probably some batching involved when rendering the actors, so adding the possibility of defining uniforms per-actor could be very difficult or drastically reduce rendering performance. But I just need to confirm if it isn't possible at all atm, and is there some plans to do this in the foreseeable future? For my specific use-case I could work with setting the uniforms 1 time per frame but NOT per actor, I think that would be simpler to add, right?

Also, now that I'm thinking... I think I could work with a post-process shader but I would need to calculate the screen position of the actor, and I didn't see any projection/view matrix listed on the uniforms in the GLDEFS wiki page.

Anyways, if any of you had to do this at some point and came up with a work-around please tell me, thanks! :D

(Sorry if my english is bad) :?
Posts: 3053
Joined: Sat May 28, 2016 1:01 pm

Re: Define uniforms in non-postprocess shaders

Post by dpJudas »

There is currently no support for this, although it has been requested by several people. There is also no official way to request the active projection or view matrices (there may be several if portals are involved, or if VR is active).

Nobody is actively working on adding uniforms to the texture shaders. It isn't so easy because they may be used for walls, planes, actors and 2D. How to design where the inputs for the uniforms comes from is a bigger part of the problem than how to upload it.
User avatar
Marisa the Magician
Posts: 3886
Joined: Fri Feb 08, 2008 9:15 am
Preferred Pronouns: She/Her
Operating System Version (Optional): (btw I use) Arch
Graphics Processor: nVidia with Vulkan support
Location: Vigo, Galicia

Re: Define uniforms in non-postprocess shaders

Post by Marisa the Magician »

Apologies for this three-year bump but... I was wondering if this could be revived. Mostly so because the current way to somehow "hackily" pass uniforms to material shaders is through sampling from camera textures, and it's... Less than desirable, to be honest, especially considering there are many ways this could go wrong.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49095
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Define uniforms in non-postprocess shaders

Post by Graf Zahl »

Find someone with the time and knowledge to add all that's needed for this and we're good to go. This isn't something that can quickly be tossed in and works

Return to “Feature Suggestions [GZDoom]”