Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.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
Ios 点基元中的纹理_Ios_Swift_Metal_Metalkit - Fatal编程技术网

Ios 点基元中的纹理

Ios 点基元中的纹理,ios,swift,metal,metalkit,Ios,Swift,Metal,Metalkit,我用点法画正方形 commandEncoder.drawPrimitives(type: .point, vertexStart: 0, vertexCount:1 ) 用这个,我传递了一个屏幕大小的纹理(可绘制大小)。我可以在着色器中绘制如下所示 fragment half4 fragment_chalk(VertexOutChalk params[[stage_in]], texture2d<half>textur

我用点法画正方形

commandEncoder.drawPrimitives(type: .point, vertexStart: 0, vertexCount:1 ) 
用这个,我传递了一个屏幕大小的纹理(可绘制大小)。我可以在着色器中绘制如下所示

fragment half4 fragment_chalk(VertexOutChalk params[[stage_in]],
                               texture2d<half>texture4 [[texture(0)]],
                              float2 texcoord [[ point_coord ]]
                              )
{

    constexpr sampler defaultSampler;
    half4 alphaSample = texture4.sample(defaultSampler,texcoord) *half4(0.8666667, 0.101960786, 0.35686275,0.7);
    return alphaSample;

} 
fragment half4 fragment_粉笔(顶点出粉笔参数[[stage_in]],
纹理2dTexture4[[纹理(0)],
浮动2 texcoord[[point_coord]]
)
{
constexpr采样器defaultSampler;
half4 alphaSample=纹理4.样本(默认采样器,texcoord)*half4(0.8666667,0.101960786,0.35686275,0.7);
返回样品;
} 
但我需要的是不要画完整的纹理。我想画对应于特定正方形的部分。对于纹理采样,我需要传递与屏幕相关的坐标。我想更改采样坐标。我该怎么做