Forums

OverviewV-Play 2 Support (Qt 5) › Antialiasing

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #9707

    Tobias

    Hello,

    I have a few rotating elements in my game. Everytime anything is spinning the edges are drawn not very nicely. I already tried to enable msaa, by adding QSG_ANTIALIASING_METHOD = msaa to the build environment variables in QtCreator. But nothing changed.
    Are there any suggestions what to do?

    Thanks

    • This topic was modified 2 years, 12 months ago.
    #9709

    Philipp

    From the Qt Docu: http://doc.qt.io/qt-5/qml-qtquick-item.html#antialiasing-prop

    antialiasing : bool

    Used by visual elements to decide if the item should use antialiasing or not. In some cases items with antialiasing require more memory and are potentially slower to render (see Antialiasing for more details).

    The default is false, but may be overridden by derived elements.

     

    • This reply was modified 2 years, 12 months ago by  pklaffert.
    #9711

    Tobias

    I have already tried this. -> nothing changed

    EntityBase {
    id: plate
    entityId: “plate”
    entityType: “t_plate”
    x: 100
    y: 100

    antialiasing: true

    height: plate_collider.height
    width: plate_collider.width
    transformOrigin: Item.TopLeft
    MultiResolutionImage {
    id: plateImage
    source: “qrc:///imgs/plate/plate.png”
    width: plate.width
    height: plate.height * 4
    x: -plate.width/2
    y: -gameWindow.step * 2

    antialiasing: true
    }

    property double originX: gameScene.width/5 //+ plate.width/2// * 2.5
    property double originY: gameScene.height – (ground.anchors.bottomMargin + ground.height – plate.height*0.55)
    property double bounce_height: gameWindow.step * defs.plate_bounce_height
    property double bounce_radius: bounce_height*2
    property double bounce_default_speed: – bounce_height / defs.plate_bounce_time_default

    BoxCollider {
    id: plate_collider
    x: -plate.width/2
    y: -plate.height/2
    width: hero.width * 2
    height: gameWindow.step
    categories: Box.Category4
    collidesWith: Box.Category2
    friction: 0
    restitution: 0
    bodyType: Body.Kinematic

    antialiasing: true
    }

    onYChanged: {
    if(y < originY-bounce_height)//(gameScene.height – (ground.anchors.bottomMargin + ground.height + bounce_height)))
    {
    plate_collider.linearVelocity.y = -bounce_default_speed //-plate_collider.linearVelocity.y
    }
    else
    {
    if(y > originY)//gameScene.height – (ground.anchors.bottomMargin + ground.height))
    {
    plate_collider.linearVelocity.y = 0
    y = originY//gameScene.height – (ground.anchors.bottomMargin + ground.height)
    }
    }
    var dx = (1 – Math.sqrt(1 – Math.pow((originY-y)/bounce_radius , 2 ) ))
    x = originX + bounce_radius * dx
    console.log( Math.asin(dx)*180/Math.PI )
    rotation= Math.asin(dx)*180/Math.PI
    }
    }

    • This reply was modified 2 years, 12 months ago by  Terry86.
    #9713

    Alex
    V-Play Team

    Hi Terry,

    pklaffert had the right idea, but the problem are the internals of the MultiResolutionImage component. It is an Item with an Image as child, so setting the antialiasing property doesn’t affect the Image. As a workaround you can access the antialiasing property of the internal image by adding image.antialiasing: true to the MultiResolutionImage. (you can ignore the warning of QtCreator that imagehas no members, this is just an autocompletion issue of the editor)

    We will change the internal image to inherit the antialiasing property of it’s internal Item parent with the next update.

    Cheers,
    Alex

    • This reply was modified 2 years, 12 months ago by  Alex.
    #9715

    Tobias

    Hi Alex,

    I updated the code like this

    MultiResolutionImage {
    id: plateImage
    source: “qrc:///imgs/plate/plate.png”
    width: plate.width
    height: plate.height * 4
    x: -plate.width/2
    y: -gameWindow.step * 2
    antialiasing: true
    smooth: true
    image.antialiasing: true
    }

    But with no effect.

    #9716

    Alex
    V-Play Team
    #9717

    Tobias
    #9719

    Tobias

    Is there a way it enable msaa and to set the semples?

    When adding QSG_ANTIALIASING_METHOD = msaa to the build environment variables in QtCreator antialiasing isn’t performed anymore.

    #9745

    Tobias

    Ok, maybe it was obvious but now I’ve found the solution to turn on msaa (multisampling) which brings you a slightly better result than the default vertex antialiasing.

    QQmlApplicationEngine engine; // something like this should already be in your code
    vplay.initialize(&engine); // something like this should already be in your code
    vplay.setMainQmlFileName(QStringLiteral("qml/Main.qml")); // something like this should already be in your code
    engine.load(QUrl(vplay.mainQmlFileName())); // something like this should already be in your code
    QQuickWindow* window = (QQuickWindow*) m_engine.rootObjects().first();
    QSurfaceFormat format;
    format.setSamples(16);
    window->setFormat(format);

    Maybe you also have to add QSG_ANTIALIASING_METHOD to the variables of the build environment in QtCreator and assign it the value msaa. By default the value should not be in the list and therefore the value vertex will be assigned, if I’m right.

    • This reply was modified 2 years, 11 months ago by  Terry86.
    • This reply was modified 2 years, 11 months ago by  Terry86.
    #9752

    Alex
    V-Play Team

    Hi Terry,

    thanks a lot for sharing your code!

    Cheers,
    Alex

    #9844

    Bas

    yess, i needed that too

    #11713

    Tobias

    Is the “image.antialiasing: true”-issues solved in the new version (2.6) ? I.e. do you changed the internal image to inherit the antialiasing property of it’s internal Item parent?

    #11715

    Christian
    V-Play Team

    Hi Tobias,

    yes the antialiasing property is now forwarded internally.

    Cheers, Chris

Viewing 13 posts - 1 through 13 (of 13 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support