hecomi / uDesktopDuplication

Desktop Duplication API implementation for Unity (only for Windows 8/10)
http://tips.hecomi.com/entry/2016/12/04/125641
MIT License
557 stars 97 forks source link

Generate mipmaps of desktop texture #21

Closed lachlansleight closed 5 years ago

lachlansleight commented 6 years ago

I'm doing duplication of a 4K desktop texture and the aliasing is super-intense. Is it possible to generate mipmaps of the duplicated texture to cut down on artifacts?

I've done a bit of looking into it and it seems that this needs to be done at the native level, which I have precisely zero understanding of 😭

That said, if it's possible to do within Unity, or within the pixel shader , that would be swell (and probably doable on my end!)

lachlansleight commented 6 years ago

Update: If I understand correctly, just changing the MipLevels parameters of the Cursor and Monitor D3D11_Texture2D_DESC to zero should generate a full set of mip levels, that I could access in Unity by setting the MipMap input parameter of the Texture2D constructor to true?

But because I have never written a line of C++ in my life, I can't for the life of me get the plugin to recompile after making those changes. I get

'errorno_t strcpy_s(char *, std:rsize_t, cosnt char *)': cannot convert argument 3 from 'const WCHAR [32]' to 'const char *' which, after about 2 hours of googling I can confidently say that I totally do not understand hehe

hecomi commented 5 years ago

I'm very sorry for the late reply...

uDD cannot generate mipmap of the desktop texture because the MipLevels of the texture provided from Windows Desktop Duplication API is 1 sadly.