游戏开发论坛

 找回密码
 立即注册
搜索
楼主: 轩辕崇正

DirectX9中非2次方尺寸的图片渲染模糊问题的完美解决方案

[复制链接]

34

主题

443

帖子

478

积分

中级会员

Rank: 3Rank: 3

积分
478
发表于 2010-10-29 20:45:00 | 显示全部楼层

Re:【分享】DirectX9中非2次方尺寸的图片渲染模糊问题的完

谢谢楼主分享,
不过图片还是以2的N次幂为好。

2万

主题

2万

帖子

6万

积分

论坛元老

Rank: 8Rank: 8

积分
66489
QQ
发表于 2010-10-30 10:04:00 | 显示全部楼层

Re:【分享】DirectX9中非2次方尺寸的图片渲染模糊问题的完

缩放成2次幂是因为旧显卡只能显示2次幂尺寸的图片,和mipmaps完全无关。

119

主题

1367

帖子

1393

积分

金牌会员

Rank: 6Rank: 6

积分
1393
发表于 2010-10-30 23:25:00 | 显示全部楼层

Re:【分享】DirectX9中非2次方尺寸的图片渲染模糊问题的完

我们的游戏用的图片都是2的n次方大小的
不管怎么说,还是谢谢lz分享心得

67

主题

390

帖子

392

积分

中级会员

Rank: 3Rank: 3

积分
392
 楼主| 发表于 2010-11-1 00:57:00 | 显示全部楼层

Re:【分享】DirectX9中非2次方尺寸的图片渲染模糊问题的完

是我奇怪了,多年来,一直以为D3D只能处理2的次方的图片,从未听闻还可以处理非2次方的情况。
即便现在在到网上查阅一翻,仍然通通都是声称要2的次方才行,似乎2的次方已成了一种定律。
就是非常奇怪,为何没有非2次方的加载方法。。这个问题我当初学DX的时候就问过,但所有人都说一定要2的次方,没别的办法,然而我看到很多商业游戏资源,并不是所有图片全是2的次方,比如2D游戏里,单个分割场景的尺寸是320×240,这个就不是2的次方。这个疑问也多年未有人给我个答案。

9

主题

132

帖子

145

积分

注册会员

Rank: 2

积分
145
QQ
发表于 2010-11-1 09:25:00 | 显示全部楼层

Re:【分享】DirectX9中非2次方尺寸的图片渲染模糊问题的完

mipmap, 没有mipmap的3d game是多么糟糕,

2万

主题

2万

帖子

6万

积分

论坛元老

Rank: 8Rank: 8

积分
66489
QQ
发表于 2010-11-1 11:06:00 | 显示全部楼层

Re:【分享】DirectX9中非2次方尺寸的图片渲染模糊问题的完

早期的显卡,以及现在的低端显卡需要2次幂尺寸的贴图。为了照顾所有的显卡所以必须这样做。
等再过5年,估计可以放弃。不过游戏机上应该不会,因为2次幂的必境快很多。

这个和D3D,OPENGL无关,只要显卡支持就都支持,反之亦然。

11

主题

1238

帖子

1782

积分

金牌会员

Rank: 6Rank: 6

积分
1782
发表于 2010-11-1 15:40:00 | 显示全部楼层

Re:【分享】DirectX9中非2次方尺寸的图片渲染模糊问题的完

楼主不会是有"尝试法"一个个改参数试出来的吧~~

0

主题

7

帖子

7

积分

新手上路

Rank: 1

积分
7
发表于 2010-11-22 17:59:00 | 显示全部楼层

Re:DirectX9中非2次方尺寸的图片渲染模糊问题的完美解决方案

糊涂,还带动这么多人一起糊涂
之所以用2次幂,那是图形sdk考虑到了很多效率的问题和实现某些功能的简洁性,你不去搞清楚这些问题,反而寻找不使用2次幂的可能途径,不知道该怎么说你才好
另外,你把过滤关掉了,为什么要关掉呢,你这样还能缩放旋转吗,还有意义吗

45

主题

1163

帖子

1165

积分

金牌会员

Rank: 6Rank: 6

积分
1165
发表于 2010-11-23 09:51:00 | 显示全部楼层

Re: DirectX9中非2次方尺寸的图片渲染模糊问题的完美解决

看下这个网站,上面统计了主流显卡是否支持 D3DPTEXTURECAPS_NONPOW2CONDITIONAL 标志

http://www.kludx.com/capability.php?capability=144

再来看看SDK中关于 D3DPTEXTURECAPS_NONPOW2CONDITIONAL 的解释:

D3DPTEXTURECAPS_NONPOW2CONDITIONAL
D3DPTEXTURECAPS_POW2 is also set, conditionally supports the use of 2D textures with dimensions that are not powers of two. A device that exposes this capability can use such a texture if all of the following requirements are met.

The texture addressing mode for the texture stage is set to D3DTADDRESS_CLAMP.
Texture wrapping for the texture stage is disabled (D3DRS_WRAP n set to 0).
Mipmapping is not in use (use magnification filter only).
Texture formats must not be D3DFMT_DXT1 through D3DFMT_DXT5.
If this flag is not set, and D3DPTEXTURECAPS_POW2 is also not set, then unconditional support is provided for 2D textures with dimensions that are not powers of two.

A texture that is not a power of two cannot be set at a stage that will be read based on a shader computation (such as the bem - ps and texm3x3 - ps instructions in pixel shaders versions 1_0 to 1_3). For example, these textures can be used to store bumps that will be fed into texture reads, but not the environment maps that are used in texbem - ps, texbeml - ps, and texm3x3spec - ps. This means that a texture with dimensions that are not powers of two cannot be addressed or sampled using texture coordinates computed within the shader. This type of operation is known as a dependent read and cannot be performed on these types of textures.


D3DPTEXTURECAPS_POW2
If D3DPTEXTURECAPS_NONPOW2CONDITIONAL is not set, all textures must have widths and heights specified as powers of two. This requirement does not apply to either cube textures or volume textures.

If D3DPTEXTURECAPS_NONPOW2CONDITIONAL is also set, conditionally supports the use of 2D textures with dimensions that are not powers of two. See D3DPTEXTURECAPS_NONPOW2CONDITIONAL description.

If this flag is not set, and D3DPTEXTURECAPS_NONPOW2CONDITIONAL is also not set, then unconditional support is provided for 2D textures with dimensions that are not powers of two.

45

主题

1163

帖子

1165

积分

金牌会员

Rank: 6Rank: 6

积分
1165
发表于 2010-11-23 10:01:00 | 显示全部楼层

Re: DirectX9中非2次方尺寸的图片渲染模糊问题的完美解决

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-5-30 12:11

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表