[SOLVED] timer uniform in custom post processing shader

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.

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: [SOLVED] timer uniform in custom post processing shader

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

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

I'm glad it worked despite my shoddy explanation :wink:

Re: timer uniform in custom post processing shader

by 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 all

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 all

gameinfo
{
	AddEventHandlers = "ShaderTimer"
}
Again: Thank you very much... Couldn't have figured it out without your help.

Re: timer uniform in custom post processing shader

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

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

Code: Select all

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?"

[SOLVED] timer uniform in custom post processing shader

by 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 all

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

Top