Jump to content

  • Log In with Google      Sign In   
  • Create Account


Texture as background for framebuffer


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 StanLee   Members   -  Reputation: 117

Like
0Likes
Like

Posted 12 October 2012 - 02:53 PM

Hello,

I am curious if it is possible to set a texture as the background for the framebuffer on which the 3D scene is rendered on in an easy way.
To be more specific:

I want to take the frames of my webcam and draw my 3D scene (which consits of particles in a black space) on it. I experimented with framebufferObjects and render-to-texture techniques. At the moment I create a framebuffer object and attach two textures to it. On one texture I render my 3D scene, while I copy the frame of my webcam to the other texture. I thought I could do something with glBlitFramebuffer() but unfortunately it just copies one texture to the other.

I thought I could somehow work with stencil buffers because I just need to punch out the black space of my 3D particle scene and draw it on my webcam frame, but I couldn't find any helpful ressources on this topic so far.

Thanks for any help in advance! :)

Sponsor:

#2 joew   Crossbones+   -  Reputation: 3581

Like
1Likes
Like

Posted 12 October 2012 - 07:14 PM

I would think the easiest (and fastest) way would be to just take the background image and put it on a quad and render it using an orthographic camera before rendering the 3d components of the scene in perspective. Unless I am not fully understanding what it is you are trying to do.

Edited by Saruman, 12 October 2012 - 07:15 PM.


#3 StanLee   Members   -  Reputation: 117

Like
0Likes
Like

Posted 13 October 2012 - 01:43 AM

Wow, so blitting the framebuffer befor drawing the scene works fine.... It's far easier then I thought.
I didn't even try this before because I supposed alle the color-values would totally mix up when I already got a background.

Thanks for your help. :)

#4 Kaptein   Prime Members   -  Reputation: 1845

Like
2Likes
Like

Posted 13 October 2012 - 04:35 AM

yes, as long as you keep in mind that both directx and opengl is a rasterizer with a depth buffer then you will be fine
for example, when you do cubemapping for background just put in the shader gl_FragDepth = 1.0, that way ALL fragments for the background
are _exactly_ at the edge of zfar and will always be the "furthest away pixel" (turn off depth test, depthfunc always, depthwrite on)
just remember though, you can do fullscreen operations before and after your scene, but almost always never in between, because that will intefere with the actual geometry
so, the usual setup is: background -> geometry -> alpha-blended geometry -> postprocessing

#5 StanLee   Members   -  Reputation: 117

Like
0Likes
Like

Posted 13 October 2012 - 08:55 AM

Thanks for the tips. I will try to keep them in mind for further projects. ;)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS