@@ -1096,7 +1096,13 @@ Int ShroudTextureShader::set(Int stage)
10961096 Matrix4x4 curView;
10971097 DX8Wrapper::_Get_DX8_Transform (D3DTS_VIEW, curView);
10981098
1099- D3DXMatrixInverse (&inv, &det, (D3DXMATRIX*)&curView);
1099+ D3DXMATRIX d3dCurView (
1100+ curView[0 ][0 ], curView[0 ][1 ], curView[0 ][2 ], curView[0 ][3 ],
1101+ curView[1 ][0 ], curView[1 ][1 ], curView[1 ][2 ], curView[1 ][3 ],
1102+ curView[2 ][0 ], curView[2 ][1 ], curView[2 ][2 ], curView[2 ][3 ],
1103+ curView[3 ][0 ], curView[3 ][1 ], curView[3 ][2 ], curView[3 ][3 ]
1104+ );
1105+ D3DXMatrixInverse (&inv, &det, &d3dCurView);
11001106
11011107 D3DXMATRIX scale,offset;
11021108
@@ -1119,8 +1125,8 @@ Int ShroudTextureShader::set(Int stage)
11191125 width = 1 .0f /(width*shroud->getTextureWidth ());
11201126 height = 1 .0f /(height*shroud->getTextureHeight ());
11211127 D3DXMatrixScaling (&scale, width, height, 1 );
1122- *(( D3DXMATRIX *)&curView) = (inv * offset) * scale;
1123- DX8Wrapper::_Set_DX8_Transform ((D3DTRANSFORMSTATETYPE )(D3DTS_TEXTURE0+stage), *((Matrix4x4*)&curView) );
1128+ D3DXMATRIX texTransform = (inv * offset) * scale;
1129+ DX8Wrapper::_Set_DX8_Transform ((D3DTRANSFORMSTATETYPE )(D3DTS_TEXTURE0+stage), texTransform );
11241130 }
11251131 m_stageOfSet=stage;
11261132 return TRUE ;
@@ -1188,8 +1194,13 @@ Int MaskTextureShader::set(Int pass)
11881194 D3DXMATRIX inv;
11891195 float det;
11901196
1191- // Get inverse view matrix so we can transform camera space points back to world space
1192- D3DXMatrixInverse (&inv, &det, (D3DXMATRIX*)&curView);
1197+ D3DXMATRIX d3dCurView (
1198+ curView[0 ][0 ], curView[0 ][1 ], curView[0 ][2 ], curView[0 ][3 ],
1199+ curView[1 ][0 ], curView[1 ][1 ], curView[1 ][2 ], curView[1 ][3 ],
1200+ curView[2 ][0 ], curView[2 ][1 ], curView[2 ][2 ], curView[2 ][3 ],
1201+ curView[3 ][0 ], curView[3 ][1 ], curView[3 ][2 ], curView[3 ][3 ]
1202+ );
1203+ D3DXMatrixInverse (&inv, &det, &d3dCurView);
11931204
11941205 D3DXMATRIX scale,offset,offsetTextureCenter;
11951206 Coord3D centerPos;
@@ -1215,18 +1226,19 @@ Int MaskTextureShader::set(Int pass)
12151226 Real worldTexelHeight=(1 .0f -fadeLevel)*25 .0f ;
12161227
12171228 // /@todo: Fix this to work with non 128x128 textures.
1229+ D3DXMATRIX texTransform;
12181230 if (worldTexelWidth != 0 && worldTexelHeight != 0 )
12191231 { Real widthScale = 1 .0f /(worldTexelWidth*128 .0f );
12201232 Real heightScale = 1 .0f /(worldTexelHeight*128 .0f );
12211233 D3DXMatrixScaling (&scale, widthScale, heightScale, 1 );
1222- *((D3DXMATRIX *)&curView) = ((inv * offset) * scale)*offsetTextureCenter;
1234+ texTransform = ((inv * offset) * scale)*offsetTextureCenter;
12231235 }
12241236 else
12251237 { D3DXMatrixScaling (&scale, 0 , 0 , 1 ); // scaling by 0 will set uv coordinates to 0,0
1226- *((D3DXMATRIX *)&curView) = ((inv * offset) * scale);
1238+ texTransform = ((inv * offset) * scale);
12271239 }
12281240
1229- DX8Wrapper::_Set_DX8_Transform (D3DTS_TEXTURE0, *((Matrix4x4*)&curView) );
1241+ DX8Wrapper::_Set_DX8_Transform (D3DTS_TEXTURE0, texTransform );
12301242
12311243 return TRUE ;
12321244}
@@ -1450,24 +1462,32 @@ Int TerrainShader2Stage::set(Int pass)
14501462 D3DXMATRIX inv;
14511463 float det;
14521464
1453- D3DXMatrixInverse (&inv, &det, (D3DXMATRIX*)&curView);
1465+ D3DXMATRIX d3dCurView (
1466+ curView[0 ][0 ], curView[0 ][1 ], curView[0 ][2 ], curView[0 ][3 ],
1467+ curView[1 ][0 ], curView[1 ][1 ], curView[1 ][2 ], curView[1 ][3 ],
1468+ curView[2 ][0 ], curView[2 ][1 ], curView[2 ][2 ], curView[2 ][3 ],
1469+ curView[3 ][0 ], curView[3 ][1 ], curView[3 ][2 ], curView[3 ][3 ]
1470+ );
1471+ D3DXMatrixInverse (&inv, &det, &d3dCurView);
14541472
14551473 if (W3DShaderManager::getCurrentShader () == W3DShaderManager::ST_TERRAIN_BASE_NOISE12)
14561474 {
14571475 // setup cloud pass
14581476 DX8Wrapper::_Get_D3D_Device8 ()->SetTexture (0 , W3DShaderManager::getShaderTexture (2 )->Peek_D3D_Texture ());
14591477
1460- updateNoise1 (((D3DXMATRIX*)&curView),&inv); // update curView with texture matrix
1461- DX8Wrapper::_Set_DX8_Transform (D3DTS_TEXTURE0, curView);
1478+ D3DXMATRIX texTransform;
1479+ terrainShader2Stage.updateNoise1 (&texTransform,&inv);
1480+ DX8Wrapper::_Set_DX8_Transform (D3DTS_TEXTURE0, texTransform);
14621481 // clouds always need bilinear filtering
14631482 DX8Wrapper::Set_DX8_Texture_Stage_State (0 , D3DTSS_MINFILTER, D3DTEXF_LINEAR);
14641483 DX8Wrapper::Set_DX8_Texture_Stage_State (0 , D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
14651484
14661485 // setup noise pass
14671486 DX8Wrapper::_Get_D3D_Device8 ()->SetTexture (1 , W3DShaderManager::getShaderTexture (3 )->Peek_D3D_Texture ());
14681487
1469- updateNoise2 (((D3DXMATRIX*)&curView),&inv);
1470- DX8Wrapper::_Set_DX8_Transform (D3DTS_TEXTURE1, curView);
1488+ D3DXMATRIX texTransform2;
1489+ terrainShader2Stage.updateNoise2 (&texTransform2,&inv);
1490+ DX8Wrapper::_Set_DX8_Transform (D3DTS_TEXTURE1, texTransform2);
14711491 // noise always needs point/linear filtering. Why point!?
14721492 DX8Wrapper::Set_DX8_Texture_Stage_State (1 , D3DTSS_MINFILTER, D3DTEXF_POINT);
14731493 DX8Wrapper::Set_DX8_Texture_Stage_State (1 , D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
@@ -1486,25 +1506,26 @@ Int TerrainShader2Stage::set(Int pass)
14861506 else
14871507 { // only 1 noise or cloud texture
14881508 // Now setup the texture pipeline.
1509+ D3DXMATRIX texTransform3;
14891510 if (W3DShaderManager::getCurrentShader () == W3DShaderManager::ST_TERRAIN_BASE_NOISE1)
14901511 { // setup cloud pass
14911512 DX8Wrapper::_Get_D3D_Device8 ()->SetTexture (0 , W3DShaderManager::getShaderTexture (2 )->Peek_D3D_Texture ());
1492- updateNoise1 (((D3DXMATRIX*)&curView) ,&inv); // update curView with texture matrix
1513+ terrainShader2Stage. updateNoise1 (&texTransform3 ,&inv);
14931514 DX8Wrapper::Set_DX8_Texture_Stage_State (0 , D3DTSS_MINFILTER, D3DTEXF_LINEAR);
14941515 DX8Wrapper::Set_DX8_Texture_Stage_State (0 , D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
14951516 }
14961517 else
14971518 {
14981519 // setup noise pass
14991520 DX8Wrapper::_Get_D3D_Device8 ()->SetTexture (0 , W3DShaderManager::getShaderTexture (3 )->Peek_D3D_Texture ());
1500- updateNoise2 (((D3DXMATRIX*)&curView) ,&inv); // update curView with texture matrix
1521+ terrainShader2Stage. updateNoise2 (&texTransform3 ,&inv);
15011522 DX8Wrapper::Set_DX8_Texture_Stage_State (1 , D3DTSS_MINFILTER, D3DTEXF_POINT);
15021523 DX8Wrapper::Set_DX8_Texture_Stage_State (1 , D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
15031524 }
15041525
15051526 DX8Wrapper::Set_DX8_Texture_Stage_State ( 1 , D3DTSS_COLOROP, D3DTOP_DISABLE );
15061527 DX8Wrapper::Set_DX8_Texture_Stage_State ( 1 , D3DTSS_ALPHAOP, D3DTOP_DISABLE );
1507- DX8Wrapper::_Set_DX8_Transform (D3DTS_TEXTURE0, *((Matrix4x4*)&curView) );
1528+ DX8Wrapper::_Set_DX8_Transform (D3DTS_TEXTURE0, texTransform3 );
15081529 }
15091530 break ;
15101531 }
@@ -1776,7 +1797,13 @@ Int TerrainShaderPixelShader::set(Int pass)
17761797
17771798 D3DXMATRIX inv;
17781799 float det;
1779- D3DXMatrixInverse (&inv, &det, (D3DXMATRIX*)&curView);
1800+ D3DXMATRIX d3dCurView (
1801+ curView[0 ][0 ], curView[0 ][1 ], curView[0 ][2 ], curView[0 ][3 ],
1802+ curView[1 ][0 ], curView[1 ][1 ], curView[1 ][2 ], curView[1 ][3 ],
1803+ curView[2 ][0 ], curView[2 ][1 ], curView[2 ][2 ], curView[2 ][3 ],
1804+ curView[3 ][0 ], curView[3 ][1 ], curView[3 ][2 ], curView[3 ][3 ]
1805+ );
1806+ D3DXMatrixInverse (&inv, &det, &d3dCurView);
17801807
17811808 DX8Wrapper::Set_DX8_Texture_Stage_State (2 , D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION);
17821809 // Two output coordinates are used.
@@ -1799,11 +1826,13 @@ Int TerrainShaderPixelShader::set(Int pass)
17991826 DX8Wrapper::Set_DX8_Texture_Stage_State (3 , D3DTSS_MINFILTER, D3DTEXF_POINT);
18001827 DX8Wrapper::Set_DX8_Texture_Stage_State (3 , D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
18011828
1802- terrainShader2Stage.updateNoise1 (((D3DXMATRIX*)&curView),&inv); // update curView with texture matrix
1803- DX8Wrapper::_Set_DX8_Transform (D3DTS_TEXTURE2, curView);
1829+ D3DXMATRIX texTransform1;
1830+ terrainShader2Stage.updateNoise1 (&texTransform1,&inv);
1831+ DX8Wrapper::_Set_DX8_Transform (D3DTS_TEXTURE2, texTransform1);
18041832
1805- terrainShader2Stage.updateNoise2 (((D3DXMATRIX*)&curView),&inv); // update curView with texture matrix
1806- DX8Wrapper::_Set_DX8_Transform (D3DTS_TEXTURE3, curView);
1833+ D3DXMATRIX texTransform2;
1834+ terrainShader2Stage.updateNoise2 (&texTransform2,&inv);
1835+ DX8Wrapper::_Set_DX8_Transform (D3DTS_TEXTURE3, texTransform2);
18071836
18081837 DX8Wrapper::Set_DX8_Texture_Stage_State (3 , D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION);
18091838 // Two output coordinates are used.
@@ -1813,21 +1842,22 @@ Int TerrainShaderPixelShader::set(Int pass)
18131842 { // single noise texture shader
18141843 DX8Wrapper::_Get_D3D_Device8 ()->SetPixelShader (m_dwBaseNoise1PixelShader);
18151844
1845+ D3DXMATRIX texTransform3;
18161846 if (W3DShaderManager::getCurrentShader () == W3DShaderManager::ST_TERRAIN_BASE_NOISE1)
18171847 { // cloud map
18181848 DX8Wrapper::_Get_D3D_Device8 ()->SetTexture (2 , W3DShaderManager::getShaderTexture (2 )->Peek_D3D_Texture ());
1819- terrainShader2Stage.updateNoise1 (((D3DXMATRIX*)&curView) ,&inv); // update curView with texture matrix
1849+ terrainShader2Stage.updateNoise1 (&texTransform3 ,&inv);
18201850 DX8Wrapper::Set_DX8_Texture_Stage_State (2 , D3DTSS_MINFILTER, D3DTEXF_LINEAR);
18211851 DX8Wrapper::Set_DX8_Texture_Stage_State (2 , D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
18221852 }
18231853 else
18241854 { // light map
18251855 DX8Wrapper::_Get_D3D_Device8 ()->SetTexture (2 , W3DShaderManager::getShaderTexture (3 )->Peek_D3D_Texture ());
1826- terrainShader2Stage.updateNoise2 (((D3DXMATRIX*)&curView) ,&inv); // update curView with texture matrix
1856+ terrainShader2Stage.updateNoise2 (&texTransform3 ,&inv);
18271857 DX8Wrapper::Set_DX8_Texture_Stage_State (2 , D3DTSS_MINFILTER, D3DTEXF_POINT);
18281858 DX8Wrapper::Set_DX8_Texture_Stage_State (2 , D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
18291859 }
1830- DX8Wrapper::_Set_DX8_Transform (D3DTS_TEXTURE2, curView );
1860+ DX8Wrapper::_Set_DX8_Transform (D3DTS_TEXTURE2, texTransform3 );
18311861 }
18321862 }
18331863 else
@@ -1897,14 +1927,20 @@ Int CloudTextureShader::set(Int stage)
18971927 D3DXMATRIX inv;
18981928 float det;
18991929
1900- D3DXMatrixInverse (&inv, &det, (D3DXMATRIX*)&curView);
1930+ D3DXMATRIX d3dCurView (
1931+ curView[0 ][0 ], curView[0 ][1 ], curView[0 ][2 ], curView[0 ][3 ],
1932+ curView[1 ][0 ], curView[1 ][1 ], curView[1 ][2 ], curView[1 ][3 ],
1933+ curView[2 ][0 ], curView[2 ][1 ], curView[2 ][2 ], curView[2 ][3 ],
1934+ curView[3 ][0 ], curView[3 ][1 ], curView[3 ][2 ], curView[3 ][3 ]
1935+ );
1936+ D3DXMatrixInverse (&inv, &det, &d3dCurView);
19011937
1902- // Get a texture matrix that applies the current cloud position
1903- terrainShader2Stage.updateNoise1 (((D3DXMATRIX*)&curView),&inv,false ); // update curView with texture matrix
1938+ D3DXMATRIX texTransform;
1939+ terrainShader2Stage.updateNoise1 (&texTransform,&inv,false );
1940+ DX8Wrapper::_Set_DX8_Transform ((D3DTRANSFORMSTATETYPE )(D3DTS_TEXTURE0+stage), texTransform);
19041941
19051942 DX8Wrapper::Set_DX8_Texture_Stage_State (stage, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION);
19061943 DX8Wrapper::Set_DX8_Texture_Stage_State (stage, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
1907- DX8Wrapper::_Set_DX8_Transform ((D3DTRANSFORMSTATETYPE )(D3DTS_TEXTURE0+stage), curView);
19081944 DX8Wrapper::Set_DX8_Texture_Stage_State (stage, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
19091945 DX8Wrapper::Set_DX8_Texture_Stage_State (stage, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
19101946 DX8Wrapper::Set_DX8_Texture_Stage_State (stage, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
@@ -2036,7 +2072,13 @@ Int RoadShaderPixelShader::set(Int pass)
20362072
20372073 D3DXMATRIX inv;
20382074 float det;
2039- D3DXMatrixInverse (&inv, &det, (D3DXMATRIX*)&curView);
2075+ D3DXMATRIX d3dCurView (
2076+ curView[0 ][0 ], curView[0 ][1 ], curView[0 ][2 ], curView[0 ][3 ],
2077+ curView[1 ][0 ], curView[1 ][1 ], curView[1 ][2 ], curView[1 ][3 ],
2078+ curView[2 ][0 ], curView[2 ][1 ], curView[2 ][2 ], curView[2 ][3 ],
2079+ curView[3 ][0 ], curView[3 ][1 ], curView[3 ][2 ], curView[3 ][3 ]
2080+ );
2081+ D3DXMatrixInverse (&inv, &det, &d3dCurView);
20402082
20412083 if (TheGlobalData && TheGlobalData->m_trilinearTerrainTex )
20422084 { DX8Wrapper::Set_DX8_Texture_Stage_State (0 , D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
@@ -2066,11 +2108,13 @@ Int RoadShaderPixelShader::set(Int pass)
20662108 DX8Wrapper::Set_DX8_Texture_Stage_State (2 , D3DTSS_MINFILTER, D3DTEXF_POINT);
20672109 DX8Wrapper::Set_DX8_Texture_Stage_State (2 , D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
20682110
2069- terrainShader2Stage.updateNoise1 (((D3DXMATRIX*)&curView),&inv, false ); // get texture projection matrix
2070- DX8Wrapper::_Set_DX8_Transform (D3DTS_TEXTURE1, curView);
2111+ D3DXMATRIX texTransform1;
2112+ terrainShader2Stage.updateNoise1 (&texTransform1,&inv, false );
2113+ DX8Wrapper::_Set_DX8_Transform (D3DTS_TEXTURE1, texTransform1);
20712114
2072- terrainShader2Stage.updateNoise2 (((D3DXMATRIX*)&curView),&inv, false ); // get texture projection matrix
2073- DX8Wrapper::_Set_DX8_Transform (D3DTS_TEXTURE2, curView);
2115+ D3DXMATRIX texTransform2;
2116+ terrainShader2Stage.updateNoise2 (&texTransform2,&inv, false );
2117+ DX8Wrapper::_Set_DX8_Transform (D3DTS_TEXTURE2, texTransform2);
20742118
20752119 DX8Wrapper::Set_DX8_Texture_Stage_State (2 , D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION);
20762120 // Two output coordinates are used.
@@ -2159,7 +2203,13 @@ Int RoadShader2Stage::set(Int pass)
21592203
21602204 D3DXMATRIX inv;
21612205 float det;
2162- D3DXMatrixInverse (&inv, &det, (D3DXMATRIX*)&curView);
2206+ D3DXMATRIX d3dCurView (
2207+ curView[0 ][0 ], curView[0 ][1 ], curView[0 ][2 ], curView[0 ][3 ],
2208+ curView[1 ][0 ], curView[1 ][1 ], curView[1 ][2 ], curView[1 ][3 ],
2209+ curView[2 ][0 ], curView[2 ][1 ], curView[2 ][2 ], curView[2 ][3 ],
2210+ curView[3 ][0 ], curView[3 ][1 ], curView[3 ][2 ], curView[3 ][3 ]
2211+ );
2212+ D3DXMatrixInverse (&inv, &det, &d3dCurView);
21632213
21642214 if (TheGlobalData && TheGlobalData->m_trilinearTerrainTex )
21652215 DX8Wrapper::Set_DX8_Texture_Stage_State (1 , D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
@@ -2180,33 +2230,33 @@ Int RoadShader2Stage::set(Int pass)
21802230 DX8Wrapper::Set_DX8_Texture_Stage_State ( 1 , D3DTSS_ALPHAARG2, D3DTA_CURRENT );
21812231 DX8Wrapper::Set_DX8_Texture_Stage_State ( 1 , D3DTSS_ALPHAOP, D3DTOP_MODULATE );
21822232
2233+ D3DXMATRIX texTransform3;
21832234 if (W3DShaderManager::getCurrentShader () == W3DShaderManager::ST_ROAD_BASE_NOISE12)
21842235 { // full shader, apply noise 1 in pass 0.
21852236 DX8Wrapper::_Get_D3D_Device8 ()->SetTexture (1 , W3DShaderManager::getShaderTexture (1 )->Peek_D3D_Texture ());
21862237 DX8Wrapper::Set_DX8_Texture_Stage_State (1 , D3DTSS_MINFILTER, D3DTEXF_LINEAR);
21872238 DX8Wrapper::Set_DX8_Texture_Stage_State (1 , D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
21882239
2189- terrainShader2Stage.updateNoise1 (((D3DXMATRIX*)&curView),&inv, false ); // get texture projection matrix
2190- DX8Wrapper::_Set_DX8_Transform (D3DTS_TEXTURE1, curView);
2240+ terrainShader2Stage.updateNoise1 (&texTransform3,&inv, false );
21912241 }
21922242 else
21932243 { // single noise texture shader
21942244 if (W3DShaderManager::getCurrentShader () == W3DShaderManager::ST_ROAD_BASE_NOISE1)
21952245 { // cloud map
21962246 DX8Wrapper::_Get_D3D_Device8 ()->SetTexture (1 , W3DShaderManager::getShaderTexture (1 )->Peek_D3D_Texture ());
2197- terrainShader2Stage.updateNoise1 (((D3DXMATRIX*)&curView) ,&inv, false ); // update curView with texture matrix
2247+ terrainShader2Stage.updateNoise1 (&texTransform3 ,&inv, false );
21982248 DX8Wrapper::Set_DX8_Texture_Stage_State (1 , D3DTSS_MINFILTER, D3DTEXF_LINEAR);
21992249 DX8Wrapper::Set_DX8_Texture_Stage_State (1 , D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
22002250 }
22012251 else
22022252 { // light map
22032253 DX8Wrapper::_Get_D3D_Device8 ()->SetTexture (1 , W3DShaderManager::getShaderTexture (2 )->Peek_D3D_Texture ());
2204- terrainShader2Stage.updateNoise2 (((D3DXMATRIX*)&curView) ,&inv, false ); // update curView with texture matrix
2254+ terrainShader2Stage.updateNoise2 (&texTransform3 ,&inv, false );
22052255 DX8Wrapper::Set_DX8_Texture_Stage_State (1 , D3DTSS_MINFILTER, D3DTEXF_POINT);
22062256 DX8Wrapper::Set_DX8_Texture_Stage_State (1 , D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
22072257 }
2208- DX8Wrapper::_Set_DX8_Transform (D3DTS_TEXTURE1, curView);
22092258 }
2259+ DX8Wrapper::_Set_DX8_Transform (D3DTS_TEXTURE1, texTransform3);
22102260 }
22112261 else
22122262 { // just base texturing
@@ -2221,7 +2271,13 @@ Int RoadShader2Stage::set(Int pass)
22212271
22222272 D3DXMATRIX inv;
22232273 float det;
2224- D3DXMatrixInverse (&inv, &det, (D3DXMATRIX*)&curView);
2274+ D3DXMATRIX d3dCurView (
2275+ curView[0 ][0 ], curView[0 ][1 ], curView[0 ][2 ], curView[0 ][3 ],
2276+ curView[1 ][0 ], curView[1 ][1 ], curView[1 ][2 ], curView[1 ][3 ],
2277+ curView[2 ][0 ], curView[2 ][1 ], curView[2 ][2 ], curView[2 ][3 ],
2278+ curView[3 ][0 ], curView[3 ][1 ], curView[3 ][2 ], curView[3 ][3 ]
2279+ );
2280+ D3DXMatrixInverse (&inv, &det, &d3dCurView);
22252281
22262282 if (TheGlobalData && TheGlobalData->m_trilinearTerrainTex )
22272283 DX8Wrapper::Set_DX8_Texture_Stage_State (1 , D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
@@ -2230,7 +2286,9 @@ Int RoadShader2Stage::set(Int pass)
22302286
22312287 DX8Wrapper::_Get_D3D_Device8 ()->SetTexture (1 , W3DShaderManager::getShaderTexture (2 )->Peek_D3D_Texture ());
22322288
2233- terrainShader2Stage.updateNoise2 (((D3DXMATRIX*)&curView),&inv, false ); // update curView with texture matrix
2289+ D3DXMATRIX texTransform;
2290+ terrainShader2Stage.updateNoise2 (&texTransform,&inv, false );
2291+ DX8Wrapper::_Set_DX8_Transform (D3DTS_TEXTURE1, texTransform);
22342292 DX8Wrapper::Set_DX8_Texture_Stage_State (1 , D3DTSS_MINFILTER, D3DTEXF_POINT);
22352293 DX8Wrapper::Set_DX8_Texture_Stage_State (1 , D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
22362294
@@ -2262,7 +2320,7 @@ Int RoadShader2Stage::set(Int pass)
22622320 DX8Wrapper::Set_DX8_Render_State (D3DRS_SRCBLEND,D3DBLEND_ZERO);
22632321 DX8Wrapper::Set_DX8_Render_State (D3DRS_DESTBLEND,D3DBLEND_SRCCOLOR);
22642322
2265- DX8Wrapper::_Set_DX8_Transform (D3DTS_TEXTURE0, curView );
2323+ DX8Wrapper::_Set_DX8_Transform (D3DTS_TEXTURE0, texTransform );
22662324 }
22672325
22682326 return TRUE ;
0 commit comments