本文介绍了在 XNA 中钳制 TextureAddressMode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直致力于在 XNA 中实现一个 2D 照明系统,并且我已经让系统工作了——只要我的窗户尺寸是 2 的幂.否则,程序会在这一行失败:

I've been working on implementing a 2D lighting system in XNA, and I've gotten the system to work--as long as my window's dimensions are powers of two. Otherwise, the program will fail at this line:

GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleStrip, Vertices, 0, 2);

异常指出XNA Framework Reach 配置文件在使用不是 2 的幂的纹理大小时要求 TextureAddressMode 为 Clamp",并且我为解决这个问题所做的每一次尝试都失败了——这是我最常见的解决方案've 在互联网上发现是将行 GraphicsDevice.SamplerStates[0] = SamplerState.LinearClamp; 直接放在上面的行上方,但这并没有解决我的问题.

The exception states that "XNA Framework Reach profile requires TextureAddressMode to be Clamp when using texture sizes that are not powers of two," and every attempt that I've made to slve this problem has failed--the most common solution I've found on the internet is to put the line GraphicsDevice.SamplerStates[0] = SamplerState.LinearClamp; directly above the line above, but that hasn't solved my problem.

如果我遗漏了解决此问题所需的任何信息,我深表歉意;我很乐意根据需要提供更多.

I apologize if I've left out any information that could be necessary to solve this; I'll be more than happy to provide more as needed.

推荐答案

这不是你之前问过的问题吗?

Isn't this the same question you asked before?

在您的 HLSL 中查找声明像素着色器正在使用的采样器的行.

In your HLSL look for the line that declares the sampler that the pixel shader is using.

您可以将地址模式设置为钳位在此行.

You can set the address mode to clamp in this line.

SamplerState somethingLikeThis {
    Filter = MIN_MAG_MIP_LINEAR;
    AddressU = Clamp;
    AddressV = Clamp;
};

这篇关于在 XNA 中钳制 TextureAddressMode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-16 16:25
查看更多