Sign in to follow this  
cywater2000

Cubic Environment Mapping Problem: **when the reflector moves...**

Recommended Posts

Cubic Environment Mapping Problem: when the reflector moves... Hello, I am working on cubic environment mapping and I found that the reflector(teapot) must stay in the center of world, or the reflected appearance would be incorrect.(as if the reflector remains to stay in the center of world) For example(D3D HDRCubeMap Sample): I moved the teapot, but: http://blog.csdn.net/images/blog_csdn_net/cywater2000/102371/r_cmhdr.jpg Then I found some information: -------------------------------------------------------------------------------------------------- The preceding discussion mentioned that environment mapping assumes that the environment is infinitely distant from the object. Now we explore the implications of this assumption. The reason for the assumption is that environment maps are accessed solely based on a 3D direction. Environment mapping has no allowance for variations in position to affect the reflected appearance of surfaces. If everything in the environment is sufficiently far away from the surface, then this assumption is approximately true. -------------------------------------------------------------------------------------------------- but how about "local environment" if the reflector is not in the center of world? I have solved the problem of Localizing Reflections(Finite-Radius cube maps) according to these paper: http://download.nvidia.com/developer/presentations/GDC_2004/GDC_2004_Gems_IBL.pdf http://www.ati.com/developer/shaderx/ShaderX_CubeEnvironmentMapCorrection.pdf However, the reflector(teapot) must stay in the center of world. I want to move my teapot... Heeeeeeeeelp! PS: I think about a way: to modify DXUTGetCubeMapViewMatrix D3DXMATRIX DXUTGetCubeMapViewMatrix( DWORD dwFace ) { //D3DXVECTOR3 vEyePt = D3DXVECTOR3( 0.0f, 0.0f, 0.0f ); D3DXVECTOR3 vEyePt = g_vRefMeshPos; //the world coordinate of the reflector(teapot) D3DXVECTOR3 vLookDir; D3DXVECTOR3 vUpDir; float x, y, z; x = fabs(g_vEnvMeshPos.x) + 10; y = fabs(g_vEnvMeshPos.y) + 10; z = fabs(g_vEnvMeshPos.z) + 10; switch( dwFace ) { case D3DCUBEMAP_FACE_POSITIVE_X: vLookDir = D3DXVECTOR3( x, 0.0f, 0.0f ); vUpDir = D3DXVECTOR3( 0.0f, 1.0f, 0.0f ); break; case D3DCUBEMAP_FACE_NEGATIVE_X: vLookDir = D3DXVECTOR3(-x, 0.0f, 0.0f ); vUpDir = D3DXVECTOR3( 0.0f, 1.0f, 0.0f ); break; case D3DCUBEMAP_FACE_POSITIVE_Y: vLookDir = D3DXVECTOR3( 0.0f, y, 0.0f ); vUpDir = D3DXVECTOR3( 0.0f, 0.0f,-1.0f ); break; case D3DCUBEMAP_FACE_NEGATIVE_Y: vLookDir = D3DXVECTOR3( 0.0f, -y, 0.0f ); vUpDir = D3DXVECTOR3( 0.0f, 0.0f, 1.0f ); break; case D3DCUBEMAP_FACE_POSITIVE_Z: vLookDir = D3DXVECTOR3( 0.0f, 0.0f, z ); vUpDir = D3DXVECTOR3( 0.0f, 1.0f, 0.0f ); break; case D3DCUBEMAP_FACE_NEGATIVE_Z: vLookDir = D3DXVECTOR3( 0.0f, 0.0f, -z ); vUpDir = D3DXVECTOR3( 0.0f, 1.0f, 0.0f ); break; } // Set the view transform for this cubemap surface D3DXMATRIX mView; D3DXMatrixLookAtLH( &mView, &vEyePt, &vLookDir, &vUpDir ); return mView; } Yes,rendering into cube texture is correct(I checked six surfaces out), but sample(texCUBE) is incorrect. I don`t konw why my demo: http://blog.csdn.net/images/blog_csdn_net/cywater2000/102371/r_cm.jpg http://blog.csdn.net/images/blog_csdn_net/cywater2000/102371/r_cm2.jpg Your any proposes are helpful. Thanks.

Share this post


Link to post
Share on other sites
hi,

the article here may give you some fresh ideas!

or you should try dynamic environment mapping like in NFS Underground
Quote:
Yes,rendering into cube texture is correct(I checked six surfaces out),
but sample(texCUBE) is incorrect. I don`t konw why
It should! Try this one, it works in this sample.


kp

Share this post


Link to post
Share on other sites
Quote:
Original post by kovacsp
hi,

the article here may give you some fresh ideas!

or you should try dynamic environment mapping like in NFS Underground
Quote:
Yes,rendering into cube texture is correct(I checked six surfaces out),
but sample(texCUBE) is incorrect. I don`t konw why
It should! Try this one, it works in this sample.


kp



Thanks.

The first paper is good but I have solved this problem according to these:
http://download.nvidia.com/developer/presentations/GDC_2004/GDC_2004_Gems_IBL.pdf
http://www.ati.com/developer/shaderx/ShaderX_CubeEnvironmentMapCorrection.pdf

You`ll find that Nvidia`s is the original complex method, ATI`s is a fast approximation one and Budapest`s is between them.

However, they can`t sovled this situation that the relative location is chaneged between the reflector and the reflective object.

For example, the reflector is at the front of the reflective object first, and then it is at the back of the reflective object.

sigh...


"Rendering to Texture Surfaces Using DirectX 7" is also good,
but if I used this methond, I would not make use of hardware-accelerated sample: cube map(texCUBE)


But thanks all the same.
Your first paper is indeed a fresh idea. :)


Waiting help...

Share this post


Link to post
Share on other sites
try something like


D3DXVECTOR3 vEyePt = g_vRefMeshPos; //the world coordinate of the reflector(teapot)
D3DXVECTOR3 vLookDir = vEyePt; // Init to world coord position
D3DXVECTOR3 vUpDir;

switch( dwFace )
{
case D3DCUBEMAP_FACE_POSITIVE_X:
vLookDir += D3DXVECTOR3( 1.f, 0.0f, 0.0f ); // Notice the plus-equal EDIT:and the direction vector
vUpDir = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
break;
case D3DCUBEMAP_FACE_NEGATIVE_X:
.
.
.



Still you might have problems with camera roll, anyhow...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this