1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-25 04:02:50 +01:00

Add more not working shader

This commit is contained in:
Elias Steurer 2022-08-10 17:33:39 +02:00
parent 872ff3f877
commit 4aa90033ab
7 changed files with 145 additions and 5 deletions

View File

@ -1,3 +1,5 @@
cmake_minimum_required(VERSION 3.16.0)
project(
ScreenPlayShader
VERSION 0.1
@ -16,6 +18,7 @@ set(QML src/ShadertoyShader.qml
src/Beam.qml
src/Wobble.qml
src/Flowmap.qml
src/Matrix.qml
src/TestMain.qml)
set(QML_PLUGIN_SOURCES src/shaderlibrary.cpp)
@ -28,6 +31,8 @@ set(SHADER
shaders/wobble.frag
shaders/evnergy_beam.frag
shaders/flowmap.frag
shaders/matrix.frag
shaders/matrix.vert
shaders/water.frag
shaders/water.vert)
@ -37,6 +42,7 @@ set(RESOURCES
assets/water_normal.png
assets/lava.png
assets/displace.png
assets/uniformclouds-1.jpg
assets/Shadertoy_Bayer.png
assets/Shadertoy_Gray_Noise_Medium.png
assets/Shadertoy_Lichen.jpg
@ -74,7 +80,7 @@ qt6_add_shaders(
FILES
${SHADER})
if(${SCREENPLAY_TESTS})
if(NOT DEFINED ${SCREENPLAY_TESTS} OR ${SCREENPLAY_TESTS})
qt_add_executable(tst_ScreenPlayShader src/TestMain.cpp)
target_link_libraries(tst_ScreenPlayShader PRIVATE Qt::Quick ${PROJECT_NAME}plugin)
target_compile_definitions(tst_ScreenPlayShader PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

View File

@ -9,7 +9,7 @@ https://github.com/Maujoe/godot-flow-map-shader/blob/master/LICENSE.md
#version 440
layout(location = 0) in vec2 coord; // Godot: UV
layout(location = 0) in vec2 qt_TexCoord0; // Godot: UV
layout(location = 0) out vec4 fragColor;
layout(binding = 1) uniform sampler2D texture_albedo;
@ -72,7 +72,7 @@ void main()
float phase1 = mod(offset + time * cycle_speed, blend_cycle);
float phase2 = mod(offset + time * cycle_speed + half_cycle, blend_cycle);
vec4 flow_tex = texture(texture_flow_map, coord);
vec4 flow_tex = texture(texture_flow_map, qt_TexCoord0);
vec2 flow;
flow.x = dot(flow_tex, flow_map_x_channel) * 2.0 - 1.0;
@ -93,8 +93,8 @@ void main()
// Multiply with scale to make flow speed independent from the uv scaling
flow *= flow_speed * uv_scale;
vec2 layer1 = flow * phase1 + coord; // coord == base_uv ?
vec2 layer2 = flow * phase2 + coord;
vec2 layer1 = flow * phase1 + qt_TexCoord0; // coord == base_uv ?
vec2 layer2 = flow * phase2 + qt_TexCoord0;
/****************************************************************************************************/
// Albedo

View File

@ -0,0 +1,68 @@
#version 440
layout(location = 0) in vec2 qt_TexCoord0;
layout(location = 0) out vec4 fragColor;
layout(binding = 1) uniform sampler2D source;
layout(binding = 2) uniform sampler2D text_pattern;
layout(std140, binding = 0) uniform buf {
// MUST BE
mat4 qt_Matrix;
float qt_Opacity;
// INCLUDED HERE
float time;
} ;
void main()
{
// vec2 uv = gl_FragCoord.xy/qt_TexCoord0; // Original Code
vec2 uv = qt_TexCoord0;
float time2 = time * 0.04;
// apply pixelate effect
vec2 uv_pixel = uv;
//vec2 uv_pixel = floor(uv * (qt_TexCoord0/4)) / (qt_TexCoord0/4); // Original Code
vec4 col1 = vec4(0.510, 0.776, 0.486, 1.0);
vec4 col2 = vec4(0.200, 0.604, 0.318, 1.0);
vec4 col3 = vec4(0.145, 0.490 ,0.278, 1.0);
vec4 col4 = vec4(0.059, 0.255, 0.251, 1.0);
// displacement on top of y
vec3 displace = texture(text_pattern, vec2(uv_pixel.x, (uv_pixel.y + time2) * 0.05)).xyz;
displace *= 0.5;
displace.x -= 1.0;
displace.y -= 1.0;
displace.y *= 0.5;
// color
vec2 uv_tmp = uv_pixel;
uv_tmp.y *= 0.2;
uv_tmp.y += time;
vec4 color = texture(text_pattern, uv_tmp + displace.xy);
fragColor = vec4(color);
return;
// match to colors
vec4 noise = floor(color * 10.0) / 5.0;
vec4 dark = mix(col1, col2, uv.y);
vec4 bright = mix(col3, col4, uv.y);
// add gradients (top dark and transparent, bottom bright)
float inv_uv = 1.0 - uv_pixel.y;
color.xyz -= 0.45 * pow(uv_pixel.y, 8.0);
color.a -= 0.2 * pow(uv_pixel.y, 8.0);
color += pow(inv_uv, 8.0);
color = mix(dark, bright, noise);
// make waterfall transparent
color.a -= 0.2;
fragColor = vec4(color);
}

View File

@ -0,0 +1,18 @@
#version 440 // 1
layout(location = 0) in vec4 position; // 2
layout(location = 1) in vec2 texcoord;
layout(location = 0) out vec2 coord; // 3
layout(std140, binding = 0) uniform buf { // 4
mat4 qt_Matrix; // 5
float qt_Opacity;
} ubuf;
out gl_PerVertex { vec4 gl_Position; }; //6
void main() {
gl_Position = vec4(texcoord, 0.0f, 1);
}

View File

@ -0,0 +1,43 @@
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import QtQuick.Controls.Material
import ScreenPlayShader
Rectangle {
color: "gray"
Image {
id: img_texture
sourceSize: Qt.size(500, 500)
source: "qrc:/qml/ScreenPlayShader/assets/uniformclouds-1.jpg"
}
Rectangle {
id: flowmap
x: 500
width: 500
height: 500
layer.enabled: true
layer.effect: ShaderEffect {
id: se
blending: false
fragmentShader: "/shaders/matrix.frag.qsb"
//vertexShader: "/shaders/matrix.vert.qsb"
property variant text_pattern: img_texture
property real time: 0
property real framerate: 60
property real updateInterval: Math.round(
(1000 / framerate) * 10) / 10
Timer {
interval: 16
running: true
repeat: true
onTriggered: {
se.time += 1
}
}
}
}
}

View File

@ -14,6 +14,9 @@ Window {
TabBar {
id: bar
width: parent.width
TabButton {
text: qsTr("Matrix")
}
TabButton {
text: qsTr("Wobble")
}
@ -36,6 +39,8 @@ Window {
currentIndex: bar.currentIndex
clip: true
Matrix {}
Flowmap {}
Wobble {}