[Qt-3d] Transparent sphere in QtQuick3D (with Qt 4.8.2)

Julian de Bhal julian.debhal at nokia.com
Fri Jun 22 05:51:48 CEST 2012


Hi Helmut,

What you're seeing is the opaque objects being drawn after the 
transparent sphere and being clipped because they're failing the depth test.

It's a general OpenGL prinicple to draw your opaque objects first (front 
to back), and then your transparent objects second (back to front) to 
avoid this problem.  We want to automate this for Qt3D users in the 
future, but it's a part of a big task and wont be ready for at least the 
next release.

In the meantime, you can control the draw order yourself simply by 
reordering your items in your QML.  The draworder is top-to-bottom, one 
element and all it's children at a time (with the option of sorting the 
children within an item by depth).

So in this case, If you move the Points element above the Sphere 
element, you'll get the interaction I think you're looking for.  I'll 
attach my source and a screenshot, you'll just need to change the 
version on Qt3D and Shapes back :p

In the general case, try and keep your opaque items above your 
transparent ones in your qml.

The circles inside the sphere are a bug.  I'm not sure why we've got 
parallel layers in there.  It looks like there's an error in our 
rendering as well - https://bugreports.qt-project.org/browse/QTBUG-26275

On 06/22/2012 01:31 AM, ext Mülner, Helmut wrote:On 06/22/2012 01:31 AM, 
ext Mülner, Helmut wrote:
>
> I would like to render a transparent sphere in QtQuick3d. This is my 
> QML file:
>
> import QtQuick 1.1
>
> import Qt3D 1.0
>
> import Qt3D.Shapes 1.0
>
> Rectangle {
>
>     id: topRect
>
>     width: 720
>
>     height: 480
>
>     color: "#3333aa"
>
>     Viewport  {
>
>         anchors.fill: parent
>
>         camera: Camera {
>
>             eye: Qt.vector3d(0,0,15)
>
>         }
>
>         light: Light {
>
>             position: Qt.vector3d(0,0,15)
>
>         }
>
>         blending: true
>
>         Sphere {
>
>             levelOfDetail: 4
>
>             axis: Qt.YAxis
>
>             radius: 2;
>
>             sortChildren: "BackToFront"
>
>             effect: Effect {
>
>                 blending: true;
>
> /*                material: Material {
>
>                     ambientColor: "#40808080";
>
>                     diffuseColor: "#40808080";
>
>                     emittedLight: "#00000000"
>
>                     specularColor: "#00000000"
>
>                 }
>
> */
>
>                 texture: "transparent.png"
>
>             }
>
>             Point {
>
>                 vertices: [
>
>                     -1, 1, 0,
>
>                     -1, -2, 0,
>
>                     1, -2, 0,
>
>                     0, 0, 2,
>
>                     0, 0, -2,
>
>                     2, 0, 0,
>
>                     -2, 0, 0,
>
>                     0, 0, 2,
>
>                     0, 0, -2
>
>                 ]
>
>                 pointSize:  8
>
>                 effect: Effect {
>
>                     color: "#FF0000"
>
>                 }
>
>             }
>
>         }
>
>     }
>
> }
>
> transparent.png is a transparent 512x512 image. ImageMagick says:
>
>   Colors: 1
>
>   Histogram:
>
>     262144: (255,255,255,127) #FFFFFF7F rgba(255,255,255,0.498039)
>
> If I use the commented out material effect, the image looks almost the 
> same:
>
> Depending on the position of the camera I see an almost transparent 
> sphere (at least the color) is blended.
>
> I see some inner circles (parallel cross sections), but I never see 
> the points inside the sphere.
>
> Did I do something wrong or is this a bug in Qt3D?
>
> --**
>
> *Helmut Mülner*
>
> DIGITAL -- Institute of Information and Communication Technologies
>
> JOANNEUM RESEARCH Forschungsgesellschaft mbH
> Steyrergasse 17, 8010 Graz, AUSTRIA
>
> phone:  +43-316-876-2612
>
> general fax: +43-316-876-1191
>
> web: http://www.joanneum.at/digital
> e-mail: _helmut.mülner at joanneum.at <mailto:helmut.m%FClner at joanneum.at>_
>
>
>
> _______________________________________________
> Qt-3d mailing list
> Qt-3d at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-3d


-- 
Julian de Bhál, Software Engineer
Qt Software, Nokia, Brisbane
>
> I would like to render a transparent sphere in QtQuick3d. This is my 
> QML file:
>
> import QtQuick 1.1
>
> import Qt3D 1.0
>
> import Qt3D.Shapes 1.0
>
> Rectangle {
>
>     id: topRect
>
>     width: 720
>
>     height: 480
>
>     color: "#3333aa"
>
>     Viewport  {
>
>         anchors.fill: parent
>
>         camera: Camera {
>
>             eye: Qt.vector3d(0,0,15)
>
>         }
>
>         light: Light {
>
>             position: Qt.vector3d(0,0,15)
>
>         }
>
>         blending: true
>
>         Sphere {
>
>             levelOfDetail: 4
>
>             axis: Qt.YAxis
>
>             radius: 2;
>
>             sortChildren: "BackToFront"
>
>             effect: Effect {
>
>                 blending: true;
>
> /*                material: Material {
>
>                     ambientColor: "#40808080";
>
>                     diffuseColor: "#40808080";
>
>                     emittedLight: "#00000000"
>
>                     specularColor: "#00000000"
>
>                 }
>
> */
>
>                 texture: "transparent.png"
>
>             }
>
>             Point {
>
>                 vertices: [
>
>                     -1, 1, 0,
>
>                     -1, -2, 0,
>
>                     1, -2, 0,
>
>                     0, 0, 2,
>
>                     0, 0, -2,
>
>                     2, 0, 0,
>
>                     -2, 0, 0,
>
>                     0, 0, 2,
>
>                     0, 0, -2
>
>                 ]
>
>                 pointSize:  8
>
>                 effect: Effect {
>
>                     color: "#FF0000"
>
>                 }
>
>             }
>
>         }
>
>     }
>
> }
>
> transparent.png is a transparent 512x512 image. ImageMagick says:
>
>   Colors: 1
>
>   Histogram:
>
>     262144: (255,255,255,127) #FFFFFF7F rgba(255,255,255,0.498039)
>
> If I use the commented out material effect, the image looks almost the 
> same:
>
> Depending on the position of the camera I see an almost transparent 
> sphere (at least the color) is blended.
>
> I see some inner circles (parallel cross sections), but I never see 
> the points inside the sphere.
>
> Did I do something wrong or is this a bug in Qt3D?
>
> --**
>
> *Helmut Mülner*
>
> DIGITAL -- Institute of Information and Communication Technologies
>
> JOANNEUM RESEARCH Forschungsgesellschaft mbH Steyrergasse 17, 8010 
> Graz, AUSTRIA phone:  +43-316-876-2612
>
> general fax: +43-316-876-1191
>
> web: http://www.joanneum.at/digitale-mail: _helmut.mülner at joanneum.at 
> <mailto:helmut.m%FClner at joanneum.at>_
>
> _______________________________________________
> Qt-3d mailing list
> Qt-3d at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-3d


-- 
Julian de Bhál, Software Engineer
Qt Software, Nokia, Brisbane

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-3d/attachments/20120622/20df06f4/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: transparent_sphere.jpg
Type: image/jpeg
Size: 7979 bytes
Desc: not available
Url : http://lists.qt.nokia.com/pipermail/qt-3d/attachments/20120622/20df06f4/attachment-0001.jpg 


More information about the Qt-3d mailing list