Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/331.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 预变形纹理多边形_C#_3d_Xna_Texturing - Fatal编程技术网

C# 预变形纹理多边形

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

我只是从3D开始,所以我有一个关于在屏幕上绘制预变形的东西的问题

通过使用一些教程,我能够理解如何以预变形的形式绘制彩色多边形,但我就是不明白如何对它们进行纹理处理。。。这可能吗?如果是,怎么做

我现在所拥有的:

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);