diff --git a/ScreenPlayShader/ShadertoyShader.qml b/ScreenPlayShader/ShadertoyShader.qml index 74a55886..d0106b40 100644 --- a/ScreenPlayShader/ShadertoyShader.qml +++ b/ScreenPlayShader/ShadertoyShader.qml @@ -3,27 +3,16 @@ import QtQuick.Controls 2.12 ShaderEffect { id: root - property real speed: 1 - - readonly property vector3d defaultResolution: Qt.vector3d( - root.width, root.height, - root.width / root.height) - function calcResolution(channel) { - if (channel) { - return Qt.vector3d(channel.width, channel.height, - channel.width / channel.height) - } else { - return defaultResolution - } - } // based on shadertoy default variables readonly property vector3d iResolution: defaultResolution + readonly property vector3d defaultResolution: Qt.vector3d( + root.width, root.height, + root.width / root.height) property real iTime: 0 property real iTimeDelta: 100 property int iFrame: 10 property real iFrameRate - property double shaderSpeed: 1.0 property vector4d iMouse //only Image or ShaderEffectSource @@ -38,6 +27,24 @@ ShaderEffect { property vector4d iDate property real iSampleRate: 44100 + property bool hoverEnabled: false + property bool running: true + + function restart() { + root.iTime = 0 + running = true + timer1.restart() + } + + function calcResolution(channel) { + if (channel) { + return Qt.vector3d(channel.width, channel.height, + channel.width / channel.height) + } else { + return defaultResolution + } + } + Image { id: ich0 visible: false @@ -55,13 +62,6 @@ ShaderEffect { visible: false } - property bool hoverEnabled: false - property bool running: true - function restart() { - root.iTime = 0 - running = true - timer1.restart() - } Timer { id: timer1 running: root.running @@ -69,9 +69,10 @@ ShaderEffect { interval: 16 repeat: true onTriggered: { - root.iTime += 0.016 * speed + root.iTime += 0.016 } } + Timer { running: root.running interval: 1000 @@ -155,12 +156,6 @@ uniform sampler2D iChannel3;" void main(void) { mainImage(gl_FragColor, vec2(vertex.x, iResolution.y - vertex.y)); -}" - - readonly property string defaultPixelShader: " -void mainImage(out vec4 fragColor, in vec2 fragCoord) -{ -fragColor = vec4(fragCoord, fragCoord.x, fragCoord.y); }" property bool runShader: true diff --git a/ScreenPlayShader/assets/Shadertoy_Bayer.png b/ScreenPlayShader/assets/Shadertoy_Bayer.png new file mode 100644 index 00000000..6eef5259 Binary files /dev/null and b/ScreenPlayShader/assets/Shadertoy_Bayer.png differ diff --git a/ScreenPlayShader/assets/Shadertoy_Gray_Noise_Medium.png b/ScreenPlayShader/assets/Shadertoy_Gray_Noise_Medium.png new file mode 100644 index 00000000..c39dcc9f Binary files /dev/null and b/ScreenPlayShader/assets/Shadertoy_Gray_Noise_Medium.png differ diff --git a/ScreenPlayShader/assets/Shadertoy_Lichen.jpg b/ScreenPlayShader/assets/Shadertoy_Lichen.jpg new file mode 100644 index 00000000..9c60a6e5 Binary files /dev/null and b/ScreenPlayShader/assets/Shadertoy_Lichen.jpg differ diff --git a/ScreenPlayShader/shader.qrc b/ScreenPlayShader/shader.qrc index fb1b05ec..beb6f9cd 100644 --- a/ScreenPlayShader/shader.qrc +++ b/ScreenPlayShader/shader.qrc @@ -7,7 +7,6 @@ assets/Shadertoy_Bayer.png assets/Shadertoy_Gray_Noise_Medium.png assets/Shadertoy_Lichen.jpg - Noise_Watery.frag ShadertoyShader.qml diff --git a/ScreenPlayShader/shaderlibrary.cpp b/ScreenPlayShader/shaderlibrary.cpp index 5984b6c2..4911a69e 100644 --- a/ScreenPlayShader/shaderlibrary.cpp +++ b/ScreenPlayShader/shaderlibrary.cpp @@ -19,3 +19,4 @@ ShaderLibrary::ShaderLibrary(QQuickItem* parent) ShaderLibrary::~ShaderLibrary() { } + diff --git a/ScreenPlayShader/shaderlibrary.h b/ScreenPlayShader/shaderlibrary.h index cc870d06..6747f92c 100644 --- a/ScreenPlayShader/shaderlibrary.h +++ b/ScreenPlayShader/shaderlibrary.h @@ -27,6 +27,7 @@ public: { return m_fragment; } + public slots: void setVertex(QString vertex) {