Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Problem transforming vertices in RHW projection

$
0
0
Hello, I have a big old project that cannot be converted from D3D_XYZRHW to D3D_XYZ. The problem is whatever polygons around me distort, but everything in the distance is good. It seems to happen when NDC space vertex.x <= 0. I guess clipping must be the solution; but I don't know how. Here is my current code. VERTEX_DECL LocalToScreen( const Vector& vector ) { VERTEX_DECL vertex; vertex.xyz = vector - Game::Eye; vertex.xyz = Game::CameraOrientation * Game::ProjectionMatrix * vertex.xyz; vertex.xyz.x = vertex.xyz.x / vertex.xyz.z; vertex.xyz.y = vertex.xyz.y / vertex.xyz.z; vertex.xyz.z = 1.0 / vertex.xyz.z; // This stops polygons around camera distorting; but it fully removes them which // is not a proper solution. I think I need some kind of clamping. if ( vertex.z <= 0.0 ) { return vertex; } vertex.xyz.x = vertex.xyz.x * Game::HalfViewportWidth + Game::HalfViewportWidth; vertex.xyz.y = vertex.xyz.y * -Game::HalfViewportHeight + Game::HalfViewportHeight; vertex.rhw = vertex.xyz.z; vertex.xyz.z = vertex.xyz.z * 0.000588; // Legacy. This doesn't seem to do anything. return vertex; }

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>