Page 1 of 1

Access pixel data from Rectangle2D

Posted: Thu Nov 13, 2014 5:48 am
by shapeare2014
My current rendering workflow is based on Ogre's rendering to texture tutorial:
1. rendering an object from the view of the camera, save the result to a texture named texture0
2. Sending texture0 to a custom defined material that was attached to a Rectangle2D object.

Now I want to access the pixel data of Rectangle2D (notice that it is different from texture0 because of the custom defined material), is there any way to do so?

Re: Access pixel data from Rectangle2D

Posted: Sat Nov 15, 2014 9:07 am
by amartin
I'm not sure exactly what you mean by pixel data here. If you just want to change how it looks then I think you want a fragment shader which will be what actually outputs the colour that is drawn for each pixel. If you need it in the code itself for some reason then you'll need to do the first render pass to get Tex0. Set the texture to the rectangle. Render the rectangle to texture then blitt that second texture to memory.

Re: Access pixel data from Rectangle2D

Posted: Tue Nov 18, 2014 8:50 am
by shapeare2014
amartin wrote:I'm not sure exactly what you mean by pixel data here. If you just want to change how it looks then I think you want a fragment shader which will be what actually outputs the colour that is drawn for each pixel. If you need it in the code itself for some reason then you'll need to do the first render pass to get Tex0. Set the texture to the rectangle. Render the rectangle to texture then blitt that second texture to memory.
I need the data in the code. How can I render the rectangle to texture? I only know how to render a scene to a texture and then attach that texture to a rectangle, but don't know how to render the rectangle again to a texture.

Re: Access pixel data from Rectangle2D

Posted: Tue Nov 18, 2014 10:12 am
by amartin
shapeare2014 wrote: I need the data in the code. How can I render the rectangle to texture? I only know how to render a scene to a texture and then attach that texture to a rectangle, but don't know how to render the rectangle again to a texture.
It's really simple. You do it by making a scene that displays only the rectangle. Set the viewport dimensions to however large you want the pixel data and and position the rectangle so that it fills the entire window.