Jump to content

[SOLVED] Problem with clipping plane


photo

Recommended Posts

Hi,

I am currently facing a problem with clipping plane. In my project, I need to implement a function that clips the plane of the object. To do it in a naive way, I can use the OpenGL function glClipPlane.  If we use this function on a fixed pipeline setting, this works out. However, in the Unigine system, this is a programmable pipeline environment. So probably we will need to implement a shader for this functionality. So how can we do this? Is there a simple way to add a shader in Unigine to clip plane? Or there is even a solution that I don't need a shader to do this?  If I implement this in an existing shader, for instance the vertex_copy.shader, will this have potential bad influence on it?

 

Thanks!

Link to comment

There already was a similar feature request for build-in geometry clipping. I think it still is on a very long wish list. If you have to implement it on your own I would assume that you have to modify PIXEL shaders instead of vertex shaders for getting pixel-precise clipping.

 

A clipping plane (in world coordinates) could be provided via vec4 material parameter and within pixel shader you could reconstruct pixel world position and test it against this plane. If the pixel is on the clip side that you simply discard the pixel.       

Link to comment

Our devs generated one more variant: use an oblique projection matrix to create a clipping plane. If such matrix is set as Projection one, it could do the trick.

Link to comment

Our devs generated one more variant: use an oblique projection matrix to create a clipping plane. If such matrix is set as Projection one, it could do the trick.

I do not quite understand what you mean by using an oblique projection matrix? If I understood, what you mean is using the advantage of frustum of the projection matrix to clip the object? If my projection matrix  for clipping the plane is m1, and the real projection matrix is m2.  Then I should do:

m1 * m2 * model_view?

Link to comment
  • 3 months later...

Our devs generated one more variant: use an oblique projection matrix to create a clipping plane. If such matrix is set as Projection one, it could do the trick.

 

 

could you explain it more clearly?

Link to comment
  • 2 months later...
×
×
  • Create New...