# Projecting to Infinity + Interpolation

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

## 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 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 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 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 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 on other sites
Quote:
 Original post by hplus0603If 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

1. 1
Rutin
37
2. 2
3. 3
4. 4
5. 5

• 11
• 10
• 13
• 101
• 11
• ### Forum Statistics

• Total Topics
632974
• Total Posts
3009662
• ### Who's Online (See full list)

There are no registered users currently online

×