Oblique Frustum Clipping
这里是例子代码:
http://www.terathon.com/code/oblique.html
具体的说明可以参见 http://www.opengl.org/discussion_boards/cgi_directory/ultimatebb.cgi?ubb=get_topic;f=6;t=000170
其重要部分摘录如下:
Let P = (Px, Py, Pz, Pw) be the eye-space plane to which you would like to clip.This will replace your ordinary near plane and should be facing away from thecamera, so Pz < 0. Let Q be an eye-space point. If P dot Q = 0, then Q lies on the plane P. What we want to do is modify the projection matrix M so that points Q forwhich P dot Q = 0 get transformed in such a way that the transformed z-coordinateis the negation of the transformed w-coordinate. This corresponds tothe projected z-coordinate that you would ordinarily get for a point lyingon the near plane. After division by the w-coordinate, you get -1. The projection matrix M transforms points from eye space into homogeneous clipspace. To obtain the clip-space plane P', we need to multiply P by the inversetranspose of M. (This is because planes are covariant vectors.) The clip-spaceplane P' is given by -1 TP' = (M ) P Let Q' be the projection of the point Q, given by Q' = MQ. If Q lies on the plane P,then P' dot Q' = 0, but we want it to be -Q'w so that it corresponds to the near plane.So we force it by subtracting 1 from the w-coordinate of P'. Before doing this,however, we want to divide P' by its z-coordinate as to avoid scaling the zdirection in clip space. Doing all of this gives us the following plane P": P'x P'y P'wP" = (-----, -----, 1, ----- - 1) P'z P'z P'z We integrate this into the projection matrix M by constructing a new projectionmatrix M' as follows. [ 1 0 0 0 ] [ ] [ 0 1 0 0 ]M' = [ ] M [ P"x P"y 1 P"w ] [ ] [ 0 0 0 1 ] The matrices M and M' only differ in the entries of the 3rd row, so we could justcalculate replacements for 3rd-row entries of M as follows: M'(3,1) = P" dot M_1M'(3,2) = P" dot M_2M'(3,3) = P" dot M_3M'(3,4) = P" dot M_4 where M_i means the i-th column of M and M'(i,j) means the (i,j)-th entry of M'.
Okay -- here's the short, short version of the optimal implementation of the oblique frustum. Let C = camera-space clipping plane. Assume the camera is on the negative side of the plane: C_w < 0. Let M be the original projection matrix; M must be invertible, but otherwise we don't care whatit is. We'll modify the third row of M so that the near plane coincides with the arbitraryclipping plane C. We aren't allowed to modify the fourth row of M because doing so would screwup the perspective-correct vertex attribute interpolation. (The fourth row usually justmoves the z-coordinate of a camera-space point into the w-coordinate of a clip-space point.) Given a projection matrix M, the near plane is always M_4 + M_3, and the far plane is alwaysM_4 - M_3. (M_i means the i-th row of M.) To force the near plane to coincide with theclipping plane C, we must have M_3 = aC - M_4, where a is some positive scale factor that wecan adjust. Why adjust a? Because now our far plane F has been moved to F = 2*M_4 - aC, which is notgenerally parallel to C. F intersects C on the x-y plane, so it's really not in a goodposition. The best we can do is minimize the size of the view frustum by choosing theconstant a so that F contains the corner Q of the view frustum opposite the near plane C.This point Q is given by Q = M^-1 * (sgn(C_x), sgn(C_y), 1, 1), where M^-1 is the inverse of the projection matrix. (The points (+/-1, +/-1, 1, 1) are thefour corners of the view frustum on the far plane in clip space.) The scale factor a is nowgiven by a = (2*M_4 dot Q) / (C dot Q). Since M_4 is usually (0, 0, -1, 0), this can be simplified a little. All we have to do to the original projection matrix M is replace the third row with aC - M_4. -- Eric Lengyel
Oblique Frustum Clipping相关推荐
- Avoiding 16 Common OpenGL Pitfalls(避免 16 个常见的 OpenGL 陷阱)
前言 避免 16 个常见的 OpenGL 陷阱原文 Avoiding 16 Common OpenGL Pitfalls Copyright 1998, 1999 by Mark J. Kilgard ...
- CG 学习 (1)——CG概览
去年因为去Moto上海研发中心研究人机交互的部门去面试, 临时学了一个星期的CG 编程,后来就束之高阁了,现在重新拾起来,在这里给自己学习历程留下一个回忆,若能给初学者一些借鉴,不胜荣幸. 学一门编程 ...
- 3D图形的概念和渲染管线(Render Pipeline)
3D图形的概念和渲染管线(Render Pipeline) 前面介绍了3D图形历史,接下来要解说的是3D图形的处理流程. 3D图形管线的流程图 图1是3D图形的流程模型.这个虽然是对应DirectX ...
- 西川善司的3D图形技术概念和渲染管线的处理
from: http://psv.tgbus.com/news/ynzx/201305/20130528094843.shtml 3D图形技术概念和渲染管线的处理 一:3D图形的概念 图1是3D图形的 ...
- [西川善司]3D图形技术概念和渲染管线的处理
翻译 Trace校对&注解 千里马肝: http://www.opengpu.org/forum.php?mod=viewthread&tid=7376&extra=page% ...
- 【西川善司】3D图形的概念和渲染管线(5回完)
本文取自西川善司的3D图形技术连载,全99回 本贴为9~13回,争取每1~2天更新一回吧.半年更新完. 也希望大家能支持. 翻译 Trace 校对&注解 千里马肝 http://www.ope ...
- 软光栅个人项目介绍,编写思路及后期整理
软光栅项目主要是在学习了计算机图形学相关知识之后,主要是Games101,202,tiny shader等教程,然后借鉴了很多前辈们的思路和框架逻辑编写的. 渲染帧率来说,blinn-phong渲染维 ...
- 【西川善司的3D图形技术连载】3D图形的概念和渲染管线(Render Pipeline)(9~13回)
3D图形的概念和渲染管线(Render Pipeline) 前面介绍了3D图形历史,接下来要解说的是3D图形的处理流程. 3D图形管线的流程图 图1是3D图形的流程模型.这个虽然是对应DirectX ...
- DirectX下 Viewing Frustum 的详细实现
本文大部分内容翻译自Gil Gribb和Klaus Hartmann合写的<Fast Extraction of Viewing Frustum Planes from the World-Vi ...
最新文章
- 美国星巴克肯德基明年将支持Apple Pay
- python中不能使用索引运算的是_Python数据分析之Pandas库(笔记)
- 转: HTTP 错误 401.1 - 未经授权:访问由于凭据无效被拒绝的另类解决方案
- C#中全局作用域的常量、字段、属性、方法的定义与使用
- 数据库内容导出为excel并下载
- 数据分析与挖掘实战-航空公司客户价值分析
- Unity Shader 屏幕后效果——Bloom外发光
- 【具体数学--读书笔记】1.1 The Power of Hanoi
- linux 常用指令汇总
- onmounted vue3_Vue3.x 生命周期 和 Composition API 核心语法理解
- C#实现百度AI-实时语音识别转写-附源码
- java服务端监控平台设计
- PTA 硬币找钱问题
- Android 之 Activity 的生命周期(PS:文章多图,流量警告)
- 国内外对于GaN中Fe相关点缺陷结构的局域特性的研究进展
- 深度学习入门 ---稀疏自编码器
- springMVC + Dubbo + zooKeeper超详细 步骤
- 关闭交互式服务检测(UI0Detect)
- OPPO 2019校园招聘C/C++开发工程师(手机方向) 笔试编程题-2018.09.10
- 最实用的深度学习教程 Practical Deep Learning For Coders (Kaggle 冠军 Jeremy Howard 亲授)
热门文章
- Linkage Mapper 之 Barrier Mapper 功能解析(含实际案例分析)
- svchost -k DcomLaunch CPU占有过高解决方法
- 卧槽!GitHub标星7.9K star,抢茅台酒脚本竟然开源了!网友:已抢到,真香!
- 多元(二元)函数极限的存在性问题
- F#基础教程 定义mutable记录类型
- 计算机组成与系统结构实验-基于微程序控制的CPU设计
- 编译chrome for android,Chrome for Android 编译了两天终于在师傅指导下搞定
- 正常正则表达式(不允许为空)
- 2021SC@SDUSC-Zxing(一):Zxing初步认识
- Java的本地内存 直接内存 元空间