-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add simple example and add README.md
- Loading branch information
Showing
15 changed files
with
285 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# ShaderNodes # | ||
|
||
ShaderNodes is a shader generator for Qt3D inspired by material designers found | ||
in 3D software like Blender. | ||
It produces GLSL shaders based on an object graph built in QML or C++. | ||
|
||
Currently, only graphs built in QML are supported. | ||
|
||
The simplest way to use ShaderNodes is to use the ShaderBuilderMaterial. | ||
This can be used directly in place of any Qt3D material: | ||
|
||
```qml | ||
Entity { | ||
components: [ | ||
ShaderBuilderMaterial { | ||
id: material | ||
fragmentColor: StandardMaterial { | ||
color: "green" | ||
normal: Bump { | ||
texture: Noise { | ||
vector: material.fragment.position | ||
} | ||
} | ||
} | ||
}, | ||
SphereMesh { | ||
id: mesh | ||
} | ||
] | ||
} | ||
``` | ||
|
||
You can also build your own materials by using a ShaderBuilderEffect | ||
or by generating the shader code with ShaderBuilder directly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ TEMPLATE = subdirs | |
|
||
SUBDIRS += \ | ||
sharedmaterials \ | ||
sharednodes | ||
sharednodes \ | ||
simple |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <QGuiApplication> | ||
#include <QQmlApplicationEngine> | ||
#include <QSurfaceFormat> | ||
#include <vendor.h> | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
QSurfaceFormat format; | ||
format.setMajorVersion(3); | ||
format.setMinorVersion(3); | ||
QSurfaceFormat::setDefaultFormat(format); | ||
|
||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); | ||
QGuiApplication app(argc, argv); | ||
QQmlApplicationEngine engine; | ||
qpm::init(app, engine); | ||
engine.load(QUrl(QStringLiteral("qrc:/main_simple.qml"))); | ||
|
||
return app.exec(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import QtQuick 2.7 | ||
import QtQuick.Controls 1.0 as QQC1 | ||
import QtQuick.Controls 2.0 | ||
import QtQuick.Layouts 1.0 | ||
|
||
import QtQuick.Scene3D 2.0 | ||
|
||
import Qt3D.Core 2.0 | ||
import Qt3D.Extras 2.0 | ||
import Qt3D.Input 2.0 | ||
import Qt3D.Logic 2.0 | ||
import Qt3D.Render 2.0 | ||
|
||
import ShaderNodes 1.0 | ||
|
||
ApplicationWindow { | ||
id: window | ||
|
||
visible: true | ||
width: 1280 | ||
height: 1024 | ||
title: qsTr("Simple example") | ||
|
||
Scene3D { | ||
id: root | ||
|
||
anchors.fill: parent | ||
|
||
aspects: ["logic", "input"] | ||
Entity { | ||
components: [ | ||
RenderSettings{ | ||
activeFrameGraph: ForwardRenderer { | ||
camera: Camera { | ||
id: mainCamera | ||
projectionType: CameraLens.PerspectiveProjection | ||
fieldOfView: 50 | ||
aspectRatio: root.width / root.height | ||
nearPlane: 1.0 | ||
farPlane: 100.0 | ||
position: Qt.vector3d(8, 4, 8) | ||
viewCenter: Qt.vector3d(0, 0, 0) | ||
upVector: Qt.vector3d(0.0, 1.0, 0.0) | ||
} | ||
clearColor: Qt.rgba(0.2, 0.2, 0.2) | ||
} | ||
}, | ||
InputSettings {} | ||
] | ||
|
||
OrbitCameraController { | ||
camera: mainCamera | ||
} | ||
|
||
Entity { | ||
components: [ | ||
ShaderBuilderMaterial { | ||
id: material | ||
fragmentColor: StandardMaterial { | ||
color: "green" | ||
normal: Bump { | ||
texture: Noise { | ||
vector: material.fragment.position | ||
} | ||
} | ||
} | ||
}, | ||
SphereMesh { | ||
id: mesh | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<RCC> | ||
<qresource prefix="/"> | ||
<file>main_simple.qml</file> | ||
</qresource> | ||
</RCC> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
TEMPLATE = app | ||
|
||
QT += qml quick | ||
CONFIG += c++11 | ||
|
||
SOURCES += \ | ||
main_simple.cpp | ||
|
||
RESOURCES += qml.qrc | ||
|
||
include(../../package_vendor.pri) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.