
uniform vec2 glow;
uniform float ambientbri;
uniform sampler3D noise3d;
uniform sampler2D textuuri;
uniform sampler2D envi;

varying float brite;
varying float distance;
varying vec3 tpos;
varying float alphashit;
varying float poks;
varying vec2 envidir;

const float ambient=0.0625;



void main() {	

  vec3 col1 = brite*vec3(1.0, 0.975, 0.925);
  vec3 col2 = ambientbri*ambient*vec3(0.3, 0.6, 1.0);

  vec3 tpos2=tpos*0.5-mod(tpos, 10.0);
  float tex = texture3D(noise3d, tpos2*0.25).r;
  //tex = tex-texture3D(noise3d, tpos*0.02).r*0.6;
  tex *= texture2D(textuuri, tpos.xy*0.4);
  tex = 1.0-tex*0.5;
  tex *= texture2D(envi, envidir);
  
  if (alphashit==0.0) discard;
  
  vec3 plusplus = vec3(poks*2.0, poks*1.0, poks*0.5)*1.5;

  gl_FragData[0] = vec4((col1*col1+col2*4.0)*tex*glow.y+vec3(0.35, 0.5, 1.0)*glow.x+plusplus, 1.0);
  //gl_FragData[0] = vec4(poks, poks, poks, 1.0);
  gl_FragData[1].r = distance;
}
