829 static const int DMA_GridSizeLog2 = 6;
830 static const int DMA_GridSize = 1 << DMA_GridSizeLog2;
831 static const int DMA_NumVertsPerEye = (DMA_GridSize + 1) * (DMA_GridSize + 1);
832 static const int DMA_NumTrisPerEye = (DMA_GridSize) * (DMA_GridSize)*2;
835 const float fadeOutBorderFraction = 0.075f;
838 float xOffset = 0.0f;
844 *pNumVertices = DMA_NumVertsPerEye;
845 *pNumTriangles = DMA_NumTrisPerEye;
848 *ppTriangleListIndices = (uint16_t*)(
new uint16_t[
sizeof(uint16_t) * (*pNumTriangles) * 3]);
853 for (
int y = 0; y <= DMA_GridSize; y++)
855 for (
int x = 0; x <= DMA_GridSize; x++)
860 sourceCoordNDC.
x = 2.0f * ((float)x / (
float)DMA_GridSize) - 1.0f;
861 sourceCoordNDC.
y = 2.0f * ((float)y / (
float)DMA_GridSize) - 1.0f;
869 screenNDC.
x = std::max(-1.0f, std::min(screenNDC.
x, 1.0f));
870 screenNDC.
y = std::max(-1.0f, std::min(screenNDC.
y, 1.0f));
874 SLVec2f tanEyeAnglesR, tanEyeAnglesG, tanEyeAnglesB;
907 default: assert(
false);
break;
913 float edgeFadeIn = (1.0f / fadeOutBorderFraction) *
916 float edgeFadeInScreen = (2.0f / fadeOutBorderFraction) *
918 edgeFadeIn = std::min(edgeFadeInScreen, edgeFadeIn);
920 pcurVert->
Shade = std::max(0.0f, std::min(edgeFadeIn, 1.0f));
929 uint16_t* pcurIndex = *ppTriangleListIndices;
931 for (
int triNum = 0; triNum < DMA_GridSize * DMA_GridSize; triNum++)
935 assert(DMA_GridSize <= 256);
936 int x = ((triNum & 0x0001) >> 0) |
937 ((triNum & 0x0004) >> 1) |
938 ((triNum & 0x0010) >> 2) |
939 ((triNum & 0x0040) >> 3) |
940 ((triNum & 0x0100) >> 4) |
941 ((triNum & 0x0400) >> 5) |
942 ((triNum & 0x1000) >> 6) |
943 ((triNum & 0x4000) >> 7);
944 int y = ((triNum & 0x0002) >> 1) |
945 ((triNum & 0x0008) >> 2) |
946 ((triNum & 0x0020) >> 3) |
947 ((triNum & 0x0080) >> 4) |
948 ((triNum & 0x0200) >> 5) |
949 ((triNum & 0x0800) >> 6) |
950 ((triNum & 0x2000) >> 7) |
951 ((triNum & 0x8000) >> 8);
952 int FirstVertex = x * (DMA_GridSize + 1) + y;
974 if ((x < DMA_GridSize / 2) != (y < DMA_GridSize / 2))
976 *pcurIndex++ = (uint16_t)FirstVertex;
977 *pcurIndex++ = (uint16_t)FirstVertex + 1;
978 *pcurIndex++ = (uint16_t)FirstVertex + (DMA_GridSize + 1) + 1;
980 *pcurIndex++ = (uint16_t)FirstVertex + (DMA_GridSize + 1) + 1;
981 *pcurIndex++ = (uint16_t)FirstVertex + (DMA_GridSize + 1);
982 *pcurIndex++ = (uint16_t)FirstVertex;
986 *pcurIndex++ = (uint16_t)FirstVertex;
987 *pcurIndex++ = (uint16_t)FirstVertex + 1;
988 *pcurIndex++ = (uint16_t)FirstVertex + (DMA_GridSize + 1);
990 *pcurIndex++ = (uint16_t)FirstVertex + 1;
991 *pcurIndex++ = (uint16_t)FirstVertex + (DMA_GridSize + 1) + 1;
992 *pcurIndex++ = (uint16_t)FirstVertex + (DMA_GridSize + 1);
SLVec2f TransformTanFovSpaceToRendertargetNDC(ScaleAndOffset2D const &eyeToSourceNDC, SLVec2f const &tanEyeAngle)
void TransformScreenNDCToTanFovSpaceChroma(SLVec2f *resultR, SLVec2f *resultG, SLVec2f *resultB, DistortionRenderDesc const &distortion, const SLVec2f &framebufferNDC)
SLVec2f TransformTanFovSpaceToScreenNDC(DistortionRenderDesc const &distortion, const SLVec2f &tanEyeAngle, bool usePolyApprox)
SLVec2f TransformRendertargetNDCToTanFovSpace(const ScaleAndOffset2D &eyeToSourceNDC, const SLVec2f &textureNDC)
struct HmdRenderInfo::ShutterInfo Shutter