【发布时间】:2015-10-09 16:17:59
【问题描述】:
我正在尝试优化绘制具有 3 种不同纹理的立方体。我想要达到的一个效果是:
我现在正在做的是使用三个 Draw() 调用来绘制立方体:
graphicsDevice.Textures[0] = cube.frontTexture;
graphicsDevice
.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0,
36, 0, 2);
graphicsDevice.Textures[0] = cube.backTexture;
graphicsDevice
.DrawIndexedPrimitives(PrimitiveType.TriangleList, 6, 0,
30, 0, 2);
graphicsDevice.Textures[0] = cube.sideTexture;
graphicsDevice
.DrawIndexedPrimitives(PrimitiveType.TriangleList, 12, 0,
24, 0, 8);
然后在像素着色器中处理我的纹理我对纹理进行采样:
texture Texture;
sampler textureSampler : register(s0) = sampler_state {
Texture = (Texture);
Filter = MIN_MAG_MIP_POINT;
AddressU = Wrap;
AddressV = Wrap;
};
并产生输出:
return tex2D(textureSampler, texCoord); // I have my texCoords from vertex shader output
不幸的是,在我的场景中有数百个具有不同纹理的相似立方体以及其他对象,这对 FPS 速率有不良影响。我注意到我可以在像素着色器中采样多个纹理:
graphicsDevice.Textures[0] = cube.frontTexture;
graphicsDevice.Textures[1] = cube.backTexture;
graphicsDevice.Textures[2] = cube.sideTexture;
我能否以某种方式将每个纹理粘贴到像素着色器中长方体的正确面,以便在一次 Draw() 调用中绘制它?我使用 Silverlight 5.0,但任何关于 XNA 或 MonoGames 的答案都将不胜感激:)
【问题讨论】:
标签: silverlight xna silverlight-5.0 monogame hlsl