C# 预变形纹理多边形
我只是从3D开始,所以我有一个关于在屏幕上绘制预变形的东西的问题 通过使用一些教程,我能够理解如何以预变形的形式绘制彩色多边形,但我就是不明白如何对它们进行纹理处理。。。这可能吗?如果是,怎么做 我现在所拥有的:C# 预变形纹理多边形,c#,3d,xna,texturing,C#,3d,Xna,Texturing,我只是从3D开始,所以我有一个关于在屏幕上绘制预变形的东西的问题 通过使用一些教程,我能够理解如何以预变形的形式绘制彩色多边形,但我就是不明白如何对它们进行纹理处理。。。这可能吗?如果是,怎么做 我现在所拥有的: private void TestVertices() { vertices = new VertexPositionColor[3]; vertices[0].Position = new Vector3(-0.5f, -0.5f, 0f); vertices[0].Color
private void TestVertices()
{
vertices = new VertexPositionColor[3];
vertices[0].Position = new Vector3(-0.5f, -0.5f, 0f);
vertices[0].Color = Color.Red;
vertices[1].Position = new Vector3(0, 0.5f, 0f);
vertices[1].Color = Color.Green;
vertices[2].Position = new Vector3(0.5f, -0.5f, 0f);
vertices[2].Color = Color.Blue;
}
及
不要使用顶点的
VertexPositionColor
,而是使用顶点的VertexPositionColorTexture
,并在每个轴上将TextureCoordination
成员设置为0到1之间的值
绘制时,将GraphicsDevice.Texture[0]
设置为要使用的纹理
确保像素着色器执行以下操作:
// in the header:
sampler myTexture : register(s0);
// in your shader function:
float4 outputColor = input.Color * tex2D(myTexture, input.TexCoord);
如果您使用的是
basicefect
,那么等效的方法就是使用VertexPositionColorTexture
,将basicefect.Texture
设置为您的纹理,并将basicefect.TextureEnabled=true
谢谢:)这正是我想要做的!
// in the header:
sampler myTexture : register(s0);
// in your shader function:
float4 outputColor = input.Color * tex2D(myTexture, input.TexCoord);