Chen.Gaowei Posted March 13, 2013 Share Posted March 13, 2013 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
ulf.schroeter Posted March 13, 2013 Share Posted March 13, 2013 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
Chen.Gaowei Posted March 14, 2013 Author Share Posted March 14, 2013 Will I be able to add a custmoized shader into Unigine? And if so, how can I do it? Link to comment
ulf.schroeter Posted March 14, 2013 Share Posted March 14, 2013 Yes, this its possible. One example for a custom shade https://developer.unigine.com/forum/topic/439-masking-a-viewport/#entry4083 There are some more examples, search the forum for 'shader' keyword Link to comment
ulf.schroeter Posted March 14, 2013 Share Posted March 14, 2013 https://developer.unigine.com/forum/topic/925-how-can-i-get-a-objects-world-position-in-a-vertex-shader/?hl=shader#entry4535 Link to comment
ulf.schroeter Posted March 14, 2013 Share Posted March 14, 2013 https://developer.unigine.com/forum/topic/277-use-special-shader-in-unigine/?hl=shader#entry1396 Link to comment
ulf.schroeter Posted March 14, 2013 Share Posted March 14, 2013 And finally a sample for world position reconstruction https://developer.unigine.com/forum/topic/1798-solved-how-to-get-depth-information-outof-the-graphics-card/?p=9688 Link to comment
manguste Posted March 14, 2013 Share Posted March 14, 2013 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
Chen.Gaowei Posted March 19, 2013 Author Share Posted March 19, 2013 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
Zhou.Alone Posted July 10, 2013 Share Posted July 10, 2013 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
frustum Posted September 15, 2013 Share Posted September 15, 2013 Check the data/samples/render/oblique_00.cpp sample for more detail. But currently we have problem with world light source when oblique perspective projection is enabled. Link to comment
Recommended Posts