开发者

OpenGLES Shadow Volume

I succesfully implement shadow volume on iOS.

However I got the following issue how can I clip the vertex position to the far plane like NV_depth_clamp is doing in GLSL? this is my vertex shader code:

void main( void ) { 

highp vec3 eyepos = vec3( MODELVIEW * vec4( VERTEX, 1.0 ) );

normal = normalize( NORMALMATRIX * NORMAL );

highp vec3 ldir = normalize( LIGHTPOS - eyepos );

highp float开发者_高级运维 ndotl = max( dot( normal, ldir ), 0.0 );

// How can I clip that to the far plane automatically!??!!?
if( ndotl > 0.0 ) gl_Position = PROJECTION * vec4( eyepos + ( ldir * -2000.0 ), 1.0 );

else  gl_Position = PROJECTION * vec4( eyepos, 1.0 );
}

Second, while searching for the issue above, I found that the shadow volume zfail method (which is what I implement) is patented is that true? does that mean I can't use it in a commercial application on the App Store?

TIA!


Cheers, at the far clip plane, z/w = 1. So you need to transform both eyepos and ldir by projection, and then add as much ldir to eyepos so that it ends up at the far plane. This might be tricky though, because the far clip plane may clip your polygons if they lie exactly on it, so some tweaking might be required.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜