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.
////////
one plane can be sepcified by :
Ax+By+Cz+D = 0;
The vector (A, B, C) represents the normal of the plane and the value D is
the distance of the plane along that vector from the origin.

To figure out whether a point should or should not be clipped against a
plane, we need
to evaluate the distance from a point P to a plane with the equation:
Dist = (A × P.x) + (B × P.y) + (C × P.z) + D

If the distance is less than 0, we know the point is behind the plane and
should be clipped and if the distance is greater than or equal to 0, it
should
not be clipped.
//user clip plane vertex shader
uniform vec4 u_clipPlane;
uniform mat4 matViewProjection;
attribute vec4 rm_Vertex;
varying float u_clipDist;
void main(void)
{
// Compute the distance between the vertex and the clip plane
u_clipDist = dot(rm_Vertex.xyz, u_clipPlane.xyz) + u_clipPlane.w;
gl_Position = matViewProjection * rm_Vertex;
}
/////////////
according to those,

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?




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]<clutter%[email protected]>
>
>

Reply via email to