1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
/*
* File: SeparateAlphaTextureShader.frag.txt
* Shader for drawing of textures where the alpha channel is looked up
* separately from the RGB channels, i.e. RGB texel lookup uses texture
* coordinates offset by given optional shift parameters.
*
* (c) 2009 - 2016 by Mario Kleiner, licensed under MIT license.
*
*/
/* Attributes passed from Screen(): See the ProceduralShadingAPI.m file for infos: */
attribute vec4 modulateColor;
attribute vec4 auxParameters0;
/* Information passed to the fragment shader: */
varying vec4 baseColor;
void main()
{
/* Apply standard geometric transformations to patch: */
gl_Position = ftransform();
/* Alpha: Do not pass real texture coordinates, but ones corrected for hardware offsets (-0.5,0.5) */
gl_TexCoord[0] = (gl_TextureMatrix[0] * gl_MultiTexCoord0) + vec4(-0.5, 0.5, 0.0, 0.0);
/* Color: Apply offsets to primary texcoords, then pass them as secondary texcoords set: */
/* Start with original texcoords: */
vec4 modTexCoord = gl_MultiTexCoord0;
/* Add (x,y) offset passed in 3rd and 4th auxParameters0 elements: */
modTexCoord.xy = modTexCoord.xy + auxParameters0.zw;
/* Correct for hw offsets, apply texture matrix: */
gl_TexCoord[1] = (gl_TextureMatrix[0] * modTexCoord) + vec4(-0.5, 0.5, 0.0, 0.0);
/* Apply (x,y) offsets past matrix transformations, from 1st and 2nd auxParameters0 elements: */
gl_TexCoord[1].xy = gl_TexCoord[1].xy + auxParameters0.xy;
/* Pass through modulateColor: */
baseColor = modulateColor;
}
|