FBO and the FB's depth

导读:





[OpenGL] FBO and the FB's depth







Archon

Member #4,195

January 2004





I have a complex problem with the framebuffer objects, blending and depth in OpenGL:
In previous threads, I've been asking how to create a FBO as well as use it to implement a 2D lighting system that would be blended straight on top of the scene.

But what I need to do is copy the default framebuffer's depth buffer into the lighting FBO's depth buffer so that, when I do the lighting portion of the rendering, the lights wont appear in front of objects where they are supposed to be behind.

Either that, or preferably I could just use the depth buffer directly when rendering to the FBO's texture.

However, I don't know how to do this.

Does this require another extension?

Additionally, what could be done about objects that are partially translucent (alpha < 1.0) and where there is supposed to be light behind it?







Arthur Kalliokoski

Member #5,540

February 2005







Quote:

do the lighting portion of the rendering, the lights wont appear in front of objects where they are supposed to be behind.
Could you reword that please? It makes my brain go into an infinite loop.
Does BillG lay awake at night, worrying whether the financial institutions entrusted with his loot are running Windows software?







Kitty Cat

Member #2,815

October 2002





I think what he's asking for is being able to copy the depth buffer from the main framebuffer (0), that he's already rendered, into the FBO so that drawing to the FBO will be properly affected by the depth test.

The two ways I can think of to do it efficiently would either be to use a PBO (so copy the depth channel like backbuffer->pbo->depth_texture).. or render the scene using the FBO, copy it to the main backbuffer, then clear the FBO's color buffer (leaving the depth buffer alone) to render the lights, then blend that onto the backbuffer.
--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham
Got APEG? [kcat.strangesoft.net]







Archon

Member #4,195

January 2004







Quote:

or render the scene using the FBO, copy it to the main backbuffer, then clear the FBO's color buffer (leaving the depth buffer alone) to render the lights, then blend that onto the backbuffer.
Good idea KC. Thanks.

However, do you know what I could do about lighting and partially alpha-ed textures?
Maybe I'd need to render the scene in three loops:
Render normal, solid textures;

Turn on depth mask (or is it the other way around?)
Render partially-alpha textures
Render pixel lighting texture
Turn off depth mask
Flip backbuffer
Does that sound correct?







Kitty Cat

Member #2,815

October 2002







Quote:

However, do you know what I could do about lighting and partially alpha-ed textures?
Translucent textures/objects are done after the main scene:
1) Render opaque objects (roughly sorted near to far) with depth testing and writing on. Most masked images (where alpha is only 1 or 0, but not in between) can be done here with alpha testing turned on.
2) Render translucent objects far to near with depth testing on and depth writing off.
3) Copy the FBO to backbuffer and clear the FBO's color buffer
4) Render lights with depth testing on and depth writing off.
5) Blend the FBO onto the backbuffer and flip
--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham
Got APEG? [kcat.strangesoft.net]







Archon

Member #4,195

January 2004





Thanks, I should be OK from that.

If not, I'll just bother you in IRC!







Thomas Fjellstrom

Member #476

June 2000







Quote:

If not, I'll just bother you in IRC!
Oh thanks now KC will never be alive in #allegro >:E
--
Thomas Fjellstrom - [ website [strangesoft.net]] - [ email [mailto:tfjellstrom@strangesoft.net]] - [ Allegro Wiki] - [ Allegro SVN Snapshots [strangesoft.net]] - [ Allegro TODO]
"laughing at people in general is fun" -- X-G | "God Bless Joe Pesci" -- George Carlin [religiousfreaks.com]
"Well.. now that you mention it, you are kind of.. nothing." -- Inphernic
"I'm sure someone will come along and declare their own stupidity (usually demonstrated with the phrase "old")" -- Thomas Harte
"Goto is the buldozer of coding. Sometimes, the buldozer is just the right tool for the job. Not often, but sometimes." -- LordBob

本文转自
http://www.allegro.cc/forums/thread/596061
内附安装教程,含14套模板。 此源码为商业版全功能无授权版,1031全新的友价虚拟物品在线交易商城   模板源码,含14套模板带熊掌号及百度主动提交插件   源码运行环境,以下是友价虚拟物品在线交易   商城模板源码1031商业版的修复内容:   手机端:   新增手机版任务大厅功能   更新商家版会员中心界面   电脑端:   编辑商品视频栏目直接以弹窗方式展开,不用切换页面   调整保证金规则(有订单未完成,禁止解冻保证金)   新增商品问答功能   新增评价视频晒单功能   完善退款记录功能,每次退款跟处理结果都做记录(旧的只能保留最+新一次的退款记录)   支付宝等付款时,资金记录里同时记录交易号   阿里云OSS设置开关功能(后台基本设置-存储接口里)   开通阿里云OSS产品效果图也能存储的功能   友价   查看更多关于 友价 的文章   虚拟物品在线交易商城模板源码1023商业版源码安装教程   1.把程序上传到网站根目录下,不支持二级目录安装;   2.用EditPlus或者Notepad等代码编辑软件打开数据库配置文件:config/config.php 把里面的数据库信息改为自己的mysql数据库信息   文件内有标注,根据标注提示修改   3.导入数据库。把数据库目录下的shujku.sql数据库备份文件还原到你的mysql数据库内。   4.修改熊掌号地址,用editplus或者Notepad等代码编辑软件打开文件 user/baidu.php 把里面的这个域名 www.baidu.com 改为自己的   5.修改邮件通知名称,文件路径 yjadmin1/shop.php 把里面的关于 商业源码 这个名称,改为自己的,建议不要太长,否则会被屏蔽
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值