This commit is contained in:
FMS-Cat
2021-03-30 02:13:15 +09:00
parent 77b17fa3f6
commit d9d5eddc8b
5 changed files with 24 additions and 17 deletions

File diff suppressed because one or more lines are too long

View File

@@ -7,8 +7,8 @@ export const audio = new AudioContext();
let music: Music; let music: Music;
if ( process.env.DEV ) { if ( process.env.DEV ) {
// music = new MusicRealtime(); music = new MusicRealtime();
music = new MusicOffline(); // music = new MusicOffline();
} else { } else {
music = new MusicOffline(); music = new MusicOffline();
} }

View File

@@ -12,6 +12,7 @@ import musicVert from './music.vert';
const discardFrag = '#version 300 es\nvoid main(){discard;}'; const discardFrag = '#version 300 es\nvoid main(){discard;}';
const sectionResets = [ const sectionResets = [
0.0,
16.0, 16.0,
80.0, 80.0,
144.0, 144.0,
@@ -143,8 +144,8 @@ export abstract class Music {
const barLength = 240.0 / MUSIC_BPM; const barLength = 240.0 / MUSIC_BPM;
const sectionReset = binarySearch( sectionResets, time ); const sectionReset = binarySearch( sectionResets, time );
const sectionBegin = sectionResets[ sectionReset ]; const sectionBegin = sectionResets[ sectionReset - 1 ];
const sectionLength = sectionResets[ sectionReset + 1 ] - sectionBegin; const sectionLength = sectionResets[ sectionReset ] - sectionBegin;
program.attribute( 'off', this.__bufferOff, 1 ); program.attribute( 'off', this.__bufferOff, 1 );
program.uniform( 'bpm', '1f', MUSIC_BPM ); program.uniform( 'bpm', '1f', MUSIC_BPM );

View File

@@ -17,6 +17,7 @@ const float SECTION_PSY = 464.0 * BEAT;
#define saturate(i) clamp(i, 0.,1.) #define saturate(i) clamp(i, 0.,1.)
#define aSaturate(i) clamp((i),-1.,1.) #define aSaturate(i) clamp((i),-1.,1.)
#define fs(i) (fract(sin((i)*114.514)*1919.810))
#define linearstep(a,b,x) saturate(((x)-(a))/((b)-(a))) #define linearstep(a,b,x) saturate(((x)-(a))/((b)-(a)))
#define n2r(n) (pow(2.,((n)-1.)/12.)) #define n2r(n) (pow(2.,((n)-1.)/12.))
#define n2f(n) (n2r(float(n))*440.) #define n2f(n) (n2r(float(n))*440.)
@@ -45,10 +46,6 @@ float auto( float y ) {
return texture( samplerAutomaton, vec2( off / bufferLength, y ) ).x; return texture( samplerAutomaton, vec2( off / bufferLength, y ) ).x;
} }
float fs( float s ) {
return fract( sin( s * 114.514 ) * 1919.810 );
}
vec2 fbm( vec2 p ) { vec2 fbm( vec2 p ) {
vec2 sum = vec2( 0.0 ); vec2 sum = vec2( 0.0 );
@@ -356,21 +353,21 @@ vec2 mainAudio( vec4 time ) {
} }
// -- kick --------------------------------------------------------------------------------------- // -- kick ---------------------------------------------------------------------------------------
if ( inRange( time.w, SECTION_NEURO, SECTION_WHOA ) ) { if ( inRange( time.w, SECTION_NEURO, SECTION_WHOA - 2.5 * BEAT ) ) {
float t = mod( mod( mod( time.y, 4.0 * BEAT ), 3.25 * BEAT ), 1.75 * BEAT ); float t = mod( mod( mod( time.y, 4.0 * BEAT ), 3.25 * BEAT ), 1.75 * BEAT );
sidechain = smoothstep( 0.0, 0.7 * BEAT, t ); sidechain = smoothstep( 0.0, 0.7 * BEAT, t );
dest += 0.25 * kick( t, 1.0 ); dest += 0.25 * kick( t, 1.0 );
} }
// -- hihat -------------------------------------------------------------------------------------- // -- hihat --------------------------------------------------------------------------------------
if ( inRange( time.w, SECTION_NEURO, SECTION_WHOA ) ) { if ( inRange( time.w, SECTION_NEURO, SECTION_WHOA - 4.0 * BEAT ) ) {
float t = mod( time.x, 0.25 * BEAT ); float t = mod( time.x, 0.25 * BEAT );
float decay = mix( 40.0, 100.0, fs( floor( time.z / ( 0.25 * BEAT ) ) ) ); float decay = mix( 40.0, 100.0, fs( floor( time.z / ( 0.25 * BEAT ) ) ) );
dest += 0.13 * mix( 0.3, 1.0, sidechain ) * hihat2( t, decay ); dest += 0.13 * mix( 0.3, 1.0, sidechain ) * hihat2( t, decay );
} }
// -- snare -------------------------------------------------------------------------------------- // -- snare --------------------------------------------------------------------------------------
if ( inRange( time.w, SECTION_NEURO, SECTION_WHOA ) ) { if ( inRange( time.w, SECTION_NEURO, SECTION_WHOA - 4.0 * BEAT ) ) {
float t = mod( time.y - 2.0 * BEAT, 4.0 * BEAT ); float t = mod( time.y - 2.0 * BEAT, 4.0 * BEAT );
dest += 0.1 * snare( t ); dest += 0.1 * snare( t );
} }
@@ -409,10 +406,19 @@ vec2 mainAudio( vec4 time ) {
dest += 0.25 * kick( t, 1.0 ); dest += 0.25 * kick( t, 1.0 );
} }
// -- snare -------------------------------------------------------------------------------------- // -- gabber -------------------------------------------------------------------------------------
if ( inRange( time.w, SECTION_WHOA, SECTION_PORTER_FUCKING_ROBINSON ) ) { if (
float t = mod( time.z - 4.0 * BEAT, 8.0 * BEAT ); inRange( time.w, SECTION_WHOA, SECTION_PORTER_FUCKING_ROBINSON ) &&
dest += 0.1 * snare( t ); inRange( mod( time.z, 8.0 * BEAT ), 4.0 * BEAT, 8.0 * BEAT )
) {
const int pattern[16] = int[](
0, 1, 0, 1,
2, 3, 4, 0,
1, 2, 0, 1,
2, 3, 4, 5
);
float tHeadKick = 0.25 * BEAT * float( pattern[ int( time.y / 0.25 / BEAT ) ] );
float tKick = tHeadKick + mod( time.y, 0.25 * BEAT );
} }
// -- amen --------------------------------------------------------------------------------------- // -- amen ---------------------------------------------------------------------------------------

View File

@@ -101,7 +101,7 @@ void main() {
for ( int i = 0; i < MARCH_ITER; i ++ ) { for ( int i = 0; i < MARCH_ITER; i ++ ) {
isect = map( rayPos ); isect = map( rayPos );
accum += isect * INV_MARCH_ITER; accum += isect * INV_MARCH_ITER;
rayLen += stepLen * 0.8 + 0.2 * prng( seed ); rayLen += stepLen * 0.5 + 0.5 * prng( seed );
rayPos = rayOri + rayDir * rayLen; rayPos = rayOri + rayDir * rayLen;
if ( rayLen > cameraNearFar.y ) { break; } if ( rayLen > cameraNearFar.y ) { break; }