<div dir="ltr">Hi Robert,<div>Thanks again for your info. So due to increasing issues with transparency and depth testing in our project for more 3D UIs and UIs that just want to use depth instead of changing the draw order to simulate depth all the time, I'm really thinking of attempting to modify the clutter source code and change the rendering code to implement the multi-pass gaming rendering technique you mentioned above. </div>
<div>It seems that there would be several steps on the way to achieving that goal, first of which would be to make sure render nodes are used for all painting and then building a full scene tree of render nodes so that it can be split and sorted. Also render nodes would need additional information such as the full transformation matrix and state of depth testing and whether there is any transparency which might be difficult to determine sometimes, such as if it is in an alpha channel of a texture. Then there are ClutterEffects to deal with. Then there are other state changes happening in clutter_actor_paint() that need to be captured in the render nodes. There are probably many more things to deal with. How much work do you think this is? Am I going to hit difficult road blocks?</div>
<div><br></div><div>Thanks,</div><div>Reza</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jan 6, 2014 at 3:37 PM, Robert Bragg <span dir="ltr"><<a href="mailto:robert@sixbynine.org" target="_blank">robert@sixbynine.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Reza,<br>
<br>
I'm afraid this is going to be awkward to handle for a few different reasons...<br>
<br>
One issue here is that cogl-pango currently abstracts away what<br>
CoglPipeline gets used internally during _draw_layout(). This is<br>
necessary to some extent because pango supports rich text and so<br>
cogl-pango at least needs to be able to change the color, but also<br>
because internally glyphs are stored in a number of atlas textures and<br>
for any given text cogl-pango needs to figure out what texture the<br>
glyphs you need are stored in and setup the CoglPipeline so it reads<br>
from the right texture.<br>
<br>
It would be good to add a way for a user to perhaps specify a template<br>
pipeline that cogl-pango could then derive from before maying any<br>
changes, or alternatively add some hooks that give you enough<br>
information to completely own how all CoglPipelines are created.<br>
<br>
Besides this missing api capability though, you should understand that<br>
each glyph is basically drawn as a textured rectangle that maps a<br>
sub-region of a glyph-cache atlas texture to the rectangle that bounds<br>
that glyph. This means that in terms of geometry each glyph is<br>
represented as a rectangle and so you can't just rely on depth testing<br>
based on the geometry, you also need to make sure that you discard<br>
transparent and semi transparent fragments so they don't affect depth<br>
testing. If you do that though you will be left with horrible jaggie<br>
edges on all of your glpyhs I think that will be difficult to address,<br>
given the design of Clutter.<br>
<br>
I'm afraid that there is no silver bullet for this kind of problem and<br>
clutter and cogl-pango aren't currently well geared to support your<br>
use case. Although we created toys in the past that used depth testing<br>
with Clutter, it was never really considered a priority when there was<br>
no pressing use case which means that Clutter isn't designed to take<br>
advantage of GPU depth testing.<br>
<br>
Often applications using the GPU (e.g. games using OpenGL/D3D) that<br>
want to use depth testing to avoid overdraw but that also need to draw<br>
transparent objects will use a two pass approach. They will do an<br>
opaque pass that draws all opaque objects with depth writing and<br>
testing enabled in a front-to-back order and then they will do a<br>
blending pass that will draw all transparent objects with blending<br>
enabled, depth testing enabled, depth write disable and in a<br>
back-to-front order. The way Clutter is currently designed, it only<br>
has one pass with no depth sorting and it doesn't know about GPU depth<br>
testing itself (it's just that actors can use Cogl to use depth<br>
testing without Clutter being aware). This means it will be difficult<br>
to solve this in the same way that something like a game engine could.<br>
<br>
As it happens I'm currently working on a project called Rig, which is<br>
trying to create a UI technology and design tool that can hopefully<br>
help us better utilize modern GPUs in UI design, but I'm afraid it's<br>
such early days for that, that it probably wouldn't be helpful for you<br>
yet. From the sounds of what you're trying to do with Clutter though,<br>
it seems you're treading uncharted territory and I think this is an<br>
example of something that's going to be difficult to handle well.<br>
<br>
Sorry that this answer might not be very helpful to you.<br>
<br>
kind regards,<br>
Robert<br>
<div><div class="h5"><br>
<br>
On Sat, Dec 14, 2013 at 3:10 AM, Reza Ghassemi <<a href="mailto:reza.robin1@gmail.com">reza.robin1@gmail.com</a>> wrote:<br>
> Hi,<br>
><br>
> If I have two ClutterText actors at different depths and have depth testing<br>
> enabled, the text itself still draws only in the order the actors are added<br>
> to the stage, regardless of their depths.<br>
><br>
> Is this a known limitation due to how the cogl-pango API is implemented?<br>
> How hard would this be to fix?<br>
> I notice in cogl-pango-render.c in cogl_pango_show_layout:<br>
><br>
> if (qdata->display_list == NULL)<br>
> {<br>
> ...<br>
> ...<br>
> pango_renderer_draw_layout (PANGO_RENDERER (priv), layout, 0, 0);<br>
> priv->display_list = NULL;<br>
><br>
> qdata->mipmapping_used = priv->use_mipmapping;<br>
> }<br>
><br>
> cogl_framebuffer_push_matrix (fb);<br>
> cogl_framebuffer_translate (fb, x, y, 0);<br>
><br>
> _cogl_pango_display_list_render (fb,<br>
> qdata->display_list,<br>
> color);<br>
><br>
> cogl_framebuffer_pop_matrix (fb);<br>
><br>
> This looks like pango_renderer_draw_layout is drawing it to an offscreen<br>
> buffer then it is being drawn to the cogl framebuffer. So why does it not<br>
> obey depth testing?<br>
><br>
><br>
> Thanks,<br>
> Reza<br>
><br>
</div></div>> _______________________________________________<br>
> Cogl mailing list<br>
> <a href="mailto:Cogl@lists.freedesktop.org">Cogl@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/cogl" target="_blank">http://lists.freedesktop.org/mailman/listinfo/cogl</a><br>
><br>
</blockquote></div><br></div>