Replicate OpenGL Blending in Metal

﹥>﹥吖頭↗ 提交于 2019-12-06 05:38:56

I found the problem, it was with how the textures were created, not how the blending was set up which was correct. When creating the textures with MetalKit on one set I used the option: [MTKTextureLoaderOptionSRGB: NSNumber(value:0)] and didn't on the other. When they both were set to be the same (either 1 or 0) they matched and blending worked correctly.

Shader ended up being:

fragment float4 terrainFragment(FragmentIn inFrag [[stage_in]],
                            texture2d<float, access::sample> colorTexture [[ texture(0) ]],
                            sampler colorSampler [[ sampler(0) ]]) {
    float4 color = colorTexture.sample(colorSampler, inFrag.uv * 1.33);
    color *= float4(inFrag.shadow,inFrag.shadow,inFrag.shadow,1);
    return color * 4;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!