#灰度是什么格式?在 directX 中渲染目标?
我有一个 directx9 游戏引擎,它使用以下格式创建其正常适配器: D3DFMT_X8R8G8B8 我有一个系统,可以将一些对象渲染到屏幕外渲染目标,作为光照贴图。然后,我使用该光照贴图数据合成回后台缓冲区,它们充当全屏“蒙版”,让我在黑暗场景中获得火把或其他光源的效果。 一切都很好。 问题是,我知道我的大屏幕外光照贴图渲染目标在大分辨率下每个都是 16MB,而我实际上只需要其中的 8 位数据(灰度),因此 75% 的 32 位渲染目标内存是浪费。 (我的目标是低规格卡)。 我尝试将渲染目标创建为 D3DFMT_A8 但 directx 默默地失败了(如果我添加 CheckDeviceFormat() 我看到它发生)并创建 32 位。我使用 D3DXCreateTexture 函数 我的问题是,什么格式最适合创建这些离屏缓冲区?
谢谢您的帮助,我不擅长渲染目标相关的东西:)
I have a directx9 game engine that creates its normal adaptor with this format:
D3DFMT_X8R8G8B8
I have a system where I render some objects to an offscreen render target, as lightmaps. I then use that lightmap data to composite back to the back buffer where they act as a full screen 'mask' and let me get the effect of torches or other light sources on a dark scene.
Everything works just great.
The problem is, I'm aware that my big offscreen lightmap render targets are 16MB each, at a large res, and I only really need 8 bits of data (greyscale) from them, so 75% of the 32 bit render target memory is a waste. (I'm targeting low spec cards).
I tried creating the render targets as
D3DFMT_A8
But directx silently fails on that (if I add CheckDeviceFormat() I see it happen) and creates 32 bit anyway. I use the D3DXCreateTexture function
My question is, what format is best for creating these offscreen buffers?
Thankyou for your help, I'm not good at render target related stuff :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
D3DFMT_L8 是 8 位亮度。我相信 GeForce 3 支持它(即第一款带有着色器 1.1 的消费卡!),因此必须随处可用。我认为颜色读作 L,L,L,1,即 rgb = 亮度值,alpha = 1。
编辑:此工具对于查找大写字母很有用:
http://zp.lo3.wroc.pl/cdragan/wizard.php
D3DFMT_L8 is 8 bit luminance. I believe it's supported on GeForce 3 (i.e. the first consumer card with shader 1.1!), so must be available everywhere. I think the colour is read as L, L, L, 1, i.e. rgb = luminance value, alpha = 1.
Edit: this tool is useful for finding caps:
http://zp.lo3.wroc.pl/cdragan/wizard.php
主题:如果您的目标是较低规格的卡,那么您很可能在根本不支持 8 位单通道渲染目标的系统上运行。
如果您使用着色器进行渲染和合成,则应该可以将 RGBA 通道用于光照贴图的 4 个交替像素,从而打包您的信息。也许您可以告诉我们更多有关您当前渲染设置的信息?
题外话:很高兴您来到 StackOverflow,我是您工作的忠实粉丝!
Ontopic: If you are targeting lower spec cards, you are very likely to be running on systems where 8-bit single channel render targets are not supported at all.
If you are using shaders to do the rendering and compositing, it should be possible to use the rgba channels for 4 alternating pixels of your lightmap, packing your information. Perhaps you can tell us a little bit more about your current rendering setup?
Offtopic: AWESOME to have you here on StackOverflow, big fan of your work!