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!
(Sorry if my english is bad)
Define uniforms in non-postprocess shaders
Moderator: GZDoom Developers
-
- Posts: 1
- Joined: Wed Jul 03, 2019 12:05 am
- Contact:
Re: Define uniforms in non-postprocess shaders
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.
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.
- 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
- Contact:
Re: Define uniforms in non-postprocess shaders
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.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49073
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Define uniforms in non-postprocess shaders
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