【发布时间】:2014-05-02 22:02:36
【问题描述】:
我有一个 3D 网格。是否有可能在 OpenGL 中渲染像glClipPlane 这样的剖面图(剪辑)?
我正在使用 Three.js r65。
我添加的最新着色器是:
片段着色器:
uniform float time;
uniform vec2 resolution;
varying vec2 vUv;
void main( void )
{
vec2 position = -1.0 + 2.0 * vUv;
float red = abs( sin( position.x * position.y + time / 2.0 ) );
float green = abs( cos( position.x * position.y + time / 3.0 ) );
float blue = abs( cos( position.x * position.y + time / 4.0 ) );
if(position.x > 0.2 && position.y > 0.2 )
{
discard;
}
gl_FragColor = vec4( red, green, blue, 1.0 ); }
顶点着色器:
varying vec2 vUv;
void main()
{
vUv = uv;
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
gl_Position = projectionMatrix * mvPosition;
}
【问题讨论】:
-
您找到满意的解决方案了吗?我遇到了similar question。
-
还没有。我仍然有疑问。
-
现在在three.js 中有对此类功能的原生支持。在下面检查我的答案!
-
这个问题具有误导性。如果您正在寻找 Three.js answear,请在问题中指定。 WebGL !=== 三.js
标签: three.js opengl-es-2.0 webgl fragment-shader vertex-shader