On Wed, 2009-09-02 at 00:41 +0800, JiangWei Zhou wrote:

> hi, Neil,
>   i once tried clip plane,but i cannot see the correct result, maybe
> because of  my wrong understanding  . because we build our clutter
> based on gles2.0.
> in gles2.0, glClipPlane is not supported yet. so i first consider to
> use
> user-clip-plane to emulate the glClipPlane.
> the following is about user clip plane from gles2.0 programming
> guideline.

<snip>

> in clutter,firstly, i need to figure out the user clip plane. it is
> very cruial in the vertex shader.
> and  the clip plane can be computed from 3 points in one plane.
> here, are those three points from the clipping area( we can just
> choose the rect's three corner point)?
> i am not sure about that.
> 
> can you give me some idea on how to get one correct clip plane for
> clipping which can be applied for user clip
> plane?

Ah yes, I forgot that GLES 2.0 doesn't support clip planes :( I think
the easiest thing to do here would be to patch Clutter and fill in the
cogl_wrap_glClipPlane function in clutter/cogl/gles/cogl-gles2-wrapper.c
That already specifies the plane as four values for the equation. You
could then pass these values on through uniforms to the vertex shader.
If you fill in this function then you can use Clutter's existing
mechanism to calculate the clip planes for a given rectangle. You would
also have to patch _cogl_features_init to set the
COGL_FEATURE_FOUR_CLIP_PLANES flag so that Clutter will try to use the
clip planes. This requires four clip planes for a rectangle so I guess
you would need 16 uniforms to the vertex shader and 4 varyings to pass
to the fragment shader. It could end up being very expensive.

It might also be worth looking in to ways of avoiding clipping
altogether in your application if at all possible. The only thing in
Clutter core that I can think of that requires clipping would be an
editable ClutterText. It is possible to change ClutterText so that it
changes the vertex and texture coords rather than requiring the hardware
to do the clipping. A patch was made for this a while ago in bug #833
but it was never applied because we decided it was simpler to just use
GL's clipping mechanisms.

Regards,
- Neil

> 
> 
> 
> 
> regards
> 
> 
> On Tue, Sep 1, 2009 at 7:18 PM, Neil Roberts <[email protected]>
> wrote:
>         On Tue, 2009-09-01 at 01:01 +0000, jiangwei zhou wrote:
>         
>         >    we know that at present  the clutter's clipping is
>         implemented in
>         > clip plane/stencil  buffer/Scissor.
>         >
>         >    using stencil buffer, we can implement  arbitrarily
>         ploygonous
>         > clipping. it is one very common way to do the clipping in
>         gles.
>         >
>         >    but now ,we have a new demand to implement the clipping
>         without
>         > stencil buffer . because in our target the clipping based on
>         stencil
>         > buffer is very slow, unacceptable.
>         >
>         >    we consider two ways. i hope other guys can give me some
>         suggestion
>         > or new idear.
>         >
>         >     1. if  only rect clipping is considered,can i clip the
>         actor in
>         > fragment shader?
>         >
>         >         the clip arear is in object coordinates, can i in
>         fragment
>         > shader , convert the fragment coord point from clip
>         coordinates to
>         > object coordiantes ,then using rect including algorthim to
>         discard
>         > those not in the area?
>         
>         
>         If the clip region is a rectangle, Cogl should already
>         automatically use
>         glScissor (if possible) or the clip planes if it is not a
>         screen
>         rectangle. I think the clip planes and scissor rect should be
>         quite fast
>         so there probably isn't any benefit to using a fragment shader
>         in this
>         case.
>         
>         Also as far as I understand, using 'discard' on a lot of GLES2
>         hardware
>         is not recommended so it may even end up slower than the
>         stencil buffer.
>         
>         Regards,
>         - Neil
>         
>         --
>         To unsubscribe send a mail to [email protected]
>         
> 

-- 
To unsubscribe send a mail to [email protected]

Reply via email to