[DX11] Full Screen Quad

Started by
-1 comments, last by martinperry 12 years, 6 months ago
I am trying to render full screen quad.

I precompute coordinates


viewProj = ortho matrix for viewport

float startX = -viewport->Width * 0.5f;
float startY = -viewport->Height * 0.5f;
float endX = viewport->Width * 0.5f;
float endY = viewport->Height * 0.5f;


MyMath::Vector3 vecA = MyMath::Vector3(startX, startY, 1);
MyMath::Vector3 vecB = MyMath::Vector3(startX, endY , 1);
MyMath::Vector3 vecC = MyMath::Vector3(endX , startY, 1);
MyMath::Vector3 vecD = MyMath::Vector3(endX , endY , 1);


vecA = MyMath::Vector3::TransformCoordinate(vecA, viewProj);
vecB = MyMath::Vector3::TransformCoordinate(vecB, viewProj);
vecC = MyMath::Vector3::TransformCoordinate(vecC, viewProj);
vecD = MyMath::Vector3::TransformCoordinate(vecD, viewProj);



For every position, i set corners UV (0,0) , (1,1), (0, 1) or (1, 0) - that is correct

Ok.. so far, everything is OK (quad is correctly rendered)
)pix.png

Into that quad, I render 32x32 texture, taht should be filled in PS. Now my problem is, that if i debug pixel, i got incorrect UV coordinates. Eg... coordinates seems to be clipped from fullQuad (viewport.Width x viewport.Height).. so my 32x32 texture occupied only part of whole "quad", so tex coordinates are wrong.
If I use same princip in DX9, everything work just fine.

How can I fill texture, that is smaller tah viewport ? On next image... X = 31, Y = 31... UV are correct.. but if I debug that pixel [31,31] i got incorrect UV values (image 2)

pix2.png

pix3.png

This topic is closed to new replies.

Advertisement