mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-06 19:12:30 +01:00
Add shadertoy shader
This commit is contained in:
parent
6d7389833d
commit
0fa55884ac
@ -3,12 +3,10 @@ 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,
|
||||
root.width / root.height)
|
||||
function calcResolution(channel) {
|
||||
if (channel) {
|
||||
@ -19,7 +17,7 @@ ShaderEffect {
|
||||
}
|
||||
}
|
||||
|
||||
// based on shadertoy default vartiables
|
||||
// based on shadertoy default variables
|
||||
readonly property vector3d iResolution: defaultResolution
|
||||
property real iTime: 0
|
||||
property real iTimeDelta: 100
|
||||
@ -119,7 +117,8 @@ out vec4 fragColor;"
|
||||
#version 110
|
||||
#define texture texture2D"
|
||||
|
||||
property string versionString: GraphicsInfo.majorVersion === 3 ? "gl3Ver" : "gl2Ver"
|
||||
property string versionString: (GraphicsInfo.majorVersion === 3
|
||||
|| GraphicsInfo.majorVersion === 4) ? gl3Ver : gl2Ver
|
||||
|
||||
vertexShader: "
|
||||
uniform mat4 qt_Matrix;
|
||||
@ -165,6 +164,6 @@ fragColor = vec4(fragCoord, fragCoord.x, fragCoord.y);
|
||||
}"
|
||||
|
||||
property bool runShader: true
|
||||
property string pixelShader: ""
|
||||
fragmentShader: forwardString + (pixelShader ? pixelShader : defaultPixelShader) + startCode
|
||||
property string pixelShader
|
||||
onPixelShaderChanged: root.fragmentShader = forwardString + pixelShader + startCode
|
||||
}
|
@ -1,19 +1,18 @@
|
||||
#include "screenplayshader_plugin.h"
|
||||
|
||||
#include <qqml.h>
|
||||
#include <QQmlEngine>
|
||||
#include <QUrl>
|
||||
#include <qqml.h>
|
||||
|
||||
QObject* ScreenPlayShaderLibrarySingleton(QQmlEngine* engine, QJSEngine* scriptEngine)
|
||||
{
|
||||
Q_UNUSED(scriptEngine)
|
||||
//Add QRC
|
||||
// engine->addImportPath("qrc:/ShaderWrapper/");
|
||||
// engine->addImportPath("..");
|
||||
return new ShaderLibrary();
|
||||
}
|
||||
|
||||
void ScreenPlayShaderPlugin::registerTypes(const char* uri)
|
||||
{
|
||||
|
||||
qmlRegisterType(QUrl("qrc:/ShaderWrapper/ShadertoyShader.qml"), "ScreenPlay.ShadertoyShader", 1,0, "ShadertoyShader");
|
||||
qmlRegisterSingletonType<ShaderLibrary>(uri, 1, 0, "ShaderLibrary", ScreenPlayShaderLibrarySingleton);
|
||||
}
|
||||
|
@ -4,9 +4,12 @@
|
||||
<file>lightning.vert</file>
|
||||
<file>water.frag</file>
|
||||
<file>water.vert</file>
|
||||
<file>assets/Shadertoy_Bayer.png</file>
|
||||
<file>assets/Shadertoy_Gray_Noise_Medium.png</file>
|
||||
<file>assets/Shadertoy_Lichen.jpg</file>
|
||||
<file>Noise_Watery.frag</file>
|
||||
</qresource>
|
||||
<qresource prefix="/ShaderWrapper">
|
||||
<file>ScreenPlayShader.qml</file>
|
||||
<file>Testyyy.qml</file>
|
||||
<file>ShadertoyShader.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -28,8 +28,7 @@ BaseWindow::BaseWindow(QString projectFilePath, const QVector<int> activeScreens
|
||||
QJsonDocument configJsonDocument;
|
||||
QJsonParseError parseError;
|
||||
|
||||
if (projectFilePath.contains("file:\\\\\\"))
|
||||
projectFilePath = projectFilePath.remove("file:\\\\\\");
|
||||
|
||||
|
||||
projectFile.setFileName(projectFilePath + "/project.json");
|
||||
projectFile.open(QIODevice::ReadOnly | QIODevice::Text);
|
||||
@ -64,7 +63,7 @@ BaseWindow::BaseWindow(QString projectFilePath, const QVector<int> activeScreens
|
||||
qFatal("No type was specified inside the json object!");
|
||||
}
|
||||
|
||||
setBasePath(projectFilePath);
|
||||
setBasePath(QUrl::fromUserInput(projectFilePath).toLocalFile());
|
||||
setFullContentPath("file:///" + projectFilePath + "/" + projectObject.value("file").toString());
|
||||
|
||||
auto reloadQMLLambda = [this]() { emit reloadQML(type()); };
|
||||
@ -166,9 +165,11 @@ QString BaseWindow::loadFromFile(const QString& filename)
|
||||
{
|
||||
QFile file;
|
||||
file.setFileName(basePath() + "/" + filename);
|
||||
qWarning() << " loadFromFile: " << file.fileName() << file.readAll();
|
||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
return file.readAll();
|
||||
}
|
||||
qWarning() << "Could not loadFromFile: " << file.fileName();
|
||||
return "";
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user