Define uniforms in non-postprocess shaders

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

Moderator: GZDoom Developers

Define uniforms in non-postprocess shaders

Postby emprosthotonos » Wed Jul 03, 2019 12:31 am

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) :?
Joined: 03 Jul 2019
Github ID: glhrmfrts

Re: Define uniforms in non-postprocess shaders

Postby dpJudas » Wed Jul 03, 2019 3:55 am

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.
Joined: 28 May 2016

Re: Define uniforms in non-postprocess shaders

Postby Marisa the Magician » Thu May 19, 2022 3:37 pm

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
Marisa the Magician
ZScript Crimester
Joined: 08 Feb 2008
Location: Vigo, Galicia
Discord: Marisa the Magician#1666
Twitch ID: MarisaDOOM
Github ID: OrdinaryMagician
Operating System: Other Linux 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Define uniforms in non-postprocess shaders

Postby Graf Zahl » Thu May 19, 2022 4:05 pm

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
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Joined: 19 Jul 2003
Location: Germany

Return to Feature Suggestions

Who is online

Users browsing this forum: No registered users and 0 guests