From 6132841d2129a06f7b840d97cee76cb621367bcd Mon Sep 17 00:00:00 2001 From: Wanshuo Date: Wed, 7 May 2025 16:19:44 +0800 Subject: [PATCH 1/6] SoundWaveFilter Signed-off-by: Wanshuo --- BUILD.gn | 1 + include/ge_shader_filter_params.h | 28 +++ include/ge_visual_effect_impl.h | 14 ++ .../include/ge_sound_wave_filter.h | 198 ++++++++++++++++++ src/ge_render.cpp | 7 + src/ge_sound_wave_filter.cpp | 100 +++++++++ src/ge_visual_effect_impl.cpp | 68 ++++++ 7 files changed, 416 insertions(+) create mode 100644 rosen/modules/graphics_effect/include/ge_sound_wave_filter.h create mode 100644 src/ge_sound_wave_filter.cpp diff --git a/BUILD.gn b/BUILD.gn index 1e3abc5..c8c602c 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -63,6 +63,7 @@ ohos_source_set("graphics_effect_src") { "src/ge_magnifier_shader_filter.cpp", "src/ge_mesa_blur_shader_filter.cpp", "src/ge_render.cpp", + "src/ge_sound_wave_filter.cpp", "src/ge_system_properties.cpp", "src/ge_visual_effect.cpp", "src/ge_visual_effect_container.cpp", diff --git a/include/ge_shader_filter_params.h b/include/ge_shader_filter_params.h index a29221b..2f625a5 100644 --- a/include/ge_shader_filter_params.h +++ b/include/ge_shader_filter_params.h @@ -20,6 +20,7 @@ #include #include "utils/matrix.h" +#include "common/rs_color.h" namespace OHOS { namespace Rosen { @@ -53,6 +54,33 @@ struct GEWaterRippleFilterParams { uint32_t rippleMode = 1; }; +constexpr char GE_FILTER_SOUND_WAVE[] = "SOUND_WAVE" +constexpr char GE_FILTER_SOUND_WAVE_COLORONE[] = "COLORONE"; +constexpr char GE_FILTER_SOUND_WAVE_COLORTWO[] = "COLORTWO"; +constexpr char GE_FILTER_SOUND_WAVE_COLORTHREE[] = "COLORTHREE"; +constexpr char GE_FILTER_SOUND_WAVE_COLORPROGRESS[] = "COLORPROGRESS"; +constexpr char GE_FILTER_SOUND_WAVE_CENTERBRIGHTNESS[] = "CENTERBRIGHTNESS"; +constexpr char GE_FILTER_SOUND_WAVE_SOUNDINTENSITY[] = "SOUNDINTENSITY"; +constexpr char GE_FILTER_SOUND_WAVE_SHOCKWAVEALPHAONE[] = "SHOCKWAVEALPHAONE"; +constexpr char GE_FILTER_SOUND_WAVE_SHOCKWAVEALPHATWO[] = "SHOCKWAVEALPHATWO"; +constexpr char GE_FILTER_SOUND_WAVE_SHOCKWAVEPROGRESSONE[] = "SHOCKWAVEPROGRESSONE"; +constexpr char GE_FILTER_SOUND_WAVE_SHOCKWAVEPROGRESSTWO[] = "SHOCKWAVEPROGRESSTWO"; +struct GESoundWaveFilterParams { + //sound wave + uint32_t colorOne = 0xFFFFFFFF; + uint32_t colorTwo = 0xFFFFFFFF; + uint32_t colorThree = 0xFFFFFFFF; + float colorProgress = 0.0f; + float centerBrightness = 1.0f; + float soundIntensity = 0.0f; + + //shock wave + float shockWaveAlphaOne_ = 1.0f; + float shockWaveAlphaTwo_ = 1.0f; + float shockWaveProgressOne_ = 0.0f; + float shockWaveProgressTwo_ = 0.0f; +} + constexpr char GE_FILTER_GREY[] = "GREY"; constexpr char GE_FILTER_GREY_COEF_1[] = "GREY_COEF_1"; constexpr char GE_FILTER_GREY_COEF_2[] = "GREY_COEF_2"; diff --git a/include/ge_visual_effect_impl.h b/include/ge_visual_effect_impl.h index d6e3df1..aefaa4e 100644 --- a/include/ge_visual_effect_impl.h +++ b/include/ge_visual_effect_impl.h @@ -42,6 +42,7 @@ public: DOT_MATRIX, FLOW_LIGHT_SWEEP, COMPLEX_SHADER, + SOUND_WAVE, MAX }; @@ -142,6 +143,16 @@ public: return magnifierParams_; } + void MakeSoundWaveParams() + { + soundWaveParams_ = std::make_shared(); + } + + const std::shared_ptr& GetSoundWaveParams() const + { + return soundWaveParams_; + } + private: static std::map> g_initialMap; @@ -154,6 +165,8 @@ private: void SetMagnifierParamsUint32(const std::string& tag, uint32_t param); void SetWaterRippleParams(const std::string& tag, float param); + void SetSoundWaveParamsUint32(const std::string& tag, uint32_t param); + void SetSoundWaveParamsFloat(const std::string& tag, float param); FilterType filterType_ = GEVisualEffectImpl::FilterType::NONE; @@ -165,6 +178,7 @@ private: std::shared_ptr magnifierParams_ = nullptr; std::shared_ptr waterRippleParams_ = nullptr; + std::shared_ptr soundWaveParams_ = nullptr; }; } // namespace Drawing diff --git a/rosen/modules/graphics_effect/include/ge_sound_wave_filter.h b/rosen/modules/graphics_effect/include/ge_sound_wave_filter.h new file mode 100644 index 0000000..85b9e4f --- /dev/null +++ b/rosen/modules/graphics_effect/include/ge_sound_wave_filter.h @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef GRAPHICS_EFFECT_GE_SOUND_WAVE_FILTER_H +#define GRAPHICS_EFFECT_GE_SOUND_WAVE_FILTER_H + +#include + +#include "ge_shader_filter.h" +#include "ge_visual_effect.h" + +#include "draw/canvas.h" +#include "effect/color_filter.h" +#include "effect/runtime_effect.h" +#include "effect/runtime_shader_builder.h" +#include "image/image.h" +#include "utils/matrix.h" +#include "utils/rect.h" + +namespace OHOS { +namespace Rosen { +class GESoundWaveFilter : public GEShaderFilter { +public: + GESoundWaveFilter(const Drawing::GESoundWaveFilterParams& params); + ~GESoundWaveFilter() override = default; + + std::shared_ptr ProcessImage(Drawing::Canvas& canvas, const std::shared_ptr image, + const Drawing::Rect& src, const Drawing::Rect& dst) override; + +private: + std::shared_ptr GetSoundWaveEffect(); + // sound wave + Drawing::Color colorOne_ = Drawing::Color::COLOR_WHITE; + Drawing::Color colorTwo_ = Drawing::Color::COLOR_WHITE; + Drawing::Color colorThree_ = Drawing::Color::COLOR_WHITE; + float colorProgress_ = 0.0f; + float centerBrightness_ = 1.0f; + float soundIntensity_ = 0.0f; + + // shock wave + float shockWaveAlphaOne_ = 1.0f; + float shockWaveAlphaTwo_ = 1.0f; + float shockWaveProgressOne_ = 0.0f; + float shockWaveProgressTwo_ = 0.0f; + + inline static const std::string shaderStringSoundWave = R"( + uniform shader image; + uniform half2 iResolution; + uniform vec3 colorOne; + uniform vec3 colorTwo; + uniform vec3 colorThree; + uniform half colorProgress; + uniform half centerBrightness; + uniform half soundIntensity; + uniform half shockWaveAlphaOne; + uniform half shockWaveAlphaTwo; + uniform half shockWaveProgressOne; + uniform half shockWaveProgressTwo; + + float smin(float a, float b, float k) + { + k *= 6.0; + float h = max(k-abs(a-b), 0.0)/k; + return min(a, b) - h*h*h*k*(1.0/6.0); + } + + // Create a smooth color gradient effect based on the threshold over X or Y or user defined + // Ideal for movement, but not for rotation + vec3 colorGradient(vec3 colorOne, vec3 colorTwo, float startPos, float endPos, float threshold) + { + float stepValue = (threshold >= startPos && threshold <= endPos) ? 1.0 : 0.0; + vec3 returnValue = mix(colorOne, colorTwo, smoothstep(startPos, endPos, threshold)) * stepValue; + return returnValue; + } + + vec3 colorWheel(vec2 uv, vec2 circleCenter, float circleRadius, float animationTime) + { + float mask = length(uv+circleCenter)/circleRadius; + float distanceFromCenter = fract(mask-animationTime*10.0); + + vec3 color = colorGradient(colorOne, colorTwo, 0.0, 0.2, distanceFromCenter) + + colorGradient(colorTwo, colorThree, 0.2, 0.6, distanceFromCenter) + + colorGradient(colorThree, colorOne, 0.6, 1.0, distanceFromCenter); + color *= (1.0 - step(1.0, mask)); + return color; + } + + vec4 soundWaveDistortionEffects(vec2 screenUVs, vec2 centeredUVs, float animationTime) + { + vec2 lightPulseUVs = centeredUVs + vec2(0.0, 1.12); // uv minus pulse center position + float frequency = fract(animationTime*5.0); // frequency of distortion waves + float radius = mix(0.17, 0.68, frequency); + float lightPulseDistance = length(lightPulseUVs) - radius; + + float lightPulseThickness = 0.12; + float lightPulse = smoothstep(lightPulseThickness, -0.025, abs(lightPulseDistance)); + if (lightPulse > 0.0) + { + float animationMask = smoothstep(1.0, 0.4, frequency); + + vec2 directionVector = normalize(lightPulseUVs); + vec2 normal = directionVector * lightPulseDistance * lightPulse*animationMask; + vec2 refractedUVs = clamp(mix(screenUVs, screenUVs - normal * 0.25, 0.3), 0.001, 0.999); + return vec4(refractedUVs, normal.y, lightPulse); + } + return vec4(screenUVs, 0.0, 0.0); + } + + vec3 soundWaveLightEffects(vec2 uv, vec2 centeredUVs, vec3 currentColor, vec3 centerColor) + { + float circleRadius = 0.125; + + // Control the height of the circle + float circleHeight = mix(-0.2, 0.03, soundIntensity); + float spreadX = pow(100.0, -soundIntensity) + 1.0;// Control the spread of the mask across X + + float smoothUnionThreshold = mix(0.0657, 0.09, soundIntensity); + float horizonOffset = -0.02; + vec2 circlePosition = vec2(0.0, circleHeight); + centeredUVs.y += 1.0; + centeredUVs.y += mix(0.09, 0.0, soundIntensity); + float circleSDF = length(centeredUVs-circlePosition)-circleRadius ; + circleSDF += smoothUnionThreshold; + float smoothUnionDistance = smin(circleSDF, centeredUVs.y-horizonOffset, smoothUnionThreshold); + float horizontalGradient = smoothstep(0.9 * spreadX, 0.0, abs(uv.x*2.0-1.0)); + float smoothGap = mix(0.08, 0.1085, horizontalGradient); + float smoothUnion = smoothstep(smoothGap, -0.035, mix(0.0, 0.66, smoothUnionDistance)); + + // Control the spread of the mask across X + smoothUnion *= mix(0.65, 1.0, horizontalGradient); + + float brightnessValue = centerBrightness *smoothstep(5.0, 0.0, circleSDF); + + return currentColor+centerColor*smoothUnion* brightnessValue; + } + + half4 main(float2 fragCoord) { + vec2 uv = fragCoord.xy/iResolution.xy; + uv.y = 1.0 - uv.y; + if (uv.y>0.3) { + return vec4(0.0); + } + float screenRatio = iResolution.x/iResolution.y; + vec2 centeredUVs = uv*2.0 - 1.0; + centeredUVs.x *= screenRatio; + vec2 screenUVs = uv; + + vec3 finalColor = vec3(0.); + vec3 centerColor = colorWheel(centeredUVs, vec2(0.0, 1.0), 0.125+2.0, colorProgress); + + // 声波畸变 + vec4 soundWaveDistortion = vec4(0.0); + vec4 soundWaveDistortion2 = vec4(0.0); + soundWaveDistortion = soundWaveDistortionEffects(uv, centeredUVs, shockWaveProgressOne); + uv = soundWaveDistortion.xy; + + soundWaveDistortion2 = soundWaveDistortionEffects(uv, centeredUVs, shockWaveProgressTwo); + uv = soundWaveDistortion2.xy; + + finalColor.rgb = image.eval(vec2(uv.x, 1.0 - uv.y) * iResolution.xy).rgb; + + finalColor.rgb = soundWaveLightEffects(screenUVs, centeredUVs, finalColor.rgb, centerColor); + + // 添加来自折射畸变的光线 Add sutil light from the refraction distortion + finalColor.rgb = soundWaveDistortion.z > 0.0 + ? finalColor.rgb + centerColor * vec3(soundWaveDistortion.z) * shockWaveAlphaOne + : finalColor.rgb; + finalColor.rgb = soundWaveDistortion.w > 0.0 + ? finalColor.rgb + centerColor * vec3(pow(soundWaveDistortion.w, 6.0))*0.3 * shockWaveAlphaOne + : finalColor.rgb; + + finalColor.rgb = soundWaveDistortion2.z > 0.0 + ? finalColor.rgb + centerColor * vec3(soundWaveDistortion2.z) * shockWaveAlphaTwo + : finalColor.rgb; + finalColor.rgb = soundWaveDistortion2.w > 0.0 + ? finalColor.rgb + centerColor * vec3(pow(soundWaveDistortion2.w, 6.0))*0.3 * shockWaveAlphaTwo + : finalColor.rgb; + + return vec4(finalColor, 1.0); + } + )"; +}; + +} // namespace Rosen +} // namespace OHOS + +#endif // GRAPHICS_EFFECT_GE_SOUND_WAVE_FILTER_H \ No newline at end of file diff --git a/src/ge_render.cpp b/src/ge_render.cpp index d4a3afa..280f9f9 100644 --- a/src/ge_render.cpp +++ b/src/ge_render.cpp @@ -21,9 +21,11 @@ #include "ge_linear_gradient_blur_shader_filter.h" #include "ge_log.h" #include "ge_magnifier_shader_filter.h" +#include "ge_sound_wave_filter.h" #include "ge_visual_effect_impl.h" #include "ge_water_ripple_filter.h" #include "ge_external_dynamic_loader.h" +#include "platform/common/rs_log.h" namespace OHOS { namespace GraphicsEffectEngine { @@ -146,6 +148,11 @@ std::vector> GERender::GenerateShaderFilter( shaderFilter = std::make_shared(*waterRippleParams); break; } + case Drawing::GEVisualEffectImpl::FilterType::SOUND_WAVE: { + const auto& soundWaveParams = ve->GetSoundWaveParams(); + shaderFilter = std::make_shared(*soundWaveParams); + break; + } default: break; } diff --git a/src/ge_sound_wave_filter.cpp b/src/ge_sound_wave_filter.cpp new file mode 100644 index 0000000..66e10a7 --- /dev/null +++ b/src/ge_sound_wave_filter.cpp @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "ge_log.h" +#include "ge_sound_wave_filter.h" + +namespace OHOS { +namespace Rosen { + +namespace { +constexpr static uint8_t COLOR_CHANNEL = 3; // 3 len of rgb +} // namespace + +GESoundWaveFilter::GESoundWaveFilter(const Drawing::GESoundWaveFilterParams& params) + :colorProgress_(params.colorProgress), centerBrightness_(params.centerBrightness), + soundIntensity_(params.soundIntensity), shockWaveAlphaOne_(params.shockWaveAlphaOne), + shockWaveAlphaTwo_(params.shockWaveAlphaTwo), shockWaveProgressOne_(params.shockWaveProgressOne), + shockWaveProgressTwo_(params.shockWaveProgressTwo) +{ + colorOne_ = Drawing::Color(params.colorOne); + colorTwo_ = Drawing::Color(params.colorTwo); + colorThree_ = Drawing::Color(params.colorThree); +} + + +std::shared_ptr GESoundWaveFilter::ProcessImage(Drawing::Canvas& canvas, + const std::shared_ptr image, const Drawing::Rect& src, const Drawing::Rect& dst) +{ + if (image == nullptr) { + LOGE("GESoundWaveFilter::ProcessImage input is invalid"); + return nullptr; + } + + Drawing::Matrix matrix; + auto shader = Drawing::ShaderEffect::CreateImageShader(*image, Drawing::TileMode::CLAMP, + Drawing::TileMode::CLAMP, Drawing::SamplingOptions(Drawing::FilterMode::LINEAR), matrix); + auto imageInfo = image->GetImageInfo(); + float height = imageInfo.GetHeight(); + float width = imageInfo.GetWidth(); + if (height < 1e-6 || width < 1e-6) { + return nullptr; + } + auto soundWaveShader = GetSoundWaveEffect(); + if (soundWaveShader == nullptr) { + LOGE("GESoundWaveFilter::ProcessImage g_SoundWaveEffect init failed"); + return nullptr; + } + + float colorOne[COLOR_CHANNEL] = {colorOne_.GetRedF(), colorOne_.GetGreenF(), colorOne_.GetBlueF()}; + float colorTwo[COLOR_CHANNEL] = {colorTwo_.GetRedF(), colorTwo_.GetGreenF(), colorTwo_.GetBlueF()}; + float colorThree[COLOR_CHANNEL] = {colorThree_.GetRedF(), colorThree_.GetGreenF(), colorThree_.GetBlueF()}; + + Drawing::RuntimeShaderBuilder builder(soundWaveShader); + builder.SetChild("image", shader); + builder.SetUniform("iResolution", width, height); + builder.SetUniform("colorOne", colorOne, COLOR_CHANNEL); + builder.SetUniform("colorTwo", colorTwo, COLOR_CHANNEL); + builder.SetUniform("colorThree", colorThree, COLOR_CHANNEL); + builder.SetUniform("colorProgress", colorProgress_); + builder.SetUniform("centerBrightness", centerBrightness_); + builder.SetUniform("soundIntensity", soundIntensity_); + builder.SetUniform("shockWaveAlphaOne", shockWaveAlphaOne_); + builder.SetUniform("shockWaveAlphaTwo", shockWaveAlphaTwo_); + builder.SetUniform("shockWaveProgressOne", shockWaveProgressOne_); + builder.SetUniform("shockWaveProgressTwo", shockWaveProgressTwo_); + + auto invertedImage = builder.MakeImage(canvas.GetGPUContext().get(), nullptr, imageInfo, false); + if (invertedImage == nullptr) { + LOGE("GESoundWaveFilter::ProcessImage make image failed"); + return nullptr; + } + return invertedImage; +} + +std::shared_ptr GESoundWaveFilter::GetSoundWaveEffect() +{ + static std::shared_ptr g_soundWaveShader = nullptr; + if (g_soundWaveShader == nullptr) { + g_soundWaveShader = Drawing::RuntimeEffect::CreateForShader(shaderStringSoundWave); + } + return g_soundWaveShader; +} + + +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/src/ge_visual_effect_impl.cpp b/src/ge_visual_effect_impl.cpp index 308d1e8..78c5232 100644 --- a/src/ge_visual_effect_impl.cpp +++ b/src/ge_visual_effect_impl.cpp @@ -64,6 +64,12 @@ std::map> GEVisualEf impl->SetFilterType(GEVisualEffectImpl::FilterType::WATER_RIPPLE); impl->MakeWaterRippleParams(); } + }, + { GE_FILTER_SOUND_WAVE, + [](GEVisualEffectImpl* impl) { + impl->SetFilterType(GEVisualEffectImpl::FilterType::SOUND_WAVE); + impl->MakeSoundWaveParams(); + } } }; @@ -176,6 +182,10 @@ void GEVisualEffectImpl::SetParam(const std::string& tag, float param) SetWaterRippleParams(tag, param); break; } + case FilterType::SOUND_WAVE: { + SetSoundWaveParamsFloat(tag, param); + break; + } default: break; } @@ -242,6 +252,10 @@ void GEVisualEffectImpl::SetParam(const std::string& tag, const uint32_t param) } break; } + case FilterType::SOUND_WAVE: { + SetSoundWaveParamsUint32(tag, param); + break; + } default: break; } @@ -422,6 +436,60 @@ void GEVisualEffectImpl::SetWaterRippleParams(const std::string& tag, float para it->second(this, param); } } + +void GEVisualEffectImpl::SetSoundWaveParamsUint32(const std::string& tag, uint32_t param) +{ + if (soundWaveParams_ == nullptr) { + return; + } + + static std::unordered_map> actions = { + + { GE_FILTER_SOUND_WAVE_COLORONE, + [](GEVisualEffectImpl* obj, uint32_t p) { obj->soundWaveParams_->colorOne = p; } }, + { GE_FILTER_SOUND_WAVE_COLORTWO, + [](GEVisualEffectImpl* obj, uint32_t p) { obj->soundWaveParams_->colorTwo = p; } }, + { GE_FILTER_SOUND_WAVE_COLORTHREE, + [](GEVisualEffectImpl* obj, uint32_t p) { obj->soundWaveParams_->colorThree = p; } }, + }; + + auto it = actions.find(tag); + if (it != actions.end()) { + it->second(this, param); + } +} + +void GEVisualEffectImpl::SetSoundWaveParamsFloat(const std::string& tag, float param) +{ + if (soundWaveParams_ == nullptr) { + return; + } + + static std::unordered_map> actions = { + + { GE_FILTER_SOUND_WAVE_COLORPROGRESS, + [](GEVisualEffectImpl* obj, float p) { obj->soundWaveParams_->colorProgress = p; } }, + { GE_FILTER_SOUND_WAVE_CENTERBRIGHTNESS, + [](GEVisualEffectImpl* obj, float p) { obj->soundWaveParams_->centerBrightness = p; } }, + { GE_FILTER_SOUND_WAVE_SOUNDINTENSITY, + [](GEVisualEffectImpl* obj, float p) { obj->soundWaveParams_->soundIntensity = p; } }, + { GE_FILTER_SOUND_WAVE_SHOCKWAVEALPHAONE, + [](GEVisualEffectImpl* obj, float p) { obj->soundWaveParams_->shockWaveAlphaOne = p; } }, + { GE_FILTER_SOUND_WAVE_SHOCKWAVEALPHATWO, + [](GEVisualEffectImpl* obj, float p) { obj->soundWaveParams_->shockWaveAlphaTwo = p; } }, + { GE_FILTER_SOUND_WAVE_SHOCKWAVEPROGRESSONE, + [](GEVisualEffectImpl* obj, float p) { obj->soundWaveParams_->shockWaveProgressOne = p; } }, + { GE_FILTER_SOUND_WAVE_SHOCKWAVEPROGRESSTWO, + [](GEVisualEffectImpl* obj, float p) { obj->soundWaveParams_->shockWaveProgressTwo = p; } }, + }; + + auto it = actions.find(tag); + if (it != actions.end()) { + it->second(this, param); + } +} + + } // namespace Drawing } // namespace Rosen } // namespace OHOS -- Gitee From eff2da58ba7cd58ce1bbc65548f407341190e99a Mon Sep 17 00:00:00 2001 From: WanShuo Date: Wed, 7 May 2025 09:12:05 +0000 Subject: [PATCH 2/6] update ge_sound_wave_filter.h. Signed-off-by: WanShuo --- rosen/modules/graphics_effect/include/ge_sound_wave_filter.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rosen/modules/graphics_effect/include/ge_sound_wave_filter.h b/rosen/modules/graphics_effect/include/ge_sound_wave_filter.h index 85b9e4f..ac6b668 100644 --- a/rosen/modules/graphics_effect/include/ge_sound_wave_filter.h +++ b/rosen/modules/graphics_effect/include/ge_sound_wave_filter.h @@ -87,7 +87,7 @@ private: vec3 colorWheel(vec2 uv, vec2 circleCenter, float circleRadius, float animationTime) { float mask = length(uv+circleCenter)/circleRadius; - float distanceFromCenter = fract(mask-animationTime*10.0); + float distanceFromCenter = fract(mask-animationTime); vec3 color = colorGradient(colorOne, colorTwo, 0.0, 0.2, distanceFromCenter) + colorGradient(colorTwo, colorThree, 0.2, 0.6, distanceFromCenter) @@ -99,7 +99,7 @@ private: vec4 soundWaveDistortionEffects(vec2 screenUVs, vec2 centeredUVs, float animationTime) { vec2 lightPulseUVs = centeredUVs + vec2(0.0, 1.12); // uv minus pulse center position - float frequency = fract(animationTime*5.0); // frequency of distortion waves + float frequency = fract(animationTime); // frequency of distortion waves float radius = mix(0.17, 0.68, frequency); float lightPulseDistance = length(lightPulseUVs) - radius; -- Gitee From 3f507ac6fe646419b37070b1e917ba3a4e50aafd Mon Sep 17 00:00:00 2001 From: WanShuo Date: Wed, 7 May 2025 09:28:05 +0000 Subject: [PATCH 3/6] update include/ge_shader_filter_params.h. Signed-off-by: WanShuo --- include/ge_shader_filter_params.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/ge_shader_filter_params.h b/include/ge_shader_filter_params.h index 9ff396d..114c67a 100644 --- a/include/ge_shader_filter_params.h +++ b/include/ge_shader_filter_params.h @@ -54,7 +54,7 @@ struct GEWaterRippleFilterParams { uint32_t rippleMode = 1; }; -constexpr char GE_FILTER_SOUND_WAVE[] = "SOUND_WAVE" +constexpr char GE_FILTER_SOUND_WAVE[] = "SOUND_WAVE"; constexpr char GE_FILTER_SOUND_WAVE_COLORONE[] = "COLORONE"; constexpr char GE_FILTER_SOUND_WAVE_COLORTWO[] = "COLORTWO"; constexpr char GE_FILTER_SOUND_WAVE_COLORTHREE[] = "COLORTHREE"; @@ -75,10 +75,10 @@ struct GESoundWaveFilterParams { float soundIntensity = 0.0f; //shock wave - float shockWaveAlphaOne_ = 1.0f; - float shockWaveAlphaTwo_ = 1.0f; - float shockWaveProgressOne_ = 0.0f; - float shockWaveProgressTwo_ = 0.0f; + float shockWaveAlphaOne = 1.0f; + float shockWaveAlphaTwo = 1.0f; + float shockWaveProgressOne = 0.0f; + float shockWaveProgressTwo = 0.0f; } constexpr char GE_FILTER_GREY[] = "GREY"; -- Gitee From 531a7cd18cf25f68e33b285bcad8c32caa0b6e49 Mon Sep 17 00:00:00 2001 From: Wanshuo Date: Wed, 7 May 2025 18:52:35 +0800 Subject: [PATCH 4/6] fix file Signed-off-by: Wanshuo --- include/ge_shader_filter_params.h | 10 +++++----- .../include => include}/ge_sound_wave_filter.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) rename {rosen/modules/graphics_effect/include => include}/ge_sound_wave_filter.h (98%) diff --git a/include/ge_shader_filter_params.h b/include/ge_shader_filter_params.h index 9ff396d..114c67a 100644 --- a/include/ge_shader_filter_params.h +++ b/include/ge_shader_filter_params.h @@ -54,7 +54,7 @@ struct GEWaterRippleFilterParams { uint32_t rippleMode = 1; }; -constexpr char GE_FILTER_SOUND_WAVE[] = "SOUND_WAVE" +constexpr char GE_FILTER_SOUND_WAVE[] = "SOUND_WAVE"; constexpr char GE_FILTER_SOUND_WAVE_COLORONE[] = "COLORONE"; constexpr char GE_FILTER_SOUND_WAVE_COLORTWO[] = "COLORTWO"; constexpr char GE_FILTER_SOUND_WAVE_COLORTHREE[] = "COLORTHREE"; @@ -75,10 +75,10 @@ struct GESoundWaveFilterParams { float soundIntensity = 0.0f; //shock wave - float shockWaveAlphaOne_ = 1.0f; - float shockWaveAlphaTwo_ = 1.0f; - float shockWaveProgressOne_ = 0.0f; - float shockWaveProgressTwo_ = 0.0f; + float shockWaveAlphaOne = 1.0f; + float shockWaveAlphaTwo = 1.0f; + float shockWaveProgressOne = 0.0f; + float shockWaveProgressTwo = 0.0f; } constexpr char GE_FILTER_GREY[] = "GREY"; diff --git a/rosen/modules/graphics_effect/include/ge_sound_wave_filter.h b/include/ge_sound_wave_filter.h similarity index 98% rename from rosen/modules/graphics_effect/include/ge_sound_wave_filter.h rename to include/ge_sound_wave_filter.h index 85b9e4f..ac6b668 100644 --- a/rosen/modules/graphics_effect/include/ge_sound_wave_filter.h +++ b/include/ge_sound_wave_filter.h @@ -87,7 +87,7 @@ private: vec3 colorWheel(vec2 uv, vec2 circleCenter, float circleRadius, float animationTime) { float mask = length(uv+circleCenter)/circleRadius; - float distanceFromCenter = fract(mask-animationTime*10.0); + float distanceFromCenter = fract(mask-animationTime); vec3 color = colorGradient(colorOne, colorTwo, 0.0, 0.2, distanceFromCenter) + colorGradient(colorTwo, colorThree, 0.2, 0.6, distanceFromCenter) @@ -99,7 +99,7 @@ private: vec4 soundWaveDistortionEffects(vec2 screenUVs, vec2 centeredUVs, float animationTime) { vec2 lightPulseUVs = centeredUVs + vec2(0.0, 1.12); // uv minus pulse center position - float frequency = fract(animationTime*5.0); // frequency of distortion waves + float frequency = fract(animationTime); // frequency of distortion waves float radius = mix(0.17, 0.68, frequency); float lightPulseDistance = length(lightPulseUVs) - radius; -- Gitee From 6c8d9c21fb793e2285085011428c286a4fe72823 Mon Sep 17 00:00:00 2001 From: Wanshuo Date: Wed, 7 May 2025 19:31:35 +0800 Subject: [PATCH 5/6] fix params --- include/ge_shader_filter_params.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ge_shader_filter_params.h b/include/ge_shader_filter_params.h index 114c67a..d6593a1 100644 --- a/include/ge_shader_filter_params.h +++ b/include/ge_shader_filter_params.h @@ -79,7 +79,7 @@ struct GESoundWaveFilterParams { float shockWaveAlphaTwo = 1.0f; float shockWaveProgressOne = 0.0f; float shockWaveProgressTwo = 0.0f; -} +}; constexpr char GE_FILTER_GREY[] = "GREY"; constexpr char GE_FILTER_GREY_COEF_1[] = "GREY_COEF_1"; -- Gitee From 6e6c59168d8b50c46b04966c8a95e2a73a7cb36c Mon Sep 17 00:00:00 2001 From: Wanshuo Date: Wed, 7 May 2025 19:33:51 +0800 Subject: [PATCH 6/6] fix params Signed-off-by: Wanshuo --- include/ge_shader_filter_params.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ge_shader_filter_params.h b/include/ge_shader_filter_params.h index 114c67a..d6593a1 100644 --- a/include/ge_shader_filter_params.h +++ b/include/ge_shader_filter_params.h @@ -79,7 +79,7 @@ struct GESoundWaveFilterParams { float shockWaveAlphaTwo = 1.0f; float shockWaveProgressOne = 0.0f; float shockWaveProgressTwo = 0.0f; -} +}; constexpr char GE_FILTER_GREY[] = "GREY"; constexpr char GE_FILTER_GREY_COEF_1[] = "GREY_COEF_1"; -- Gitee