Access pixel data from Rectangle2D

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
shapeare2014
Gnoblar
Posts: 7
Joined: Thu Oct 09, 2014 8:26 am

Access pixel data from Rectangle2D

Post by shapeare2014 » Thu Nov 13, 2014 5:48 am

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?
0 x

amartin
Halfling
Posts: 87
Joined: Wed Aug 14, 2013 6:55 am
Location: Norway

Re: Access pixel data from Rectangle2D

Post by amartin » Sat Nov 15, 2014 9:07 am

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.
0 x

shapeare2014
Gnoblar
Posts: 7
Joined: Thu Oct 09, 2014 8:26 am

Re: Access pixel data from Rectangle2D

Post by shapeare2014 » Tue Nov 18, 2014 8:50 am

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.
0 x

amartin
Halfling
Posts: 87
Joined: Wed Aug 14, 2013 6:55 am
Location: Norway

Re: Access pixel data from Rectangle2D

Post by amartin » Tue Nov 18, 2014 10:12 am

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.
0 x

Post Reply