#include "common.hlsli"

struct 	v2p
{
 	float2 	tc0: 		TEXCOORD0;	// base
 	float3 	tc1: 		TEXCOORD1;	// environment
  	float4	c0:			COLOR0;		// sun.(fog*fog)
};

// Pixel
uniform	float4 		m_actor_params;
uniform	float4 		m_affects;

float get_noise(float2 co)
{
	return (frac(sin(dot(co.xy ,float2(12.9898,78.233))) * 43758.5453))*0.5;
};


float4 	main( v2p I ): COLOR
{
	// широкая полоска искажений	
	float problems = cos( ( frac( timers.z * 4 ) - 0.5 ) * 3.1416 )*2 - 0.8;
	float AMPL = 0.3;
	I.tc0.y -= ( m_affects.x > 0.15 && I.tc0.x > problems-AMPL && I.tc0.x < problems+AMPL) ? cos(4.71*(I.tc0.x-problems)/AMPL) * sin( frac(timers.z)*6.2831*90 )  * (m_affects.x/10) * (AMPL-abs(I.tc0.x-problems))/AMPL : 0;
	
	float4	t_base 		= tex2D		(s_base,	I.tc0);		
	
	float tmp = 1-m_actor_params.y;
	tmp = clamp(tmp, 0, 0.5);
	t_base.r +=tmp*t_base.a;
	
	tmp = 0.5-abs(m_actor_params.y-0.5);
	tmp = clamp(tmp, 0, 0.5);	
	t_base.g +=tmp*t_base.a;
		

	// Шум при выбросе
	float noise	= get_noise(I.tc0*timers.z) * m_affects.x * 2;		
	t_base.r += noise;
	t_base.g += noise;
	t_base.b += noise;
	
	return  float4	(t_base.r, t_base.g, t_base.b, 1);
}

