Archived

This topic is now archived and is closed to further replies.

dansteph

Z-fighting only when rotating ? could this be ? (image)

Recommended Posts

My wave animate smoothly but when I'm rotating the camera I experience strange flickering: the whole sea move slightly up and down sort of flickering. The sea is still cut clearly but even the far sea wich is a plane move like this up and down. This *seem* a z-figthing trouble (ok when W-Buffer) but I wonder if I do something false with my camera rotating routine (quaternion) while I don't have this problem when translating only. Here my camera routine I use a damper for the rotation (rot=rot*0.9+new_rot*0.1)
    
D3DXMatrixTranslation(&m_MatSrc,Glob.fCamPosX[FREE],Glob.fCamPosY[FREE],Glob.fCamPosZ[FREE]);
D3DXQuaternionRotationYawPitchRoll(&qRot,D3DXToRadian(Glob.fCamRotX[FREE]),D3DXToRadian(Glob.fCamRotY[FREE]),D3DXToRadian(Glob.fCamRotZ[FREE]));
D3DXMatrixRotationQuaternion(&matR,&qRot);
D3DXMatrixMultiply(&m_MatSrc,&matR,&m_MatSrc);
D3DXMatrixInverse(&m_MatDest,NULL,&m_MatSrc);
    
Thanks for any reply Dan Edited by - dansteph on January 3, 2002 7:38:03 PM

Share this post


Link to post
Share on other sites
Last minute:

This have nothing to do with Z-Fighting
instead all object are moving like in a shaker
as long as I''m located at about 100''000 (zx) world coordinate
at 1''000''000 (xz) all shake furiously but only when the camera is rotating. At 0;0 all is quiet.

Is this a general precision issue os is something wrong with my rotation stuff ?

My world is at least 600''000 wide I cannot imagine relocating everything at center every 1000 move unit. it will become a nightmare.

Dan

Share this post


Link to post
Share on other sites
quote:
Original post by dansteph
Is this a general precision issue os is something wrong with my rotation stuff ?

Yes. This is a precision issue. With a 4-byte floating point variable you have about 7 digits of precision. At 1,000,000 units you have used all of them. Even rotation of a camera around a unit sphere[located at(1000000, 0, 0)] will be incredibly bouncy.

quote:
Original post by dansteph
My world is at least 600'000 wide I cannot imagine relocating everything at center every 1000 move unit. it will become a nightmare.

Yes. Depending on your code, it may become a nightmare. Sorry.



Edited by - The Bear on January 4, 2002 6:01:49 PM

Share this post


Link to post
Share on other sites
Thanks bear,

all I can say is

AAAARGHHH !!!! (to say the less)

I''m turning around but
the first thing that come in mind is scalling all the world down diging in my 18''000 line of code.

:-(

Dan

Share this post


Link to post
Share on other sites
Unfortunately, just scaling down the world won''t make a difference. You would be merely moving the problem into a different location. If everything is smaller, the camera has to make more refined (smaller) movements. So the effect is the same.

For example: Let''s say your world is 1''000''000 (7 digits) units wide and the camera needs to make 0,01 (2 digits) unit movements at the edge so it is not bouncy. If you scale your world down to 1''000 (4 digits) units wide, your camera will have to make 0,00001 (5 digits) unit movements at the edge so it is not bouncy. Either way you are using 9 digits of precision. Since you only have 7, you have a problem.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Have you thought about using greater precision variables?
I''ve seen up to 10-byte precision floating points used. Since your using VB(?) I''m not sure if you can get any more precision than a double.

Share this post


Link to post
Share on other sites
It has to do with the precision that the underlying code (DirectX/OpenGL) is using. You can use any precision variable you want, but once you pass it to the graphics API, it''s out of your hands.

Share this post


Link to post
Share on other sites
Well I have hard time figuring how I will get out of this one...
the solution seem to stay always in the same square zone of
0,0 10''000 10''000 and have another pair of coordinate defining sort of latitude longitude.
So if I''m in midle of my world (say square lat=10 long=10)
and go >10''000 I re-enter at 0 and change square coordinate....

Damn in a midle of a fight when dozen gun fire I should then
move all the scene object relative back to 0 ? and what if I''m just at the limit crossing it frequently ?... Not good.

Another solution is to stay always at same coordinate making the entire world moving around... brps someone have aspirin ?

Anyways that prob suck a lot, writing a game is enough complicated without that...

I wonder how commercial simulator handle this ?

Thanks for reply I will make a brain storm with a beer...

Dan
"Sad"

Share this post


Link to post
Share on other sites
For those that are interested or are willing designing large
world: (this shake trouble appear >50'000/100'000 )

I have searched some around the net and the solution seem to
keep the camera at 0,0,0 making the world moving around. Far
object may then be as far as you want you don't care because you
disable them outside of your clipping view and use double to
maintain world 's coordinate.

I agree with bear that scalling down isn't a solution here.

This is new to me but I think I will maintain all the object in
their respective world coordinate and compute local coord only
when I come "close".

Let's say the camera pseudo coordinate is 100'000 all object
greater than 110'000 and less than 90'000 are untouched and
disabled (far view=9000) if an object is at say 105'000 I
substract the pseudo coordinate =5000 and I draw it at 5000 from
my camera. (sorry if unclear english isn't usuall language)


here pseudo code for an object that will also move trought the
world


for each moving object (X axe only for clarity):

      
// value are as follow

double ObjectTrueWorldX; // object World pos

float ObjectMovingX; // object's moving in world

float ObjectLocalX; // Object->camera relative position

double CameraPseudoPosX; // the camera's fake world position

float CameraMoveX; // the camera's fake moving


// Loop code

ObjectTrueWorldX+=ObjectMovingX; // apply the object moving

CameraPseudoPosX+=CameraMoveX; // move the pseudo pos of camera


if(InCameraRange(ObjectTrueWorldX)==TRUE)
{
ObjectLocalX=ObjectTrueWorldX-CameraPseudoPosX; // get local coord

SetMatrixObjectPosX(ObjectLocalX); // set the object pos with a digest value (<10'000)

DrawObject();
}


Mhhh this may be tuned but sound a good caneva all bullet
or "close" effect objects won't have world coordinate only the
delta from moving camera applied while they don't exist in the
far world. Also sky, sun, sea will stay at identity.

Game maker ARE masochist

Dan


Edited by - dansteph on January 4, 2002 10:22:17 PM

Share this post


Link to post
Share on other sites
To close this thread for futur archive reading.

Implementation of keeping the camera at 0,0,0 while all the
world move around was done in a snap. This is not as complicated
as it seem.

Now My world is as bigger as I want (double) and nothing suffer
from precision issue. Animation is Smooth like a silk even at
pos greater than 10'000'000,0f.

So if your world is gonna use float value bigger than 99'999.9f
for position you may SERIOUSLY think about this solution. (even
bigger than 9'999,9f may cause precision lose but I didn't
experienced it)

Dan


Edited by - dansteph on January 8, 2002 4:40:24 PM

Share this post


Link to post
Share on other sites