Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. How do I create QtQuick class using custom shaders in Qt Quick Scene Graph rendering?
Forum Updated to NodeBB v4.3 + New Features

How do I create QtQuick class using custom shaders in Qt Quick Scene Graph rendering?

Scheduled Pinned Locked Moved Unsolved Qt 6
2 Posts 1 Posters 213 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.
  • W Offline
    W Offline
    wooseokyourself
    wrote on last edited by
    #1

    Hi. i'm developing desktop app targeting Windows, and it's constructed by QML for UI and C++ for backend. (Qt 6)

    Let me assume my app is a FPS game to simplify explaining my situation. In C++ parts, there are an image of game scene and a vertex which represents a cross-hair. And I want to show the composition of game scene and the cross-hair through QML.

    So I just draw the cross-hair directly in the game scene in C++ part and let QML's viewport to read this image as a property and show. It works fine.

    But from now on I need to apply custom shader to the game scene. Of course, this shader should not be applied in the cross-hair.

    So I've found Qt Quick Scene Graph but still can't figure it out. As far as I understand, I have to make my QML's viewport to read a texture of the game scene and the cross-hair vertex as a properties, and when the Qt Quick scene graph rendering is called, the viewport needs to render each of these two properties with a custom shader.

    If I'm right, which class should I inherit from and override to use my custom shaders in QML?

    Any advice will be appreciated. Thanks.

    1 Reply Last reply
    0
    • W Offline
      W Offline
      wooseokyourself
      wrote on last edited by wooseokyourself
      #2

      I found a great example that might be helpful for my problem.

      https://doc.qt.io/qt-6/qtquick-scenegraph-custommaterial-example.html

      If I’m success I’ll post it here.


      I couldn't make it cuz the scene graph of Qt Quick2 can't have more than one shader for its nodes.

      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