[SOLVED] timer uniform in custom post processing shader

Ask about editing graphics, sounds, models, music, etc here!
Shaders (GLSL) and SNDINFO questions also go here!

Moderators: GZDoom Developers, Raze Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

[SOLVED] timer uniform in custom post processing shader

Postby hg82 » Tue Apr 03, 2018 2:42 pm

Hey everybody,

I went out to add some nice post processing shaders to GzDoom. Right now I'm working on a vignette shader and I try to animate the vignette.
As far as I understand the wiki I should be able to use a timer uniform through just defining it at the top of my shader.

But the mentioned
Code: Select allExpand view
uniform float timer;
doesn't do anything. It seams to always be 0...

Is the timer not working for post processing shaders or am I missing something? Could someone please point me in the right direction?
I spent hours to get this working without results...

Any help is much appreciated.

Cheers
HG
Last edited by hg82 on Mon Apr 09, 2018 3:06 am, edited 1 time in total.
User avatar
hg82
 
Joined: 22 Mar 2018

Re: timer uniform in custom post processing shader

Postby Pixel Eater » Tue Apr 03, 2018 5:01 pm

In your Zscript file you'll need to add the line:

Code: Select allExpand view
Shader.SetUniform1f( p, "Shader Name", "timer", ( gametic + e.FracTic ) * 1 / 35 ) ;

I'm not good with terminology but it should go in the "event block?"
User avatar
Pixel Eater
I sense evil I fear it here today, Like a bad dream that never goes away -MBerry
 
 
 
Joined: 02 Aug 2017
Location: In between the Moon and you, between the buried and me.

Re: timer uniform in custom post processing shader

Postby hg82 » Mon Apr 09, 2018 3:06 am

Thanks Pixel Eater!

I could figure it out.

You need to have something like this in your ZSCRIPT lump:
Code: Select allExpand view
class ShaderTimer : EventHandler
{
   override void RenderOverlay(RenderEvent e)
   {
      // thanks to Pixel Eater from the ZDoom Forums!!!
      float timer = (gametic +  e.FracTic) * 1 / 35;
      // set timer uniforms for the shaders
      Shader.SetUniform1f(players[consoleplayer], "PostVignette", "timer", timer);
      Shader.SetUniform1f(players[consoleplayer], "PostNoise", "timer", timer);
   }
}


Then you need to add your event handler class in the "gameinfo" block inside your "mapinfo" lump
Code: Select allExpand view
gameinfo
{
   AddEventHandlers = "ShaderTimer"
}


Again: Thank you very much... Couldn't have figured it out without your help.
User avatar
hg82
 
Joined: 22 Mar 2018

Re: [SOLVED] timer uniform in custom post processing shader

Postby Pixel Eater » Wed Apr 11, 2018 3:03 pm

I'm glad it worked despite my shoddy explanation :wink:
User avatar
Pixel Eater
I sense evil I fear it here today, Like a bad dream that never goes away -MBerry
 
 
 
Joined: 02 Aug 2017
Location: In between the Moon and you, between the buried and me.


Return to Assets (and other stuff)

Who is online

Users browsing this forum: No registered users and 0 guests