Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML Shaders
Qt 6.11 is out! See what's new in the release blog

QML Shaders

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 1.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    ustulation
    wrote on last edited by
    #1

    I recently found out that though Animations do a great job super-cool stuffs in QML are done using shaders. Now I know nothing about this. "One eg I found out is here":http://ilkka.github.io/blog/2011/03/04/qtquick_2_scenegraph_glsl_fragment_shader_tutorial/.

    I would certainly like to add such effects to my project but I know nothing about shaders. However I've programmed in WPF3D - C# in the past on 3D modelling of real-world surfaces so I have some knowledge of mesh, geometry, texture etc. I want some advice on how do I start learning the usage of Shaders in QML. Do i need to study OpenGL 1st or some specific offerings of OpenGL or something called GLSL? Is there any other way i can have those effects (for eg the one in the link i posted)?

    1 Reply Last reply
    0
    • V Offline
      V Offline
      Vincent007
      wrote on last edited by
      #2

      I suggest you try this simple "example":http://doc-snapshot.qt-project.org/qdoc/qml-qtquick-shadereffect.html first.

      and then try other examples.

      @
      import QtQuick 2.0

      Rectangle {
      width: 200; height: 100
      Row {
      Image { id: img; sourceSize { width: 100; height: 100 } source: "qt-logo.png" }
      ShaderEffect {
      width: 100; height: 100
      property variant src: img
      vertexShader: "
      uniform highp mat4 qt_Matrix;
      attribute highp vec4 qt_Vertex;
      attribute highp vec2 qt_MultiTexCoord0;
      varying highp vec2 coord;
      void main() {
      coord = qt_MultiTexCoord0;
      gl_Position = qt_Matrix * qt_Vertex;
      }"
      fragmentShader: "
      varying highp vec2 coord;
      uniform sampler2D src;
      uniform lowp float qt_Opacity;
      void main() {
      lowp vec4 tex = texture2D(src, coord);
      gl_FragColor = vec4(vec3(dot(tex.rgb, vec3(0.344, 0.5, 0.156))), tex.a) * qt_Opacity;
      }"
      }
      }
      }
      @

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved