question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

user defined clip plane

See original GitHub issue

I’d like to use user defined clipping planes. In openGL i would use:

glClipPlane(GL_CLIP_PLANE0, planeEq);
glEnable(GL_CLIP_PLANE0);

How can I do the same with webGL?

Issue Analytics

  • State:closed
  • Created 12 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
Slayvincommented, Aug 21, 2013

Hey many thanks guys!!

Your suggestions made me reconsider the problem, and I noticed that there was no ‘general’ lag, but only flickering when the near clip plane changes (the mirror position compared to the mirrored camera position).

So, you were almost there @WestLangley: it’s the matrices of the mirrored camera you need to update, not the camera itself.

Result: no more ‘lag’ : http://jsfiddle.net/slayvin/PT32b/2/ 😃

Maybe we could abstract this into it’s own object.

Yes, I’ve thought about it. It would be great to have a new THREE.mirror() that handles everything. I’ll try to code something…

2reactions
Slayvincommented, Aug 20, 2013

I recently encountered the same problem while implementing reflective flat surfaces (aka ‘mirrors’ 😄 ) into three.js As far as I know, you can not have user-defined clipping planes with WebGL, at least not with the ‘simple’ openGL way you described. The trick is to use the “Oblique View Frustum” method, which is explained in this paper: http://www.terathon.com/lengyel/Lengyel-Oblique.pdf The purpose of this method is to replace the near clip plane of your mirrored camera frustum by the plane defined by the reflective surface. There is even some source code provided (in C++ though): http://www.terathon.com/code/oblique.html

I successfully ported that method in three.js and here is a sample scene to show this live: http://jsfiddle.net/slayvin/PT32b/

The only remaining issue is that the renderTarget is rendered a frame behind, and I have no clue why! This causes some flickering when the camera moves too fast and when the mirror is going through other objects.

Any idea on how to fix this? Do I need to implement a kind of multi-buffering method, or is it simply because I don’t udpdate the camera matrix after modifying the frustum? If so, how can I do that?

Read more comments on GitHub >

github_iconTop Results From Across the Web

User-Defined Clip Plane - OpenGL Wiki
User -Defined Clip Plane. From OpenGL Wiki. Redirect page. Jump to navigation Jump to search. Redirect to:.
Read more >
User clip planes on feature level 9 hardware - Win32 apps
A clip plane is defined by a vector with 4 components. The first three components define an x, y, z vector that emanates...
Read more >
Clip Planes
I define my half-space using a unitized normal vector in (A,B,C) and a distance-from-origin in D. Clip planes are usually defined in world...
Read more >
User-defined clipping planes, TInputShortcut example
ClipPlane allows you to define custom clipping planes. See our documentation of nodes, X3D documentation of ClipPlane, and a simple demo or very ......
Read more >
Post: Clipping Plane - MIDAS IT
It displays the defined Clipping Plane when user click the Apply button in the Property Window or the Plot button in the Define...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found