일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- conda
- null
- sql
- ngui
- pi
- SVN
- DROP
- Shader
- with
- awk
- postgresql
- dataframe
- C++
- sqlite
- pandas
- List
- c++11
- expect
- python
- SSH
- autovacuum
- mysql
- 배열
- if
- 쉘
- boost
- ubuntu
- FIND
- Eclipse
- Unity
Archives
- Today
- Total
その先にあるもの…
NVidia NearClipPlane 본문
예전에 물을 구현할 때 물 표면에 반사되는 씬을 clipping할때 사용
void NearClipPlane::ClipProjectionMatrix(D3DXMATRIXA16 & matView, D3DXMATRIXA16 & matProj, D3DXPLANE & clip_plane, LPDIRECT3DDEVICE9 pd3dDevice) { D3DXMATRIXA16 matClipProj; D3DXMATRIXA16 WorldToProjection; WorldToProjection = matView * matProj; // m_clip_plane is plane definition (world space) D3DXPlaneNormalize(&clip_plane, &clip_plane); D3DXMatrixInverse(&WorldToProjection, NULL, &WorldToProjection); D3DXMatrixTranspose(&WorldToProjection, &WorldToProjection); D3DXVECTOR4 clipPlane(clip_plane.a, clip_plane.b, clip_plane.c, clip_plane.d); D3DXVECTOR4 projClipPlane; // transform clip plane into projection space D3DXVec4Transform(&projClipPlane, &clipPlane, &WorldToProjection); D3DXMatrixIdentity(&matClipProj); if (projClipPlane.w == 0) // or less than a really small value { // plane is perpendicular to the near plane pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj); return; } D3DXVec4Normalize(&projClipPlane, &projClipPlane); // bug fix by David Whatley if (projClipPlane.w > 0) { projClipPlane = -projClipPlane; projClipPlane.w += 1; } // put projection space clip plane in Z column matClipProj(0, 2) = projClipPlane.x; matClipProj(1, 2) = projClipPlane.y; matClipProj(2, 2) = projClipPlane.z; matClipProj(3, 2) = projClipPlane.w; // multiply into projection matrix D3DXMATRIXA16 projClipMatrix = matProj * matClipProj; pd3dDevice->SetTransform( D3DTS_PROJECTION, &projClipMatrix); }
http://download.nvidia.com/developer/SDK/Individual_Samples/DEMOS/Direct3D9/NearClipPlane.zip
'프로그래밍 > 3D' 카테고리의 다른 글
Frustum 그리기 (0) | 2015.03.19 |
---|---|
Z Buffer State (0) | 2015.03.04 |
Dissolve Shader (0) | 2015.02.11 |
normal에 역행렬 전치행렬하는 이유 (0) | 2014.03.25 |
동차좌표(homogeneous coordinate) (0) | 2014.02.06 |
Comments