[Cogl] Shader and blend string in Mash

Neil Roberts neil at linux.intel.com
Fri Nov 21 10:53:34 PST 2014


Hi Elias,

I think what you need to fix this is the depth buffer. The depth buffer
is a GL feature to avoid painting parts of triangles that are obscured
by something that was painted earlier but is closer to the viewer.

It's a bit awkward to use the depth buffer with Mash. If you look at the
lights example in the Mash source code you can see two lines where it it
registers a callback before and after the paint signal of the model to
enable and disable depth testing:

https://github.com/clutter-project/mash/blob/master/examples/lights.c#L455

If you do something similar in your application it might just work. I'm
not sure how tricky this is to do in Python.

However, something to note is that this API to enable and disable the
depth buffer is deprecated in Cogl and it might not be terribly
efficient. The recommended way to do it now is to call
cogl_pipeline_set_depth_state to enable it for the pipeline of the
model. You can get access to the pipeline with mash_model_get_material.
However I'm not sure how well this will work in Python and in practice
it will probably just work fine to use the old deprecated way so I would
recommend just doing that.

Hope that helps.

Regards,
- Neil

Elias Bakken <elias.bakken at gmail.com> writes:

> Hello, list!
> I've been struggling for a long time with Mash and how to get a model
> looking somewhat natural.
> The only way a model will look is either flat shaded or something that
> looks like transparent, but not quite..
>
> I have recently extended Mash to also be able to load .STL models in
> addition to .PLY since this is going to be used for a 3D-printer UI, but my
> limited knowledge of 3D-graphics, shaders and blend strings has caused my
> work to come to a halt.
>
> Is there something in the new pipeline API that can cause not visible faces
> to be drawn as well as the visible ones by default? If I set backface
> culling to 1 (COGL_PIPELINE_CULL_FACE_MODE_BACK is not exposed for some
> reason...), then the symptoms disappear, at least for simple model like a
> cube, more complex models still have some "transparency", perhaps since
> there are faces facing the camera...
>
> Or is there something wrong with the shader:
> https://github.com/clutter-project/mash/blob/master/mash/mash-light-set.c#L264
>
> See attachments (hopefully) for with/without backface culling.
> Kind regards,
> -Elias
> _______________________________________________
> Cogl mailing list
> Cogl at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/cogl


More information about the Cogl mailing list