[Algorithms] screenspace xy -> uv
Brought to you by:
vexxed72
From: Roy J. <sag...@st...> - 2001-03-31 16:21:59
|
Hi guys, I'm using dx8 and I'm trying to render an object which has the texture-coordinates setup in such a way that the texture-coordinates of the object correspond to the screenspace x/y coordinates. So basically, if the object would be a sphere and I was rendering on an empty screen, you'd see the sphere as an (ahem) 'circular viewing hole' to the texture. A bit like when I would use a stencil-buffer to only allow pixels to be set where the sphere was. (Btw, the reason I'm doing all this is because I want to take a render-to-texture surface and map it on to the object.) Um, anyhow, I'm having trouble doing this. The problem is perspective correction. When I have a simple square with constant z facing the camera everything's ok, but when I take one of the square's vertices and change the z the texture looks warped. How do I fix this? In dx8 I can't turn off perspective correction anymore, so is there a way to do it nicely? Can it be done using vertex-shaders? Thanks in advance for any help, Roy. |