diff --git a/Resources/oscilloscope/empty.jpg b/Resources/oscilloscope/empty.jpg index 7506914..51952db 100644 Binary files a/Resources/oscilloscope/empty.jpg and b/Resources/oscilloscope/empty.jpg differ diff --git a/Resources/oscilloscope/noise.jpg b/Resources/oscilloscope/noise.jpg index 8066386..7df423f 100644 Binary files a/Resources/oscilloscope/noise.jpg and b/Resources/oscilloscope/noise.jpg differ diff --git a/Source/SosciPluginProcessor.cpp b/Source/SosciPluginProcessor.cpp index 96efd98..8dfe33e 100644 --- a/Source/SosciPluginProcessor.cpp +++ b/Source/SosciPluginProcessor.cpp @@ -47,7 +47,7 @@ void SosciAudioProcessor::processBlock(juce::AudioBuffer& buffer, juce::M point = { x, y, brightness }; } - for (auto& effect : effects) { + for (auto& effect : permanentEffects) { point = effect->apply(sample, point); } diff --git a/Source/visualiser/OutputFragmentShader.glsl b/Source/visualiser/OutputFragmentShader.glsl index 48425da..6f6b914 100644 --- a/Source/visualiser/OutputFragmentShader.glsl +++ b/Source/visualiser/OutputFragmentShader.glsl @@ -9,7 +9,7 @@ uniform sampler2D uTexture5; //screen glow uniform float uExposure; uniform float uSaturation; uniform float uNoise; -uniform float uTime; +uniform float uRandom; uniform float uGlow; uniform float uAmbient; uniform float uFishEye; @@ -26,8 +26,16 @@ vec3 desaturate(vec3 color, float factor) { return vec3(mix(color, gray, factor)); } -float noise(in vec2 uv, in float time) { - return (fract(sin(dot(uv, vec2(12.9898,78.233)*2.0 + time)) * 43758.5453)) - 0.5; +float noise(vec2 texCoord, float time) { + // Combine texture coordinate and time to create a unique seed + float seed = dot(texCoord, vec2(12.9898, 78.233)) + time; + + // Use fract and sin to generate a pseudo-random value + return fract(sin(seed) * 43758.5453) - 0.5; +} + +vec4 max4(vec4 a, vec4 b) { + return vec4(max(a.r, b.r), max(a.g, b.g), max(a.b, b.b), max(a.a, b.a)); } void main() { @@ -49,7 +57,7 @@ void main() { if (uRealScreen > 0.5) { vec4 reflection = texture2D(uTexture4, vTexCoord); vec4 screenGlow = texture2D(uTexture5, vTexCoord); - scatter += screenGlow * reflection * max(1.0 - uAmbient, 0.0); + scatter += max4(screenGlow * reflection * max(1.0 - uAmbient, 0.0), vec4(0.0)); } float light = line.r + uGlow * 1.5 * screen.g * screen.g * tightGlow.r; @@ -62,7 +70,10 @@ void main() { gl_FragColor.rgb += ambient * screen.rgb; } gl_FragColor.rgb = desaturate(gl_FragColor.rgb, 1.0 - uSaturation); - gl_FragColor.rgb += uNoise * noise(gl_FragCoord.xy, uTime); + float noiseR = noise(gl_FragCoord.xy * 0.01, uRandom * 100.0); + float noiseG = noise(gl_FragCoord.xy * 0.005, uRandom * 50.0); + float noiseB = noise(gl_FragCoord.xy * 0.07, uRandom * 80.0); + gl_FragColor.rgb += uNoise * vec3(noiseR, noiseG, noiseB); gl_FragColor.a = 1.0; } diff --git a/Source/visualiser/VisualiserComponent.cpp b/Source/visualiser/VisualiserComponent.cpp index c09c857..8d7c2b7 100644 --- a/Source/visualiser/VisualiserComponent.cpp +++ b/Source/visualiser/VisualiserComponent.cpp @@ -1005,18 +1005,6 @@ void VisualiserComponent::drawCRT() { setShader(glowShader.get()); setOffsetAndScale(glowShader.get()); drawTexture({blur3Texture}); - - // blur the glow texture to blend it nicely. blur3Texture and blur1Texture are reserved, so we can't use them - // horizontal 512x512 - activateTargetTexture(blur2Texture); - setShader(wideBlurShader.get()); - wideBlurShader->setUniform("uOffset", 1.0f / 512.0f, 0.0f); - drawTexture({glowTexture}); - - // vertical 512x512 - activateTargetTexture(glowTexture); - wideBlurShader->setUniform("uOffset", 0.0f, 1.0f / 512.0f); - drawTexture({blur2Texture}); } #endif @@ -1025,7 +1013,7 @@ void VisualiserComponent::drawCRT() { outputShader->setUniform("uExposure", 0.25f); outputShader->setUniform("uSaturation", (float) settings.getSaturation()); outputShader->setUniform("uNoise", (float) settings.getNoise()); - outputShader->setUniform("uTime", time); + outputShader->setUniform("uRandom", juce::Random::getSystemRandom().nextFloat()); outputShader->setUniform("uGlow", (float) settings.getGlow()); outputShader->setUniform("uAmbient", (float) settings.getAmbient()); setOffsetAndScale(outputShader.get()); @@ -1198,8 +1186,6 @@ void VisualiserComponent::paint(juce::Graphics& g) { } void VisualiserComponent::renderScope(const std::vector& xPoints, const std::vector& yPoints, const std::vector& zPoints) { - time += 0.01f; - if (screenType != settings.getScreenType()) { screenType = settings.getScreenType(); #if SOSCI_FEATURES diff --git a/Source/visualiser/VisualiserComponent.h b/Source/visualiser/VisualiserComponent.h index 6e3d89c..527b009 100644 --- a/Source/visualiser/VisualiserComponent.h +++ b/Source/visualiser/VisualiserComponent.h @@ -157,8 +157,6 @@ private: juce::OpenGLContext openGLContext; - float time = 0; - juce::Rectangle buttonRow; juce::Rectangle viewportArea; diff --git a/sosci.jucer b/sosci.jucer index e5ef2bf..7026a40 100644 --- a/sosci.jucer +++ b/sosci.jucer @@ -147,6 +147,10 @@ file="Source/visualiser/BlurFragmentShader.glsl"/> + +