【发布时间】:2019-01-23 06:33:40
【问题描述】:
我正在将纹理传递给片段着色器我想将该像素值中的纹理颜色与蓝色 Alpha 0.2 混合我该怎么做?
片段着色器
fragment float4 bezier_fragment(VertexOutBezier params[[stage_in]],
texture2d<float> texture [[texture(0)]]
VertexOutBezier
struct VertexOutBezier {
float4 pos[[position]];
float4 color;
};
目前我正在这样做,但在示例中的此着色器函数中出现错误。 "No matching member function for call to 'sample'" 在 float canvasColor Initialization 行中
fragment float4 bezier_fragment(VertexOutBezier params[[stage_in]],
texture2d<float> texture [[texture(0)]]
)
{
constexpr sampler defaultSampler;
float4 canvasColor = texture.sample(defaultSampler, params.pos);
float4 finalColor = mix(canvasColor, params.color, 0.2);
return finalColor;
}
【问题讨论】:
-
当您发布这样的问题时,您应该逐字显示完整编译器输出。