-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from Absulit/dev
Dev
- Loading branch information
Showing
47 changed files
with
1,073 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"Cognitive Dissonance" Kevin MacLeod (incompetech.com) | ||
Licensed under Creative Commons: By Attribution 4.0 License | ||
http://creativecommons.org/licenses/by/4.0/ |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const compute = /*wgsl*/` | ||
@compute @workgroup_size(8,8,1) | ||
fn main( | ||
@builtin(global_invocation_id) GlobalId: vec3<u32>, | ||
@builtin(workgroup_id) WorkGroupID: vec3<u32>, | ||
@builtin(local_invocation_id) LocalInvocationID: vec3<u32> | ||
) { | ||
let time = params.time; | ||
} | ||
`; | ||
|
||
export default compute; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { fnusin } from '../../src/core/animation.js'; | ||
import { snoise } from './../../src/core/noise2d.js'; | ||
import { sdfCircle } from './../../src/core/sdf.js'; | ||
import { WHITE, RED, layer } from './../../src/core/color.js'; | ||
import { audioAverage, audioAverageSegments } from '../../src/core/audio.js'; | ||
|
||
const frag = /*wgsl*/` | ||
${fnusin} | ||
${snoise} | ||
${sdfCircle} | ||
${layer} | ||
${audioAverage} | ||
${audioAverageSegments} | ||
${WHITE} | ||
${RED} | ||
@fragment | ||
fn main( | ||
@location(0) color: vec4<f32>, | ||
@location(1) uv: vec2<f32>, | ||
@location(2) ratio: vec2<f32>, // relation between params.screenWidth and params.screenHeight | ||
@location(3) uvr: vec2<f32>, // uv with aspect ratio corrected | ||
@location(4) mouse: vec2<f32>, | ||
@builtin(position) position: vec4<f32> | ||
) -> @location(0) vec4<f32> { | ||
let audioX = audio.data[ u32(uvr.x * params.audioLength)] / 256; | ||
if(params.mouseClick == 1.){ | ||
click_event.updated = 1; | ||
} | ||
var c = vec4f(); | ||
c.r = audioX; | ||
c.a = 1.; | ||
return c; | ||
} | ||
`; | ||
|
||
export default frag; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import vert from './vert.js'; | ||
import compute from './compute.js'; | ||
import frag from './frag.js'; | ||
import Points from './../../src/absulit.points.module.js'; | ||
|
||
let audio = null; | ||
|
||
const base = { | ||
vert, | ||
compute, | ||
frag, | ||
/** | ||
* | ||
* @param {Points} points | ||
*/ | ||
init: async points => { | ||
let volume = 1; | ||
let loop = true; | ||
// audio = points.addAudio('audio', './../../audio/generative_audio_test.ogg', volume, loop); | ||
audio = points.addAudio('audio', './../../audio/cognitive_dissonance.mp3', volume, loop, false); | ||
points.addEventListener('click_event', data => { | ||
audio.play(); | ||
}, 2); | ||
// points.addAudio('audio', 'https://mdn.github.io/voice-change-o-matic/audio/concert-crowd.ogg', volume, loop); | ||
points.addStorage('result', 10, 'f32', 1); | ||
}, | ||
/** | ||
* | ||
* @param {Points} points | ||
*/ | ||
update: points => { | ||
}, | ||
|
||
remove: _ => { | ||
audio.pause(); | ||
audio.remove(); | ||
} | ||
} | ||
|
||
export default base; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const vert = /*wgsl*/` | ||
@vertex | ||
fn main( | ||
@location(0) position: vec4<f32>, | ||
@location(1) color: vec4<f32>, | ||
@location(2) uv: vec2<f32>, | ||
@builtin(vertex_index) vertexIndex: u32 | ||
) -> Fragment { | ||
return defaultVertexBody(position, color, uv); | ||
} | ||
`; | ||
|
||
export default vert; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const compute = /*wgsl*/` | ||
@compute @workgroup_size(8,8,1) | ||
fn main( | ||
@builtin(global_invocation_id) GlobalId: vec3<u32>, | ||
@builtin(workgroup_id) WorkGroupID: vec3<u32>, | ||
@builtin(local_invocation_id) LocalInvocationID: vec3<u32> | ||
) { | ||
let time = params.time; | ||
} | ||
`; | ||
|
||
export default compute; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { fnusin } from '../../src/core/animation.js'; | ||
import { snoise } from '../../src/core/noise2d.js'; | ||
import { sdfCircle } from '../../src/core/sdf.js'; | ||
import { WHITE, RED, GREEN, YELLOW, layer } from '../../src/core/color.js'; | ||
import { audioAverage, audioAverageSegments } from '../../src/core/audio.js'; | ||
import { texturePosition } from '../../src/core/image.js'; | ||
|
||
const frag = /*wgsl*/` | ||
${fnusin} | ||
${snoise} | ||
${sdfCircle} | ||
${layer} | ||
${audioAverage} | ||
${audioAverageSegments} | ||
${WHITE} | ||
${RED} | ||
${GREEN} | ||
${YELLOW} | ||
${texturePosition} | ||
@fragment | ||
fn main( | ||
@location(0) color: vec4<f32>, | ||
@location(1) uv: vec2<f32>, | ||
@location(2) ratio: vec2<f32>, // relation between params.screenWidth and params.screenHeight | ||
@location(3) uvr: vec2<f32>, // uv with aspect ratio corrected | ||
@location(4) mouse: vec2<f32>, | ||
@builtin(position) position: vec4<f32> | ||
) -> @location(0) vec4<f32> { | ||
if(params.mouseClick == 1.){ | ||
click_event.updated = 1; | ||
} | ||
// let audioAverage = audioAverage(audio); | ||
// let audioAverageSegments = audioAverageSegments(2); | ||
let n = snoise(uvr / params.sliderA + params.time); | ||
let feedbackColor = texturePosition(feedbackTexture, imageSampler, vec2(), uvr * vec2f(1, 1.01), true); | ||
let segmentNum = 4; | ||
let subSegmentLength = i32(params.audioLength) / segmentNum; | ||
for (var index = 0; index < segmentNum ; index++) { | ||
var audioAverage = 0.; | ||
for (var index2 = 0; index2 < subSegmentLength; index2++) { | ||
let audioIndex = index2 * index; | ||
let audioValue = audio.data[audioIndex] / 256; | ||
audioAverage += audioValue; | ||
} | ||
result[index] = audioAverage / f32(subSegmentLength); | ||
} | ||
let circle1 = sdfCircle(vec2(.5), result[0] * .4, .0, uvr) * WHITE; | ||
let circle2 = sdfCircle(vec2(.5), result[1] * .4, .0, uvr) * GREEN; | ||
let circle3 = sdfCircle(vec2(.5), result[2] * .4, .0, uvr) * YELLOW; | ||
let circle4 = sdfCircle(vec2(.5), result[3] * .4, .0, uvr) * RED; | ||
// return c; | ||
// return layer(circle2 * WHITE, c + circle); | ||
// return c + circle - circle2; | ||
return layer(feedbackColor * .9, layer(circle1, layer(circle2, layer(circle3, circle4)))); | ||
} | ||
`; | ||
|
||
export default frag; |
Oops, something went wrong.