WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Getting data from a render texture (https://forum.worldviz.com/showthread.php?t=1969)

Joran 04-14-2009 04:07 AM

Getting data from a render texture
 
Hello,

I want to get the data from a depth texture. I use the following command to create the texture:

Code:

depthtex = viz.addRenderTexture(format = viz.TEX_DEPTH, width = 8, height = 8)
And somewhere else I attach this texture to a viz.RENDER_DEPTH render node. Is there a way to get the data from this texture in python?

Greetings, Joran.

farshizzo 04-16-2009 10:30 AM

There is currently no built-in way to retrieve the data from a render texture. You could create a modifier plugin that attaches a post draw callback to the underlying osg::CameraNode object. From the callback you should be able to read the pixels from the texture into memory.

Do you need the data for real-time purposes (i.e. every frame)? If not, you can workaround the problem by rendering the depth texture to the screen and then capturing the screen to a file.

Joran 04-17-2009 12:24 AM

It is for real time processing. Is there any chance this functionality will be added in the future to Vizard?

Otherwise I will have to make that plugin. I am not looking forward to that.

Joran 06-03-2013 02:11 AM

I am revisiting this 'problem'. The version using a plugin did work (I need to recompile the plugin again). But now I saw the .saveToBuffer() method. It looks very useful. I still have:

Code:

depthtex = viz.addRenderTexture(format = viz.TEX_DEPTH, width = 8, height = 8)
And i can now save it to a buffer with:

Code:

depthtex.saveToBuffer('')
.

But this buffer then contains an 8 bit z-buffer. When I change my texture format to viz.TEX_DEPTH_32, I get the error message:

Code:

error pixelFormat = 81a7
** ERROR: Texture does not contain image data, cannot save to buffer

I am almost where I want to be. Is there some way to save a 16 bit or 32 bit z-buffer? Or maybe could the support for it be added to saveToBuffer?

Greetings, Joran.


All times are GMT -7. The time now is 04:29 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC