rohit.gonsalves_ Posted February 11, 2016 Posted February 11, 2016 Hi,I have Unigine 2 evaluation version. I want to connect the grabbed frames at 30FPS from Unigine to our application.I can see that there is one APPGrabber plugin for that.The best I think I should grab the texture on GPU and share it with our application on GPU itself. As transfer from GPU to System memory in ARGB space is very bandwidth intensive.Is this possible with existing API? Our application is in DirectX 11 too.Please advise Rohit
unclebob Posted February 12, 2016 Posted February 12, 2016 Hi there, Rohit! There's no need to copy textures from GPU to CPU each frame. Instead, render Unigine viewport to a texture by using TextureRender class. Here's code sample: using namespace Unigine; // initialization TextureRenderPtr texture_render = TextureRender::create(); texture_render->create2D(width,height); TexturePtr target_texture = Texture::create(); target_texture->create2D(width,height,Texture::FORMAT_RGBA8,Texture::USAGE_RENDER); // you can also specify another texture flags such as filtering or uv wraping // frame update Render *render = Render::get(); // get these variables from player node UNIGINE_MAT4 modelview; mat4 projection; String post_materials; int viewport_mask; int reflection_mask; int use_shadows = 1; int use_visualizer = 1; // render viewport texture_render->setColorTexture(0,target_texture); texture_render->enable(); render->renderViewport(projection,modelview,post_materials,viewport_mask,reflection_mask,use_shadows,use_visualizer); texture_render->flush(); texture_render->disable(); After that call, you'll be able to use target_texture in your drawing code.
rohit.gonsalves_ Posted June 8, 2016 Author Posted June 8, 2016 Hi Unclebob, Thanks for the update. I have another question regarding this.. If null renderer is selected; Can we grab textures as suggested in above solution? Our application will have preview and program outputs.. So we need to do double rendering at 30 FPS for each view. In this case; screen renderer is not required and API will take out texture GRAB from unigine and use in our application. One rendering will be for preview and one for program. It will only differ in camera positions... One more question when null renderer is selected; which Api will render the scene if the answer to previous question is 'Yes'. Please advise.
unclebob Posted June 9, 2016 Posted June 9, 2016 Hi there, Rohit! NULL renderer means there's no graphics API at all so you won't be able to render and grab textures, though the code will compile & run. In your case I guess it's better to implement custom App which will skip window creation and create two TextureRender instances instead: one for preview, another for the program. Hope that'll help! P.S. Actually, many of our clients are asking about off-screen rendering solution so we're thinking about that, no ETA though. Probably, this might be implemented as AppOffscreen plugin which will do the job. P.P.S. Next time it's better to start new topic so people (as well as our team) don't get confused and miss important questions.
Borisov Posted June 29, 2016 Posted June 29, 2016 Hi, unclebob! In 2.2.1 Framework version, Render class does't have renderViewport function. Would you please explain to my, how to rewrite your example for 2.2.1 version?
silent Posted June 30, 2016 Posted June 30, 2016 Hi, You can use new class Viewport to render into the texture. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
Borisov Posted June 30, 2016 Posted June 30, 2016 Hi. silent! Yes, I know about Viewport class. But I need example with TextureRender.
Recommended Posts