kopia lustrzana https://github.com/jameshball/osci-render
				
				
				
			Make the visualiser closer to the original, and change how the colour selection works
							rodzic
							
								
									735b6a292a
								
							
						
					
					
						commit
						36cee45ca3
					
				|  | @ -572,29 +572,27 @@ void OscirenderAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer, ju | |||
|     juce::SpinLock::ScopedLockType lock1(parsersLock); | ||||
|     juce::SpinLock::ScopedLockType lock2(effectsLock); | ||||
| 
 | ||||
|     if (totalVolume > EPSILON) { | ||||
|         for (auto& effect : toggleableEffects) { | ||||
|             bool isEnabled = effect->enabled != nullptr && effect->enabled->getValue(); | ||||
|             bool isSelected = effect->selected == nullptr ? true : effect->selected->getBoolValue(); | ||||
|             if (isEnabled && isSelected) { | ||||
|                 if (effect->getId() == custom->getId()) { | ||||
|                     effect->setExternalInput(&inputBuffer); | ||||
|                 } | ||||
|                 effect->processBlock(outputBuffer3d, midiMessages); | ||||
|                 effect->setExternalInput(nullptr); | ||||
|     for (auto& effect : toggleableEffects) { | ||||
|         bool isEnabled = effect->enabled != nullptr && effect->enabled->getValue(); | ||||
|         bool isSelected = effect->selected == nullptr ? true : effect->selected->getBoolValue(); | ||||
|         if (isEnabled && isSelected) { | ||||
|             if (effect->getId() == custom->getId()) { | ||||
|                 effect->setExternalInput(&inputBuffer); | ||||
|             } | ||||
|             effect->processBlock(outputBuffer3d, midiMessages); | ||||
|             effect->setExternalInput(nullptr); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|         if (previewEffect) { | ||||
|             const bool prevEnabled = (previewEffect->enabled != nullptr) && previewEffect->enabled->getValue(); | ||||
|             const bool prevSelected = (previewEffect->selected == nullptr) ? true : previewEffect->selected->getBoolValue(); | ||||
|             if (!(prevEnabled && prevSelected)) { | ||||
|                 if (previewEffect->getId() == custom->getId()) { | ||||
|                     previewEffect->setExternalInput(&inputBuffer); | ||||
|                 } | ||||
|                 previewEffect->processBlock(outputBuffer3d, midiMessages); | ||||
|                 previewEffect->setExternalInput(nullptr); | ||||
|     if (previewEffect) { | ||||
|         const bool prevEnabled = (previewEffect->enabled != nullptr) && previewEffect->enabled->getValue(); | ||||
|         const bool prevSelected = (previewEffect->selected == nullptr) ? true : previewEffect->selected->getBoolValue(); | ||||
|         if (!(prevEnabled && prevSelected)) { | ||||
|             if (previewEffect->getId() == custom->getId()) { | ||||
|                 previewEffect->setExternalInput(&inputBuffer); | ||||
|             } | ||||
|             previewEffect->processBlock(outputBuffer3d, midiMessages); | ||||
|             previewEffect->setExternalInput(nullptr); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -11,7 +11,7 @@ uniform vec2 uOffset; | |||
| uniform vec2 uScale; | ||||
| uniform float uFishEye; | ||||
| uniform sampler2D uScreen; // still sampled for focus/gain texturing, but we'll reduce its influence on colour | ||||
| uniform float uLineHueShift; // 0..1 hue shift for the beam colour | ||||
| uniform vec3 uLineColor; | ||||
| uniform float uUseVertexColor; // 1.0 to use per-vertex RGB, 0.0 to use hue-only | ||||
| varying float vSize; | ||||
| varying vec4 uvl; | ||||
|  | @ -52,13 +52,8 @@ void main() { | |||
|     float len = uvl.z; | ||||
|     vec2 xy = uvl.xy; | ||||
|     float brightness; | ||||
|     // Determine base color: either per-vertex RGB with hue shift, or hue-only using a fixed seed color | ||||
|     vec3 baseColor; | ||||
|     if (uUseVertexColor > 0.5) { | ||||
|         baseColor = hueShift(vColor, uLineHueShift); | ||||
|     } else { | ||||
|         baseColor = hueShift(vec3(1.0, 0.0, 0.0), uLineHueShift); | ||||
|     } | ||||
|     // Determine base color: either per-vertex RGB, or a color from the settings | ||||
|     vec3 baseColor = uUseVertexColor > 0.5 ? vColor : uLineColor; | ||||
|     baseColor = clamp(baseColor, 0.0, 1.0); | ||||
|      | ||||
|     float sigma = vSize/5.0; | ||||
|  |  | |||
|  | @ -74,15 +74,16 @@ void main() { | |||
|     } | ||||
|      | ||||
|     // making the range of the glow slider more useful | ||||
|     float glow = 2.0 * pow(uGlow, 1.5); | ||||
|     float glow = 1.75 * pow(uGlow, 1.5); | ||||
|     float scatterScalar = 0.3 * (2.0 + 1.0 * screen.g + 0.5 * screen.r); | ||||
|     vec3 bloom = glow * ((0.2 * screen.r + 0.6 * screen.g) * tightGlow.rgb + scatter.rgb * scatterScalar); | ||||
|     vec3 bloom = glow * ((0.25 * screen.r + 0.75 * screen.g) * tightGlow.rgb + scatter.rgb * scatterScalar); | ||||
|     if (uRealScreen > 0.5) { | ||||
|         float ambientFactor = (1.0 - uRealScreen) * max(uAmbient, 0.0); | ||||
|         bloom += ambientFactor * 0.6 * scatterScalar; | ||||
|     } | ||||
|     float screenFactor = clamp(screen.r, 0.1, 1.0); | ||||
|     float screenFactor = clamp(screen.r * 4.0, 0.1, 1.0); | ||||
|     vec3 light = screenFactor * line.rgb + bloom; | ||||
|     // vec3 light = line.rgb + bloom; | ||||
|     // tone map | ||||
|     vec3 tlight = 1.0 - exp(-uExposure * light); | ||||
|     // Overexposure that goes to white regardless of colour, like the old single-colour shader | ||||
|  | @ -90,7 +91,7 @@ void main() { | |||
|     float s = max(max(tlight.r, tlight.g), tlight.b); // perceived brightness proxy | ||||
|     vec3 baseCol = s > 1e-6 ? (tlight / s) : vec3(0.0); | ||||
|     // Mimic old curve: 0.3 + (brightness^6) * uOverexposure, then clamp to [0,1] | ||||
|     float whiteMix = clamp(0.3 + pow(s, 6.0) * uOverexposure * 1.3, 0.0, 1.0); | ||||
|     float whiteMix = clamp(0.3 + pow(s, 3.0) * uOverexposure, 0.0, 1.0); | ||||
|     vec3 colorOut = mix(baseCol, vec3(1.0), whiteMix) * s; | ||||
|     gl_FragColor.rgb = desaturate(colorOut, 1.0 - uLineSaturation); | ||||
|     if (uRealScreen > 0.5) { | ||||
|  |  | |||
|  | @ -101,8 +101,13 @@ public: | |||
|         return persistenceEffect->getActualValue() - 1.33; | ||||
|     } | ||||
|      | ||||
|     double getHue() { | ||||
|         return hueEffect->getActualValue(); | ||||
|     juce::Colour getColour() { | ||||
|         return juce::Colour::fromFloatRGBA( | ||||
|             (float) lineRedEffect->getActualValue(), | ||||
|             (float) lineGreenEffect->getActualValue(), | ||||
|             (float) lineBlueEffect->getActualValue(), | ||||
|             1.0f | ||||
|         ); | ||||
|     } | ||||
|      | ||||
|     double getLineSaturation() { | ||||
|  | @ -144,7 +149,7 @@ public: | |||
| #endif | ||||
|      | ||||
|     double getFocus() { | ||||
|         return focusEffect->getActualValue() / 100; | ||||
|         return 0.8 * focusEffect->getActualValue() / 100; | ||||
|     } | ||||
|      | ||||
|     double getNoise() { | ||||
|  | @ -269,12 +274,28 @@ public: | |||
|             VERSION_HINT, 0.5, 0, 6.0 | ||||
|         ) | ||||
|     ); | ||||
|     std::shared_ptr<osci::Effect> hueEffect = std::make_shared<osci::SimpleEffect>( | ||||
|     std::shared_ptr<osci::Effect> lineRedEffect = std::make_shared<osci::SimpleEffect>( | ||||
|         new osci::EffectParameter( | ||||
|             "Line Hue", | ||||
|             "Controls the hue of the beam of the oscilloscope.", | ||||
|             "hue", | ||||
|             VERSION_HINT, 125, 0, 359, 1 | ||||
|             "Line Red", | ||||
|             "Controls the red component of the line color.", | ||||
|             "lineRed", | ||||
|             VERSION_HINT, 0.0, 0.0, 1.0 | ||||
|         ) | ||||
|     ); | ||||
|     std::shared_ptr<osci::Effect> lineGreenEffect = std::make_shared<osci::SimpleEffect>( | ||||
|         new osci::EffectParameter( | ||||
|             "Line Green", | ||||
|             "Controls the green component of the line color.", | ||||
|             "lineGreen", | ||||
|             VERSION_HINT, 1.0, 0.0, 1.0 | ||||
|         ) | ||||
|     ); | ||||
|     std::shared_ptr<osci::Effect> lineBlueEffect = std::make_shared<osci::SimpleEffect>( | ||||
|         new osci::EffectParameter( | ||||
|             "Line Blue", | ||||
|             "Controls the blue component of the line color.", | ||||
|             "lineBlue", | ||||
|             VERSION_HINT, 0.0, 0.0, 1.0 | ||||
|         ) | ||||
|     ); | ||||
|     std::shared_ptr<osci::Effect> intensityEffect = std::make_shared<osci::SimpleEffect>( | ||||
|  | @ -345,7 +366,9 @@ public: | |||
|      | ||||
|     std::vector<std::shared_ptr<osci::Effect>> effects = { | ||||
|         persistenceEffect, | ||||
|         hueEffect, | ||||
|         lineRedEffect, | ||||
|         lineGreenEffect, | ||||
|         lineBlueEffect, | ||||
|         intensityEffect, | ||||
|         lineSaturationEffect, | ||||
|         focusEffect, | ||||
|  |  | |||
|  | @ -548,7 +548,7 @@ void VisualiserRenderer::drawLineTexture(const std::vector<float> &xPoints, cons | |||
|     if (mode == RenderMode::XYZ) { | ||||
|         brightness = parameters.getUpsamplingEnabled() ? &smoothedZSamples : &zSamples; | ||||
|     } | ||||
|         drawLine(xPoints, yPoints, brightness, rPoints, gPoints, bPoints, renderMode.load()); | ||||
|     drawLine(xPoints, yPoints, brightness, rPoints, gPoints, bPoints, renderMode.load()); | ||||
|     glBindTexture(GL_TEXTURE_2D, targetTexture.value().id); | ||||
| } | ||||
| 
 | ||||
|  | @ -757,7 +757,8 @@ void VisualiserRenderer::drawLine(const std::vector<float> &xPoints, const std:: | |||
|     lineShader->setUniform("uSize", (GLfloat)parameters.getFocus()); | ||||
|     lineShader->setUniform("uGain", 450.0f / 512.0f); | ||||
|     lineShader->setUniform("uInvert", 1.0f); | ||||
|     lineShader->setUniform("uLineHueShift", (GLfloat)(parameters.getHue() / 360.0)); | ||||
|     juce::Colour lineColour = parameters.getColour(); | ||||
|     lineShader->setUniform("uLineColor", lineColour.getFloatRed(), lineColour.getFloatGreen(), lineColour.getFloatBlue()); | ||||
|     lineShader->setUniform("uUseVertexColor", mode == RenderMode::XYRGB ? 1.0f : 0.0f); | ||||
| 
 | ||||
|     float intensity = parameters.getIntensity() * (41000.0f / sampleRate) * 1.0f; | ||||
|  |  | |||
|  | @ -58,7 +58,9 @@ public: | |||
| private: | ||||
|     GroupedSettings lineColour{ | ||||
|         std::vector<std::shared_ptr<EffectComponent>>{ | ||||
|             std::make_shared<EffectComponent>(*parameters.hueEffect), | ||||
|             std::make_shared<EffectComponent>(*parameters.lineRedEffect), | ||||
|             std::make_shared<EffectComponent>(*parameters.lineGreenEffect), | ||||
|             std::make_shared<EffectComponent>(*parameters.lineBlueEffect), | ||||
|             std::make_shared<EffectComponent>(*parameters.lineSaturationEffect), | ||||
|             std::make_shared<EffectComponent>(*parameters.intensityEffect), | ||||
|         }, | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 James H Ball
						James H Ball