Question

I thought the answer should be before. But I have a shader which seems to contradict this:

float4 vp(
        // Vertex Inputs
        in float4 position        : POSITION,
        uniform float4x4 worldViewProj) : TEXCOORD6
{
    float4 p = mul(worldViewProj, position);
    p.y /= 2.0;
    return p;
}

worldViewProj is the combined matrix converting world position to screen coords. I expected this vertex shader would squash the output into the top half of the render-target, and indeed it does do this - but the bottom half of the view then gets filled with more geometry which normally is out of view.

Is this simply due to the GPU's culling being quite crude?

Was it helpful?

Solution

First comes Vertex Shader, then comes Clipping (see http://download.microsoft.com/download/f/2/d/f2d5ee2c-b7ba-4cd0-9686-b6508b5479a1/direct3d10_web.pdf for full D3D10 pipeline)

So you basically in your Vertex Shader project ALL vertices to screen and then scale them in screen space by 0.5. Thus modified vertices are then clipped resulting in whole screen filled with geometry. I suppose you expected to see half a screen filled and half a screen blank?

OTHER TIPS

Culling occurs after the vertex stage.

The vertex shader is the stage at which the geometry is actually created. Before then, the geometry exists only as arbitrary data which the vertex shader takes as input. Once the vertex shader has generated the vertex, then it may undergo frustum and face culling (either back or front). It does not make since to say that culling occurs before the vertex stage, since their is no actual geometry before then (it is one of the first stages in the pipeline).

Depth (or Occlusion) culling, which is most likely what you mean by "culling", is performed just before the pixel shader, once the depth of the pixel has been interpolated.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top