Rendering to texture, then that texture to screen

Problems building or running the engine, queries about how to use features etc.
Post Reply
MoriaOrc
Gnoblar
Posts: 3
Joined: Wed Jul 06, 2016 2:45 pm

Rendering to texture, then that texture to screen

Post by MoriaOrc »

Hello everyone,

I am new to Ogre and I’m trying to port code of a Java desktop application which used direct OpenGL calls.

In this application we are trying to render the floor of a world in 2D. This floor is divided into different pieces and each of these pieces may overlap with others. When they overlap, we alpha blend them so they look the way we want.

To get the effect we desire we have to render each floor piece onto a bigger texture the same size as the screen using the current camera’s orientation. We use one shader for this. Then using a different shader we render the big target texture onto the screen.

I’m trying to figure out how this can be done using Ogre. Initially, I thought that each floor piece could be a SceneNode, then on the Pass of the Material, set the blending function to SBF_ONE and SBF_ONE_MINUS_SOURCE_ALPHA, similar to how it is on the Java code. However, doing this does not let us apply the desired effects we want on the textures.

I then tried to mimic our Java code by using a RenderTexture as shown here http://www.ogre3d.org/tikiwiki/tiki-ind ... Tutorial+7 but that tutorial renders to the screen as well, while in our case we do not want the intermediate texture to be rendered on the screen.

We want to render things onto a texture, then that texture onto the screen. We don’t want to render whatever is on the screen onto a texture. I have also looked at compositors but I wasn’t able to figure out if that’s what is actually needed in this case. Compositors seem to be for applying post filter effects, while we actually want is a “prefilter”. Once again, we want to render to a texture, then that texture to screen using separate shaders for each step which in the end give us the desired effect.

I’m wondering if this is possible with Ogre and if anyone would be so kind as to please point me in the right direction?

Cheers,
frostbyte
Orc Shaman
Posts: 737
Joined: Fri May 31, 2013 2:28 am
x 65

Re: Rendering to texture, then that texture to screen

Post by frostbyte »

i got a little lost with what you try to do, but you can use shaders either in compositor or in materials and define your own blending...
if you mean that you want to render a sceneNode seperatly than thats a different story....
the way i do it is to hide all scene nodes except the one i want, setCamera+RTT for it and render, this way might be a bit wasteful on performance
but its ok for my needs, hope that helped somehow (-:
the woods are lovely dark and deep
but i have promises to keep
and miles to code before i sleep
and miles to code before i sleep..

coolest videos link( two minutes paper )...
https://www.youtube.com/user/keeroyz/videos
MoriaOrc
Gnoblar
Posts: 3
Joined: Wed Jul 06, 2016 2:45 pm

Re: Rendering to texture, then that texture to screen

Post by MoriaOrc »

Maybe I added too much detail. What I want to do can be summarized as wanting to draw onto a texture and then that texture onto the screen. The tutorials and posts I was able to find on the internet draw whatever is on the screen onto a texture which is not what I want.
frostbyte
Orc Shaman
Posts: 737
Joined: Fri May 31, 2013 2:28 am
x 65

Re: Rendering to texture, then that texture to screen

Post by frostbyte »

ok...i think maybe i'm starting to understand what you mean...still not sure...
just giving you some directions, so you'll need to do some further digging about renderQueue and Compositor passes...

you can assign entities into renderQueue using void Ogre::Entity::setRenderQueueGroup(uint8 queueID)
in the Compositor pass you can set the target to your RTT, define the renderQueue assosiated with this pass and set the shader( your own custom blending )
you can use this http://www.ogre3d.org/docs/api/1.8/clas ... tener.html to set shader params etc...
you can also use renderQueueStarted to set some queueID specific entity/material params

can ogre do this or that? .....Generaly speaking...
each SceneRenderer has its own way of handling the Scene rendering pipeline, so not all ways of doing stuff( like with the liberty that openGL gives you )
will perfectly fit the Ogre design, however Ogre's design is quite flexible( you can even issue GL calls ), so most of the times you can find a way around....
just takes time...have fun...
the woods are lovely dark and deep
but i have promises to keep
and miles to code before i sleep
and miles to code before i sleep..

coolest videos link( two minutes paper )...
https://www.youtube.com/user/keeroyz/videos
MoriaOrc
Gnoblar
Posts: 3
Joined: Wed Jul 06, 2016 2:45 pm

Re: Rendering to texture, then that texture to screen

Post by MoriaOrc »

Thank you very much for your answers frostbyte. Finally, I was able to do what I wanted. Basically, I had to create a render texture as a render target. Then add a camera to it which had the same values as my actual camera. After calling update on the render texture, my scene is rendered to it. It was actually much more simple than I thought it was. It was the step of using a different camera and a separate scene for doing the off screen rendering that was missing. If I used the actual scene and camera it would render to the screen as well which is not what I wanted.


Thanks again!
Post Reply