points.uniforms
uniforms: UniformsUtils.merge( [
/* UniformsLib.points
*/
{
diffuse : { value : new Color( 0xeeeeee ) },
opacity : { value : 1.0 },
size : { value : 1.0 },
scale : { value : 1.0 },
map : { value : null },
uvTransform : { value : new Matrix3() }
}
/* UniformsLib.fog
*/
{
fogDensity : { value : 0.00025 },
fogNear : { value : 1 },
fogFar : { value : 2000 },
fogColor : { value : new Color( 0xffffff ) }
}
] ),
points_vert.glsl
uniform float size;
uniform float scale;
/* common.glsl */
#define PI 3.14159265359
#define PI2 6.28318530718
#define PI_HALF 1.5707963267949
#define RECIPROCAL_PI 0.31830988618
#define RECIPROCAL_PI2 0.15915494
#define LOG2 1.442695
#define EPSILON 1e-6
#define saturate(a) clamp( a, 0.0, 1.0 )
#define whiteCompliment(a) ( 1.0 - saturate( a ) )
float pow2( const in float x ) { return x*x; }
float pow3( const in float x ) { return x*x*x; }
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
float average( const in vec3 color ) { return dot ( color, vec3 ( 0.3333 ) ); }
highp float rand( const in vec2 uv ) {
const highp float a = 12.9898 , b = 78.233 , c = 43758.5453 ;
highp float dt = dot ( uv.xy, vec2 ( a,b ) ), sn = mod ( dt, PI );
return fract (sin (sn) * c);
}
struct IncidentLight {
vec3 color;
vec3 direction;
bool visible;
};
struct ReflectedLight {
vec3 directDiffuse;
vec3 directSpecular;
vec3 indirectDiffuse;
vec3 indirectSpecular;
};
struct GeometricContext {
vec3 position;
vec3 normal;
vec3 viewDir;
};
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
return normalize ( ( matrix * vec4 ( dir, 0.0 ) ).xyz );
}
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
return normalize ( ( vec4 ( dir, 0.0 ) * matrix ).xyz );
}
vec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {
float distance = dot ( planeNormal, point - pointOnPlane );
return - distance * planeNormal + point;
}
float sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {
return sign ( dot ( point - pointOnPlane, planeNormal ) );
}
vec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {
return lineDirection * ( dot ( planeNormal, pointOnPlane - pointOnLine ) / dot ( planeNormal, lineDirection ) ) + pointOnLine;
}
mat3 transposeMat3( const in mat3 m ) {
mat3 tmp;
tmp[ 0 ] = vec3 ( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
tmp[ 1 ] = vec3 ( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
tmp[ 2 ] = vec3 ( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
return tmp;
}
float linearToRelativeLuminance( const in vec3 color ) {
vec3 weights = vec3 ( 0.2126 , 0.7152 , 0.0722 );
return dot ( weights, color.rgb );
}
/* color_pars_vertex.glsl */
#ifdef USE_COLOR
varying vec3 vColor;
#endif
/* fog_pars_vertex.glsl */
#ifdef USE_FOG
varying float fogDepth;
#endif
/* morphtarget_pars_vertex.glsl */
#ifdef USE_MORPHTARGETS
#ifndef USE_MORPHNORMALS
uniform float morphTargetInfluences[ 8 ];
#else
uniform float morphTargetInfluences[ 4 ];
#endif
#endif
/* logdepthbuf_pars_vertex.glsl */
#ifdef USE_LOGDEPTHBUF
#ifdef USE_LOGDEPTHBUF_EXT
varying float vFragDepth;
#else
uniform float logDepthBufFC;
#endif
#endif
/* clipping_planes_pars_vertex.glsl */
#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG ) && ! defined( MATCAP )
varying vec3 vViewPosition;
#endif
void main() {
/* color_vertex.glsl */
#ifdef USE_COLOR
vColor.xyz = color.xyz;
#endif
/* begin_vertex.glsl */
vec3 transformed = vec3 ( position );
/* morphtarget_vertex.glsl */
#ifdef USE_MORPHTARGETS
transformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];
transformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];
transformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];
transformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];
#ifndef USE_MORPHNORMALS
transformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];
transformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];
transformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];
transformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];
#endif
#endif
/* project_vertex.glsl */
vec4 mvPosition = modelViewMatrix * vec4 ( transformed, 1.0 );
gl_Position = projectionMatrix * mvPosition;
gl_PointSize = size;
#ifdef USE_SIZEATTENUATION
bool isPerspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 );
if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
#endif
/* logdepthbuf_vertex.glsl */
#ifdef USE_LOGDEPTHBUF
#ifdef USE_LOGDEPTHBUF_EXT
vFragDepth = 1.0 + gl_Position .w;
#else
gl_Position .z = log2 ( max ( EPSILON, gl_Position .w + 1.0 ) ) * logDepthBufFC - 1.0 ;
gl_Position .z *= gl_Position .w;
#endif
#endif
/* clipping_planes_vertex.glsl */
#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG ) && ! defined( MATCAP )
vViewPosition = - mvPosition.xyz;
#endif
/* worldpos_vertex.glsl */
#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )
vec4 worldPosition = modelMatrix * vec4 ( transformed, 1.0 );
#endif
/* fog_vertex.glsl */
#ifdef USE_FOG
fogDepth = -mvPosition.z;
#endif
}
points_frag.glsl
uniform vec3 diffuse;
uniform float opacity;
/* common.glsl */
#define PI 3.14159265359
#define PI2 6.28318530718
#define PI_HALF 1.5707963267949
#define RECIPROCAL_PI 0.31830988618
#define RECIPROCAL_PI2 0.15915494
#define LOG2 1.442695
#define EPSILON 1e-6
#define saturate(a) clamp( a, 0.0, 1.0 )
#define whiteCompliment(a) ( 1.0 - saturate( a ) )
float pow2( const in float x ) { return x*x; }
float pow3( const in float x ) { return x*x*x; }
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
float average( const in vec3 color ) { return dot ( color, vec3 ( 0.3333 ) ); }
highp float rand( const in vec2 uv ) {
const highp float a = 12.9898 , b = 78.233 , c = 43758.5453 ;
highp float dt = dot ( uv.xy, vec2 ( a,b ) ), sn = mod ( dt, PI );
return fract (sin (sn) * c);
}
struct IncidentLight {
vec3 color;
vec3 direction;
bool visible;
};
struct ReflectedLight {
vec3 directDiffuse;
vec3 directSpecular;
vec3 indirectDiffuse;
vec3 indirectSpecular;
};
struct GeometricContext {
vec3 position;
vec3 normal;
vec3 viewDir;
};
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
return normalize ( ( matrix * vec4 ( dir, 0.0 ) ).xyz );
}
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
return normalize ( ( vec4 ( dir, 0.0 ) * matrix ).xyz );
}
vec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {
float distance = dot ( planeNormal, point - pointOnPlane );
return - distance * planeNormal + point;
}
float sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {
return sign ( dot ( point - pointOnPlane, planeNormal ) );
}
vec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {
return lineDirection * ( dot ( planeNormal, pointOnPlane - pointOnLine ) / dot ( planeNormal, lineDirection ) ) + pointOnLine;
}
mat3 transposeMat3( const in mat3 m ) {
mat3 tmp;
tmp[ 0 ] = vec3 ( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
tmp[ 1 ] = vec3 ( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
tmp[ 2 ] = vec3 ( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
return tmp;
}
float linearToRelativeLuminance( const in vec3 color ) {
vec3 weights = vec3 ( 0.2126 , 0.7152 , 0.0722 );
return dot ( weights, color.rgb );
}
/* color_pars_fragment.glsl */
#ifdef USE_COLOR
varying vec3 vColor;
#endif
/* map_particle_pars_fragment.glsl */
#ifdef USE_MAP
uniform mat3 uvTransform;
uniform sampler2D map;
#endif
/* fog_pars_fragment.glsl */
#ifdef USE_FOG
uniform vec3 fogColor;
varying float fogDepth;
#ifdef FOG_EXP2
uniform float fogDensity;
#else
uniform float fogNear;
uniform float fogFar;
#endif
#endif
/* logdepthbuf_pars_fragment.glsl */
#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
uniform float logDepthBufFC;
varying float vFragDepth;
#endif
/* clipping_planes_pars_fragment.glsl */
#if NUM_CLIPPING_PLANES > 0
#if ! defined( PHYSICAL ) && ! defined( PHONG ) && ! defined( MATCAP )
varying vec3 vViewPosition;
#endif
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif
void main() {
/* clipping_planes_fragment.glsl */
#if NUM_CLIPPING_PLANES > 0
vec4 plane;
#pragma unroll_loop
for ( int i = 0 ; i < UNION_CLIPPING_PLANES; i ++ ) {
plane = clippingPlanes[ i ];
if ( dot ( vViewPosition, plane.xyz ) > plane.w ) discard ;
}
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
bool clipped = true ;
#pragma unroll_loop
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
plane = clippingPlanes[ i ];
clipped = ( dot ( vViewPosition, plane.xyz ) > plane.w ) && clipped;
}
if ( clipped ) discard ;
#endif
#endif
vec3 outgoingLight = vec3 ( 0.0 );
vec4 diffuseColor = vec4 ( diffuse, opacity );
/* logdepthbuf_fragment.glsl */
#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
gl_FragDepthEXT = log2 ( vFragDepth ) * logDepthBufFC * 0.5 ;
#endif
/* map_particle_fragment.glsl */
#ifdef USE_MAP
vec2 uv = ( uvTransform * vec3 ( gl_PointCoord .x, 1.0 - gl_PointCoord .y, 1 ) ).xy;
vec4 mapTexel = texture2D ( map, uv );
diffuseColor *= mapTexelToLinear( mapTexel );
#endif
/* color_fragment.glsl */
#ifdef USE_COLOR
diffuseColor.rgb *= vColor;
#endif
/* alphatest_fragment.glsl */
#ifdef ALPHATEST
if ( diffuseColor.a < ALPHATEST ) discard ;
#endif
outgoingLight = diffuseColor.rgb;
gl_FragColor = vec4 ( outgoingLight, diffuseColor.a );
/* premultiplied_alpha_fragment.glsl */
#ifdef PREMULTIPLIED_ALPHA
gl_FragColor .rgb *= gl_FragColor .a;
#endif
/* tonemapping_fragment.glsl */
#if defined( TONE_MAPPING )
gl_FragColor .rgb = toneMapping( gl_FragColor .rgb );
#endif
/* encodings_fragment.glsl */
gl_FragColor = linearToOutputTexel( gl_FragColor );
/* fog_fragment.glsl */
#ifdef USE_FOG
#ifdef FOG_EXP2
float fogFactor = whiteCompliment( exp2 ( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );
#else
float fogFactor = smoothstep ( fogNear, fogFar, fogDepth );
#endif
gl_FragColor .rgb = mix ( gl_FragColor .rgb, fogColor, fogFactor );
#endif
}
Back to Index Source