Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
pidan
/
FuSiLive
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
2f03c130
authored
Jun 24, 2025
by
pidan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试代码备份
parent
b3d504ca
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
9 deletions
DevelopmentPods/FUSBDAlphaPlayer/FUSBDAlphaPlayer/Classes/Render/bd_shaders.metal
DevelopmentPods/FUSBDAlphaPlayer/FUSBDAlphaPlayer/Classes/Render/bd_shaders.metal
View file @
2f03c130
...
...
@@ -29,20 +29,27 @@ fragment float4 samplingShader(RasterizerData input [[stage_in]],
texture2d<float> textureUV [[ texture(BDAlphaPlayerFragmentTextureIndexTextureUV) ]],
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;
// 主体颜色采样(右半边)
float2 colorTexCoord = float2(input.textureCoordinate.x / 2 + 0.5, input.textureCoordinate.y);
float yColor = textureY.sample(textureSamplerLinear, colorTexCoord).r;
float2 uvColor = textureUV.sample(textureSamplerLinear, colorTexCoord).rg;
float3 yuv
= float3(textureY.sample(textureSampler, float2(tcx, input.textureCoordinate.y)).r,
textureUV.sample(textureSampler, float2(tcx, input.textureCoordinate.y)).rg
);
float3 yuv
Color = float3(yColor, uvColor);
float3 rgb = convertMatrix->matrix * (yuvColor + convertMatrix->offset
);
float3 rgb = convertMatrix->matrix * (yuv + convertMatrix->offset);
// Alpha 采样(左半边)
float2 alphaTexCoord = float2(input.textureCoordinate.x / 2, input.textureCoordinate.y);
float yAlpha = textureY.sample(textureSamplerNearest, alphaTexCoord).r;
float3 alpha = float3(textureY.sample(textureSampler, float2(input.textureCoordinate.x / 2, input.textureCoordinate.y)).r,
textureUV.sample(textureSampler, float2(input.textureCoordinate.x / 2, input.textureCoordinate.y)).rg);
// 映射 Alpha 范围
#define ALPHA_MIN 0.1
#define ALPHA_MAX 0.9
float finalAlpha = saturate((yAlpha - ALPHA_MIN) / (ALPHA_MAX - ALPHA_MIN));
float3 alphargb = convertMatrix->matrix * (alpha + convertMatrix->offset);
return float4(rgb, alphargb.r);
return float4(rgb, finalAlpha);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment