Jump to content

[SOLVED] Rendering to texture


photo

Recommended Posts

Hi,

Im new to unigine and im bit stuck with rendering to texture. Any help would be aprecieted.

What im trying to do is to create is to create the same texture buffers as in RenderDeferred deferred;

(not exactly but for debugging purpose ive tried to do exactly that). 

In method void RenderRenderer::render_world(const char *materials,int shadows) 

ive commented everything and left only :

RenderDeferred deferred;
create_deferred(&deferred);
 
// render deferred texture
if(render_skip_deferred == 0) {
//
saveState();
state->clearTextures();
deferred.texturerender->enable(TextureRender::DISCARD_ALL);
state->clearStates();
 
// state
state->setBufferMask(0,BUFFER_COLOR | BUFFER_DEPTH);
state->clearBuffer(BUFFER_COLOR | BUFFER_DEPTH);
 
// render deferred surfaces
render->beginProfiler("RPDeferred: ");
for(int i = 0; i < scene->getNumOpacityGroups(); i++) {
render_deferred_surfaces(scene->getOpacitySurfaces(i));
render_deferred_object_decals(scene->getOpacityObjectDecals(i));
render_deferred_decal_renders(scene->getOpacityDecalRenders(i));
}
render_deferred_surfaces(scene->getTransparentSurfaces(),0);
render->endProfiler();
 
deferred.texturerender->flush();
deferred.texturerender->disable();
restoreState();
}
 
and i render texture deferred.normal_texture in some WidgetSprite onb the screen and it shows correct values. Then ive added: 
RenderDeferred deferred_RSM;
create_reflective_shadow_map(&deferred_RSM);
//create_deferred(&deferred_temp);
//we do swap of deferred_RSM and deferred later on
//state->getDeferred(&deferred_temp);
// render deferred texture
if(render_skip_deferred == 0) {
 
saveState();
state->clearTextures();
deferred_RSM.texturerender->enable(TextureRender::DISCARD_ALL);
state->clearStates();
 
// state
state->setBufferMask(0,BUFFER_COLOR | BUFFER_DEPTH);
state->clearBuffer(BUFFER_COLOR | BUFFER_DEPTH);
 
// render deferred surfaces
render->beginProfiler("RPDeferred: ");
for(int i = 0; i < scene->getNumOpacityGroups(); i++) {
render_deferred_surfaces(scene->getOpacitySurfaces(i));
render_deferred_object_decals(scene->getOpacityObjectDecals(i));
render_deferred_decal_renders(scene->getOpacityDecalRenders(i));
}
render_deferred_surfaces(scene->getTransparentSurfaces(),0);
render->endProfiler();
 
deferred_RSM.texturerender->flush();
deferred_RSM.texturerender->disable();
restoreState();
 
}
 
Which is basicly the same stuff but with deferred_RSM instead of deferred. create_reflective_shadow_map  allocates on gpu new textures for deferred_RSM in the same way as create_deferred(&deferred);. Instead of getDeferredTexture(width,height); it uses
getRSMTexture(width,height) which allocates texture in new deferred_rsm_textures instead of in deferred_textures. But in my debug widgetsprite deferred_RSM .normal_texture doesn't show anything. Im kind of stucked in here and i wonder if it's just enought to do deferred_RSM.texturerender->enable(TextureRender::DISCARD_ALL); and some rendering and then
deferred_RSM.texturerender->flush();
deferred_RSM.texturerender->disable();
to fill the texture context or i have to do something with shader?
Thanks
 
 
 

 

Link to comment
×
×
  • Create New...