From b57ca265cb1424d6e087ec3151aa0422fd07ed2f Mon Sep 17 00:00:00 2001 From: FMS-Cat Date: Sat, 27 Mar 2021 20:19:32 +0900 Subject: [PATCH] aesthetics: update condition --- src/shaders/condition.frag | 15 +++++++++++++-- src/shaders/condition.vert | 4 ++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/shaders/condition.frag b/src/shaders/condition.frag index 9cb9cb1..bbde3c4 100644 --- a/src/shaders/condition.frag +++ b/src/shaders/condition.frag @@ -2,11 +2,14 @@ precision highp float; +const float RADIUS_CULL_SPHERE = 1.5; + const int MTL_UNLIT = 1; #define saturate(i) clamp(i,0.,1.) #define linearstep(a,b,x) saturate(((x)-(a))/((b)-(a))) +in float vScale; in float vPhase; in vec3 vNormal; in vec4 vPosition; @@ -35,10 +38,18 @@ uniform float phaseOffset; uniform float phaseWidth; void main() { - float phase = fract( 2.0 * vPhase + vHuh.z + 0.1 * time + vHuh.y + phaseOffset ); + float phase = fract( 2.0 * vPhase + vHuh.z + 0.1 * time + vHuh.y + phaseOffset / vScale ); if ( phase > phaseWidth ) { discard; } - vec3 color = vec3( 2.0 ); + float lenFromCenter = length( vPosition.xyz ); + if ( lenFromCenter < RADIUS_CULL_SPHERE ) { discard; } + + float colorPhase = exp( -4.0 * ( lenFromCenter - RADIUS_CULL_SPHERE ) ); + vec3 color = mix( + vec3( 2.0 ), + vec3( 0.0 ), + colorPhase + ); #ifdef FORWARD fragColor = vec4( color, 1.0 ); diff --git a/src/shaders/condition.vert b/src/shaders/condition.vert index f45bafe..3d5dbb6 100644 --- a/src/shaders/condition.vert +++ b/src/shaders/condition.vert @@ -8,6 +8,7 @@ layout (location = 0) in vec2 what; layout (location = 1) in vec4 huh; out float vPhase; +out float vScale; out vec3 vNormal; out vec4 vPosition; out vec4 vHuh; @@ -36,6 +37,9 @@ void main() { vec3 tube = 0.1 * basis * vec3( sin( theta ), cos( theta ), 0.0 ); vNormal = ( normalMatrix * vec4( tube, 1.0 ) ).xyz; + vScale = exp( 2.0 * fs( huh.z + 2.56 * huh.y ) ); + vPosition.xyz *= vScale; + vPosition.xyz += tube; vPosition = modelMatrix * vPosition;