Home » Community » Forums » » Virtual Camera Position (VCP)
  Intel sponsors gamedev.net search:   
[Control Panel] [Register] [Bookmarks] [Who's Online] [Active Topics] [Stats] [FAQ] [Search]

Add Forum to Favorites |  Send Topic To a Friend | View Forum FAQ | Track this topic


 Last Thread Next Thread 
 Virtual Camera Position (VCP)
Post Reply 
Interesting technique

 User Rating: 1318   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Shouldn't it be possible to eliminate the step of rendering to the texture, rendering the reflection directly to the final video buffer instead?

I think it would just require a little more calculation involving the clipping planes and the camera transformation.

 User Rating: 1015    Report this Post to a Moderator | Link

quote:
Original post by Anonymous Poster
Shouldn't it be possible to eliminate the step of rendering to the texture, rendering the reflection directly to the final video buffer instead?

I think it would just require a little more calculation involving the clipping planes and the camera transformation.


Yes u r correct. An even better way of doing planar mirrors in 3D is through the combined usage of the clipping planes, depth and stencil buffers. That way, u only swap in and out from the framebuffer (backbuffer) without the need for a 2nd render target. The reflection will also be "pixel perfect" even if u r standing rite infront of it. However, getting it to work with objects place infront AND behind the mirror will need some trickery. I'll release a short article and demo source for doing that soon.

However it must be noted that on modern hardware, it may not be much faster than the VCP method. Also it does not offer the flexibility of putting the reflection on uneven surfaces, which the VCP method can do easily with the resultant texture.


- Hun Yen Kwoon

 User Rating: 1052   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Just a note. This article was written well over 1 yr ago. As some of u had already know, u can also find a copy of it from the following link: http://www.auscoders.com/articles/yenkwoonhun/vcp/vcp.html

U can also find the iotd of 16th Oct 2002 at the following link:
http://www.flipcode.com/cgi-bin/msg.cgi?showThread=10-16-2002&forum=iotd&id=-1

-Hun Yen Kwoon

[edited by - HunYenKwoon on December 19, 2003 4:38:07 AM]

 User Rating: 1052   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

I missed out on a limitation of the sample program provided. The transformation of the mirror quad back to camera space only works for quads that are positioned non-parallel to the x-z plane. If a mirror quad is positioned parallel to the x-z plane, the sample code does not transform it back to camera space properly.

- Workaround
- Add additional rotation with respect to the y-axis. The above deficiency sterns from the fact that the rotations are w.r.t the x-axis only.
- Position the quad in camera space and apply a transformation to position it in world-space. Later when u need to transform it back to camera space, just use the inverse of the transformation.


-Hun Yen Kwoon

 User Rating: 1052   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Hi,
First of all congratulation HenYenKwon, this is a great algorithm for doing reflections.
I ported it to OpenGL and it works...
Although I have made some changes:
1) The algorithm as described by you always positions the plane in the x-y plane no special cases have to be made (step 5). The only difference in OpenGL is that when determining the rotation around the x axis you do PlaneLeftToRightvector dot (-1,0,0) instead of (1,0,0).
And for the rotation around the y axis PlaneUpvector dot (0,1,0) as you described.

2) When positioning the Virtual Camera behind the mirrored plane to point toward the real camera postion (step 10) I had problems in openGL when the planeNormal of the mirror was (0,1,0) which means the plane was on the x-z plane and the Virtual camera is looking up to the real camera with normalized direction (0,1,0). You state always to use the world up (0,1,0) but the gluLookAt function does not work correctly when the up vector is the same as the direction vector.
So I used the planeUpvector as the up vector for the gluLookat function and it works fine.

I noticed that when you look at the plane from the side the image is more pixelated as
when you look at it from above. Is this OK? Can I do anything to alleviate this?

Thanks
Dimi

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Hi,
I have found an even better way to create the camera alignment matrix.
Instead of computing roty, rotx matrices, you create one 3x3 matrix and multiply everything
with that matrix. This matrix transforms everything to eye space and has to be mutliplied with the vertices of the plane and the VCP.
To create this matrix use the normalize versions of the planeLeftRight, planeUp, planeNormal vector as computed in the paper and put them as rows into a matrix.
Easy heh :)
In OpenGL the matrix is as follows

-planeLeftRight.X(), -planeLeftRight.Y(), -planeLeftRight.Z(),
planeUp.X(), planeUp.Y(), planeUp.Z(),
-planeNormal.X(), -planeNormal.Y(), -planeNormal.Z()

The might look like this code is:

TMatrix33 mrot(-planeLeftRight.X(), -planeLeftRight.Y(), -planeLeftRight.Z(),
planeUp.X(), planeUp.Y(), planeUp.Z(),
-planeNormal.X(), -planeNormal.Y(), -planeNormal.Z());

TVector32 newverticesMirror[4];
TVector32 newVCamPos;
TVector32 newn;

newVCamPos = mrot*VCamPos;
for (int i=0; i<4; i++)
{
newverticesMirror[i] = mrot*verticesMirror[i] - newVCamPos;
}

Dimi

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

hi christop,
I need ported it to OpenGL, I try but I canīt do it.
please drop me a mail at:

oduconge@yahoo.es

 User Rating: 1015    Report this Post to a Moderator | Link

All times are ET (US)

Post Reply
 Last Thread Next Thread 
Forum Rules:
You may not post new threads
You may post replies
You may not edit your posts
You may not use HTML in your posts
Jump To:
Administrative Options: