diff --git a/src/shaders/bounding-box.frag b/src/shaders/bounding-box.frag index ed44783..4d0620d 100644 --- a/src/shaders/bounding-box.frag +++ b/src/shaders/bounding-box.frag @@ -14,12 +14,11 @@ in vec4 vPosition; #ifdef SHADOW out vec4 fragColor; - - uniform vec2 cameraNearFar; - uniform vec3 cameraPos; #endif uniform float time; +uniform vec2 cameraNearFar; +uniform vec3 cameraPos; void main() { float phase = vPositionWithoutModel.x + vPositionWithoutModel.y + vPositionWithoutModel.z; @@ -30,7 +29,12 @@ void main() { } #ifdef FORWARD - fragColor = vec4( 1.0 ); + vec3 color = vec3( 1.0 ); + + float lenV = length( cameraPos - vPosition.xyz ); + color *= exp( -0.4 * max( lenV - 3.0, 0.0 ) ); + + fragColor = vec4( color, 1.0 ); #endif #ifdef SHADOW diff --git a/src/shaders/flicky-particles-render.frag b/src/shaders/flicky-particles-render.frag index 6a54f09..8b00009 100644 --- a/src/shaders/flicky-particles-render.frag +++ b/src/shaders/flicky-particles-render.frag @@ -45,11 +45,11 @@ uniform sampler2D samplerRandomStatic; #ifdef DEPTH out vec4 fragColor; - - uniform vec2 cameraNearFar; - uniform vec3 cameraPos; #endif +uniform vec2 cameraNearFar; +uniform vec3 cameraPos; + // == utils ======================================================================================== mat2 rotate2D( float t ) { return mat2( cos( t ), sin( t ), -sin( t ), cos( t ) ); @@ -177,7 +177,12 @@ void main() { } #ifdef FORWARD - fragColor = vec4( 0.2 ); + vec3 color = vec3( 1.0 ); + + float lenV = length( cameraPos - vPosition.xyz ); + color *= exp( -0.4 * max( lenV - 3.0, 0.0 ) ); + + fragColor = vec4( color, 1.0 ); #endif #ifdef DEFERRED