Archived

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

T&L: why does it just work with LH projections?

This topic is 5507 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I recently enjoyed myself 2 days debugging why my engine just displays fog in software rendering; as soon as T&L powers, all fogging disappears. I now found out, that as soon as I use D3DXMatrixPerspectiveFovLH instead of D3DXMatrixPerspectiveFovRH, the fog is back again (newest GF3 drivers). To make sure I am right, I took the DX8 C++ sample MFCFog and changed there as well from LH to RH: all fogging was gone as expected in HAL mode; REF still displays it correctly. Why does this happen? Is just my driver too lazy or am I really forced to use the LH mode? Any answers win my deepest salutations. - thomas

Share this post


Link to post
Share on other sites
Although I haven''t used fog in D3D, I''m pretty sure you have to specify near and far clipping planes. Changing from LH to RH could change the way the fog clipping planes are handled. Maybe you should make the far distance negative?

Share this post


Link to post
Share on other sites
On flipcode, "Nick" posted this:
Assuming that it is just 'depth' fog, the driver might just use the z component for the depth. However, LH and RH have different orientations of the z-axis, so the driver should negate the z component to get the depth in the RH coordinate system.

So the only 'correct' solution is to wait till they have a driver that does this correctly. A hack to fix it with the current driver could be to make the fog start and end ranges negative. Or you could use another type of fog...



My answer:
You are right! I changed the fog values to negative numbers and it worked! But just for the case WorldMatrix=Identity and camera steers through ViewMatrix.

Thats amazing. Let me summerize:
When using right-handed stuff (and this should be a great number as we all learned to use the right fingers for cross products..), then:
- I have to set positive fog start/end values when the system runs REF
- I have to set negative fog start/end values when it runs HAL.
- I am no longer allowed to have a ViewMatrix=Identity and transform everything via WolrdMatrix as I do now, seems as if the driver simply checks ViewMatrix translations for fog depth, whew.

But how do you know if the users driver is as thumb as mine? As soon as some drivers do it correctly, I am lost and have no control on depth fog appeareances on other machines.
Moreover, other z-depth related things might go wrong as well. And how I use the View/WorldMatrices should be my decision.

How did you fix that?

[edited by - Renus on November 19, 2002 2:35:51 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
is _34 of the RH projection matrix 1, i.e., "W friendly"?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
just tried what you did w/MFCFog and i get HW T&L either RH or LH. gforce2go w/latest drivers.

Share this post


Link to post
Share on other sites
Thats great, thank you for your test. Did you also see the fog then? I didn''t, and GForce3 is a common card.

I think I have to go for LH, but that will force me to rewrite a large amount of code. Ugly enough that my physics engine then still has RH corss products while renderer goes LH.
I''d say nvidia has no directx compliant drivers, bad guys..

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
yes. i tried all functions: vertex fog, pixel fog, linear, exp, exp2, color, range, windowed, fullscreen, ...

everything worked fine and fps were roughly the same for either LH or RH.

Share this post


Link to post
Share on other sites