[Qt-3d] Transparent sphere in QtQuick3D (with Qt 4.8.2)
Sylvain THIBAUT
Sylvain.THIBAUT at amplitude-ortho.com
Fri Jun 22 08:21:34 CEST 2012
Hi,
If you want to avoid the parallel layers, you should just enable the back face culling (Item3D{cullFaces: Item3D. CullBackFaces}). This is a side effect of glBlengFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SOURCE_ALPHA) which is the default blend function, the final result depends on the rendering order. The sphere is a convex surface, so disabling the back face rendering should normally work.
Regards,
Sylvain
De : qt-3d-bounces+sylvain.thibaut=amplitude-ortho.com at qt.nokia.com [mailto:qt-3d-bounces+sylvain.thibaut=amplitude-ortho.com at qt.nokia.com] De la part de Julian de Bhal
Envoyé : vendredi 22 juin 2012 05:52
À : "ext Mülner, Helmut"
Cc : qt-3d at qt.nokia.com
Objet : Re: [Qt-3d] Transparent sphere in QtQuick3D (with Qt 4.8.2)
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<mailto: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)
}
&nb!
sp; &
nbsp; blending: true
Sphere {
levelOfDetail: 4
axis: Qt.YAxis
radius: 2;
sortChildren: "BackToFront"
&nbs!
p; ef
fect: Effect {
blending: true;
/* material: Material {
ambientColor: "#40808080";
diffuseColor: "#40808080";
emittedLight: "#00000000"
specularColor: "#00000000"
}
*/
texture: "transparent.png"
}
Point {
vert!
ices: [
-1, 1, 0,
-1, -2, 0,
1, -2, 0,
0, 0, 2,
0, 0, -2,
!
&nbs
p; 2, 0, 0,
-2, 0, 0,
0, 0, 2,
0, 0, -2
]
pointSize:&nb!
sp; 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<mailto: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/ad9842f4/attachment-0001.html
More information about the Qt-3d
mailing list