I can't figure out why the pixel shader won't run. I'm using the Blinn-Phong per-pixel shader from here. Only change I've made is that I pass an aditional color per vertex which gets multiplied by the light-color in the pixel shader.

So far the Graphics Analyzer shows me a valid IA-result and the same (okay looking) result in the VS-stage. I disabled depth-stencil for testing and though everything looks rather fine I always see "Stage did not run. No output." when I inspect the captured frame.

This is my Projection-matrix:

_projection = Matrix.PerspectiveFovLH((float) Math.PI / 4.0f, viewports[0].Width / viewports[0].Height,
            0.1f, 100f);

Values are Width: 1346, Height: 800

My View is calculated like this:

_rotation = Quaternion.RotationYawPitchRoll(Yaw, Pitch, Roll);
Vector3.Transform(ref _target, ref _rotation, out _target);

Vector3 up = Vector3.UnitY;
Vector3.Transform(ref up, ref _rotation, out up);

_view = Matrix.LookAtLH(Position, _target, up);

Whereas Position: X:50, Y:50, Z:-300, Target: X:50, Y:50, Z:0 and Yaw, Pitch, Roll are all 0.

World-Matrix is currently Matrix.Identity.

The quad I try to render spans itself from X:0, Y:0 to X:100, Y:100 with 4 vertices and 6 indices.

I first thought that SV_POSITION must be a normalized value since it's obviously a SV-coordinate and someone posted in another thread that this solved his problem - but then the VS-stage does not show anything at all and PS still won't run.

It's been quite some years since I last worked with DirectX so I'm not sure anymore why this happens.

Graphics Analyzer View


Your input w values are zeros.

The mathematical principles which projection matrices are based on rely on the input vector w element to be 1.0. The GPU later uses the resulting w element of each position vector to perform the perspective divide.

In your case, your projection cannot work (because you input w = 0) and the perspective divide is a divide-by-zero.

| improve this answer | |
  • 1
    \$\begingroup\$ You're correct. I figured this out a while ago, but this was ultimately the issue. I was used to not having to set the w-coordinate manually as XNA did that automatically. Thus I overlooked it all the time. \$\endgroup\$ – SharpShade Jun 5 '18 at 6:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.