1uniform mat4 g_WorldViewProjectionMatrix; 2 3attribute vec3 inPosition; 4attribute vec4 inColor; 5attribute vec4 inTexCoord; 6 7varying vec4 color; 8 9#ifdef USE_TEXTURE 10varying vec4 texCoord; 11#endif 12 13#ifdef POINT_SPRITE 14uniform mat4 g_WorldViewMatrix; 15uniform mat4 g_WorldMatrix; 16uniform vec3 g_CameraPosition; 17uniform float m_Quadratic; 18const float SIZE_MULTIPLIER = 4.0; 19attribute float inSize; 20#endif 21 22void main(){ 23 vec4 pos = vec4(inPosition, 1.0); 24 25 gl_Position = g_WorldViewProjectionMatrix * pos; 26 color = inColor; 27 28 #ifdef USE_TEXTURE 29 texCoord = inTexCoord; 30 #endif 31 32 #ifdef POINT_SPRITE 33 vec4 worldPos = g_WorldMatrix * pos; 34 float d = distance(g_CameraPosition.xyz, worldPos.xyz); 35 gl_PointSize = max(1.0, (inSize * SIZE_MULTIPLIER * m_Quadratic) / d); 36 37 //vec4 worldViewPos = g_WorldViewMatrix * pos; 38 //gl_PointSize = (inSize * SIZE_MULTIPLIER * m_Quadratic)*100.0 / worldViewPos.z; 39 40 color.a *= min(gl_PointSize, 1.0); 41 #endif 42}