Horde3D

Next-Generation Graphics Engine
It is currently 29.03.2024, 12:38

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: 10.08.2010, 14:29 
Offline

Joined: 15.02.2009, 02:13
Posts: 161
Location: Sydney Australia
Hi all, I've been thinking a bit on what would be the most efficient way to make a copy of the framebuffer to a lower res texture. The Horde3D way I am guessing is to do a h3dMapResStream of the main framebuffer, copy out the colour or depth buffer to system memory, unmap the stream, resize the image on the CPU to fit something like 512x256 (if the source was like 800x480), then create a texture and h3dMapResStream this to copy over the result. I'm a bit worried about the performance drop of this technique especially on ES devices.

Would this be the way to go about copying colour & depth to a texture, or is there another way with the pipeline system where I can just set XML to do this for me? My other idea was to not draw to the framebuffer but render to texture RGB and have alpha contain a linear 8-bit depth made from a shader, while having an additional 16/24-bit depth renderbuffer attachment and then later apply the result as one quad to the framebuffer. What do you think?

Almost forgot to mention, this is on hardware which only supports 1 colour attachment for textures but can have a few renderbuffer storage attachments (eg. depth/stencil). The reason to my madness is more or less having good source data to do fancy shaders without drawing the scene more than once or at most only drawing twice.

Thanks! It's a bit of a pain having no shader access of the framebuffer itself for blending! Unless I'm missing something...

_________________
-Alex
Website


Top
 Profile  
Reply with quote  
PostPosted: 10.08.2010, 16:11 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
You should be able to do that using the DrawQuad pipeline command.
e.g. to copy from one render-target to another:
Code:
      <SwitchTarget target="MY_LOW_RES" />
      <BindBuffer sampler="color" sourceRT="MY_HIGH_RES" bufIndex="0" />
      <DrawQuad material="materials/myPostProcessing.material.xml" context="COPY_RGBA" />
Or if you want to input a color/depth render and combine them into one output:
Code:
      <SwitchTarget target="MY_LOW_RES" />
      <BindBuffer sampler="color" sourceRT="MY_HIGH_RES" bufIndex="0" />
      <BindBuffer sampler="depth" sourceRT="MY_HIGH_RES" bufIndex="32" />
      <DrawQuad material="materials/myPostProcessing.material.xml" context="COPY_RGB_AND_DEPTH_TO_RGBA" />
(n.b. You'd have to make the myPostProcessing.material.xml file, and the COPY_RGBA/COPY_RGB_AND_DEPTH_TO_RGBA contexts ;) )


Top
 Profile  
Reply with quote  
PostPosted: 10.08.2010, 17:29 
Offline

Joined: 15.02.2009, 02:13
Posts: 161
Location: Sydney Australia
Thanks for the tips DarkAngel!

I've been studying the existing pipelines and noticed this technique, very clever. I suppose you can't do the same with the window's framebuffer because it's a renderbuffer?

To get around that I've made a SCRATCHBUF render target which is a texture with RGBA8 and has renderbuffer storage of stencil/depth (had to hack horde to do this) and will just store the additional linear depth to alpha. Apparently NPOT render targets are like 10x slower than POT ones on PowerVR SGX hardware so I hope 512x256 for an 800x480 display is good enough! 1024x512 is an option, but that's quite a bit of fillrate wastage, although it would give a bit of fake AA...

Does this make sense: could horde be extended to have an easy option where DrawQuad could have its verts set for an 800x480 texture area on a 1024x512 framebuffer, and could just glScissor this so it doesn't draw beyond the 800x480 area?

_________________
-Alex
Website


Top
 Profile  
Reply with quote  
PostPosted: 11.08.2010, 07:58 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
For copying the window framebuffer to a texture, you could try out glCopyTexSubImage2D. On PC you also have glBlitFramebufferEXT to copy the framebuffer to an FBO, however, I assume this function is not available on ES.

MistaED wrote:
Does this make sense: could horde be extended to have an easy option where DrawQuad could have its verts set for an 800x480 texture area on a 1024x512 framebuffer, and could just glScissor this so it doesn't draw beyond the 800x480 area?

You would probably want to use glViewport rather than glScissor in that case so that your image does not get cut off but is scaled accordingly. You can set the viewport before rendering using h3dSetupViewport but the setting is global and not for specific render targets.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 36 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group