pointSprite.frag 622 Bytes
Newer Older
1
// PointSprite::fragmentShaderText
2

3
4
uniform sampler2D SpriteTexture;
uniform float size;
5
6
7
8
9
10
11
12

#ifdef WITH_COLOR_PER_VERTEX 
	VARYING_FRAG vec3 colorsprite;
#else
	uniform vec3 colorsprite;
#endif


13
14
15
16
17
18
19
20
21
22
23
24
VARYING_FRAG vec2 texCoord;
VARYING_FRAG vec2 positionFragIn;
VARYING_FRAG vec4 mvpFragIn;
void main(void)
{
	float lum = texture2D(SpriteTexture, texCoord).s;
	if (lum==0.0)
		discard;
	vec2 v = texCoord-vec2(0.5,0.5);
	float z = size * sqrt(1.0-dot(v,v));
	vec2 zfrag = positionFragIn + vec2(z,0.0);
	gl_FragDepth = 0.5 + 0.5 * dot(zfrag, mvpFragIn.xy) / dot(zfrag, mvpFragIn.zw);
25
26
	gl_FragColor = vec4(colorsprite,0.0)*lum;
}