Jump to content

Problem: Offscreen rendering using UnigineApp


photo

Recommended Posts

Hi There...

 

I have created one custom App. Created the DirectX11 Device and context.

I haven't created any swap chain as there is no windows where I want to render.

 

I have created TextureRenderer and Texture. Using it for rendering viewport on this render target texture.

 

m_pTextureRender = TextureRender::create();
m_pTextureRender->create2D(_dwWidth,_dwHeight);


m_pTexture = Texture::create();
m_pTexture->create2D(_dwWidth,_dwHeight,Texture::FORMAT_RGB8,Texture::USAGE_RENDER); 


m_pTextureDS = Texture::create();
m_pTextureDS->create2D(_dwWidth,_dwHeight,Texture::FORMAT_D24,Texture::USAGE_RENDER); 

 

In CFG file I have loaded one world.

<item name="console_command" type="string">world_load samples/animation/animation_00</item>

 Console shows that world is loading fine. 

 

post-41-0-55558600-1466679838_thumb.png

 

Then I am acquiring game player and setting the matrices and render it.

 

const char* post_materials = "";
Render *render = Render::get();
Game *game = Game::get();
PlayerPtr playerCam = game->getPlayer();


mat4 proj =  playerCam->getProjection();
mat4 mv = playerCam->getModelview();


m_pTextureRender->setColorTexture(0,m_pTexture);
m_pTextureRender->enable();
render->renderViewport(proj, mv, post_materials, m_iViewportMask, m_iReflectionMask, m_iUseShadows);
m_pTextureRender->flush();
m_pTextureRender->disable();


if( _saveimage )
{
     ImagePtr img = Image::create();
     m_pTexture->getImage(img);
     img->save("C://image.png",0.85f);
}

But now the rendering is black. Why it is not capturing the world? What could be the issue?

 

Please advise. 

Rohit

 

 

Link to comment

Guess What...

 

I have changed the Viewport mask to 1 and its working..... Able to get the result. The next step is to use the GPU texture in my application. This could be tricky now....

 

@silent: Tomorrow I will post the code here...

 

Rohit

Link to comment
  • 5 months later...

My Engine is integrated with Unigine Output. Wonderful..

One GPU.. Initialized with Our engine.. DX11 Device and Context.

Same is used to initialize the Unigine.

Now unigine output is shared on GPU with DX11 API with Our engine and Bingo...

Runs smooth,. 

The next step is to take few DX11 textures from  Our engine and map them to Unigine for further processing.

One GPU two things... Excellent...

Link to comment
×
×
  • Create New...