Commit 2f03c130 by pidan

测试代码备份

parent b3d504ca
...@@ -29,20 +29,27 @@ fragment float4 samplingShader(RasterizerData input [[stage_in]], ...@@ -29,20 +29,27 @@ fragment float4 samplingShader(RasterizerData input [[stage_in]],
texture2d<float> textureUV [[ texture(BDAlphaPlayerFragmentTextureIndexTextureUV) ]], texture2d<float> textureUV [[ texture(BDAlphaPlayerFragmentTextureIndexTextureUV) ]],
constant BDAlphaPlayerConvertMatrix *convertMatrix [[ buffer(BDAlphaPlayerFragmentInputIndexMatrix) ]]) constant BDAlphaPlayerConvertMatrix *convertMatrix [[ buffer(BDAlphaPlayerFragmentInputIndexMatrix) ]])
{ {
constexpr sampler textureSampler (mag_filter::linear, min_filter::linear); constexpr sampler textureSamplerLinear (mag_filter::linear, min_filter::linear);
constexpr sampler textureSamplerNearest (mag_filter::nearest, min_filter::nearest);
float tcx = input.textureCoordinate.x / 2 + 0.5;
// 主体颜色采样(右半边)
float3 yuv = float3(textureY.sample(textureSampler, float2(tcx, input.textureCoordinate.y)).r, float2 colorTexCoord = float2(input.textureCoordinate.x / 2 + 0.5, input.textureCoordinate.y);
textureUV.sample(textureSampler, float2(tcx, input.textureCoordinate.y)).rg); float yColor = textureY.sample(textureSamplerLinear, colorTexCoord).r;
float2 uvColor = textureUV.sample(textureSamplerLinear, colorTexCoord).rg;
float3 rgb = convertMatrix->matrix * (yuv + convertMatrix->offset);
float3 yuvColor = float3(yColor, uvColor);
float3 alpha = float3(textureY.sample(textureSampler, float2(input.textureCoordinate.x / 2, input.textureCoordinate.y)).r, float3 rgb = convertMatrix->matrix * (yuvColor + convertMatrix->offset);
textureUV.sample(textureSampler, float2(input.textureCoordinate.x / 2, input.textureCoordinate.y)).rg);
// Alpha 采样(左半边)
float3 alphargb = convertMatrix->matrix * (alpha + convertMatrix->offset); float2 alphaTexCoord = float2(input.textureCoordinate.x / 2, input.textureCoordinate.y);
return float4(rgb, alphargb.r); float yAlpha = textureY.sample(textureSamplerNearest, alphaTexCoord).r;
// 映射 Alpha 范围
#define ALPHA_MIN 0.1
#define ALPHA_MAX 0.9
float finalAlpha = saturate((yAlpha - ALPHA_MIN) / (ALPHA_MAX - ALPHA_MIN));
return float4(rgb, finalAlpha);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment