aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/FixedFuncPoints.vp
blob: 4a5d93a3d81adbcc6f0574af38cdcd69f774c262 (plain)
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

#if __VERSION__ >= 130
  #define attribute in
  #define varying out
#endif

#include es_precision.glsl

#include mgl_const.glsl
#include mgl_uniform.glsl
#include mgl_attribute.glsl
#include mgl_varying.glsl

#include mgl_settexcoord.vp

void main(void)
{
  if( mgl_ColorEnabled > 0 ) {
    frontColor = mgl_Color;
  } else {
    frontColor = mgl_ColorStatic;
  }

  vec4 eyeCoord = mgl_PMVMatrix[1] * mgl_Vertex;
  gl_Position = mgl_PMVMatrix[0] * eyeCoord;

  float dist = distance(eyeCoord, vec4(0.0, 0.0, 0.0, 1.0));
  float atten = sqrt( 1.0 / ( pointDistanceConstantAtten +
                              ( pointDistanceLinearAtten +
                                pointDistanceQuadraticAtten * dist
                              ) * dist
                            )
                    );
  float size = clamp(pointSize * atten, pointSizeMin, pointSizeMax);
  gl_PointSize = max(size, pointFadeThresholdSize);

  float fade = min(size, pointFadeThresholdSize) / pointFadeThresholdSize;
  frontColor.a *= fade * fade;
}