Sign in to follow this  

Projecting to Infinity + Interpolation

This topic is 4330 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

In the fixed function pipeline, an untransformed vertex can only have (x,y,z) specified and w == 1 is assumed. But many algorithms need w == 0 (volumetric shadows for example).. Is there a round about? and can the vertex shader do that correctly (I don't know nothing about shaders yet -- so this can be a good motive to start learning it)? [Edited by - arithma on February 4, 2006 6:57:36 AM]

Share this post


Link to post
Share on other sites
In the fixed function pipeline you can have x,y,z and w for example using by using
void glVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w);
in OpenGL.
and in D3D you can use
struct CUSTOMVERTEX
{
FLOAT x, y, z, rhw;
DWORD color;
};

#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE)
for example;
and you have not to set w=1.but some Transformations need a w<>0.
In a shader you have full control over the x,y,z,w parameters and your matrixes so you can do what you want. But you can make many effects(like volumetric shadows) without shaders too.

Share this post


Link to post
Share on other sites
Actually, it is an assumed 1 for positions and 0 for vectors. In the shader you will specify the position and normal as float3. Then it is up to you whether you put a 1 or 0 in the w position (like float4(normal, 0.0f) for normals and float4(pos, 1.0f) for positions.

In the fixed pipeline (using the FVF), DX knows to treat the vertex positions as points (with w=1) and normals as vectors (w=0).

Share this post


Link to post
Share on other sites
The problem with using fixed function DirectX 8 is that the W format (RHW) is assumed to already have been transformed. There's no way to have the FFP in DirectX 8 transform vertices with W = 0. The reason is that the FVF is specified using the vertex shader setter.

In DirectX 9, you can specify a vertex shader of NULL, which means the FFP will be used. You can separately specify the format of the vertices using SetFVF() for fixed-function processing -- you still don't get a pre-transformed 4-component format, though.

I wonder if setting the vertex shader to NULL and setting the format with SetVertexDeclaration() would do it?

If not, then you can fake the presence of a 0 "W" coordinate by sending in 3-component vectors, and then setting up the WORLD transform matrix to either ignore the input W by nuking the entire fourth row, or generating a 0 output W while still applying translation, by nuking the entire fourth column to 0.

Btw: regarding matrix rows or columns, see my article on DirectX, OpenGL and other matrix layout conventions.

Share this post


Link to post
Share on other sites
Assume that a line is made from two points: (x,y,z,1) and (u,v,w,0)...
How are the depth values interpolated on the screen:

My guess was that somewhere that line (after being projected) is intersected with the z = 1 plane and then interpolation takes place

Another related question: Are z-values interpolated using correct depth interplolation (interpolating 1/z) or just linear interpolation.

Share this post


Link to post
Share on other sites
Quote:
Original post by hplus0603
If not, then you can fake the presence of a 0 "W" coordinate by sending in 3-component vectors, and then setting up the WORLD transform matrix to either ignore the input W by nuking the entire fourth row, or generating a 0 output W while still applying translation, by nuking the entire fourth column to 0.


That's only true to some extent because you cannot set the matrix independantly for each vertex of your triangle, that means you cannot have degenerated triangles inside your pipeline.

The vertex shaders should have no problem with that luckily. If you haven't got a vertex shader capable card you can still rely on software vertex shaders.

LeGreg

Share this post


Link to post
Share on other sites

This topic is 4330 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this