in vec4 varColor;
in vec2 varTexCoord;
#ifdef USE_FOG
in float varFog;
#endif  // USE_FOG
#ifdef USE_ENV
in vec2 varEnvCoord;
#endif  // USE_ENV

// textures
uniform sampler2D diffuseTexture;
#ifdef USE_ENV
uniform sampler2D envTexture;
#endif  // USE_ENV

// constants
BeginBlock(Constants)
_uniform vec3 shadowColor;
_uniform vec3 fogColor;
_uniform vec2 fogParams;
EndBlock

// params
BeginBlock(Params)
_uniform vec4 modelUpVec;
_uniform vec4 effectParams;
_uniform vec3 mirrorParams;
_uniform float alphaRef;
_uniform vec3 tint;
_uniform vec3 envColor;
_uniform vec3 envMatX;
_uniform vec3 envMatY;
_uniform bool envGood;
EndBlock

void main(void)
{
  vec4 diffuse = texture(diffuseTexture, varTexCoord);
  #ifdef ALPHA_TEST
  if (diffuse.a < alphaRef) {
    discard;
  }
  #endif  // ALPHA_TEST
  outColor = varColor * diffuse;

  #ifdef USE_ENV
  vec3 specular = texture(envTexture, varEnvCoord).rgb;
  outColor.rgb += envColor * specular;
  #endif  // USE_ENV

  #ifdef USE_FOG
  outColor.rgb = mix(fogColor, outColor.rgb, varFog);
  #endif  // USE_FOG
}
