gpt4 book ai didi

c++ - QML:如何将着色器效果与 QtGraphical 效果混合?

转载 作者:行者123 更新时间:2023-11-28 00:05:11 24 4
gpt4 key购买 nike

我试图在我的背景图像上实现两种效果:波浪(着色器)效果和着色(QtGraphical)效果。不幸的是,它们只单独出现,(即一张图片是我背景上的波浪效果,另一张只是我背景的彩色)。

我想将两者合二为一,但已经花了好几个小时了。有人知道怎么做吗?

Colorize {
anchors.fill: background
source: background
hue: 0.0
saturation: 0.5
lightness: -0.2
}

ShaderEffect {
height: intro_over ? 0 : parent.height;
width: intro_over ? 0 : parent.width;

property variant source: background
property real frequency: 8
property real amplitude: 0.1
property real time: 0.0

// Animation stuff

fragmentShader: "
varying highp vec2 qt_TexCoord0;
uniform sampler2D source;
uniform lowp float qt_Opacity;
uniform highp float frequency;
uniform highp float amplitude;
uniform highp float time;
void main() {
highp vec2 pulse = sin(time - frequency * qt_TexCoord0);
highp vec2 coord = qt_TexCoord0 + amplitude * vec2(pulse.x, -pulse.x);
gl_FragColor = texture2D(source, coord) * qt_Opacity;
}"
}

最佳答案

使用 ShaderEffectSource .在您的示例中,为 Colorize 项目添加一个 id,并创建一个 ShaderEffectSource 作为 ShaderEffect 的来源:

Colorize {
id: colorize
anchors.fill: background
source: background
hue: 0.0
saturation: 0.5
lightness: -0.2
}

ShaderEffect {
height: intro_over ? 0 : parent.height;
width: intro_over ? 0 : parent.width;

property variant source: ShaderEffectSource {
sourceItem: colorize
hideSource: true
}
property real frequency: 8
property real amplitude: 0.1
property real time: 0.0
}

关于c++ - QML:如何将着色器效果与 QtGraphical 效果混合?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36122468/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com