[help] loop through array

[help] loop through array

Postby zrrion the insect » Sat Jun 23, 2018 5:24 am

I have a shader:
Code: Select allExpand view
void main()
   vec3 colour = texture(InputTexture, TexCoord).rgb;
   vec3 cyan = vec3(0.0, 1.0, 1.0);
   vec3 rainbow[6] = {   vec3(0.93, 0.75, 0.60), vec3(1.00, 0.59, 0.23, vec3(0.97, 0.94, 0.30), vec3(0.75, 0.89, 0.30), vec3(0.72, 0.82, 0.93), vec3(0.92, 0.51, 0.90) };

   if (colour == cyan)   
      FragColor = vec4(rainbow[int(timer/35) % 6], 0.0);
      FragColor = vec4(colour, 1.0);
and in gldefs I have:
Code: Select allExpand view
HardwareShader PostProcess Screen
   Name "CyanShader"
   Shader "shaders/PostProcess/CYAN.fp" 330
   Uniform float timer

I am trying to get it to recolor all cyan on the screen to the colours in the array. Idealy it should switch colours after 6 tics.
Presently it will recolor cyan, but it does not cycle through the array. Could someone point me in the right direction?
User avatar
zrrion the insect
Like a fish in a child's hands.
Joined: 25 Jun 2009
Location: Time Station 1: Moon of Glendale

Re: [help] loop through array

Postby Pixel Eater » Sat Jun 23, 2018 6:20 am

Do you already have the timer being sent from ZScript? Something like:

Code: Select allExpand view
class "Your Event Handler" : EventHandler
   override void RenderOverlay( RenderEvent e )
      Shader.SetUniform1f( players[ consoleplayer ], "Your Shader Name", "timer", gametic + e.FracTic );

Edit: Actually if you're going by ticks you could possibly use 'override void WorldTick()' instead of the RenderOverlay() stuff and leave off '+ e.FracTic'.
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 Shaders

Who is online

Users browsing this forum: No registered users and 1 guest